ControlDesign

 StateFeedbackClosedLoop
 determine the closed-loop equations of a system with state feedback controller

 Calling Sequence StateFeedbackClosedLoop(sys, Kc, opts)

Parameters

 sys - System; system object Kc - Matrix; state feedback gain opts - (optional) equation(s) of the form option = value; specify options for the StateFeedbackClosedLoop command

Options

 • Kr = Matrix or 0
 Specify a feedforward gain ${K}_{r}$ (reference input). If Kr = 0, there are no reference inputs $r$ and the returned closed-loop system is autonomous. The default value is 0.
 • augment_output = true or false
 True means append the sys inputs to the output vector of the closed-loop system. The default is false.
 • 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).

Description

 • The StateFeedbackClosedLoop command calculates the closed-loop system equations of the state feedback controller with ${K}_{c}$ gain and plant sys.
 • When the option Kr is specified, the state feedback controller is governed by the control law ${u}_{c}=-{K}_{c}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}.\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}x+{K}_{r}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}.\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}r$, where $x$ is the state vector of sys, $r$ is the reference vector, ${K}_{c}$ is the feedback gain and ${K}_{r}$ is the direct or feedforward gain.
 • The 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). It is assumed that the state feedback controller gains are obtained using the sys representation obtained by DynamicSystems[StateSpace].
 • The StateFeedbackClosedLoop command returns a system object whose type is the same as the type of sys, unless the option outputtype is specified.
 • The closed-loop system inputs are
 – the reference inputs $r={y}_{\mathrm{_ref}}$ (when a non-zero Kr Matrix is specified)
 The reference vector $r$ contains a reference signal for each sys output $y$.
 • The closed-loop system outputs are
 – the outputs $y$ of sys
 – the controller outputs ${u}_{c}$ (if augment_output = true)

Examples

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

A DC motor with stator inductance $L$, stator resistance $R$, electromotive force (emf) constant $K$, rotor moment of inertia $J$, and damping ratio $b$ is modeled using the following differential equations.

 > $\mathrm{eqs}≔\left[L\left(\frac{ⅆ}{ⅆt}i\left(t\right)\right)+Ri\left(t\right)=V\left(t\right)-Kw\left(t\right),J\left(\frac{ⅆ}{ⅆt}w\left(t\right)\right)+bw\left(t\right)=Ki\left(t\right)-T\left(t\right)\right]:$

The input variables are the source voltage $V\left(t\right)$ and the torque load $T\left(t\right)$, and the output variables are the rotor angular speed $w\left(t\right)$ and the stator current $i\left(t\right)$.

 > $\mathrm{sysde}≔\mathrm{DiffEquation}\left(\mathrm{eqs},':-\mathrm{inputvariable}'=\left[V\left(t\right),T\left(t\right)\right],':-\mathrm{outputvariable}'=\left[w\left(t\right),i\left(t\right)\right]\right):$

In state-space form:

 > $\mathrm{sys}≔\mathrm{StateSpace}\left(\mathrm{sysde}\right):$
 > $\mathrm{PrintSystem}\left(\mathrm{sys}\right)$
 $\left[\begin{array}{l}{\mathbf{State Space}}\\ {\mathrm{continuous}}\\ {\mathrm{2 output\left(s\right); 2 input\left(s\right); 2 state\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{V}{}\left({t}\right){,}{T}{}\left({t}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{w}{}\left({t}\right){,}{i}{}\left({t}\right)\right]\\ {\mathrm{statevariable}}{=}\left[{\mathrm{x1}}{}\left({t}\right){,}{\mathrm{x2}}{}\left({t}\right)\right]\\ {\mathrm{a}}{=}\left[\begin{array}{cc}{-}\frac{{R}}{{L}}& {-}\frac{{K}}{{L}}\\ \frac{{K}}{{J}}& {-}\frac{{b}}{{J}}\end{array}\right]\\ {\mathrm{b}}{=}\left[\begin{array}{cc}\frac{{1}}{{L}}& {0}\\ {0}& {-}\frac{{1}}{{J}}\end{array}\right]\\ {\mathrm{c}}{=}\left[\begin{array}{cc}{0}& {1}\\ {1}& {0}\end{array}\right]\\ {\mathrm{d}}{=}\left[\begin{array}{cc}{0}& {0}\\ {0}& {0}\end{array}\right]\end{array}\right$ (1)

For control, the controlled input is the voltage $V\left(t\right)$ and the controlled output is the DC motor speed $w\left(t\right)$. The corresponding subsystem is obtained.

 > $\mathrm{sys}≔\mathrm{Subsystem}\left(\mathrm{sys},\left\{1\right\},\left\{1\right\}\right):$
 > $\mathrm{PrintSystem}\left(\mathrm{sys}\right)$
 $\left[\begin{array}{l}{\mathbf{State Space}}\\ {\mathrm{continuous}}\\ {\mathrm{1 output\left(s\right); 1 input\left(s\right); 2 state\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{V}{}\left({t}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{w}{}\left({t}\right)\right]\\ {\mathrm{statevariable}}{=}\left[{\mathrm{x1}}{}\left({t}\right){,}{\mathrm{x2}}{}\left({t}\right)\right]\\ {\mathrm{a}}{=}\left[\begin{array}{cc}{-}\frac{{R}}{{L}}& {-}\frac{{K}}{{L}}\\ \frac{{K}}{{J}}& {-}\frac{{b}}{{J}}\end{array}\right]\\ {\mathrm{b}}{=}\left[\begin{array}{c}\frac{{1}}{{L}}\\ {0}\end{array}\right]\\ {\mathrm{c}}{=}\left[\begin{array}{cc}{0}& {1}\end{array}\right]\\ {\mathrm{d}}{=}\left[\begin{array}{c}{0}\end{array}\right]\end{array}\right$ (2)

Designing the state feedback controller with gains $\mathrm{Kc}$ and $\mathrm{Kr}$ ($u=-\mathrm{Kc}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}.\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}x+\mathrm{Kr}r$) by  pole placement with desired poles ${p}_{1}$ and ${p}_{2}$.

Obtaining the feedback gain $\mathrm{Kc}$:

 > $\mathrm{Kc},\mathrm{Kr}≔\mathrm{StateFeedback}:-\mathrm{PolePlacement}\left(\mathrm{sys},\left[{p}_{1},{p}_{2}\right],'\mathrm{return_Kr}'\right)$
 ${\mathrm{Kc}}{,}{\mathrm{Kr}}{≔}\left[\begin{array}{cc}{-}\frac{{J}{}{L}{}{{p}}_{{1}}{+}{J}{}{L}{}{{p}}_{{2}}{+}{J}{}{R}{+}{L}{}{b}}{{J}}& \frac{{{J}}^{{2}}{}{L}{}{{p}}_{{1}}{}{{p}}_{{2}}{+}{J}{}{L}{}{b}{}{{p}}_{{1}}{+}{J}{}{L}{}{b}{}{{p}}_{{2}}{-}{J}{}{{K}}^{{2}}{+}{L}{}{{b}}^{{2}}}{{J}{}{K}}\end{array}\right]{,}\left[\begin{array}{c}\frac{{L}{}{J}{}{{p}}_{{1}}{}{{p}}_{{2}}}{{K}}\end{array}\right]$ (3)

The closed-loop equations of the state feedback control system are obtained next.

 > $\mathrm{clsys}≔\mathrm{StateFeedbackClosedLoop}\left(\mathrm{sys},\mathrm{Kc},':-\mathrm{Kr}'=\mathrm{Kr}\right):$
 > $\mathrm{PrintSystem}\left(\mathrm{clsys}\right)$
 $\left[\begin{array}{l}{\mathbf{State Space}}\\ {\mathrm{continuous}}\\ {\mathrm{1 output\left(s\right); 1 input\left(s\right); 2 state\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{\mathrm{w_ref}}{}\left({t}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{w}{}\left({t}\right)\right]\\ {\mathrm{statevariable}}{=}\left[{\mathrm{x1}}{}\left({t}\right){,}{\mathrm{x2}}{}\left({t}\right)\right]\\ {\mathrm{a}}{=}\left[\begin{array}{cc}{-}\frac{{R}}{{L}}{+}\frac{{J}{}{L}{}{{p}}_{{1}}{+}{J}{}{L}{}{{p}}_{{2}}{+}{R}{}{J}{+}{b}{}{L}}{{L}{}{J}}& {-}\frac{{K}}{{L}}{-}\frac{{{J}}^{{2}}{}{L}{}{{p}}_{{1}}{}{{p}}_{{2}}{+}{J}{}{L}{}{b}{}{{p}}_{{1}}{+}{J}{}{L}{}{b}{}{{p}}_{{2}}{-}{J}{}{{K}}^{{2}}{+}{L}{}{{b}}^{{2}}}{{L}{}{J}{}{K}}\\ \frac{{K}}{{J}}& {-}\frac{{b}}{{J}}\end{array}\right]\\ {\mathrm{b}}{=}\left[\begin{array}{c}\frac{{J}{}{{p}}_{{1}}{}{{p}}_{{2}}}{{K}}\\ {0}\end{array}\right]\\ {\mathrm{c}}{=}\left[\begin{array}{cc}{0}& {1}\end{array}\right]\\ {\mathrm{d}}{=}\left[\begin{array}{c}{0}\end{array}\right]\end{array}\right$ (4)

Using outputtype and augment_output, the transfer function of closed-loop system is obtained.  The output vector will contain the controller output $V\left(t\right)$.

 > $\mathrm{clsys1}≔\mathrm{StateFeedbackClosedLoop}\left(\mathrm{sys},\mathrm{Kc},':-\mathrm{Kr}'=\mathrm{Kr},':-\mathrm{outputtype}'=\mathrm{tf},':-\mathrm{augment_output}'=\mathrm{true}\right):$
 > $\mathrm{PrintSystem}\left(\mathrm{clsys1}\right)$
 $\left[\begin{array}{l}{\mathbf{Transfer Function}}\\ {\mathrm{continuous}}\\ {\mathrm{2 output\left(s\right); 1 input\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{\mathrm{w_ref}}{}\left({s}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{w}{}\left({s}\right){,}{V}{}\left({s}\right)\right]\\ {{\mathrm{tf}}}_{{1}{,}{1}}{=}\frac{{{p}}_{{1}}{}{{p}}_{{2}}}{{{s}}^{{2}}{+}\left({-}{{p}}_{{1}}{-}{{p}}_{{2}}\right){}{s}{+}{{p}}_{{1}}{}{{p}}_{{2}}}\\ {{\mathrm{tf}}}_{{2}{,}{1}}{=}\frac{{L}{}{J}{}{{p}}_{{1}}{}{{p}}_{{2}}{}{{s}}^{{2}}{+}{{p}}_{{1}}{}{{p}}_{{2}}{}\left({R}{}{J}{+}{b}{}{L}\right){}{s}{+}{{p}}_{{1}}{}{{p}}_{{2}}{}\left({{K}}^{{2}}{+}{R}{}{b}\right)}{{K}{}{{s}}^{{2}}{+}{K}{}\left({-}{{p}}_{{1}}{-}{{p}}_{{2}}\right){}{s}{+}{K}{}{{p}}_{{1}}{}{{p}}_{{2}}}\end{array}\right$ (5)

Assign numerical values for the parameters:

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

Next, the numeric values for the desired poles are obtained. For 0.1% overshoot, settling time of about 1 sec, the damping ratio $Z$  and the natural frequency $\mathrm{\omega }$ are defined as follows:

 > $Z≔0.98:$$\mathrm{ω}≔\frac{5}{Z}:$
 > $\mathrm{poles}≔\left[\mathrm{solve}\left({s}^{2}+2Z\mathrm{ω}s+{\mathrm{ω}}^{2},s\right)\right]:$
 > ${p}_{1}≔{\mathrm{poles}}_{1};$${p}_{2}≔{\mathrm{poles}}_{2}$
 ${{p}}_{{1}}{≔}{-}{4.999999998}{+}{1.015293305}{}{I}$
 ${{p}}_{{2}}{≔}{-}{4.999999998}{-}{1.015293305}{}{I}$ (6)

Then, the numeric values for the feedback gain $\mathrm{Kc}$ and the feed-forward gain $\mathrm{Kr}$ are:

 > $\mathrm{Kc}≔\mathrm{map}\left(\mathrm{simplify},\mathrm{eval}\left(\mathrm{Kc},\mathrm{params}\right),'\mathrm{zero}'\right)$
 ${\mathrm{Kc}}{≔}\left[\begin{array}{cc}{-}{1.000000002}& {13.00541026}\end{array}\right]$ (7)
 > $\mathrm{Kr}≔\mathrm{map}\left(\mathrm{simplify},\mathrm{eval}\left(\mathrm{Kr},\mathrm{params}\right),'\mathrm{zero}'\right)$
 ${\mathrm{Kr}}{≔}\left[\begin{array}{c}{13.01541024}\end{array}\right]$ (8)
 > $\mathrm{clsys}≔\mathrm{StateFeedbackClosedLoop}\left(\mathrm{sys},\mathrm{Kc},':-\mathrm{Kr}'=\mathrm{Kr},':-\mathrm{parameters}'=\mathrm{params}\right):$
 > $\mathrm{PrintSystem}\left(\mathrm{clsys}\right)$
 $\left[\begin{array}{l}{\mathbf{State Space}}\\ {\mathrm{continuous}}\\ {\mathrm{1 output\left(s\right); 1 input\left(s\right); 2 state\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{\mathrm{w_ref}}{}\left({t}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{w}{}\left({t}\right)\right]\\ {\mathrm{statevariable}}{=}\left[{\mathrm{x1}}{}\left({t}\right){,}{\mathrm{x2}}{}\left({t}\right)\right]\\ {\mathrm{a}}{=}\left[\begin{array}{cc}{3.999999886872274}{}{{10}}^{{-9}}& {-}{26.03082052}\\ {1.0}& {-}{10.0}\end{array}\right]\\ {\mathrm{b}}{=}\left[\begin{array}{c}{26.03082048}\\ {0.0}\end{array}\right]\\ {\mathrm{c}}{=}\left[\begin{array}{cc}{0.0}& {1.0}\end{array}\right]\\ {\mathrm{d}}{=}\left[\begin{array}{c}{0.0}\end{array}\right]\end{array}\right$ (9)

Plotting the closed-loop system step response:

 > $\mathrm{ResponsePlot}\left(\mathrm{clsys},8\mathrm{Step}\left(\right),'\mathrm{duration}'=10,'\mathrm{numpoints}'=200,'\mathrm{labels}'=\left["t","DC Motor Rotational Speed"\right],'\mathrm{labeldirections}'=\left[\mathrm{horizontal},\mathrm{vertical}\right],'\mathrm{gridlines}'=\mathrm{true},'\mathrm{view}'=\left[0..10,0..10\right]\right)$

Obtain the properties of the step response such as steady-state value and settling-point.

 > $\mathrm{prop}≔\mathrm{StepProperties}\left(\mathrm{clsys}\right)$
 ${\mathrm{prop}}{≔}{1.}{,}\left[{0.103866687817983}{,}{0.100000000000000}\right]{,}\left[{0.231175892242102}{,}{0.333333333333333}\right]{,}\left[{0.441908334624695}{,}{0.666666666666667}\right]{,}\left[{0.742737847117827}{,}{0.900000000000000}\right]{,}\left[{\mathrm{undefined}}{,}{\mathrm{undefined}}\right]{,}\left[{1.09872655595021}{,}{0.980000000000000}\right]$ (10)
 > $\mathrm{plots}:-\mathrm{display}\left(\mathrm{plot}\left(\left[{\mathrm{prop}}_{2..7}\right],'\mathrm{style}'=\mathrm{point},'\mathrm{symbol}'=\mathrm{cross},'\mathrm{color}'=\mathrm{blue},'\mathrm{symbolsize}'=30\right),\mathrm{plot}\left(\left[\left[0,{\mathrm{prop}}_{1}\right],\left[10,{\mathrm{prop}}_{1}\right]\right],'\mathrm{color}'=\mathrm{gray}\right),\mathrm{ResponsePlot}\left(\mathrm{clsys},\mathrm{Step}\left(\right),'\mathrm{duration}'=10,'\mathrm{numpoints}'=200\right),'\mathrm{gridlines}'=\mathrm{true},'\mathrm{title}'="Step response",'\mathrm{labels}'=\left["t","DC Motor Rotational Speed"\right],'\mathrm{labeldirections}'=\left[\mathrm{horizontal},\mathrm{vertical}\right],'\mathrm{view}'=\left[0..10,0..1.2\right]\right)$