up

PDF letter size

EGME 511 (Advanced Mechanical Vibration) Final Project
Stabilization of an inverted pendulum on moving cart using feedback control

Nasser M. Abbasi

Spring 2009   Compiled on September 9, 2023 at 1:57pm

Contents

 1 Introduction
 2 Analysis
  2.1 Stability of open loop system
 3 Comparing solution with and without stabilizing control law
 4 Conclusion

1 Introduction

Given the following system

pict
Figure 1: System to control

Need to find control law \(u\left ( t\right ) \) to stabilize the inverted pendulum. First we need to obtain the equations of motions.

2 Analysis

Let the Lagrangian coordinates be \(\theta \) and \(x\) as shown. Let \(L\) be the Lagrangian. Let \(T\) be the kinetic energy of the system and let \(U\) be the potential energy. Hence\[ L=T-U \] and \[ T=\frac {1}{2}M\dot {x}^{2}+\frac {1}{2}mv^{2}\] Where \(v\) is the linear velocity of the blob \(m\) relative to the inertial system.

pict
Figure 2: Velocity diagram

Hence, since \(v=l\dot {\theta }\), we obtain\begin {align*} v^{2} & =\left ( \dot {x}+v_{x}\right ) ^{2}+v_{y}^{2}\\ & =\left ( \dot {x}+v\cos \theta \right ) ^{2}+\left ( v\sin \theta \right ) ^{2}\\ & =\left ( \dot {x}+l\dot {\theta }\cos \theta \right ) ^{2}+\left ( l\dot {\theta }\sin \theta \right ) ^{2}\\ & =\dot {x}^{2}+l^{2}\dot {\theta }^{2}\cos ^{2}\theta +2\dot {x}l\dot {\theta }\cos \theta +l^{2}\dot {\theta }^{2}\sin ^{2}\theta \\ & =\dot {x}^{2}+l^{2}\dot {\theta }^{2}+2\dot {x}l\dot {\theta }\cos \theta \end {align*}

Hence \(T\) becomes\[ T=\frac {1}{2}M\dot {x}^{2}+\frac {1}{2}m\left ( \dot {x}^{2}+l^{2}\dot {\theta }^{2}+2\dot {x}l\dot {\theta }\cos \theta \right ) \] And since the blob is losing potential energy as it move downwards, we obtain \(U\) as (assuming zero potential energy is the ground level)\[ U=mgl\cos \theta \] Therefore the Lagrangian is

\begin {align*} L & =T-U\\ & =\frac {1}{2}M\dot {x}^{2}+\frac {1}{2}m\left ( \dot {x}^{2}+l^{2}\dot {\theta }^{2}+2\dot {x}l\dot {\theta }\cos \theta \right ) -mgl\cos \theta \end {align*}

To obtain the equation of motions, we need to evaluate \(\frac {d}{dt}\left ( \frac {\partial L}{\partial \dot {q}_{i}}\right ) -\frac {\partial L}{\partial q_{i}}=Q_{i}\) for each Lagrangian coordinate \(q_{i}\) and \(Q_{i}\) is the generalized force for that coordinate. Hence for \(\theta \) we obtain\begin {align*} \frac {\partial L}{\partial \dot {\theta }} & =\frac {1}{2}m\left ( 2l^{2}\dot {\theta }+2\dot {x}l\cos \theta \right ) \\ \frac {d}{dt}\left ( \frac {\partial L}{\partial \dot {\theta }}\right ) & =\frac {1}{2}m\left ( 2l^{2}\ddot {\theta }+2\ddot {x}l\cos \theta -2\dot {x}l\sin \left ( \theta \right ) \dot {\theta }\right ) \\ \frac {\partial L}{\partial \theta } & =\frac {1}{2}m\left ( -2\dot {x}l\dot {\theta }\sin \theta \right ) +mgl\sin \theta \end {align*}

Hence EQM for \(\theta \) is\begin {align} \frac {d}{dt}\left ( \frac {\partial L}{\partial \dot {\theta }}\right ) -\frac {\partial L}{\partial \theta } & =Q\nonumber \\ \frac {1}{2}m\left ( 2l^{2}\ddot {\theta }+2\ddot {x}l\cos \theta -2\dot {x}l\sin \left ( \theta \right ) \dot {\theta }\right ) -\left ( \frac {1}{2}m\left ( -2\dot {x}l\dot {\theta }\sin \theta \right ) +mgl\sin \theta \right ) & =Q\nonumber \\ ml\ddot {\theta }+m\ddot {x}\cos \theta -m\dot {x}\sin \theta \dot {\theta }+m\dot {x}\dot {\theta }\sin \theta -mg\sin \theta & =\frac {Q}{l}\nonumber \\ ml\ddot {\theta }+m\ddot {x}\cos \theta -mg\sin \theta & =\frac {Q}{l}\tag {1} \end {align}

Now we need to obtain \(Q\) for the coordinate \(\theta \). Apply a virtual displacement \(\delta \theta \) and determine the work done by \(u\left ( t\right ) \)

pict
Figure 3: virtual work for \(\theta \)

Hence the work done by \(u\) is making virtual displacement \(\delta \theta \) is zero, since \(u\) is not in the line of force along this displacement. Therefore, the EQM for \(\theta \) is from Eq (1) above\begin {equation} ml\ddot {\theta }+m\ddot {x}\cos \theta -mg\sin \theta =0\tag {2} \end {equation} Now we find EQM for coordinate \(x\)\begin {align*} \frac {\partial L}{\partial \dot {x}} & =M\dot {x}+\frac {1}{2}m\left ( 2\dot {x}+2l\dot {\theta }\cos \theta \right ) \\ \frac {d}{dt}\left ( \frac {\partial L}{\partial \dot {x}}\right ) & =M\ddot {x}+\frac {1}{2}m\left ( 2\ddot {x}+2l\ddot {\theta }\cos \theta -2l\dot {\theta }\sin \left ( \theta \right ) \dot {\theta }\right ) \\ & =M\ddot {x}+m\left ( \ddot {x}+l\ddot {\theta }\cos \theta -l\dot {\theta }^{2}\sin \theta \right ) \\ \frac {\partial L}{\partial x} & =0 \end {align*}

Hence EQM for \(x\) is \begin {align*} \frac {d}{dt}\left ( \frac {\partial L}{\partial \dot {x}}\right ) -\frac {\partial L}{\partial x} & =Q\\ \left ( M+m\right ) \ddot {x}+ml\ddot {\theta }\cos \theta -ml\dot {\theta }^{2}\sin \theta & =Q \end {align*}

Now we need to find \(Q\) for \(x\). Apply virtual displacement in the \(x\) direction, and find work done by \(u\)

pict
Figure 4: virtual displacement in the \(x\) direction

\[ \delta W=u\left ( \delta x\right ) \] But \(Q=\frac {\delta W}{\delta x}\), hence we see that \(Q=u\), therefore, the EQM becomes\begin {equation} \left ( M+m\right ) \ddot {x}+ml\ddot {\theta }\cos \theta -ml\dot {\theta }^{2}\sin \theta =u\tag {3} \end {equation} Conclusion: The two equations of motion are\begin {align*} ml\ddot {\theta }+m\ddot {x}\cos \theta -mg\sin \theta & =0\\ \left ( M+m\right ) \ddot {x}+ml\ddot {\theta }\cos \theta -ml\dot {\theta }^{2}\sin \theta & =u \end {align*}

Assuming small angle approximation gives\begin {align} l\ddot {\theta }+\ddot {x}-g\theta & =0\tag {4}\\ \left ( M+m\right ) \ddot {x}+ml\ddot {\theta } & =u\tag {5} \end {align}

Now we solve for  \(\ddot {x}\) and \(\ddot {\theta }\) from Eqs (4) and (5). From Eq (5) \[ \ddot {x}=\frac {u-ml\ddot {\theta }}{\left ( M+m\right ) }\] Substituting the above into Eq (4) gives\begin {align} l\ddot {\theta }+\left ( \frac {u-ml\ddot {\theta }}{\left ( M+m\right ) }\right ) -g\theta & =0\nonumber \\ \left ( M+m\right ) l\ddot {\theta }+u-ml\ddot {\theta }-\left ( M+m\right ) g\theta & =0\nonumber \\ \ddot {\theta }Ml-\left ( M+m\right ) g\theta & =-u\nonumber \\ \ddot {\theta } & =\frac {-u+\left ( M+m\right ) g\theta }{Ml}\tag {6} \end {align}

Using result for \(\ddot {\theta }\) found in Eq (6) and substituting into (5) gives\begin {align*} \ddot {x} & =\frac {u-ml\ddot {\theta }}{\left ( M+m\right ) }\\ \ddot {x} & =\frac {u-ml\left ( \frac {-u+\left ( M+m\right ) g\theta }{Ml}\right ) }{\left ( M+m\right ) }\\ & =\frac {uM+mu-mMg\theta -m^{2}g\theta }{M\left ( M+m\right ) }\\ & =\frac {-gm\theta \left ( M+m\right ) }{M\left ( M+m\right ) }+\frac {u}{M}\\ & =\frac {-gm\theta }{M}+\frac {u}{M} \end {align*}

To summarize what we have so far. We have obtained two linearized equations of motion for \(\theta \) and \(x\) and they are the following\begin {align*} l\ddot {\theta }+\ddot {x}-g\theta & =u\\ \left ( M+m\right ) \ddot {x}+ml\ddot {\theta } & =u \end {align*}

Now we convert the equations to state space. Let \(x_{1}=x,x_{2}=\dot {x},x_{3}=\theta ,x_{4}=\dot {\theta }\), hence \[ \left . \begin {array} [c]{c}x_{1}=x\\ x_{2}=\dot {x}\\ x_{3}=\theta \\ x_{4}=\dot {\theta }\end {array} \right \} \rightarrow \left . \begin {array} [c]{l}\dot {x}_{1}=\dot {x}=x_{2}\\ \dot {x}_{2}=\ddot {x}\\ \dot {x}_{3}=\dot {\theta }=x_{4}\\ \dot {x}_{4}=\ddot {\theta }\end {array} \right \} \rightarrow \left . \begin {array} [c]{l}\dot {x}_{1}=\dot {x}=x_{2}\\ \dot {x}_{2}=\frac {-gm\theta }{M}+\frac {u}{M}\\ \dot {x}_{3}=\dot {\theta }=x_{4}\\ \dot {x}_{4}=\frac {-u+\left ( M+m\right ) g\theta }{Ml}\end {array} \right \} \]\[\begin {array} [c]{ll}\dot {x}_{1}= & x_{2}\\ \dot {x}_{2}= & \frac {-gmx_{3}}{M}+\frac {u}{M}\\ \dot {x}_{3}= & x_{4}\\ \dot {x}_{4}= & x_{3}\frac {g\left ( M+m\right ) }{Ml}-\frac {u}{Ml}\end {array} \] Writing the above in the form \(\dot {X}=AX+Bu\) we obtain \begin {align*} \begin {pmatrix} \dot {x}_{1}\\ \dot {x}_{2}\\ \dot {x}_{3}\\ \dot {x}_{4}\end {pmatrix} & =\begin {pmatrix} 0 & 1 & 0 & 0\\ 0 & 0 & \frac {-gm}{M} & 0\\ 0 & 0 & 0 & 1\\ 0 & 0 & \frac {g\left ( M+m\right ) }{Ml} & 0 \end {pmatrix}\begin {pmatrix} x_{1}\\ x_{2}\\ x_{3}\\ x_{4}\end {pmatrix} +\begin {pmatrix} 0\\ \frac {1}{M}\\ 0\\ \frac {-1}{Ml}\end {pmatrix} u\\ \mathbf {y} & =\begin {pmatrix} 1 & 0 & 1 & 0 \end {pmatrix}\begin {pmatrix} x_{1}\\ x_{2}\\ x_{3}\\ x_{4}\end {pmatrix} \end {align*}

2.1 Stability of open loop system

To determine the stability of the above system (now that it is a linear system since we have linearized it), we first find the equilibrium point. This is found by setting \(\mathbf {\dot {x}=0}\), and this results in \(x_{2}=0,x_{3}=0,x_{4}=0\), i.e. \(\dot {x}=0,\theta =0,\) and \(\dot {\theta }=0\). Notice that the value of \(x\) is not important for the equilibrium point. Now we need to determine if this point is stable or not.\begin {align*} \det \begin {pmatrix} -\lambda & 1 & 0 & 0\\ 0 & -\lambda & \frac {-gm}{M} & 0\\ 0 & 0 & -\lambda & 1\\ 0 & 0 & \frac {g\left ( M+m\right ) }{Ml} & -\lambda \end {pmatrix} & =0\\ -\frac {1}{Ml}\left ( Mg\lambda ^{2}-Ml\lambda ^{4}+gm\lambda ^{2}\right ) & =0\\ \lambda ^{2}\left ( Ml\lambda ^{2}-g\left ( m+M\right ) \right ) & =0 \end {align*}

Hence\[ \lambda =\left \{ 0,0,\frac {1}{Ml}\sqrt {Mgl\left ( M+m\right ) },-\frac {1}{Ml}\sqrt {Mgl\left ( M+m\right ) }\right \} \] Since \(M,l,m,g\) are all positive, we see that one root will be in the RHS of the complex plane. Therefore the open loop system is unstable.

To stabilize it, we need to supply a control law \(u\) to force the roots of the new \(A\) matrix to be all in the LHS of the complex plane.

Let\begin {align} \mathbf {u} & =\mathbf {Fx}\tag {7}\\ & =\left ( f_{1},f_{2},f_{3},f_{4}\right ) \left ( x_{1},x_{2},x_{3},x_{4}\right ) ^{T}\nonumber \\ & =f_{1}x_{1}+f_{2}x_{2}+f_{3}x_{3}+f_{4}x_{4}\nonumber \end {align}

Hence Eq (7) becomes\begin {align*} \begin {pmatrix} \dot {x}_{1}\\ \dot {x}_{2}\\ \dot {x}_{3}\\ \dot {x}_{4}\end {pmatrix} & =\left \{ \begin {pmatrix} 0 & 1 & 0 & 0\\ 0 & 0 & \frac {-gm}{M} & 0\\ 0 & 0 & 0 & 1\\ 0 & 0 & \frac {g\left ( M+m\right ) }{Ml} & 0 \end {pmatrix} +\begin {pmatrix} 0\\ \frac {1}{M}\\ 0\\ \frac {-1}{Ml}\end {pmatrix}\begin {pmatrix} f_{1} & f_{2} & f_{3} & f_{4}\end {pmatrix} \right \} \begin {pmatrix} x_{1}\\ x_{2}\\ x_{3}\\ x_{4}\end {pmatrix} \\\begin {pmatrix} \dot {x}_{1}\\ \dot {x}_{2}\\ \dot {x}_{3}\\ \dot {x}_{4}\end {pmatrix} & =\left \{ \begin {pmatrix} 0 & 1 & 0 & 0\\ 0 & 0 & \frac {-gm}{M} & 0\\ 0 & 0 & 0 & 1\\ 0 & 0 & \frac {g\left ( M+m\right ) }{Ml} & 0 \end {pmatrix} +\begin {pmatrix} 0 & 0 & 0 & 0\\ \frac {1}{M}f_{1} & \frac {1}{M}f_{2} & \frac {1}{M}f_{3} & \frac {1}{M}f_{4}\\ 0 & 0 & 0 & 0\\ -\frac {1}{Ml}f_{1} & -\frac {1}{Ml}f_{2} & -\frac {1}{Ml}f_{3} & -\frac {1}{Ml}f_{4}\end {pmatrix} \allowbreak \right \} \begin {pmatrix} x_{1}\\ x_{2}\\ x_{3}\\ x_{4}\end {pmatrix} \\\begin {pmatrix} \dot {x}_{1}\\ \dot {x}_{2}\\ \dot {x}_{3}\\ \dot {x}_{4}\end {pmatrix} & =\begin {pmatrix} 0 & 1 & 0 & 0\\ \frac {1}{M}f_{1} & \frac {1}{M}f_{2} & \frac {1}{M}f_{3}-\frac {1}{M}gm & \frac {1}{M}f_{4}\\ 0 & 0 & 0 & 1\\ -\frac {1}{Ml}f_{1} & -\frac {1}{Ml}f_{2} & \frac {1}{M}\frac {g}{l}\left ( M+m\right ) -\frac {1}{Ml}f_{3} & -\frac {1}{Ml}f_{4}\end {pmatrix}\begin {pmatrix} x_{1}\\ x_{2}\\ x_{3}\\ x_{4}\end {pmatrix} \\ \mathbf {y} & =\begin {pmatrix} 1 & 0 & 1 & 0 \end {pmatrix}\begin {pmatrix} x_{1}\\ x_{2}\\ x_{3}\\ x_{4}\end {pmatrix} \end {align*}

Therefore\begin {align*} \det \begin {pmatrix} -\lambda & 1 & 0 & 0\\ \frac {1}{M}f_{1} & \frac {1}{M}f_{2}-\lambda & \frac {1}{M}f_{3}-\frac {1}{M}gm & \frac {1}{M}f_{4}\\ 0 & 0 & -\lambda & 1\\ -\frac {1}{Ml}f_{1} & -\frac {1}{Ml}f_{2} & \frac {1}{M}\frac {g}{l}\left ( M+m\right ) -\frac {1}{Ml}f_{3} & -\frac {1}{Ml}f_{4}-\lambda \end {pmatrix} & =0\\ \frac {1}{Ml}\left ( gf_{1}+\lambda ^{2}f_{3}+\lambda ^{3}f_{4}+g\lambda f_{2}-Mg\lambda ^{2}+Ml\lambda ^{4}-gm\lambda ^{2}-l\lambda ^{2}f_{1}-l\lambda ^{3}f_{2}\right ) & =0 \end {align*}

Hence\begin {equation} \ \lambda ^{4}+\lambda ^{3}\frac {\left ( f_{4}-l\ f_{2}\right ) }{M\ l}+\lambda ^{2}\frac {\left ( f_{3}-M\ g-g\ m-l\ f_{1}\right ) }{M\ l}+\lambda \frac {\ g\ f_{2}}{M\ l}+\frac {g\ f_{1}}{M\ l}=0\tag {8} \end {equation} We now need to determine \(f_{1},f_{2},f_{3}\) and \(f_{4}\). Assume we require that the closed loop poles be located at\[ \lambda =\left \{ -1,-2,-1+i,-1-i\right \} \] Hence, the characteristic polynomial is\begin {align} \Delta \left ( \lambda \right ) & =\left ( \lambda +1\right ) \left ( \lambda +2\right ) \left ( \lambda +1-i\right ) \left ( \lambda +1+i\right ) \nonumber \\ & =\lambda ^{4}+5\lambda ^{3}+10\lambda ^{2}+10\lambda +4\tag {9} \end {align}

Compare Eqs (8,9) we obtain the following\begin {align*} \frac {\left ( f_{4}-l\ f_{2}\right ) }{M\ l} & =5\\ \frac {\left ( f_{3}-M\ g-g\ m-l\ f_{1}\right ) }{M\ l} & =10\\ \frac {\ g\ f_{2}}{M\ l} & =10\\ \frac {g\ f_{1}}{M\ l} & =4 \end {align*}

Or\begin {align*} f_{4}-l\ f_{2} & =5Ml\\ f_{3}-l\ f_{1} & =10Ml+g\left ( M+m\right ) \\ f_{2} & =10\frac {Ml}{g}\\ f_{1} & =4\frac {Ml}{g} \end {align*}

Hence\begin {align*} f_{4} & =5Ml\left ( 1+\frac {2l}{g}\right ) \\ f_{3} & =2Ml\left ( 5+\ \frac {2l}{g}\right ) +g\left ( M+m\right ) \\ f_{2} & =10\frac {Ml}{g}\\ f_{1} & =4\frac {Ml}{g} \end {align*}

Therefore, given \(M,m,g,l\) we can find \(f_{1},f_{2},f_{3},f_{4}\) which will generate force \(u\left ( t\right ) \) which will keep the poles of the closed loop system in the LHS of the complex plane, and keep the inverted pendulum stable. For example, using \(M=1kg,m=0.1kg,l=1,g=10m/s^{2}\) gives

\begin {align*} f_{4} & =5\left ( 1+\frac {2}{10}\right ) =6\\ f_{3} & =2\left ( 5+\ \frac {2}{10}\right ) +10\left ( 1.1\right ) =21.4\\ \ \ f_{2} & =10\frac {1}{10}=1\\ f_{1} & =\frac {4}{10}=0.4 \end {align*}

3 Comparing solution with and without stabilizing control law

We will now generate the solution \(x\left ( t\right ) ,\theta \left ( t\right ) \) for some initial conditions and plot these solutions against time. In the first case, we assume \(u\left ( t\right ) \) is zero. Hence we will observe that the system is unstable, i.e. \(\theta \left ( t\right ) \) will grow away from the marginally stable position which is \(\theta =0^{0}\) and will not return back. Next, we will introduce \(u\left ( t\right ) \) as determined in the previous section, and observe the new solution to see that it remains near or at the \(\theta =0^{0}\) position.

First, we need to decide on some initial conditions. These must be such that \(\theta \left ( 0\right ) \) close to zero and for \(x\left ( 0\right ) \) we can use \(zero\). Hence, let\begin {align*} \theta \left ( 0\right ) & =\theta _{0}\\ \dot {\theta }\left ( 0\right ) & =\dot {\theta }_{0}\\ x\left ( 0\right ) & =0\\ \dot {x}\left ( 0\right ) & =\dot {x}_{0} \end {align*}

To determine \(\mathbf {y}\), which is the solution of the system, we first must solve equation (7) and (8) for the above IC.

The solution to (7) is given by solution to \begin {equation} \mathbf {\dot {x}=}A\mathbf {x}\tag {10} \end {equation} Which is \[ \mathbf {x}\left ( t\right ) =\mathbf {x}\left ( 0\right ) e^{At}\] Where \[ \mathbf {x}\left ( t\right ) =\begin {pmatrix} x_{1}\left ( t\right ) \\ x_{2}\left ( t\right ) \\ x_{3}\left ( t\right ) \\ x_{4}\left ( t\right ) \end {pmatrix} \] And \[ \mathbf {x}\left ( 0\right ) =\begin {pmatrix} x_{1}\left ( 0\right ) \\ x_{2}\left ( 0\right ) \\ x_{3}\left ( 0\right ) \\ x_{4}\left ( 0\right ) \end {pmatrix} =\begin {pmatrix} 0\\ \dot {x}_{0}\\ \theta _{0}\\ \dot {\theta }_{0}\end {pmatrix} \] Taking Laplace transform of (10) results in\begin {align*} sX\left ( s\right ) -\mathbf {x}\left ( 0\right ) & =AX\left ( s\right ) \\ X\left ( s\right ) & =\left ( sI-A\right ) ^{-1}\mathbf {x}\left ( 0\right ) \end {align*}

Hence\[ \mathbf {x}\left ( t\right ) =\mathcal {L}^{-1}\left [ \left ( sI-A\right ) ^{-1}\right ] \mathbf {x}\left ( 0\right ) \] Therefore, the solution to\[\begin {pmatrix} \dot {x}_{1}\\ \dot {x}_{2}\\ \dot {x}_{3}\\ \dot {x}_{4}\end {pmatrix} =\begin {pmatrix} 0 & 1 & 0 & 0\\ 0 & 0 & \frac {-gm}{M} & 0\\ 0 & 0 & 0 & 1\\ 0 & 0 & \frac {g\left ( M+m\right ) }{Ml} & 0 \end {pmatrix}\begin {pmatrix} x_{1}\\ x_{2}\\ x_{3}\\ x_{4}\end {pmatrix} \] Is

\begin {align*} \mathbf {x}\left ( t\right ) & =\mathcal {L}^{-1}\left [ \left ( \begin {pmatrix} s & 0 & 0 & 0\\ 0 & s & 0 & 0\\ 0 & 0 & s & 0\\ 0 & 0 & 0 & s \end {pmatrix} -\begin {pmatrix} 0 & 1 & 0 & 0\\ 0 & 0 & \frac {-gm}{M} & 0\\ 0 & 0 & 0 & 1\\ 0 & 0 & \frac {g\left ( M+m\right ) }{Ml} & 0 \end {pmatrix} \right ) ^{-1}\right ] \begin {pmatrix} 0\\ \dot {x}_{0}\\ \theta _{0}\\ \dot {\theta }_{0}\end {pmatrix} \\ & =\mathcal {L}^{-1}\left [ \begin {pmatrix} s & -1 & 0 & 0\\ 0 & s & \frac {1}{M}gm & 0\\ 0 & 0 & s & -1\\ 0 & 0 & -\frac {1}{M}\frac {g}{l}\left ( M+m\right ) & s \end {pmatrix} ^{-1}\right ] \begin {pmatrix} 0\\ \dot {x}_{0}\\ \theta _{0}\\ \dot {\theta }_{0}\end {pmatrix} \\ & =\mathcal {L}^{-1}\left [ \begin {pmatrix} \frac {1}{s} & \frac {1}{s^{2}} & gl\frac {m}{Mgs-Mls^{3}+gms} & gl\frac {m}{Mgs^{2}-Mls^{4}+gms^{2}}\\ 0 & \frac {1}{s} & gl\frac {m}{-Mls^{2}+Mg+gm} & gl\frac {m}{Mgs-Mls^{3}+gms}\\ 0 & 0 & -Ml\frac {s}{-Mls^{2}+Mg+gm} & -M\frac {l}{-Mls^{2}+Mg+gm}\\ 0 & 0 & -\frac {Mg+gm}{-Mls^{2}+Mg+gm} & -Ml\frac {s}{-Mls^{2}+Mg+gm}\end {pmatrix} \right ] \begin {pmatrix} 0\\ \dot {x}_{0}\\ \theta _{0}\\ \dot {\theta }_{0}\end {pmatrix} \\ & =\begin {pmatrix} 1 & t & glm\left ( \frac {1}{Mg+gm}-\frac {\cosh t\sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) }}{Mg+gm}\right ) & glm\left ( \frac {t}{Mg+gm}-\frac {\sinh t\sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) }}{\left ( Mg+gm\right ) \sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) }}\right ) \\ 0 & 1 & -\frac {1}{M}gm\frac {\sinh t\sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) }}{\sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) }} & glm\left ( \frac {1}{Mg+gm}-\frac {\cosh t\sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) }}{Mg+gm}\right ) \\ 0 & 0 & \cosh t\sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) } & \frac {\sinh t\sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) }}{\sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) }}\\ 0 & 0 & \frac {1}{Ml}\left ( \sinh t\sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) }\right ) \frac {Mg+gm}{\sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) }} & \cosh t\sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) }\end {pmatrix}\begin {pmatrix} 0\\ \dot {x}_{0}\\ \theta _{0}\\ \dot {\theta }_{0}\end {pmatrix} \\ & =\begin {pmatrix} t\dot {x}_{0}+glm\theta _{0}\left ( \frac {1}{Mg+gm}-\frac {\cosh t\sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) }}{Mg+gm}\right ) +\dot {\theta }_{0}glm\left ( \frac {t}{Mg+gm}-\frac {\sinh t\sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) }}{\left ( Mg+gm\right ) \sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) }}\right ) \\ \dot {x}_{0}+\dot {\theta }_{0}glm\left ( \frac {1}{Mg+gm}-\frac {\cosh t\sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) }}{Mg+gm}\right ) -\frac {1}{M}gm\theta _{0}\frac {\sinh t\sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) }}{\sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) }}\\ \theta _{0}\cosh t\sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) }+\dot {\theta }_{0}\frac {\sinh t\sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) }}{\sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) }}\\ \dot {\theta }_{0}\cosh t\sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) }+\frac {1}{Ml}\theta _{0}\left ( \sinh t\sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) }\right ) \frac {Mg+gm}{\sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) }}\end {pmatrix} \end {align*}

Therefore, the solution to \(x_{3}\left ( t\right ) \) which is \(\theta \left ( t\right ) \) is given by\[ \theta \left ( t\right ) =\theta _{0}\cosh t\sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) }+\dot {\theta }_{0}\frac {\sinh t\sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) }}{\sqrt {\frac {1}{Ml}\left ( Mg+gm\right ) }}\] Let \(\theta _{0}=\frac {\pi }{10},\dot {\theta }_{0}=1rad/\sec \), we plot the above solution for \(t=0\) up to \(10\) seconds

pict
Figure 5: unstable \(\theta \)

We plot the solution to (8), which is the state space equation with the stabilizing control law derived above,which is the following\[\begin {pmatrix} \dot {x}_{1}\\ \dot {x}_{2}\\ \dot {x}_{3}\\ \dot {x}_{4}\end {pmatrix} =\begin {pmatrix} 0 & 1 & 0 & 0\\ \frac {1}{M}f_{1} & \frac {1}{M}f_{2} & \frac {1}{M}f_{3}-\frac {1}{M}gm & \frac {1}{M}f_{4}\\ 0 & 0 & 0 & 1\\ -\frac {1}{Ml}f_{1} & -\frac {1}{Ml}f_{2} & \frac {1}{M}\frac {g}{l}\left ( M+m\right ) -\frac {1}{Ml}f_{3} & -\frac {1}{Ml}f_{4}\end {pmatrix}\begin {pmatrix} x_{1}\\ x_{2}\\ x_{3}\\ x_{4}\end {pmatrix} \] Where\begin {align*} f_{4} & =5Ml\left ( 1+\frac {2l}{g}\right ) \\ f_{3} & =2Ml\left ( 5+\ \frac {2l}{g}\right ) +g\left ( M+m\right ) \\ \ \ f_{2} & =10\frac {Ml}{g}\\ f_{1} & =4\frac {Ml}{g} \end {align*}

Where the above values determined to cause the closed loop poles to be located at \[ \left \{ -1,-2,-1+i,-1-i\right \} \] Hence\begin {align*} \mathbf {x}\left ( t\right ) & =\mathcal {L}^{-1}\left [ \left ( sI-A\right ) ^{-1}\right ] \mathbf {x}\left ( 0\right ) \\ & =\mathcal {L}^{-1}\left ( \begin {pmatrix} s & 0 & 0 & 0\\ 0 & s & 0 & 0\\ 0 & 0 & s & 0\\ 0 & 0 & 0 & s \end {pmatrix} -\begin {pmatrix} 0 & 1 & 0 & 0\\ \frac {1}{M}f_{1} & \frac {1}{M}f_{2} & \frac {1}{M}f_{3}-\frac {1}{M}gm & \frac {1}{M}f_{4}\\ 0 & 0 & 0 & 1\\ -\frac {1}{Ml}f_{1} & -\frac {1}{Ml}f_{2} & \frac {1}{M}\frac {g}{l}\left ( M+m\right ) -\frac {1}{Ml}f_{3} & -\frac {1}{Ml}f_{4}\end {pmatrix} \right ) ^{-1}\begin {pmatrix} 0\\ \dot {x}_{0}\\ \theta _{0}\\ \dot {\theta }_{0}\end {pmatrix} \\ & =\mathcal {L}^{-1}\begin {pmatrix} s & -1 & 0 & 0\\ -\frac {1}{M}f_{1} & s-\frac {1}{M}f_{2} & \frac {1}{M}gm-\frac {1}{M}f_{3} & -\frac {1}{M}f_{4}\\ 0 & 0 & s & -1\\ \frac {1}{Ml}f_{1} & \frac {1}{Ml}f_{2} & \frac {1}{Ml}f_{3}-\frac {1}{M}\frac {g}{l}\left ( M+m\right ) & s+\frac {1}{Ml}f_{4}\end {pmatrix} ^{-1}\begin {pmatrix} 0\\ \dot {x}_{0}\\ \theta _{0}\\ \dot {\theta }_{0}\end {pmatrix} \end {align*}

