⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pid_tuner.m

📁 很优良的PID控制器设计仿真程序与模型,经过严格检验
💻 M
📖 第 1 页 / 共 4 页
字号:
                    'Rivera et al',...
                    'Fruehauf et al',...
                    'Lee et al');
            case 6
                str=str2mat('Regulator-minimum IAE (Pessen)',...
                    'Servo-minimum-ISTSE (Zhuang & Atherton)',...
                    'Regulator-minimum-ISTSE (Zhuang & Atherton)',...
                    'Servo-nearly minimum IAE ITAE (Hwang & Fang)',...
                    'Regulator-nearly minimum IAE ITAE (Hwang & Fang)',...
                    'Simultaneous Servo/regulator-nearly minimum IAE ITAE (Hwang & Fang)',...
                    'McMillan',...
                    'Tan et al [Am=2,φm=pi/4]',...
                    'Tan et al [Arbitrary Am,φm]');
            case 7
                str=str2mat('Astrom & Hagglund [max sensitivity=1.4]',...
                    'Astrom & Hagglund [max sensitivity=2.0]');
        end
    case 3
        switch key2
            case 1 
                str=str2mat('Hang et al',...
                    'Witt & Waggoner',...
                    'St.Clair ["aggressive" tuning]',...
                    'St.Clair ["conservative" tuning]');
            case 2
                str=str2mat('Minimum IAE (Kaya & Scheib)',...
                    'Minimum ISE (Kaya & Scheib)',...
                    'minimum ITAE (Kaya & Scheib)');
            case 3
                str=str2mat('Minimum IAE (Kaya & Scheib) [First Function]',...
                    'Minimum IAE (Kaya & Scheib) [Second Function]',...
                    'Minimum ISE (Kaya & Scheib) [First Function]',...
                    'Minimum ISE (Kaya & Scheib) [Second Function]',...
                    'minimum ITAE (Kaya & Scheib) [First Function]',...
                    'Minimum ITAE (Kaya & Scheib) [Second Function]');
            case 4
                str=str2mat('Tsang & Rad',...
                    'Tsang et al [ξ=0.0]',...
                    'Tsang et al [ξ=0.1]',...
                    'Tsang et al [ξ=0.2]',...
                    'Tsang et al [ξ=0.3]',...
                    'Tsang et al [ξ=0.4]',...
                    'Tsang et al [ξ=0.5]',...
                    'Tsang et al [ξ=0.6]',...
                    'Tsang et al [ξ=0.7]',...
                    'Tsang et al [ξ=0.8]',...
                    'Tsang et al [ξ=0.9]',...
                    'Tsang et al [ξ=1.0]'); 
            case 5
                str=str2mat('Chien [First Function]',...
                    'Chien [Second Function]');
            case 6
                str=str2mat('Minimum IAE regulator (Shinskey) [First Funtion]',...
                    'Minimum IAE regulator (Shinskey) [Second Funtion]');
            case 7
                str=str2mat('Minimum IAE (Kaya & Scheib)',...
                    'Minimum ISE (Kaya & Scheib)',...
                    'minimum ITAE (Kaya & Scheib)');
        end
end
set(handles.h_lstAlgorithm,'String',str,'Value',1);
function h_lstPID_CreateFcn(hObject, eventdata, handles)if ispc    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end
function h_lstPIPID_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

function pid_tuner_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);

function varargout = pid_tuner_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function h_lstApply_Callback(hObject, eventdata, handles)h_lstPIPID_Callback(hObject, eventdata, handles);function h_btnDisplay_Callback(hObject, eventdata, handles)
xx=get(handles.h_btnDesign,'UserData');
x_result=xx{1};key1=xx{2};key2=xx{3};key3=xx{4};key=xx{5};lb=xx{6};  
x_str1='';
x_str2='';
x_str3='';
x_str4='';
x_str5='';
switch length(x_result)
    case 0   
        x_str1='Failed';
    case 2
        x_str1='The PI controller is';
        if key2==7
            yy=get(handles.h_btnFOLPD,'UserData');
            L=yy{2};T=yy{3};
            t=L/(L+T);
            switch key3
                case 1
                    b=0.81*exp(0.73*t+1.9*t^2);
                    x_str3=sprintf('G_c(s)=%f(%f+1/(%fs))',x_result(1),b,x_result(2));
                case 2
                    b=0.44*exp(0.78*t-0.45*t^2);
                    x_str3=sprintf('G_c(s)=%f(%f+1/(%fs))',x_result(1),b,x_result(2));
                case 3
                    b=0.5;
                    x_str3=sprintf('G_c(s)=%f(%f+1/(%fs))',x_result(1),b,x_result(2));
            end
        else
            x_str3=sprintf('G_c(s)=%f(1+1/(%fs))',x_result(1),x_result(2));
        end
    case 4
        if x_result(4)==1
            x_str1='The PID controller is';
            if key2==7
                yy=get(handles.h_btnFOLPD,'UserData');
                L=yy{2};T=yy{3};
                t=L/(L+T); 
                switch key3
                    case 1
                        b=0.40*exp(0.18*t+2.8*t^2);
                        x_str3=sprintf('Gc_(s)=%f(%f+1/%fs+%fs)',x_result(1),b,x_result(2),x_result(3));
                    case 2
                        b=0.22*exp(0.65*t+0.051*t^2);
                        x_str3=sprintf('Gc_(s)=%f(%f+1/%fs+%fs)',x_result(1),b,x_result(2),x_result(3));
                end
            else
                x_str3=sprintf('Gc_(s)=%f(1+1/%fs+%fs)',x_result(1),x_result(2),x_result(3));
            end
        else
            x_str1='The Modified PID controller is';
            if key2==7      
                N=10;
                x_str3=sprintf('U(s)=%f(1+1/%fs)[R(s)-Y(s)(1+%fs)/(1+%fs/%6.2f)]',x_result(1),x_result(2),x_result(3),x_result(3),N);
            else
                if key2==4
                    if key3==1
                        N=5;
                    else
                        N=2.5;
                    end
                else
                    N=10;
                end
                x_str3=sprintf('Gc_(s)=%f(1+1/%fs)(1+%fs)/(1+%fs/%f)',x_result(1),x_result(2),x_result(3),x_result(3),N);
            end
        end
    otherwise
