Commit a1134b95 authored by Kristian Soltesz's avatar Kristian Soltesz
Browse files

work in progress

parent 24b014f5
......@@ -7,7 +7,7 @@
% See the git repo for further documentation.
%% Setup
clear all; close all;clc % start from blank sheet
close all;clc;clear all % start from blank sheet
% Process model (continuous time LTI SISO system).
s = zpk('s');
......@@ -24,34 +24,63 @@ Mks = 10; % Maximum allowed magnitude of transfer function from process
% sensitivity.
%% IE-minimizing PI design
disp('Computing IE-minimizing PI design...')
opts = defaults(P,'pidIE');
opts.p = [0;0]; % Design PI controller
[K1,p1,opts1] = pidIE(P,Ms,Mt,Mks,opts);
%% IAE-minimizing filtered PID design
disp('Computing IAE-minimizing filtered PID design...')
opts = defaults(P,'pidfIAE');
opts.p = [p1;0;0]; % Hot start with PI controller
[K2,p2] = pidfIAE(P,Ms,Mt,Mks,opts);
%% IAE-miniming Q design
disp('Computing IAE-minimizing Q design...')
opts = defaults(P,'optIAE',K2); % Hot start with filtered PID controller
[K3,Pd,Q] = optIAE(P,Ms,Mt,Mks,opts)
[K3,Pd,Q] = optIAE(P,Ms,Mt,Mks,opts);
% opts.optIAE.K0 = K2; % Hot start with filtered PID controller.
% %K0 = K2;
% h = 0.1/bandwidth(feedback(K0*P,1));
% if totaldelay(P)/h > 15 % avoid excessive number of states for delay-dominated plants
% h = totaldelay(P)/15;
%% Validate and visualize designs
% Pc = P;
% wN =
%
% for design = 3:-1:1 % Go backwards, to start with Q design
% P = Pc;
% eval(['K=K' num2str(design) ';'])
% switch design
% case 1
% c = 'b';
% case 2
% c = 'r';
% case 3
% c = 'g';
% P = Pd;
% wN = ; % Nyquist frequency
% end
% G = loopsens(P,K);
%
% % Determine time horizon for optimization
% loops = loopsens(P,K0); % GoF
% [y,t] = step(series(P,loops.So)); % load step response
% T0 = t(end);
% [y,t] = step(series(P,loops.So),2*T0); % longer load step response
% iy = find(abs(y)>0.005*max(abs(y))); % Find 0.5% settling time
% T = t(iy(end))
% % Optimize
% K3 = optIAE(P,Ms,Mt,Mks,h,T,K0);
%% Validate and visualize designs
\ No newline at end of file
% figure(1)
%
% figure(2)
% bode(G.So,'color',c)
% end
%
%
% % opts.optIAE.K0 = K2; % Hot start with filtered PID controller.
% % %K0 = K2;
% % h = 0.1/bandwidth(feedback(K0*P,1));
% % if totaldelay(P)/h > 15 % avoid excessive number of states for delay-dominated plants
% % h = totaldelay(P)/15;
% % end
% %
% % % Determine time horizon for optimization
% % loops = loopsens(P,K0); % GoF
% % [y,t] = step(series(P,loops.So)); % load step response
% % T0 = t(end);
% % [y,t] = step(series(P,loops.So),2*T0); % longer load step response
% % iy = find(abs(y)>0.005*max(abs(y))); % Find 0.5% settling time
% % T = t(iy(end))
% % % Optimize
% % K3 = optIAE(P,Ms,Mt,Mks,h,T,K0);
%
% %% Validate and visualize designs
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment