determine the closed-loop equations of a system with PID controller - MapleSim Help

ControlDesign[PIDClosedLoop] - determine the closed-loop equations of a system with PID controller

 Calling Sequence PIDClosedLoop(sys, pid, opts)

Parameters

 sys - System; system object pid - System; controller system object opts - (optional) equation(s) of the form option = value; specify options for the PIDClosedLoop command

Description

 • 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 ${u}_{c}$ is the ${i}^{\mathrm{th}}$ input of sys, ${y}_{\mathrm{_ref}}$ is the ${i}^{\mathrm{th}}$  input of the closed-loop.
 – If ${y}_{c}$ is the ${j}^{\mathrm{th}}$ output of sys, it remains the ${j}^{\mathrm{th}}$  output of the closed-loop.
 The rest of the inputs ${u}_{\mathrm{nc}}$ (non-controlled inputs) and outputs ${y}_{\mathrm{nc}}$ (non-controlled outputs) of sys are also included in the inputs and outputs of the closed-loop system.
 • The pid output (${u}_{c}$) 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.

Examples

 > $\mathrm{with}\left(\mathrm{DynamicSystems}\right):$
 > $\mathrm{with}\left(\mathrm{ControlDesign}\right):$

Differential equations of a DC motor model:

 > $\mathrm{eq1}:=J\left(\frac{ⅆ}{ⅆt}\mathrm{ω}\left(t\right)\right)+b\mathrm{ω}\left(t\right)-Ki\left(t\right)=0:$
 > $\mathrm{eq2}:=L\left(\frac{ⅆ}{ⅆt}i\left(t\right)\right)+Ri\left(t\right)=V\left(t\right)-K\mathrm{ω}\left(t\right):$
 > $\mathrm{eq3}:=\frac{ⅆ}{ⅆt}\mathrm{θ}\left(t\right)=\mathrm{ω}\left(t\right):$

The numeric values of the model parameters are as follows:

 > $\mathrm{params}:=\left\{J=0.01,K=0.01,L=0.5,R=1,b=0.1\right\}:$

