Some related files: mlokal\matlab\bin\nonlinpi.m : Nonlinear example (also copy here!) mlokal\latex\work\talk_feedbacktrick.tex mlokal\matlab\fb\feedback.m : Distillation example with FF and FB (NOT used) % BIG FEEDBACK/FEEDFORWARD EXAMPLE START HERE (file tunepidd) Kc=0;taui=999,taud=0;td=0;tstop=50;tys=999; tol=0.1; d=1; graphics; k=10;kd=10; tau=10; theta=0.001; Kc=0; uff=0; sim('tunepidd'); t0=Tid; y0=y; plot(t0,y0,'--'); xlabel('Time');ylabel('Output y');text(20,8,'No control') hold; % FB CONTROL: Kc=1; taui=4; uff=0; %sim('tunepidd'); plot(Tid,y,'red',Tid,ys,'--'); text(15,0.3,'Output y (PI control)') %sim('tunepidd'); plot(Tid,u); text(15,-1.5,'Input u') %Kc=1; taui=999; %sim('tunepidd'); plot(Tid,y,'red'); text(15,1.2,'Output y (P control only)') %sim('tunepidd'); plot(Tid,u); k=5; theta=0; sim('tunepidd'); plot(Tid,y,'red'); %text(10,0.5,'k=20,10,5') k=10; theta=0; sim('tunepidd'); plot(Tid,y,'red'); k=20; theta=0; sim('tunepidd'); plot(Tid,y,'red'); k=10; theta=0; tau=10;sim('tunepidd'); plot(Tid,y,'red'); %text(10,0.5,'\tau=5,10,20') k=10; theta=0; tau=5; sim('tunepidd'); plot(Tid,y,'red'); k=10; theta=0; tau=20;sim('tunepidd'); plot(Tid,y,'red'); k=3; tau=k; sim('tunepidd'); plot(Tid,y,'red'); %text(20,0.5,'k=20,10,3') k=10; tau=k; sim('tunepidd'); plot(Tid,y,'red'); k=20; tau=k; sim('tunepidd'); plot(Tid,y,'red'); k=10; theta=0; sim('tunepidd'); plot(Tid,y,'red'); %text(0.7,-6,'\theta=0,1,2,3') k=10; theta=1; sim('tunepidd'); plot(Tid,y,'r:'); k=10; theta=2; sim('tunepidd'); plot(Tid,y,'r:'); k=10; theta=3; sim('tunepidd'); plot(Tid,y,'r:'); axis([0 50 -10 10]) % FF CONTROL: uff=1; Kc=0; %sim('tunepidd'); plot(Tid,y,'red'); text(20,0.5,'Perfect FF control') k=5; theta=0; sim('tunepidd'); plot(Tid,y,'red'); %text(20,5.5,'k=5') k=10; theta=0; sim('tunepidd'); plot(Tid,y,'red'); %text(20,0.7,'k=10') k=20; theta=0; sim('tunepidd'); plot(Tid,y,'red'); %text(20,-8,'k=20') k=10; theta=0; tau=10;sim('tunepidd'); plot(Tid,y,'red'); %text(20,0.5,'\tau=10') k=10; theta=0; tau=5; sim('tunepidd'); plot(Tid,y,'red'); %text(20,3,'\tau=5') k=10; theta=0; tau=20;sim('tunepidd'); plot(Tid,y,'red'); %text(20,-2,'\tau=20') k=3; tau=k; sim('tunepidd'); plot(Tid,y,'red'); %text(20,5.5,'k=3') k=10; tau=k; sim('tunepidd'); plot(Tid,y,'red'); %text(20,0.7,'k=10') k=20; tau=k; sim('tunepidd'); plot(Tid,y,'red'); %text(20,-6,'k=20') k=10; theta=0; sim('tunepidd'); plot(Tid,y,'red'); k=10; theta=1; sim('tunepidd'); plot(Tid,y,'red'); %text(14,1,'\theta=0,1,2,3') k=10; theta=2; sim('tunepidd'); plot(Tid,y,'red'); k=10; theta=3; sim('tunepidd'); plot(Tid,y,'red'); % ENDS HERE % CASCADE EXAMPLE tys=1;td=50;tstop=100; tol=0.1; d=6; theta=1; numg=[-0.6 1]; deng = [6 1]; num2=1; den2 = conv([6 1],[0.4 1]); graphics; % Without cascade. thetaeff = 1 + 0.6 + 6/2 + 0.4 = 5, tau1 = 9 % Kc = 0.5 * tau1 / thetaeff = 0.90; taui = 9 Kc=0.90; taui=9; taud=0; Kc2=1; taui2=9999; k2 = 0; sim('tunepidc'); t1=Tid; y1=y; plot(t1,y1,'red',[0 100],[1 1],'--'),axis([0 100 -0.2 5]) % With cascade. thetaeff2 = 0.2; tau12 = 6; Kc = 0.5*6/0.2 = 12.5 -> 12; taui2 = 6 % gives L = resulting closed-loop transfer function is 1 / (0.2 s^2 + 0.5 s + 1) % which I approximate as effective delay sqrt(0.2) = 0.44 -> 0.4 % Overall outer transfer function then has tau1=6 and thetaeff = 1 + 0.6 + 0.4 =2 %which gives Kc=1.5 and taui=6 Kc=1.50; taui=6; taud=0; Kc2=12; taui2=6; k2 = 1; sim('tunepidc'); plot(t1,y1,':',[0 100],[1 1],'--',Tid,y,'red') ylabel('Output y');axis([0 100 -0.2 5]) ---------- Noen stikkord: Self-optimizing control Running 10 km : constant speed? easy to measure with clock. constant heart beat? constant level of sugar? lactic acid (melkesyre) skiing: disturbance = hill. Constant speed no longer optimal. Could have a mix depending on disturbance (constant feed when flat, lactic acid in hill?), max speed downhill turn ¨ Cell? Optimize cell growth? constant oxygen?