To make the computation easier, we now substitute numerical values for all the above parameters, which are \(M=1kg,m=0.1kg,l=1,g=10m/s^{2}\), and we obtain\[ \mathbf {x}\left ( t\right ) =\mathcal {L}^{-1}\begin {pmatrix} s & -1 & 0 & 0\\ -f_{1} & s-f_{2} & 1-f_{3} & -f_{4}\\ 0 & 0 & s & -1\\ f_{1} & f_{2} & f_{3}-10\left ( 1.1\right ) & s+f_{4}\end {pmatrix} ^{-1}\begin {pmatrix} 0\\ \dot {x}_{0}\\ \theta _{0}\\ \dot {\theta }_{0}\end {pmatrix} \] And\begin {align*} f_{4} & =5\left ( 1+\frac {2}{10}\right ) =6\\ f_{3} & =2\left ( 5+\frac {2}{10}\right ) +10\left ( 1.1\right ) =21.4\\ f_{2} & =10\frac {1}{10}=1\\ f_{1} & =\frac {4}{10}=0.4 \end {align*}

Hence\begin {align*} \mathbf {x}\left ( t\right ) & =\mathcal {L}^{-1}\begin {pmatrix} s & -1 & 0 & 0\\ -0.4 & s-1 & 1-21.4 & -6\\ 0 & 0 & s & -1\\ 0.4 & 1 & 21.4-10\left ( 1.1\right ) & s+6 \end {pmatrix} ^{-1}\begin {pmatrix} 0\\ \dot {x}_{0}\\ \theta _{0}\\ \dot {\theta }_{0}\end {pmatrix} \\ & =\mathcal {L}^{-1}\begin {pmatrix} s & -1 & 0 & 0\\ -0.4 & s-1 & -20.4 & -6\\ 0 & 0 & s & -1\\ 0.4 & 1 & 21.4-10\left ( 1.1\right ) & s+6 \end {pmatrix} ^{-1}\begin {pmatrix} 0\\ \dot {x}_{0}\\ \theta _{0}\\ \dot {\theta }_{0}\end {pmatrix} \end {align*}

Using \(\theta _{0}=\frac {\pi }{10},\dot {\theta }_{0}=1rad/\sec ,\dot {x}_{0}=1m/\sec ,\) and solving for \(\theta \left ( t\right ) \) gives

\[ \mathbf {x}\left ( t\right ) =\mathcal {L}^{-1}\begin {pmatrix} s & -1 & 0 & 0\\ -0.4 & s-1 & -20.4 & -6\\ 0 & 0 & s & -1\\ 0.4 & 1 & 21.4-10\left ( 1.1\right ) & s+6 \end {pmatrix} ^{-1}\begin {pmatrix} 0\\ 1\\ \frac {\pi }{10}\\ 1 \end {pmatrix} \] Using CAS system to matrix inverse the above and obtain the inverse Laplace transform, and pick the \(\theta \left ( t\right ) \) solution and plot it, we observe that now the system becomes stable as expected.

pict
Figure 6: Using CAS system to find inverse Laplace

4 Conclusion

We observe from the above plots and the plots shown in the computation section that with the control law derived to force the poles of the closed loop to be stable, the inverted pendulum has been stabilized.

The final angle \(\theta \) that the inverted pendulum makes with the vertical does go to zero.

From the plot of the position \(x(t)\), we see that the cart moves to the right and away from the \(x=0\) position, then it return back to \(x=0\) position, while in the same time, the pendulum swings back and forth about the \(\theta =0\) position before it finally settles down at the stable position.

This shows the using pole placement resulted in an effective control law which stabilized the system. Small angle approximation was used and the initial angle used was also assumed to be small.