Advanced t Control t Systems t Lab t Sessions t 2021-2022 Version t2 Date t: t 21.04.2022 Author t: t ir. tMehmet t Can 1. Labs tLab t The toutput tof ta tPID tcontroller, twhich tis tequal tto tthe tcontrol tinput tto tthe tplant, tis tcalculated tin tthe ttime tdomain tfrom tthe tfeedback terror tas tfollows: (1) First, tlet's ttake ta tlook tat thow tthe tPID tcontroller tworks tin ta tclosed-loop tsystem tusing tthe tschematic tshown tabove. tThe tvariable t( ) trepresents tthe ttracking terror, tthe tdifference tbetween tthe tdesired toutput t( ) tand tthe tactual toutput t( ). tThis terror tsignal t( ) tis tfed tto tthe tPID tcontroller, tand tthe tcontroller tcomputes tboth tthe tderivative tand tthe tintegral tof tthis terror tsignal twith trespect tto ttime. tThe tcontrol tsignal t( ) tto tthe tplant tis tequal tto tthe tproportional tgain t( ) ttimes tthe tmagnitude tof tthe terror tplus tthe tintegral tgain t( ) ttimes tthe tintegral tof tthe terror tplus tthe tderivative tgain t( ) ttimes tthe tderivative tof tthe terror. This tcontrol tsignal t( ) tis tfed tto tthe tplant tand tthe tnew toutput t( ) tis tobtained. tThe tnew toutput t( ) tis tthen tfed tback tand tcompared tto tthe treference tto tfind tthe tnew terror tsignal t( ). tThe tcontroller ttakes tthis tnew terror tsignal tand tcomputes tan tupdate tof tthe tcontrol tinput. tThis tprocess tcontinues twhile tthe tcontroller tis tin teffect. The ttransfer tfunction tof ta tPID tcontroller tis tfound tby ttaking tthe tLaplace ttransform tof tEquation t(1). (2) where t = tproportional tgain, t = tintegral tgain, tand t = tderivative tgain. We tcan tdefine ta tPID tcontroller tin tMATLAB tusing ta ttransfer tfunction tmodel tdirectly, tfor texample: Kp t= t1; Ki t= t1; Kd t= t1; s t= ttf('s'); C t= tKp t+ tKi/s t+ tKd*s C t= t ts^2 t+ ts t+ t1 t----------ts Continuous-time ttransfer tfunction. Alternatively, twe tmay tuse tMATLAB's tpid tobject tto tgenerate tan tequivalent tcontinuous-time tcontroller tas tfollows © tAdvanced tControl tSystems tLab tSessions, tir. tMehmet tCan page t1 tof t6 The tCharacteristics tof tthe tP, tI, tand tD tTerms Increasing tthe tproportional tgain t( ) thas tthe teffect tof tproportionally tincreasing tthe tcontrol tsignal tfor tthe tsame tlevel tof terror. tThe tfact tthat tthe tcontroller twill t"push" tharder tfor ta tgiven tlevel tof terror ttends tto tcause tthe tclosed-loop tsystem tto treact tmore tquickly, tbut talso tto tovershoot tmore. tAnother teffect tof tincreasing t is tthat tit ttends tto treduce, tbut tnot teliminate, tthe tsteadystate terror. The taddition tof ta tderivative tterm tto tthe tcontroller t( ) tadds tthe tability tof tthe tcontroller tto t"anticipate" terror. tWith tsimple tproportional tcontrol, tif t is tfixed, tthe tonly tway tthat tthe tcontrol twill tincrease tis tif tthe terror tincreases. tWith tderivative tcontrol, tthe tcontrol tsignal tcan tbecome tlarge tif tthe terror tbegins tsloping tupward, teven twhile tthe tmagnitude tof tthe terror tis tstill trelatively tsmall. tThis tanticipation ttends tto tadd tdamping tto tthe tsystem, tthereby tdecreasing tovershoot. tThe taddition tof ta tderivative tterm, thowever, thas tno teffect ton tthe tsteady-state terror. The taddition tof tan tintegral tterm tto tthe tcontroller t( ) ttends tto thelp treduce tsteady-state terror. tIf tthere tis ta tpersistent, tsteady terror, tthe tintegrator tbuilds tand tbuilds, tthereby tincreasing tthe tcontrol tsignal tand tdriving tthe terror tdown. tA tdrawback tof tthe tintegral tterm, thowever, tis tthat tit tcan tmake tthe tsystem tmore tsluggish t(and toscillatory) tsince twhen tthe terror tsignal tchanges tsign, tit tmay ttake ta twhile tfor tthe tintegrator tto t"unwind." The tgeneral teffects tof teach tcontroller tparameter t( ,t , t ) ton ta tclosed-loop tsystem tare tsummarized tin tthe ttable tbelow. tNote, tthese tguidelines thold tin tmany tcases, tbut tnot tall. tIf tyou ttruly twant tto tknow tthe teffect tof ttuning tthe tindividual tgains, tyou twill thave tto tdo tmore tanalysis, tor twill thave tto tperform ttesting ton tthe tactual tsystem. CL tRESPONSE RISE tTIME OVERSHOOT SETTLING tTIME S-S tERROR Kp Decrease Increase Small tChange Decrease Ki Decrease Increase Increase Decrease Kd Small tChange Decrease Decrease No tChange Example tProblem Suppose twe thave ta tsimple tmass-spring-damper tsystem. The tgoverning tequation tof tthis tsystem tis (3) Taking tthe tLaplace ttransform tof tthe tgoverning tequation, twe tget (4) The ttransfer tfunction tbetween tthe tinput tforce t and tthe toutput tdisplacement t then tbecomes (5) Let tm t= t1 tkg tb t= t10 tN ts/m tk t= t20 tN/m tF t= t1 tN Substituting tthese tvalues tinto tthe tabove ttransfer tfunction (6) The tgoal tof tthis tproblem tis tto tshow thow teach tof tthe tterms, t ,t , tand t , tcontributes tto tobtaining tthe tcommon tgoals tof: Fast trise ttime Minimal tovershoot Zero tsteady-state terror Open-Loop tStep tResponse © tAdvanced tControl tSystems tLab tSessions, tir. tMehmet tCan page t2 tof t6 Let's tfirst tview tthe topen-loop tstep tresponse. tCreate ta tnew tm-file tand trun tthe tfollowing tcode: s t= ttf('s'); P t= t1/(s^2 t+ t10*s t+ t20); step(P) The tDC tgain tof tthe tplant ttransfer tfunction tis t1/20, tso t0.05 tis tthe tfinal tvalue tof tthe toutput tto ta tunit tstep tinput. tThis tcorresponds tto ta tsteady-state terror tof t0.95, twhich tis tquite tlarge. tFurthermore, tthe trise ttime tis tabout tone tsecond, tand tthe tsettling ttime tis tabout t1.5 tseconds. tLet's tdesign ta tcontroller tthat twill treduce tthe trise ttime, treduce tthe tsettling ttime, tand teliminate tthe tsteady-state terror. Proportional tControl From tthe ttable tshown tabove, twe tsee tthat tthe tproportional tcontroller t( treduces tthe tsteady-state terror. ) treduces tthe trise ttime, tincreases tthe tovershoot, tand The tclosed-loop ttransfer tfunction tof tour tunity-feedback tsystem twith ta tproportional tcontroller tis tthe tfollowing, twhere t toutput t(equals t ) tand tour treference t is tthe tinput: (7) Let tthe tproportional tgain t( ) tequal t300 tand tchange tthe tm-file tto tthe tfollowing: Kp t= t300; C t= tpid(Kp) T t= tfeedback(C*P,1) t t= t0:0.01:2; step(T,t) © tAdvanced tControl tSystems tLab tSessions, tir. tMehmet tCan page t3 tof t6 is tour The tabove tplot tshows tthat tthe tproportional tcontroller treduced tboth tthe trise ttime tand tthe tsteady-state terror, tincreased tthe tovershoot, tand tdecreased tthe tsettling ttime tby ta tsmall tamount. Proportional-Derivative tControl Now, tlet's ttake ta tlook tat tPD tcontrol. tFrom tthe ttable tshown tabove, twe tsee tthat tthe taddition tof tderivative tcontrol t( ) ttends tto treduce tboth tthe tovershoot tand tthe tsettling ttime. tThe tclosed-loop ttransfer tfunction tof tthe tgiven tsystem twith ta tPD tcontroller tis: (8) Let t equal t300 tas tbefore tand tlet t tcommand twindow. equal t10. tEnter tthe tfollowing tcommands tinto tan tm-file tand trun tit tin tthe tMATLAB Kp t= t300; Kd t= t10; C t= tpid(Kp,0,Kd) T t= tfeedback(C*P,1) t t= t0:0.01:2; This tplot tshows tthat tthe taddition tof tthe tderivative tterm treduced tboth tthe tovershoot tand tthe tsettling ttime, tand thad ta tnegligible teffect ton tthe trise ttime tand tthe tsteady-state terror. Proportional-Integral tControl Before tproceeding tto tPID tcontrol, tlet's tinvestigate tPI tcontrol. tFrom tthe ttable, twe tsee tthat tthe taddition tof tintegral tcontrol t( ) ttends tto tdecrease tthe trise ttime, tincrease tboth tthe tovershoot tand tthe tsettling ttime, tand treduces tthe tsteady-state terror. tFor tthe tgiven tsystem, tthe tclosed-loop ttransfer tfunction twith ta tPI tcontroller tis: (9) Let's treduce t to t30, tand tlet t equal t70. tCreate ta tnew tm-file tand tenter tthe tfollowing tcommands. Kp t= t30; Ki t= t70; C t= tpid(Kp,Ki) T t= tfeedback(C*P,1) © tAdvanced tControl tSystems tLab tSessions, tir. tMehmet tCan page t4 tof t6 t t= t0:0.01:2; step(T,t) Run tthis tm-file tin tthe tMATLAB tcommand twindow tand tyou tshould tgenerate tthe tabove tplot. tWe thave treduced tthe tproportional tgain t( ) tbecause tthe tintegral tcontroller talso treduces tthe trise ttime tand tincreases tthe tovershoot tas tthe tproportional tcontroller tdoes t(double teffect). tThe tabove tresponse tshows tthat tthe tintegral tcontroller teliminated tthe tsteady-state terror tin tthis tcase. Proportional-Integral-Derivative tControl Now, tlet's texamine tPID tcontrol. tThe tclosed-loop ttransfer tfunction tof tthe tgiven tsystem twith ta tPID tcontroller tis: (10) After tseveral titerations tof ttuning, tthe tgains t = t350, t = t300, tand t = t50 tprovided tthe tdesired tresponse. tTo tconfirm, tenter tthe tfollowing tcommands tto tan tm-file tand trun tit tin tthe tcommand twindow. tYou tshould tobtain tthe tfollowing tstep tresponse. Kp t= t350; Ki t= t300; Kd t= t50; C t= tpid(Kp,Ki,Kd) T t= tfeedback(C*P,1); t t= t0:0.01:2; step(T,t) © tAdvanced tControl tSystems tLab tSessions, tir. tMehmet tCan page t5 tof t6 Notice tthat tthe tstep tresponse tshown tis tslower tthan tthe tproportional tcontroller twe tdesigned tby thand. tNow tclick ton tthe tShow tParameters tbutton ton tthe ttop tright. tAs texpected, tthe tproportional tgain, t , tis tsmaller tthan tthe tone twe temployed, t = t94.86 t< t300. We tcan tnow tinteractively ttune tthe tcontroller tparameters tand timmediately tsee tthe tresulting tresponse tin tthe tGUI twindow. tTry tdragging tthe tResponse tTime tslider tto tthe tright tto t0.14 ts, tas tshown tin tthe tfigure tbelow. tThis tcauses tthe tresponse tto tindeed tspeed tup, tand twe tcan tsee t is tnow tcloser tto tthe tmanually tchosen tvalue. tWe tcan talso tsee tother tperformance tand trobustness tparameters tfor tthe tsystem. tNote tthat tbefore twe tadjusted tthe tslider, tthe ttarget tphase tmargin twas t60 tdegrees. tThis tis tthe tdefault tfor tthe tpidTuner tand tgenerally tprovides ta tgood tbalance tbetween trobustness tand tperformance. Now tlet's ttry tdesigning ta tPID tcontroller tfor tour tsystem. tBy tspecifying tthe tpreviously tdesigned tor t(baseline) tcontroller, tC, tas tthe tsecond tparameter, tpidTuner twill tdesign tanother tPID tcontroller t(instead tof tP tor tPI) tand twill tcompare tthe tresponse tof tthe tsystem twith tthe tautomated tcontroller twith tthat tof tthe tbaseline. tpidTuner(P,C) t We tsee tin tthe toutput twindow tthat tthe tautomated tcontroller tresponds tslower tand texhibits tmore tovershoot tthan tthe tbaseline. tNow tchoose tthe tDomain: tFrequency toption tfrom tthe ttoolstrip, twhich treveals tfrequency tdomain ttuning tparameters. Now ttype tin t32 trad/s tfor tBandwidth tand t90 tdeg tfor tPhase tMargin, tto tgenerate ta tcontroller tsimilar tin tperformance tto tthe tbaseline. tKeep tin tmind tthat ta thigher tclosed-loop tbandwidth tresults tin ta tfaster trise ttime, tand ta tlarger tphase tmargin treduces tthe tovershoot tand timproves tthe tsystem tstability. Finally, twe tnote tthat twe tcan tgenerate tthe tsame tcontroller tusing tthe tcommand tline ttool tpidtune tinstead tof tthe tpidTuner tGUI temploying tthe tfollowing tsyntax. opts t= tpidtuneOptions('CrossoverFrequency',32,'PhaseMargin',90); [C, tinfo] t= tpidtune(P, t'pid', topts) © tAdvanced tControl tSystems tLab tSessions, tir. tMehmet tCan page t6 tof t6 Lab t2 Assignments 1. Determine tthe ttransfer tfunction tfrom tthe tunit tstep tresponse tof tthe tfirst-order tsystem tshown tin tFigure t3. tSimulate tthe tsystem tusing tMATLAB tand tcompare tthe tresults. tShow tyour tresults tclearly. 2. Design tan telectric tcircuit tthat tgives tthe tunit-step tresponses tin tFigure t3. tProve tyour tresults twith treal-time tmeasurements. tExplain tclearly twhat tchoices tyou thave tmade. tSimulate tthe tcircuit talso tin tTINA tSpice. tShow tyour tresults tclearly. 3. Apply tfeedback tin tthe tdesign tof tthe telectric tcircuit tfor tthe tunit tstep tresponse tin tFigure t3 tto tmake tthe ttime tconstant ttwo ttimes tsmaller. tDo tnot talter tthe tdesigned tcircuit tfor tthe topen-loop tsystem. tProve tyour tresults twith treal-time tmeasurements. tSimulate tthe tcircuittalso tin tTINA tSpice. tShow tyour tresults tclearly. 4. Design tthe tcontroller tin tthe tfeedback tloop tconfiguration tsuch tthat tyou tmeet tthe tspecifications tin t“2. tLab tAssignment tRequirements”. Syntax step(sys) step(sys,tFinal) step(sys,t) step(sys1,sys2,...,sysN,___) step(sys1,LineSpec1,...,sysN,LineSpecN,___) step(___,opts) y t= tstep(sys,t) [y,tOut] t= tstep(sys) [y,tOut] t= tstep(sys,tFinal) [y,t,x] t= tstep(sys) [y,t,x,ysd] t= tstep(sys) [___] t= tstep(___,opts) Description Step Response Plots step(sys) tplots tthe tresponse tof ta tdynamic tsystem tmodel tto ta tstep tinput tof tunit tamplitude. tThe tmodel tsys tcan tbe tcontinuous- tor tdiscrete-time, tand tSISO tor tMIMO. tFor tMIMO tsystems, tthe tplot tdisplays tthe tstep tresponses tfor teach tI/O tchannel. tstep tautomatically tdetermines tthe ttime tsteps tand tduration tof tthe tsimulation tbased ton tthe tsystem tdynamics. step(sys,tFinal) tsimulates tthe tstep tresponse tfrom tt t= t0 tto tthe tfinal ttime tt t= ttFinal. tThe tfunction tuses tsystem tdynamics tto tdetermine tthe tintervening ttime tsteps. step(sys,t) tplots tthe tstep tresponse tat tthe ttimes tthat tyou tspecify tin tthe tvector tt. step(sys1,sys2,...,sysN,___) tplots tthe tstep tresponse tof tmultiple tdynamic tsystems ton tthe tsame tplot. tAll tsystems tmust thave tthe tsame tnumber tof tinputs tand toutputs. tYou tcan tuse tmultiple tdynamic tsystems twith tany tof tthe tprevious tinput-argument tcombinations. step(sys1,LineSpec1,...,sysN,LineSpecN,___) tspecifies ta tcolor, tline tstyle, tand tmarker tfor teach tsystem tin tthe tplot. tYou tcan tuse tLineSpec twith tany tof tthe tprevious tinput-argument tcombinations. tWhen tyou tneed tadditional tplot tcustomization toptions, tuse tstepplot tinstead. step(___,opts) tspecifies tadditional toptions tfor tcomputing tthe tstep tresponse, tsuch tas tthe tstep tamplitude tor tinput toffset. tUse tstepDataOptions tto tcreate tthe toption tset topts. tYou tcan tuse topts twith tany tof tthe tprevious tinput-argument tand toutputargument tcombinations. Step tResponse tData y t= tstep(sys,t) treturns tthe tstep tresponse tof ta tdynamic tsystem tmodel tsys tat tthe ttimes tspecified tin tthe tvector tt. tThis tsyntax tdoes tnot tdraw ta tplot. [y,tOut] t= tstep(sys) talso treturns ta tvector tof ttimes ttOut tcorresponding tto tthe tresponses tin ty. tIf tyou tdo tnot tprovide tan tinput tvector tt tof ttimes, tstep tchooses tthe tlength tand ttime tstep tof ttOut tbased ton tthe tsystem tdynamics. [y,tOut] t= tstep(sys,tFinal) tcomputes tthe tstep tresponse tup tto tthe tend ttime ttFinal. tstep tchooses tthe ttime tstep tof ttOut tbased ton tthe tsystem tdynamics. [y,t,x] t= tstep(sys) talso treturns tthe tstate ttrajectories tx, twhen tsys tis ta tstate-space tmodel tsuch tas tan tss tor tidss tmodel. [y,t,x,ysd] t= tstep(sys) talso tcomputes tthe tstandard tdeviation tysd tof tthe tstep tresponse ty, twhen tsys tis tan tidentified tmodel tsuch tas tan tidss, tidtf, tor tidnlarx tmodel. © tAdvanced tControl tSystems tLab tSessions, tir. tMehmet page t7 tof tCan t6 [___] t= tstep(___,opts) tspecifies tadditional toptions tfor tcomputing tthe tstep tresponse, tsuch tas tthe tstep tamplitude tor tinput toffset. tUse tstepDataOptions tto tcreate tthe toption tset topts. tYou tcan tuse topts twith tany tof tthe tprevious tinput-argument tand toutput-argument tcombinations. Examples collapse tall Step tResponse tof tDynamic tSystem Try tThis tExampleCopy tCommand tCopy tCode Plot tthe tstep tresponse tof ta tcontinuous-time tsystem trepresented tby tthe tfollowing ttransfer tfunction. 2 sys(s)= . 4s +2s+10 For tthis texample, tcreate ta ttf tmodel tthat trepresents tthe ttransfer tfunction. tYou tcan tsimilarly tplot tthe tstep tresponse tof tother tdynamic tsystem tmodel ttypes, tsuch tas tzero-pole tgain t(zpk) tor tstate-space t(ss) tmodels. sys t= ttf(4,[1 t2 t10]); Plot tthe tstep tresponse. step(sys) The tstep tplot tautomatically tincludes ta tdotted thorizontal tline tindicating tthe tsteady-state tresponse. tIn ta tMATLAB® tfigure twindow, tyou tcan tright-click ton tthe tplot tto tview tother tstep-response tcharacteristics tsuch tas tpeak tresponse tand tsettling ttime. tFor tmore tinformation tabout tthese tcharacteristics, tsee tstepinfo. Step tResponse tof tDiscrete-Time tSystem Try tThis tExampleCopy tCommand tCopy tCode Plot tthe tstep tresponse tof ta tdiscrete-time tsystem. tThe tsystem thas ta tsample ttime tof t0.2 ts tand tis trepresented tby tthe tfollowing tstate-space tmatrices. A t= t[1.6 t-0.7; t1 t0]; B t= t[0.5; t0]; C t= t[0.1 t0.1]; D t= t0; Create tthe tstate-space tmodel tand tplot tits tstep tresponse. sys t= tss(A,B,C,D,0.2); step(sys) The tstep tresponse treflects tthe tdiscretization tof tthe tmodel, tshowing tthe tresponse tcomputed tevery t0.2 tseconds. Step tResponse tat tSpecified tTimes Try tThis tExampleCopy tCommand tCopy tCode Examine tthe tstep tresponse tof tthe tfollowing ttransfer tfunction. © tAdvanced tControl tSystems tLab tSessions, tir. tMehmet tCan page t8 tof t6 sys t= tzpk(-1,[-0.2+3j,-0.2-3j],1) t* ttf([1 t1],[1 t0.05]) t sys t= t t(s+1)^2 t---------------------------t(s+0.05) t(s^2 t+ t0.4s t+ t9.04) t Continuous-time tzero/pole/gain tmodel. step(sys) By tdefault, tstep tchooses tan tend ttime tthat tshows tthe tsteady tstate tthat tthe tresponse tis ttrending ttoward. tThis tsystem thas tfast ttransients, thowever, twhich tare tobscured ton tthis ttime tscale. tTo tget ta tcloser tlook tat tthe ttransient tresponse, tlimit tthe tstep tplot tto tt t= t15 ts. step(sys,15) Lab t3 Assignments 1. Determine tthe ttransfer tfunction tfrom tthe tunit tstep tresponse tof tthe tsecond-order tsystem tshown tin tFigure t4. tSimulate tthe tsystem tusing tMATLAB tand tcompare tthe tresults. tShow tyour tresults tclearly. 2. Design tan telectric tcircuit tthat tgives tthe tunit-step tresponses tin tFigure t4. tProve tyour tresults twith treal-time tmeasurements. tExplain tclearly twhat tchoices tyou thave tmade. tSimulate tthe tcircuit talso tin tTINA tSpice. tShow tyour tresults tclearly. 3. Apply tfeedback tin tthe tdesign tof tthe telectric tcircuit tfor tthe tunit-step tresponse tin tFigure t4 tto tmake tthe tovershoot ttwo ttimes tsmaller.tDo tnot talter tthe tdesigned tcircuit tfor tthe topen-loop tsystem. tProve tyour tresults twith treal-time tmeasurements. tSimulate tthe tcircuittalso tin tTINA tSpice. tShow tyour tresults tclearly. 4. Design tthe tcontroller tin tthe tfeedback tloop tconfiguration tsuch tthat tyou tmeet tthe tspecifications tin t“2. tLab tAssignment tRequirements”. Step tResponse tPlot tof tMIMO tSystems Try tThis tExampleCopy tCommand tCopy tCode Consider tthe tfollowing tsecond-order tstate-space tmodel: ˙x ˙x = −0.55720.7814−0.78140 x1x2 + 10−12 u1u2 y=[1.96916.4493] x1x2 [ 1 2] [ ][ ] [ ][ ] [ ] A t= t[-0.5572,-0.7814;0.7814,0]; B t= t[1,-1;0,2]; C t= t[1.9691,6.4493]; sys t= tss(A,B,C,0); This tmodel thas ttwo tinputs tand tone toutput, tso tit thas ttwo tchannels: tfrom tthe tfirst tinput tto tthe toutput, tand tfrom tthe tsecond tinput tto tthe toutput. tEach tchannel thas tits town tstep tresponse. When tyou tuse tstep, tit tcomputes tthe tresponses tof tall tchannels. step(sys) The tleft tplot tshows tthe tstep tresponse tof tthe tfirst tinput tchannel, tand tthe tright tplot tshows tthe tstep tresponse tof tthe tsecond tinput tchannel. tWhenever tyou tuse tstep tto tplot tthe tresponses tof ta tMIMO tmodel, tit tgenerates tan tarray tof tplots trepresenting tall tthe tI/O tchannels tof tthe tmodel. tFor tinstance, tcreate ta trandom tstate-space tmodel twith tfive tstates, tthree tinputs, tand ttwo toutputs, tand tplot tits tstep tresponse. © tAdvanced tControl tSystems tLab tSessions, tir. tMehmet tCan page t9 tof t6 sys t= trss(5,2,3); step(sys) In ta tMATLAB tfigure twindow, tyou tcan trestrict tthe tplot tto ta tsubset tof tchannels tby tright-clicking ton tthe tplot tand tselecting tI/O tSelector. Compare tResponses tof tMultiple tSystems Try tThis tExampleCopy tCommand tCopy tCode step tallows tyou tto tplot tthe tresponses tof tmultiple tdynamic tsystems ton tthe tsame taxis. tFor tinstance, tcompare tthe tclosed-loop tresponse tof ta tsystem twith ta tPI tcontroller tand ta tPID tcontroller. tCreate ta ttransfer tfunction tof tthe tsystem tand ttune tthe tcontrollers. H t= ttf(4,[1 t2 t10]); C1 t= tpidtune(H,'PI'); C2 t= tpidtune(H,'PID'); Form tthe tclosed-loop tsystems tand tplot ttheir tstep tresponses. sys1 t= tfeedback(H*C1,1); sys2 t= tfeedback(H*C2,1); step(sys1,sys2) legend('PI','PID','Location','SouthEast') By tdefault, tstep tchooses tdistinct tcolors tfor teach tsystem tthat tyou tplot. tYou tcan tspecify tcolors tand tline tstyles tusing tthe tLineSpec tinput targument. tstep(sys1,'r--',sys2,'b') tlegend('PI','PID','Location','SouthEast') The tfirst tLineSpec t'r--' tspecifies ta tdashed tred tline tfor tthe tresponse twith tthe tPI tcontroller. tThe tsecond tLineSpec t'b' tspecifies ta tsolid tblue tline tfor tthe tresponse twith tthe tPID tcontroller. tThe tlegend treflects tthe tspecified tcolors tand tlinestyles. tFor tmore tplot tcustomization toptions, tuse tstepplot. Step tResponse tof tSystems tin ta tModel tArray Try tThis tExampleCopy tCommand tCopy tCode The texample tCompare tResponses tof tMultiple tSystems tshows thow tto tplot tresponses tof tseveral tindividual tsystems ton ta tsingle taxis. tWhen tyou thave tmultiple tdynamic tsystems tarranged tin ta tmodel tarray, tstep tplots tall ttheir tresponses tat tonce. © tAdvanced tControl tSystems tLab tSessions, tir. tMehmet tCan page t10 tof t6 Create ta tmodel tarray. tFor tthis texample, tuse ta tone-dimensional tarray tof tsecond-order ttransfer tfunctions thaving tdifferent tnatural tfrequencies. tFirst, tpreallocate tmemory tfor tthe tmodel tarray. tThe tfollowing tcommand tcreates ta t1-by-5 trow tof tzero-gain tSISO ttransfer tfunctions. tThe tfirst ttwo tdimensions trepresent tthe tmodel toutputs tand tinputs. tThe tremaining tdimensions tare tthe tarray tdimensions. tsys t= ttf(zeros(1,1,1,5)); Populate tthe tarray. w0 t= t1.5:1:5.5; t% tnatural tfrequencies zeta t= t0.5; t% tdamping tconstant for ti t= t1:length(w0) tsys(:,:,1,i) t= ttf(w0(i)^2,[1 t2*zeta*w0(i) tw0(i)^2]); end (For tmore tinformation tabout tmodel tarrays tand thow tto tcreate tthem, tsee tModel tArrays.) tPlot tthe tstep tresponses tof tall tmodels tin tthe tarray. step(sys) step tuses tthe tsame tlinestyle tfor tthe tresponses tof tall tentries tin tthe tarray. tOne tway tto tdistinguish tamong tentries tis tto tuse tthe tSamplingGrid tproperty tof tdynamic tsystem tmodels tto tassociate teach tentry tin tthe tarray twith tthe tcorresponding tw0 tvalue. sys.SamplingGrid t= tstruct('frequency',w0); Now, twhen tyou tplot tthe tresponses tin ta tMATLAB tfigure twindow, tyou tcan tclick ta ttrace tto tsee twhich tfrequency tvalue tit tcorresponds tto. Step tResponse tData When tyou tgive tit tan toutput targument, tstep treturns tan tarray tof tresponse tdata. tFor ta tSISO tsystem, tthe tresponse tdata tis treturned tas ta tcolumn tvector tof tlength tequal tto tthe tnumber tof ttime tpoints tat twhich tthe tresponse tis tsampled. tYou tcan tprovide tthe tvector tt tof ttime tpoints, tor tallow tstep tto tselect ttime tpoints tfor tyou tbased ton tsystem tdynamics. tFor tinstance, textract tthe tstep tresponse tof ta tSISO tsystem tat t101 ttime tpoints tbetween tt t= t0 tand tt t= t5 ts. sys t= ttf(4,[1 t2 t10]); t t= t0:0.05:5; y t= tstep(sys,t); size(y) ans t= t1×2 t101 t1 For ta tMIMO tsystem, tthe tresponse tdata tis treturned tin tan tarray tof tdimensions tN-by-Ny-by-Nu, twhere tNy tand tNu tare tthe tnumber tof toutputs tand tinputs tof tthe tdynamic tsystem. tFor tinstance, tconsider tthe tfollowing tstate-space tmodel, trepresenting ta ttwo-input, tone-output tsystem. A t= t[-0.5572,-0.7814;0.7814,0]; B t= t[1,-1;0,2]; C t= t[1.9691,6.4493]; sys t= tss(A,B,C,0); Extract tthe tstep tresponse tof tthis tsystem tat t200 ttime tpoints tbetween tt t= t0 tand tt t= t20 ts. t t= tlinspace(0,20,200); y t= tstep(sys,t); size(y) ans t= t1×3 t200 t1 t2 y(:,i,j) tis ta tcolumn tvector tcontaining tthe tstep tresponse tfrom tthe tjth tinput tto tthe tith toutput tat tthe ttimes tt. tFor tinstance, textract tthe tstep tresponse tfrom tthe tsecond tinput tto tthe toutput. © tAdvanced tControl tSystems tLab tSessions, tir. tMehmet tCan page t11 tof t6 y12 t= ty(:,1,2); plot(t,y12) Step tResponse tPlot tof tFeedback tLoop twith tDelay Try tThis tExampleCopy tCommand tCopy tCode Create ta tfeedback tloop twith tdelay tand tplot tits tstep tresponse. s t= ttf('s'); G t= texp(-s) t* t(0.8*s^2+s+2)/(s^2+s); sys t= tfeedback(ss(G),1); step(sys) The tsystem tstep tresponse tdisplayed tis tchaotic. tThe tstep tresponse tof tsystems twith tinternal tdelays tmay texhibit todd tbehavior, tsuch tas trecurring tjumps. tSuch tbehavior tis ta tfeature tof tthe tsystem tand tnot tsoftware tanomalies. Response tto tCustom tStep tInput Try tThis tExampleCopy tCommand tCopy tCode By tdefault, tstep tapplies tan tinput tsignal tthat tchanges tfrom t0 tto t1 tat tt t= t0. tTo tcustomize tthe tamplitude tand toffset, tuse tstepDataOptions. tFor tinstance, tcompute tthe tresponse tof ta tSISO tstate-space tmodel tto ta tsignal tthat tchanges tfrom t1 tto t–1 tto tat tt t= t0. A t= t[1.6 t-0.7; t1 t0]; B t= t[0.5; t0]; C t= t[0.1 t0.1]; D t= t0; sys t= tss(A,B,C,D,0.2); opt t= tstepDataOptions; opt.InputOffset t= t1; opt.StepAmplitude t= t-2; step(sys,opt) © tAdvanced tControl tSystems tLab tSessions, tir. tMehmet tCan page t12 tof t6 For tresponses tto tarbitrary tinput tsignals, tuse tlsim. Step tResponses tof tIdentified tModels twith tConfidence tRegions Try tThis tExample This texample tuses: System tIdentification tToolbox Copy tCommand tCopy tCode Compare tthe tstep tresponse tof ta tparametric tidentified tmodel tto ta tnon-parametric t(empirical) tmodel. tAlso tview ttheir t3 tσ tconfidence tregions. Load tthe tdata. load tiddata1 tz1 Estimate ta tparametric tmodel. sys1 t= tssest(z1,4); Estimate ta tnon-parametric tmodel. sys2 t= timpulseest(z1); Plot tthe tstep tresponses tfor tcomparison. t t= t(0:0.1:10)'; [y1, t~, t~, tysd1] t= [y2, t~, t~, tysd2] t= plot(t, ty1, t'b', tt, hold ton plot(t, ty2, t'g', tt, tstep(sys1,t); tstep(sys2,t); ty1+3*ysd1, t'b:', tt, ty1-3*ysd1, t'b:') ty2+3*ysd2, t'g:', tt, ty2-3*ysd2, t'g:') Step tResponse tof tIdentified tTime-Series tModel Try tThis tExample This texample tuses: System tIdentification tToolbox Lab t4 Assignments Figure t5 tis ta tblock tdiagram tof ta tmodel tfor tan tattitude-rate tcontrol tsystem. tIt tis tdesired tto tspeed tup tthe tresponse tand talso teliminate tthetoscillatory tmode tat tthe tbeginning tof tthe tresponse. Cascade t the t hydraulic t servo t with t a t controller t gain t 𝐾. t Calculate t the t range t of t controller t gain t 𝐾 t to t keep t the t system t stable. t UsetMATLAB tto tsimulate tyour tsystem tand tcompare tthe tresults. tClearly tshow tyour tsteps tin tthe tanalysis. 2. Design tthe tcontroller t(e.g.: tPID) tin tthe tfeedback tloop tconfiguration tsuch tthat tyou tmeet tthe tspecifications tin t“2. tLab © tAdvanced tControl tSystems tLab tSessions, tir. tMehmet page t13 tof tCan t6 1. tAssignmenttRequirements”. Compute tthe tstep tresponse tof tan tidentified ttime-series tmodel. A ttime-series tmodel, talso tcalled ta tsignal tmodel, tis tone twithout tmeasured tinput tsignals. tThe tstep tplot tof tthis tmodel tuses tits t(unmeasured) tnoise tchannel tas tthe tinput tchannel tto twhich tthe tstep tsignal tis tapplied. Load tthe tdata. load tiddata9; Estimate ta ttime-series tmodel. sys t= tar(z9, t4); sys tis ta tmodel tof tthe tform tA ty(t) t= te(t) t, twhere te(t) trepresents tthe tnoise tchannel. tFor tcomputation tof tstep tresponse, te(t) tis ttreated tas tan tinput tchannel, tand tis tnamed te@y1. Plot tthe tstep tresponse. step(sys) Validate tLinearization tof tIdentified tNonlinear tARX tModel Try tThis tExample This texample tuses: System tIdentification tToolbox Copy tCommand tCopy tCode Validate tthe tlinearization tof ta tnonlinear tARX tmodel tby tcomparing tthe tsmall tamplitude tstep tresponses tof tthe tlinear tand tnonlinear tmodels. Load tthe tdata. load tiddata2 tz2; Estimate ta tnonlinear tARX tmodel. nlsys t= tnlarx(z2,[4 t3 t10],idTreePartition,'custom',... t{'sin(y1(t-2)*u1(t))+y1(t-2)*u1(t)+u1(t).*u1(t-13)',... t'y1(t-5)*y1(t-5)*y1(t-1)'},'nlr',[1:5, t7 t9]); Determine tan tequilibrium toperating tpoint tfor tnlsys tcorresponding tto ta tsteady-state tinput tvalue tof t1. u0 t= t1; [X,~,r] t= tfindop(nlsys, t'steady', t1); y0 t= tr.SignalLevels.Output; Obtain ta tlinear tapproximation tof tnlsys tat tthis toperating tpoint. sys t= tlinearize(nlsys,u0,X); Validate tthe tusefulness tof tsys tby tcomparing tits tsmall-amplitude tstep tresponse tto tthat tof tnlsys. The tnonlinear tsystem tnlsys tis toperating tat tan tequilibrium tlevel tdictated tby t(u0, ty0). tIntroduce ta tstep tperturbation tof tsize t0.1 tabout tthis tsteady-state tand tcompute tthe tcorresponding tresponse. opt t= tstepDataOptions; opt.InputOffset t= tu0; opt.StepAmplitude t= t0.1; t t= t(0:0.1:10)'; ynl t= tstep(nlsys, tt, topt); © tAdvanced tControl tSystems tLab tSessions, tir. tMehmet tCan page t14 tof t6 The tlinear tsystem tsys texpresses tthe trelationship tbetween tthe tperturbations tin tinput tto tthe tcorresponding tperturbation tin toutput. tIt tis tunaware tof tthe tnonlinear tsystem's tequilibrium tvalues. Plot tthe tstep tresponse tof tthe tlinear tsystem. opt t= tstepDataOptions; opt.StepAmplitude t= t0.1; yl t= tstep(sys, tt, topt); Add tthe tsteady-state toffset, ty0 t, tto tthe tresponse tof tthe tlinear tsystem tand tplot tthe tresponses. plot(t, tynl, tt, tyl+y0) legend('Nonlinear', t'Linear twith toffset') Input tArguments collapse tall collapse tall y t— tStep tresponse tdata array Step tresponse tdata, treturned tas tan tarray. For tSISO tsystems, ty tis ta tcolumn tvector tof tthe tsame tlength tas tt t(if tprovided) tor ttOut t(if tyou tdo tnot tprovide tt). For tsingle-input, tmulti-output tsystems, ty tis ta tmatrix twith tas tmany trows tas tthere tare ttime tsamples tand tas tmany tcolumns tas tthere tare toutputs. tThus, tthe tjth tcolumn tof ty, tor ty(:,j), tcontains tthe tstep tresponse tof tfrom tthe tinput tto tthe tjth toutput. For tMIMO tsystems, tthe tstep tresponses tof teach tinput tchannel tare tstacked tup talong tthe tthird tdimension tof ty. tThe tdimensions tof ty tare tthen tN-by-Ny-by-Nu, twhere: o o o N tis tthe tnumber tof ttime tsamples. Ny tis tthe tnumber tof tsystem toutputs. Nu tis tthe tnumber tof tsystem tinputs. Thus, ty(:,i,j) tis ta tcolumn tvector tcontaining tthe tstep tresponse tfrom tthe tjth tinput tto tthe tith toutput tat tthe ttimes tspecified tin tt tor ttOut. tOut t— tTimes tat twhich tstep tresponse tis tcomputed vector Times tat twhich tstep tresponse tis tcomputed, treturned tas ta tvector. tWhen tyou tdo tnot tprovide ta tspecific tvector tt tof ttimes, tstep tchooses tthis ttime tvector tbased ton tthe tsystem tdynamics. tThe ttimes tare texpressed tin tthe ttime tunits tof tsys. x t— tState ttrajectories array State ttrajectories, treturned tas tan tarray. tWhen tsys tis ta tstate-space tmodel, tx tcontains tthe tevolution tof tthe tstates tof tsys tat teach ttime tin tt tor ttOut. tThe tdimensions tof tx tare tN-by-Nx-by-Nu, twhere: N tis tthe tnumber tof ttime tsamples. Nx tis tthe tnumber tof tstates. Nu tis tthe tnumber tof tsystem tinputs. Thus, tthe tevolution tof tthe tstates tin tresponse tto ta tstep tinjected tat tthe tkth tinput tis tgiven tby tthe tarray tx(:,:,k). tThe trow tvector tx(i,:,k) tcontains tthe tstate tvalues tat tthe tith ttime tstep. © tAdvanced tControl tSystems tLab tSessions, tir. tMehmet tCan page t15 tof t6