end
if key==2
    x_str5=sprintf('Warning: L/T>%f',lb);
elseif key==3
    x_str5=sprintf('Warning: L/T<%f',lb);
else
end
msgbox({x_str1; x_str2; x_str3; x_str2; x_str4;x_str5},'Controller information');

function h_btnSimulation_Callback(hObject, eventdata, handles)G=get(handles.h_btnPlant,'UserData');
axes(handles.h_axMain);
set([handles.h_btnTRange,handles.h_axMain],'Visible','on');
xx=get(handles.h_btnDesign,'UserData');
key1=get(handles.h_lstPIPID,'Value');
key2=get(handles.h_lstApply,'Value');
key3=get(handles.h_lstAlgorithm,'Value');
Gd=[];
set([handles.h_txtLam,handles.h_edtLam],'Visible','off');
switch key1
    case 1
        if key2==7
            yy=get(handles.h_btnFOLPD,'UserData');
            L=yy{2};T=yy{3};
            t=L/(L+T);
            switch key3
                case 1
                    b=0.81*exp(0.73*t+1.9*t^2);
                    Gc=xx{1}(1)*(b+tf(1,[xx{1}(2) 0]));
                case 2
                    b=0.44*exp(0.78*t-0.45*t^2);
                    Gc=xx{1}(1)*(b+tf(1,[xx{1}(2) 0]));
                case 3
                    b=0.5;
                    Gc=xx{1}(1)*(b+tf(1,[xx{1}(2) 0]));
            end
        else
            Gc=xx{1}(1)*(1+tf(1,[xx{1}(2) 0]));
        end
    case 2
        if key2==7
            yy=get(handles.h_btnFOLPD,'UserData');
            L=yy{2};T=yy{3};
            t=L/(L+T); 
            switch key3
                case 1
                    b=0.40*exp(0.18*t+2.8*t^2);
                    Gc=xx{1}(1)*(b+tf(1,[xx{1}(2) 0])+tf([xx{1}(3),0],[xx{1}(3)/10,1]));
                case 2
                    b=0.22*exp(0.65*t+0.051*t^2);
                    Gc=xx{1}(1)*(b+tf(1,[xx{1}(2) 0])+tf([xx{1}(3),0],[xx{1}(3)/10,1]));
            end
        else
            Gc=xx{1}(1)*(1+tf(1,[xx{1}(2) 0])+tf([xx{1}(3),0],[xx{1}(3)/10,1]));
        end
    case 3
        if key2==7
            Gc=xx{1}(1)*(1+tf(1,[xx{1}(2) 0])); 
            Gd=Gc*tf([xx{1}(3),1],[xx{1}(3)/10,1]);
        else
            Gc=xx{1}(1)*(1+tf(1,[xx{1}(2) 0]))*tf([xx{1}(3),1],[xx{1}(3)/10,1]);
        end
end
tend=str2num(get(handles.h_edtTRange,'String')); 
if G.ioDelay==0 & ~(key1==3 & key2==7)
    step(feedback(G*Gc,1),tend); 
else
    assignin('base','num_p',G.num{1});
    assignin('base','den_p',G.den{1});
    assignin('base','num_c',Gc.num{1});
    assignin('base','den_c',Gc.den{1});
    assignin('base','Td',G.ioDelay);
    if length(Gd)>0
        assignin('base','num_d',Gd.num{1});
        assignin('base','den_d',Gd.den{1});
        [t,x,y]=sim('pid_simu_ind',[0,tend]);
    else
        [t,x,y]=sim('pid_simu',[0,tend]);
    end
    plot(t,y)
end

function h_btnTRange_Callback(hObject, eventdata, handles)
set([handles.h_edtTRange,handles.h_txtTRange],'Visible','on');

function h_edtTRange_Callback(hObject, eventdata, handles)
set([handles.h_edtTRange,handles.h_txtTRange],'Visible','off');
h_btnSimulation_Callback(hObject, eventdata, handles);
function h_btnHold_Callback(hObject, eventdata, handles)
key=get(handles.h_btnHold,'Value');
if key==0, hold off; else, hold on; end

%DO NOT edit function h_lstAlgorithm_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function h_lstAlgorithm_Callback(hObject, eventdata, handles)
function h_lstFOLPD_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function h_lstFOLPD_Callback(hObject, eventdata, handles)
function h_lstApply_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function h_edtLam_CreateFcn(hObject, eventdata, handles)if ispc    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction h_edtLam_Callback(hObject, eventdata, handles)function h_edtTRange_CreateFcn(hObject, eventdata, handles)if ispc    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -