ControlDesign
PIDAuto
automatic tuning of PID controller based on a desired closed-loop time constant
Calling Sequence
Parameters
Options
Description
Examples
References
PIDAuto(sys, Tc, opts)
sys
-
System; system object
Tc
And(positive, numeric); desired closed-loop time constant (seconds)
opts
(optional) equation(s) of the form option = value; specify options for the PIDAuto command
factored = true or false
True means return the factored version of the controller gains (K=Kp, Ti=KpKi, Td=KdKp and Nd=Tf). False means return the controller gains (Kp, Ki, Kd and Tf). The default is false.
returntype = record or system
Specifies the returned type. If a record is specified, a record containing the PID controller parameters is returned. If system is specified, a System (DynamicSystems system object) containing the transfer function of the PID controller is returned. The default value is record.
True means return a System (DynamicSystems system object) containing the PID controller transfer function. False means return a record containing the controller gains. The default value is false.
proper = true or false
True means return PID controller gains to make its transfer function proper in case Tf=0 (Tf is set to a recommended value of Kd100 . The default is false.
parameters = {list, set}(name = complexcons)
Specifies numeric values for the parameters of sys. These values override any parameters previously specified for sys. The numeric value on the right-hand side of each equation is substituted for the name on the left-hand side in the sys equations. The default is the value of sys given by DynamicSystems:-SystemOptions(parameters).
The PIDAuto command automatically calculates the controller gains of a PID controller with filtered derivative, based on the desired closed-loop time constant, Tc (seconds).
The system sys is a continuous-time linear system object created using the DynamicSystems package. The system object must be in transfer function (TF) form. The system must be single-input single-output (SISO). The system must be proper and must have a nonzero static gain.
The parameter Tc is a tuning parameter that generally has the same order of magnitude as the time constant of the closed-loop. Tune this parameter to adjust the time constant of the closed-loop precisely.
The PIDAuto command returns a record containing the controller parameters Kp, Ki, Kd and Tf, where Kp is the proportional gain, Ki is the integral gain, Kd is the derivative gain and Tf is the time constant of the derivative filter. The controller transfer function is then obtained as:
C⁡s=Kp+Kis+Kd⁢sTf⁢s+1.
If the computed value of Tf is equal to zero, the resulting PID controller transfer function is improper. A recommended value to make the transfer function proper is Tf=Kd100. This value is used when the proper option is set to true and the computed value of Tf is equal to zero. The controller transfer function is then obtained as:
C⁡s=Kp+Kis+Kd⁢s1+Kd⁢s100.
If the resulting closed-loop is unstable, use RouthTable in order to calculate a value of Tf that keeps the closed-loop stable.
If the order of sys is greater than two and sys is unstable or has complex poles, the gains are calculated using an optimization algorithm that may not be able to find a solution if Tc is too small. The error message is then could not compute a stabilizing PID. In this case, try increasing Tc until a solution can be found.
with⁡DynamicSystems:
with⁡ControlDesign:
infolevelControlDesign≔3:
Differential equations of a DC motor model:
eq1≔J⁢diff⁡ω⁡t,t+b⁢ω⁡t−K⁢i⁡t=0:
eq2≔L⁢diff⁡i⁡t,t+R⁢i⁡t=V⁡t−K⁢ω⁡t:
eq3≔diff⁡θ⁡t,t=ω⁡t:
The numeric values of the model parameters are as follows:
params≔J=0.01,K=0.01,L=0.5,R=1,b=0.1:
Transfer function
systf≔TransferFunction⁡eq1,eq2,eq3,V⁡t,i⁡t,ω⁡t,θ⁡t:
PrintSystem⁡systf
Transfer Functioncontinuous3 output(s); 1 input(s)inputvariable=V⁡soutputvariable=i⁡s,ω⁡s,θ⁡stf1,1=J⁢s+bJ⁢L⁢s2+J⁢R+L⁢b⁢s+K2+R⁢btf2,1=KJ⁢L⁢s2+J⁢R+L⁢b⁢s+K2+R⁢btf3,1=KJ⁢L⁢s3+J⁢R+L⁢b⁢s2+K2+R⁢b⁢s
Extract a subsystem with the desired output (position θ):
subsystf≔Subsystem⁡systf,all,3:
PrintSystem⁡subsystf
Transfer Functioncontinuous1 output(s); 1 input(s)inputvariable=V⁡soutputvariable=θ⁡stf1,1=KJ⁢L⁢s3+J⁢R+L⁢b⁢s2+K2+R⁢b⁢s
Design a position controller with a settling time of 4 seconds (time constant is 0.7 seconds approximately):
τ≔0.7
pid≔PIDAuto⁡subsystf,τ,parameters=params
PIDAuto: Using PIDOptimize
pid≔Recordpacked⁡Kp=10.2115133154945,Ki=0.000879895477927287,Kd=1.01771326328058,Tf=0
Get a proper transfer function for the PID controller
pidtf≔PIDAuto⁡subsystf,τ,parameters=params,returntype=system,proper=true:
PIDAuto: Using PIDOptimize PIDAuto: Computed 'Tf = 0' (improper PID transfer function); setting 'Tf = Kd/100' to make it proper
PrintSystem⁡pidtf
Transfer Functioncontinuous1 output(s); 1 input(s)inputvariable=u1⁡soutputvariable=y1⁡stf1,1=1.121637189⁢s2+10.21152227⁢s+0.00087989547790.01017713263⁢s2+1.⁢s
Calculate the closed-loop system and plot a step response:
clsys≔PIDClosedLoop⁡subsystf,pidtf,parameters=params:
PrintSystem⁡clsys
Transfer Functioncontinuous1 output(s); 1 input(s)inputvariable=theta_ref⁡soutputvariable=θ⁡stf1,1=0.01121637189⁢s2+0.1021152227⁢s+8.798954779×10−60.00005088566315⁢s5+0.005610627958⁢s4+0.06101873098⁢s3+0.1113163719⁢s2+0.1021152227⁢s+8.798954779×10−6
ResponsePlot⁡clsys,Step⁡,output=θ,duration=10,gridlines=true,parameters=params
[1] Philippe de Larminat, Automatique appliquee, Hermes, 2007.
[2] Sigurd Skogestad, Simple analytic rules for model reduction and PID controller design, Journal of Process Control, Vol. 13, 291-309, 2003.
[3] J. M. Maciejowski, Multivariable Feedback Design, Pearson Education, 1989.
[4] J. M. Edmunds, Control system design and analysis using closed-loop Nyquist and Bode arrays, International Journal of Control, 30: 5, 773-802, 1979.
See Also
ControlDesign[CohenCoon]
ControlDesign[DominantPole]
ControlDesign[GainPhaseMargin]
ControlDesign[ZNFreq]
ControlDesign[ZNTimeModified]
Download Help Document