ControlDesign
PIDClosedLoop
determine the closed-loop equations of a system with PID controller
Calling Sequence
Parameters
Options
Description
Examples
PIDClosedLoop(sys, pid, opts)
sys
-
System; system object
pid
System; controller system object
opts
(optional) equation(s) of the form option = value; specify options for the PIDClosedLoop command
outputtype = tf, coeff, zpk, ss, or de
Determines the subtype of the returned system object. The default return type is based on the type of the system object specified in the sys parameter.
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).
controlled_input = posint
Specifies the controlled input (uc) index for sys, for the MIMO case. The default is 1.
controlled_output = posint
Specifies the controlled output (yc) index for sysfor the MIMO case. The default is 1.
augment_output = true or false
True means append the controlled_input (controller output) to the output vector. The default is false.
The PIDClosedLoop command calculates the closed-loop system equations of a system sys with a PID controller pid in the direct path.
The system sys is a SISO (single input, single output) or MIMO (multiple input, multiple output) linear system object created using the DynamicSystems package. The system object can be of types: transfer function (TF), zero-pole-gain (ZPK), coefficients (Coeff), state-space (SS), and diff-equation (DE).
The controller pid is a SISO (single input, single output) system object created using the DynamicSystems package. The system object is generally a transfer function (TF).
If sys is a MIMO system, only one input and one output can be selected to form the closed-loop system with the PID controller pid.
If uc is the ith input of sys, y_ref is the ith input of the closed-loop.
If yc is the jth output of sys, it remains the jth output of the closed-loop.
The rest of the inputs unc (non-controlled inputs) and outputs ync (non-controlled outputs) of sys are also included in the inputs and outputs of the closed-loop system.
The pid output (uc) is appended to the output vector of the closed-loop if the option augment_output = true is specified.
The PIDClosedLoop command returns a system object whose type is the same as the type of sys, unless the option outputtype is specified.
with⁡DynamicSystems:
with⁡ControlDesign:
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 2 seconds (time constant is about 0.7 s):
τ≔0.7
PIDgains≔PIDAuto⁡subsystf,τ,parameters=params
PIDgains≔Recordpacked⁡Kp=10.2115133154945,Ki=0.000879895477927287,Kd=1.01771326328058,Tf=0
The controller system is designed according to the following expression:
Kc≔PIDgainsKp+PIDgainsKis+PIDgainsKd⁢s1+1100⁢PIDgainsKd⁢s
Kc≔10.2115133154945+0.000879895477927287s+1.01771326328058⁢s1+0.0101771326328058⁢s
sysKc≔TransferFunction⁡Kc:
PrintSystem⁡sysKc
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 feedback system with the original system to observe all the closed-loop system transfer functions. The controller output V⁡s is also included using the augment_output option.
feedback≔PIDClosedLoop⁡systf,sysKc,parameters=params,controlled_output=3,augment_output=true:
PrintSystem⁡feedback
Transfer Functioncontinuous4 output(s); 1 input(s)inputvariable=theta_ref⁡soutputvariable=i⁡s,ω⁡s,θ⁡s,V⁡stf1,1=5.707525218×10−7⁢s7+0.00007383461575⁢s6+0.001938610656⁢s5+0.01992714700⁢s4+0.08375976566⁢s3+0.1022235877⁢s2+8.807753734×10−6⁢s2.589350714×10−9⁢s8+5.710010486×10−7⁢s7+0.00003768910326⁢s6+0.0006954648583⁢s5+0.004914660338⁢s4+0.01347328969⁢s3+0.01737375949⁢s2+0.01022227069⁢s+8.807753734×10−7tf2,1=5.707525218×10−7⁢s6+0.00006812709054⁢s5+0.001257339750⁢s4+0.007353749497⁢s3+0.01022227069⁢s2+8.807753734×10−7⁢s2.589350714×10−9⁢s8+5.710010486×10−7⁢s7+0.00003768910326⁢s6+0.0006954648583⁢s5+0.004914660338⁢s4+0.01347328969⁢s3+0.01737375949⁢s2+0.01022227069⁢s+8.807753734×10−7tf3,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−6tf4,1=0.005608185945⁢s5+0.1183558427⁢s4+0.7249716183⁢s3+1.022226173⁢s2+0.00008807753734⁢s0.00005088566315⁢s5+0.005610627958⁢s4+0.06101873098⁢s3+0.1113163719⁢s2+0.1021152227⁢s+8.798954779×10−6
Plot the step response for the position output, θ:
ResponsePlot⁡feedback,1,duration=10,gridlines=true,parameters=params,output=θ
See Also
ControlDesign[PIDAuto]
Download Help Document