• 大小: 24KB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2021-10-24
  • 语言: Matlab
  • 标签:

资源简介

该代码为直流电机模糊PID控制,其中构建直流电机传递函数数学模型,搭建直流电机PID速度控制与模糊PID控制的比较,仿真结构建简单易懂。

资源截图

代码片段和文件信息

clc;clear;close all;

% Fungsi transfer Plant
Ts = 0.01;
J = 0.01;
b = 0.1;
Ke = 0.01;
Kt = 0.01;
R = 1;
L = 0.5;
syms s;
K = Ke;
num = K;
den = sym2poly((J*s+b)*(L*s+R)+K^2);
sys = tf(numden);
Plant = c2d(sysTs‘zoh‘);
figure
step(Plant)
title(‘Respon Sistem Awal‘)

open_system(‘SimFuzzyPID‘)
open_system(‘SimFuzzyPID/Fuzzy PID‘)

% Mendesain kendali PID konvensional
open_system(‘SimFuzzyPID/PID‘)

C0 = pid(111‘Ts‘Ts‘IF‘‘B‘‘DF‘‘B‘); % PID structure
C = pidtune(PlantC0) % design PID
[Kp Ki Kd] = piddata(C); % Parameter PID

% Asumsikan sinyal referensi bernilai 1 sehingga max. error |e|=1 
% Rentang input |E| adalah [-10 10] sehingga atur |GE| = 10.

GE = 100;
GCE = GE*(Kp-sqrt(Kp^2-4*Ki*Kd))/2/Ki; % Kp = GCU * GCE + GU * GE
GCU = Ki/GE; % Ki = GCU * GE
GU = Kd/GCE; % Kd = GU * GCE

% Fuzzy inference system Sugeno:
FIS = newfis(‘FIS‘‘FISType‘‘sugeno‘);

% Fungsi keanggotaan input error |E|:
FIS = addvar(FIS‘input‘‘E‘[-100 100]); 
FIS = addmf(FIS‘input‘1‘Negative‘‘gaussmf‘[70 -100]);
FIS = addmf(FIS‘input‘1‘Positive‘‘gaussmf‘[70 100]);

% Fungsi keanggotaan input perubahan error |CE|:
FIS = addvar(FIS‘input‘‘CE‘[-100 100]); 
FIS = addmf(FIS‘input‘2‘Negative‘‘gaussmf‘[70 -100]);
FIS = addmf(FIS‘input‘2‘Positive‘‘gaussmf‘[70 100]);

% Fungsi keanggotaan output |u|:
FIS = addvar(FIS‘output‘‘u‘[-200 200]); 
FIS = addmf(FIS‘output‘1‘Min‘‘constant‘-200);
FIS = addmf(FIS‘output‘1‘Zero‘‘constant‘0);
FIS = addmf(FIS‘output‘1‘Max‘‘constant‘200);

% Aturan Fuzzy
ruleList = [1 1 1 1 1;...   % If |E| is Negative and |CE| is Negative then |u| is -200 (MIN)
            1 2 2 1 1;...   % If |E| is Negative and |CE| is Positive then |u| is 0 (ZERO)
            2 1 2 1 1;...   % If |E| is Positive and |CE| is Negative then |u| is 0 (ZERO)
            2 2 3 1 1];     % If |E| is Positive and |CE| is Positive then |u| is 200 (MAX)
FIS = addrule(FISruleList);

sim(‘SimFuzzyPID‘)
load(‘StepPID‘)
load(‘StepFP‘)
figure
plot(StepPID(11:401)StepPID(2101:501))
hold on
plot(StepFP(11:401)StepFP(2101:501))
hold off
title(‘Respon Sistem Setelah Dikendalikan‘)
legend(‘PID‘‘Fuzzy-PID‘)

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-06-15 23:44  Fuzzy-PID-DC-Motor-Matlab-Simulink-master\
     文件        1079  2018-06-15 23:44  Fuzzy-PID-DC-Motor-Matlab-Simulink-master\LICENSE
     文件        2157  2018-06-15 23:44  Fuzzy-PID-DC-Motor-Matlab-Simulink-master\MotorFuzzyPID.m
     文件         165  2018-06-15 23:44  Fuzzy-PID-DC-Motor-Matlab-Simulink-master\README.md
     文件       23242  2018-06-15 23:44  Fuzzy-PID-DC-Motor-Matlab-Simulink-master\SimFuzzyPID.slx

评论

共有 条评论

相关资源