Beruflich Dokumente
Kultur Dokumente
ControlTutorialsforMATLABandSimulinkIntroduction:DigitalControllerDesign
SYSTEM
MODELING
Introduction:DigitalControllerDesign
ANALYSIS
Inthissectionwewilldiscussconvertingcontinuoustimemodelsintodiscrete
time (or difference equation) models. We will also introduce the ztransform
CONTROL
PID
ROOTLOCUS
FREQUENCY
and show how to use it to analyze and design controllers for discrete time
systems.
KeyMATLABcommandsusedinthistutorialare:c2d,pzmap,zgrid,step,
rlocus
STATESPACE
DIGITAL
RelatedTutorial
Links
Sampling Effects
SIMULINK
Activity
MODELING
Difference
CONTROL
EquationsInfo
Discrete
Pole
Locations
RelatedExternal
Links
Control
Implementation
Video
Contents
http://ctms.engin.umich.edu/CTMS/index.php?example=Introduction§ion=ControlDigital
2/17
20/01/2016
ControlTutorialsforMATLABandSimulinkIntroduction:DigitalControllerDesign
Contents
Introduction
ZeroHoldEquivalence
ConversionUsingc2d
Example:MassSpringDamper
StabilityandTransientResponse
DiscreteRootLocus
Introduction
Thefigurebelowshowsthetypicalcontinuousfeedbacksystemthatwehavebeenconsideringsofarinthis
tutorial.Almostallofthecontinuouscontrollerscanbebuiltusinganalogelectronics.
Thecontinuouscontroller,enclosedinthedashedsquare,canbereplacedbyadigitalcontroller,shownbelow,
thatperformssamecontroltaskasthecontinuouscontroller.Thebasicdifferencebetweenthesecontrollersis
thatthedigitalsystemoperatesondiscretesignals(orsamplesofthesensedsignal)ratherthanoncontinuous
signals.
http://ctms.engin.umich.edu/CTMS/index.php?example=Introduction§ion=ControlDigital
3/17
20/01/2016
ControlTutorialsforMATLABandSimulinkIntroduction:DigitalControllerDesign
Differenttypesofsignalsintheabovedigitalschematiccanberepresentedbythefollowingplots.
ThepurposeofthisDigitalControlTutorialistoshowyouhowtouseMATLABtoworkwithdiscretefunctions
eitherintransferfunctionorstatespaceformtodesigndigitalcontrolsystems.
ZeroHoldEquivalence
Intheaboveschematicofthedigitalcontrolsystem,weseethatthedigitalcontrolsystemcontainsbothdiscrete
andthecontinuousportions.Whendesigningadigitalcontrolsystem,weneedtofindthediscreteequivalentof
thecontinuousportionsothatweonlyneedtodealwithdiscretefunctions.
Forthistechnique,wewillconsiderthefollowingportionofthedigitalcontrolsystemandrearrangeasfollows.
http://ctms.engin.umich.edu/CTMS/index.php?example=Introduction§ion=ControlDigital
4/17
20/01/2016
ControlTutorialsforMATLABandSimulinkIntroduction:DigitalControllerDesign
TheclockconnectedtotheD/AandA/DconverterssuppliesapulseeveryTsecondsandeachD/AandA/D
sendsasignalonlywhenthepulsearrives.ThepurposeofhavingthispulseistorequirethatHzoh(z)have
only samples u(k) to work on and produce only samples of output y(k) thus, Hzoh(z) can be realized as a
discretefunction.
Thephilosophyofthedesignisthefollowing.WewanttofindadiscretefunctionHzoh(z)sothatforapiecewise
constantinputtothecontinuoussystemH(s),thesampledoutputofthecontinuoussystemequalsthediscrete
output.Supposethesignalu(k) represents a sample of the input signal. There are techniques for taking this
sampleu(k)andholdingittoproduceacontinuoussignaluhat(t).Thesketchbelowshowsthattheuhat(t)is
heldconstantatu(k)overtheintervalkTto(k+1)T.Thisoperationofholdinguhat(t)constantoverthesampling
timeiscalledzeroorderhold.
http://ctms.engin.umich.edu/CTMS/index.php?example=Introduction§ion=ControlDigital
5/17
20/01/2016
ControlTutorialsforMATLABandSimulinkIntroduction:DigitalControllerDesign
timeiscalledzeroorderhold.
The zeroorder held signal uhat(t) goes through H2(s) and A/D to produce the output y(k) that will be the
piecewisesamesignalasifthediscretesignalu(k)goesthroughHzoh(z)toproducethediscreteoutputy(k).
Nowwewillredrawtheschematic,placingHzoh(z)inplaceofthecontinuousportion.
http://ctms.engin.umich.edu/CTMS/index.php?example=Introduction§ion=ControlDigital
6/17
20/01/2016
ControlTutorialsforMATLABandSimulinkIntroduction:DigitalControllerDesign
ByplacingHzoh(z),wecandesigndigitalcontrolsystemsdealingwithonlydiscretefunctions.
Note:Therearecertaincaseswherethediscreteresponsedoesnotmatchthecontinuousresponseduetoa
holdcircuitimplementedindigitalcontrolsystems.Forinformation,seeLaggingeffectassociatedwiththehold.
ConversionUsingc2d
ThereisaMATLABfunctioncalledc2dthatconvertsagivencontinuoussystem(eitherintransferfunctionor
statespace form) to a discrete system using the zeroorder hold operation explained above. The basic
commandforthisinMATLABissys_d=c2d(sys,Ts,'zoh')
The sampling time (Ts in sec/sample) should be smaller than 1/(30*BW), where BW is the closedloop
bandwidthfrequency.
Example:MassSpringDamper
TransferFunction
Supposeyouhavethefollowingcontinuoustransferfunction
(1)
Assumingtheclosedloopbandwidthfrequencyisgreaterthan1rad/sec,wewillchoosethesamplingtime(Ts)
equalto1/100sec.Now,createannewmfileandenterthefollowingcommands.
M=1;
b=10;
http://ctms.engin.umich.edu/CTMS/index.php?example=Introduction§ion=ControlDigital
7/17
20/01/2016
b=10;
ControlTutorialsforMATLABandSimulinkIntroduction:DigitalControllerDesign
k=20;
s=tf('s');
sys=1/(M*s^2+b*s+k);
Ts=1/100;
sys_d=c2d(sys,Ts,'zoh')
sys_d=
4.837e05z+4.678e05
z^21.903z+0.9048
Sampletime:0.01seconds
Discretetimetransferfunction.
StateSpace
Thecontinuoustimestatespacemodelisasfollows:
(2)
(3)
Allconstantsarethesameasbefore.Thefollowingmfileconvertstheabovecontinuousstatespacetodiscrete
statespace.
http://ctms.engin.umich.edu/CTMS/index.php?example=Introduction§ion=ControlDigital
8/17
20/01/2016
ControlTutorialsforMATLABandSimulinkIntroduction:DigitalControllerDesign
A=[01;
k/Mb/M];
B=[0;
1/M];
C=[10];
D=[0];
Ts=1/100;
sys=ss(A,B,C,D);
sys_d=c2d(sys,Ts,'zoh')
sys_d=
a=
x1x2
x10.9990.009513
x20.19030.9039
b=
u1
x14.837e05
x20.009513
http://ctms.engin.umich.edu/CTMS/index.php?example=Introduction§ion=ControlDigital
9/17
20/01/2016
ControlTutorialsforMATLABandSimulinkIntroduction:DigitalControllerDesign
c=
x1x2
y110
d=
u1
y10
Sampletime:0.01seconds
Discretetimestatespacemodel.
Fromthesematrices,thediscretestatespacecanbewrittenas
(4)
(5)
Nowyouhavethediscretetimestatespacemodel.
StabilityandTransientResponse
Forcontinuoussystems,weknowthatcertainbehaviorsresultsfromdifferentpolelocationsinthesplane.For
instance,asystemisunstablewhenanypoleislocatedtotherightoftheimaginaryaxis.Fordiscretesystems,
wecananalyzethesystembehaviorsfromdifferentpolelocationsinthezplane.Thecharacteristicsinthez
planecanberelatedtothoseinthesplanebytheexpression
(6)
T=Samplingtime(sec/sample)
http://ctms.engin.umich.edu/CTMS/index.php?example=Introduction§ion=ControlDigital
10/17
20/01/2016
ControlTutorialsforMATLABandSimulinkIntroduction:DigitalControllerDesign
T=Samplingtime(sec/sample)
s=Locationinthesplane
z=Locationinthezplane
Thefigurebelowshowsthemappingoflinesofconstantdampingratio(zeta)andnaturalfrequency(Wn)from
thesplanetothezplaneusingtheexpressionshownabove.
Ifyounoticedinthezplane,thestabilityboundaryisnolongerimaginaryaxis,butistheunitcirclez=1.The
systemisstablewhenallpolesarelocatedinsidetheunitcircleandunstablewhenanypoleislocatedoutside.
Foranalyzingthetransientresponsefrompolelocationsinthezplane,thefollowingthreeequationsusedin
continuoussystemdesignsarestillapplicable.
http://ctms.engin.umich.edu/CTMS/index.php?example=Introduction§ion=ControlDigital
11/17
20/01/2016
ControlTutorialsforMATLABandSimulinkIntroduction:DigitalControllerDesign
(7)
(8)
(9)
where,
zeta=Dampingratio
Wn=Naturalfrequency(rad/sec)
Ts=Settlingtime
Tr=Risetime
Mp=Maximumovershoot
Important:Thenaturalfrequency(Wn)inzplanehastheunitofrad/sample,butwhenyouusetheequations
shownabove,theWnmustbeintheunitofrad/sec.
Supposewehavethefollowingdiscretetransferfunction
(10)
Createannewmfileandenterthefollowingcommands.Runningthismfileinthecommandwindowgivesyou
thefollowingplotwiththelinesofconstantdampingratioandnaturalfrequency.
numDz=1;
denDz=[10.30.5];
sys=tf(numDz,denDz,1);%the1indicatesthatthesampletimeisundetermined
pzmap(sys)
axis([1111])
http://ctms.engin.umich.edu/CTMS/index.php?example=Introduction§ion=ControlDigital
12/17
20/01/2016
ControlTutorialsforMATLABandSimulinkIntroduction:DigitalControllerDesign
zgrid
Fromthisplot,weseepolesarelocatedapproximatelyatthenaturalfrequencyof9pi/20T(rad/sample)andthe
dampingratioof0.25.Assumingthatwehaveasamplingtimeof1/20sec(whichleadstoWn=28.2rad/sec)
andusingthreeequationsshownabove,wecandeterminethatthissystemshouldhavetherisetimeof0.06
sec,asettlingtimeof0.65secandamaximumovershootof45%(0.45morethanthesteadystatevalue).Let's
obtain the step response and see if these are correct. Add the following commands to the above mfile and
rerunitinthecommandwindow.Youshouldgetthefollowingstepresponse.
sys=tf(numDz,denDz,1/20);
http://ctms.engin.umich.edu/CTMS/index.php?example=Introduction§ion=ControlDigital
13/17
20/01/2016
ControlTutorialsforMATLABandSimulinkIntroduction:DigitalControllerDesign
sys=tf(numDz,denDz,1/20);
step(sys,2.5);
Asyoucanseefromtheplot,therisetime,settlingtimeandovershootcameouttobewhatweexpected.This
showshowyoucanusethelocationsofpolesandtheabovethreeequationstoanalyzethetransientresponse
ofthesystem.
DiscreteRootLocus
The rootlocus is the locus of points where roots of characteristic equation can be found as a single gain is
variedfromzerotoinfinity.Thecharacteristicequationofanunityfeedbacksystemis
http://ctms.engin.umich.edu/CTMS/index.php?example=Introduction§ion=ControlDigital
14/17
20/01/2016
ControlTutorialsforMATLABandSimulinkIntroduction:DigitalControllerDesign
variedfromzerotoinfinity.Thecharacteristicequationofanunityfeedbacksystemis
(11)
whereG(z)isthecompensatorimplementedinthedigitalcontrollerandHzoh(z)istheplanttransferfunctionin
z.
Themechanicsofdrawingtherootlociareexactlythesameinthezplaneasinthesplane.Recallfromthe
continuousRootLocusTutorial, we used the MATLAB function called sgrid to find the rootlocus region that
givesanacceptablegain(K).Forthediscrete rootlocus analysis, we will use the function zgrid that has the
samecharacteristicsassgrid.Thecommandzgrid(zeta,Wn)drawslinesofconstantdampingratio(zeta)and
naturalfrequency(Wn).
Supposewehavethefollowingdiscretetransferfunction
(12)
andtherequirementsareadampingratiogreaterthan0.6andanaturalfrequencygreaterthan0.4rad/sample
(thesecanbefoundfromdesignrequirements,samplingtime(sec/sample)andthreeequationsshowninthe
previoussection).Thefollowingcommands draw the rootlocus with the lines of constant damping ratio and
naturalfrequency.Createannewmfileandenterthefollowingcommands.Runningthismfileshouldgiveyou
thefollowingrootlocusplot.
numDz=[10.3];
denDz=[11.60.7];
sys=tf(numDz,denDz,1);
rlocus(sys)
axis([1111])
zeta=0.4;
Wn=0.3;
http://ctms.engin.umich.edu/CTMS/index.php?example=Introduction§ion=ControlDigital
15/17
20/01/2016
Wn=0.3;
ControlTutorialsforMATLABandSimulinkIntroduction:DigitalControllerDesign
zgrid(zeta,Wn)
Fromthisplot,youshouldrealizethatthesystemisstablebecauseallpolesarelocatedinsidetheunitcircle.
Also,youseetwodottedlinesofconstantdampingratioandnaturalfrequency.Thenaturalfrequencyisgreater
than0.3outsidetheconstantWnline,andthedampingratioisgreaterthan0.4insidetheconstantzetaline.In
thisexample,wedohavetherootlocusdrawninthedesiredregion.Therefore,again(K)chosenfromoneof
thelociinthedesiredregionshouldgiveyoutheresponsethatsatisfiesdesignrequirements.
http://ctms.engin.umich.edu/CTMS/index.php?example=Introduction§ion=ControlDigital
16/17