Transfer function

 > $\mathrm{systf}:=\mathrm{TransferFunction}\left(\left[\mathrm{eq1},\mathrm{eq2},\mathrm{eq3}\right],\left[V\left(t\right)\right],\left[i\left(t\right),\mathrm{ω}\left(t\right),\mathrm{θ}\left(t\right)\right]\right):$
 > $\mathrm{PrintSystem}\left(\mathrm{systf}\right)$
 $\left[\begin{array}{l}{\mathbf{Transfer Function}}\\ {\mathrm{continuous}}\\ {\mathrm{3 output\left(s\right); 1 input\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{V}{}\left({s}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{i}{}\left({s}\right){,}{\mathrm{\omega }}{}\left({s}\right){,}{\mathrm{\theta }}{}\left({s}\right)\right]\\ {{\mathrm{tf}}}_{{1}{,}{1}}{=}\frac{{J}{}{s}{+}{b}}{{J}{}{L}{}{{s}}^{{2}}{+}\left({J}{}{R}{+}{L}{}{b}\right){}{s}{+}{{K}}^{{2}}{+}{R}{}{b}}\\ {{\mathrm{tf}}}_{{2}{,}{1}}{=}\frac{{K}}{{J}{}{L}{}{{s}}^{{2}}{+}\left({J}{}{R}{+}{L}{}{b}\right){}{s}{+}{{K}}^{{2}}{+}{R}{}{b}}\\ {{\mathrm{tf}}}_{{3}{,}{1}}{=}\frac{{K}}{{J}{}{L}{}{{s}}^{{3}}{+}\left({J}{}{R}{+}{L}{}{b}\right){}{{s}}^{{2}}{+}\left({{K}}^{{2}}{+}{R}{}{b}\right){}{s}}\end{array}\right$ (1)

Extract a subsystem with the desired output (position $\mathrm{\theta }$):

 > $\mathrm{subsystf}:=\mathrm{Subsystem}\left(\mathrm{systf},'\mathrm{all}',\left\{3\right\}\right):$
 > $\mathrm{PrintSystem}\left(\mathrm{subsystf}\right)$
 $\left[\begin{array}{l}{\mathbf{Transfer Function}}\\ {\mathrm{continuous}}\\ {\mathrm{1 output\left(s\right); 1 input\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{V}{}\left({s}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{\mathrm{\theta }}{}\left({s}\right)\right]\\ {{\mathrm{tf}}}_{{1}{,}{1}}{=}\frac{{K}}{{J}{}{L}{}{{s}}^{{3}}{+}\left({J}{}{R}{+}{L}{}{b}\right){}{{s}}^{{2}}{+}\left({{K}}^{{2}}{+}{R}{}{b}\right){}{s}}\end{array}\right$ (2)

Design a position controller with a settling time of 2 seconds (time constant is about 0.7 s):

 > $\mathrm{τ}:=0.7$
 ${\mathrm{τ}}{:=}{0.7}$ (3)
 > $\mathrm{PIDgains}:=\mathrm{PIDAuto}\left(\mathrm{subsystf},\mathrm{τ},'\mathrm{parameters}'=\mathrm{params}\right)$
 ${\mathrm{PIDgains}}{:=}{{\mathrm{Record}}}_{{\mathrm{packed}}}{}\left({\mathrm{Kp}}{=}{10.2115133154945}{,}{\mathrm{Ki}}{=}{0.000879895477927287}{,}{\mathrm{Kd}}{=}{1.01771326328058}{,}{\mathrm{Tf}}{=}{0}\right)$ (4)

The controller system is designed according to the following expression:

 > $\mathrm{Kc}:={\mathrm{PIDgains}}_{'\mathrm{Kp}'}+\frac{{\mathrm{PIDgains}}_{'\mathrm{Ki}'}}{s}+\frac{{\mathrm{PIDgains}}_{'\mathrm{Kd}'}s}{1+\frac{1{\mathrm{PIDgains}}_{'\mathrm{Kd}'}s}{100}}$
 ${\mathrm{Kc}}{:=}{10.2115133154945}{+}\frac{{0.000879895477927287}}{{s}}{+}\frac{{1.01771326328058}{}{s}}{{1}{+}{0.0101771326328058}{}{s}}$ (5)
 > $\mathrm{sysKc}:=\mathrm{TransferFunction}\left(\mathrm{Kc}\right):$
 > $\mathrm{PrintSystem}\left(\mathrm{sysKc}\right)$
 $\left[\begin{array}{l}{\mathbf{Transfer Function}}\\ {\mathrm{continuous}}\\ {\mathrm{1 output\left(s\right); 1 input\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{\mathrm{u1}}{}\left({s}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{\mathrm{y1}}{}\left({s}\right)\right]\\ {{\mathrm{tf}}}_{{1}{,}{1}}{=}\frac{{1.121637189}{}{{s}}^{{2}}{+}{10.21152227}{}{s}{+}{0.0008798954779}}{{0.01017713263}{}{{s}}^{{2}}{+}{s}}\end{array}\right$ (6)

Calculate the feedback system with the original system to observe all the closed-loop system transfer functions. The controller output $V\left(s\right)$ is also included using the augment_output option.

 > $\mathrm{feedback}:=\mathrm{PIDClosedLoop}\left(\mathrm{systf},\mathrm{sysKc},'\mathrm{parameters}'=\mathrm{params},'\mathrm{controlled_output}'=3,'\mathrm{augment_output}'=\mathrm{true}\right):$
 > $\mathrm{PrintSystem}\left(\mathrm{feedback}\right)$
 $\left[\begin{array}{l}{\mathbf{Transfer Function}}\\ {\mathrm{continuous}}\\ {\mathrm{4 output\left(s\right); 1 input\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{\mathrm{theta_ref}}{}\left({s}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{i}{}\left({s}\right){,}{\mathrm{\omega }}{}\left({s}\right){,}{\mathrm{\theta }}{}\left({s}\right){,}{V}{}\left({s}\right)\right]\\ {{\mathrm{tf}}}_{{1}{,}{1}}{=}\frac{{5.707525218}{}{{10}}^{{-7}}{}{{s}}^{{7}}{+}{0.00007383461575}{}{{s}}^{{6}}{+}{0.001938610656}{}{{s}}^{{5}}{+}{0.01992714700}{}{{s}}^{{4}}{+}{0.08375976566}{}{{s}}^{{3}}{+}{0.1022235877}{}{{s}}^{{2}}{+}{8.807753734}{}{{10}}^{{-6}}{}{s}}{{2.589350714}{}{{10}}^{{-9}}{}{{s}}^{{8}}{+}{5.710010486}{}{{10}}^{{-7}}{}{{s}}^{{7}}{+}{0.00003768910326}{}{{s}}^{{6}}{+}{0.0006954648583}{}{{s}}^{{5}}{+}{0.004914660338}{}{{s}}^{{4}}{+}{0.01347328969}{}{{s}}^{{3}}{+}{0.01737375949}{}{{s}}^{{2}}{+}{0.01022227069}{}{s}{+}{8.807753734}{}{{10}}^{{-7}}}\\ {{\mathrm{tf}}}_{{2}{,}{1}}{=}\frac{{5.707525218}{}{{10}}^{{-7}}{}{{s}}^{{6}}{+}{0.00006812709054}{}{{s}}^{{5}}{+}{0.001257339750}{}{{s}}^{{4}}{+}{0.007353749497}{}{{s}}^{{3}}{+}{0.01022227069}{}{{s}}^{{2}}{+}{8.807753734}{}{{10}}^{{-7}}{}{s}}{{2.589350714}{}{{10}}^{{-9}}{}{{s}}^{{8}}{+}{5.710010486}{}{{10}}^{{-7}}{}{{s}}^{{7}}{+}{0.00003768910326}{}{{s}}^{{6}}{+}{0.0006954648583}{}{{s}}^{{5}}{+}{0.004914660338}{}{{s}}^{{4}}{+}{0.01347328969}{}{{s}}^{{3}}{+}{0.01737375949}{}{{s}}^{{2}}{+}{0.01022227069}{}{s}{+}{8.807753734}{}{{10}}^{{-7}}}\\ {{\mathrm{tf}}}_{{3}{,}{1}}{=}\frac{{0.01121637189}{}{{s}}^{{2}}{+}{0.1021152227}{}{s}{+}{8.798954779}{}{{10}}^{{-6}}}{{0.00005088566315}{}{{s}}^{{5}}{+}{0.005610627958}{}{{s}}^{{4}}{+}{0.06101873098}{}{{s}}^{{3}}{+}{0.1113163719}{}{{s}}^{{2}}{+}{0.1021152227}{}{s}{+}{8.798954779}{}{{10}}^{{-6}}}\\ {{\mathrm{tf}}}_{{4}{,}{1}}{=}\frac{{0.005608185945}{}{{s}}^{{5}}{+}{0.1183558427}{}{{s}}^{{4}}{+}{0.7249716183}{}{{s}}^{{3}}{+}{1.022226173}{}{{s}}^{{2}}{+}{0.00008807753734}{}{s}}{{0.00005088566315}{}{{s}}^{{5}}{+}{0.005610627958}{}{{s}}^{{4}}{+}{0.06101873098}{}{{s}}^{{3}}{+}{0.1113163719}{}{{s}}^{{2}}{+}{0.1021152227}{}{s}{+}{8.798954779}{}{{10}}^{{-6}}}\end{array}\right$ (7)

Plot the step response for the position output, $\mathrm{\theta }$:

 > $\mathrm{ResponsePlot}\left(\mathrm{feedback},1,'\mathrm{duration}'=10,'\mathrm{gridlines}'=\mathrm{true},'\mathrm{parameters}'=\mathrm{params},'\mathrm{output}'=\mathrm{θ}\right)$