1.
up
2.
This page in PDF
3.
software
(a)
Mathematica notebook
(b)
Mathematica notebook in HTML
(c)
Mathematica notebook in PDF

EGME 511 (Advanced Mechanical Vibration) Final Project

Stabilization of an inverted pendulum on moving cart using feedback control

Nasser M. Abbasi

February 25, 2015

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

PIC

Need to ๏ฌnd control law u(t)  to stabilize the inverted pendulum. First we need to obtain the equations of motions.

2 Analysis

Let the Lagrangian coordinates be ๐œƒ  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

     1       1
T =  -M xห™2 + --mv2
     2       2

Where v  is the linear velocity of the blob m  relative to the inertial system.

PIC

Hence, since v =  l๐œƒห™  , we obtain

pict

Hence T  becomes

     1-   2   1- (  2   2 ห™2       ห™    )
T =  2M  ห™x +  2m   ห™x +  l๐œƒ  + 2xห™l๐œƒ cos๐œƒ

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 ๐œƒ

Therefore the Lagrangian is

pict

To obtain the equation of motions, we need to evaluate   (   )
-d  โˆ‚L- โˆ’  โˆ‚L-= Qi
dt  โˆ‚ห™qi    โˆ‚qi  for each Lagrangian coordinate qi  and Qi  is the generalized force for that coordinate. Hence for ๐œƒ  we obtain

pict

Hence EQMย for ๐œƒ  is

pict

Now we need to obtain Q  for the coordinate ๐œƒ  . Apply a virtual displacement ฮด๐œƒ  and determine the work done by u(t)

PIC

Hence the work done by u  is making virtual displacement ฮด๐œƒ  is zero, since u  is not in the line of force along this displacement. Therefore, the EQMย for ๐œƒ  is from Eq (1) above

mlยจ๐œƒ + m ยจx cos๐œƒ โˆ’ mg  sin ๐œƒ = 0
(2)

Now we ๏ฌnd EQMย for coordinate x

pict

Hence EQMย for x  is

pict

Now we need to ๏ฌnd Q  for x  . Apply virtual displacement in the x  direction, and ๏ฌnd work done by u

PIC

ฮดW  =  u(ฮดx )

But Q  = ฮดWฮดx  , hence we see that Q =  u  , therefore, the EQMย becomes

(M  + m ) ยจx + ml ยจ๐œƒ cos๐œƒ โˆ’ ml๐œƒห™2 sin ๐œƒ = u
(3)

Conclusion: The two equations of motion are

pict

Assuming small angle approximation gives

pict

Now we solve for ย ยจx  and ยจ๐œƒ from Eqs (4) and (5). From Eq (5)

            ยจ
xยจ=  u-โˆ’--ml๐œƒ-
     (M  + m )

Substituting the above into Eq (4) gives

pict

Using result for ยจ๐œƒ found in Eq (6) and substituting into (5) gives

pict

To summarize what we have so far. We have obtained two linearized equations of motion for ๐œƒ  and   x  and they are the following

pict

Now we convert the equations to state space. Let x1 = x,x2 = xห™,x3 =  ๐œƒ,x4 = ห™๐œƒ  , hence

x1 =  x )|||      ห™x1 = ห™x = x2 )|||      ห™x1 = ห™x = x2      )|||
x2 =  ห™x |}      ห™x2 = ยจx      |}      ห™x2 = โˆ’-gm-๐œƒ+  u-  |}
          โ†’                   โ†’          M     M
x3 =  ๐œƒ |||      ห™x3 = ห™๐œƒ = x4 |||      ห™x3 = ๐œƒห™= x4      |||
x  =  ห™๐œƒ |)      ห™x =  ยจ๐œƒ      |)      ห™x  = โˆ’-u+(M+m--)g๐œƒ |)
  4             4                  4        Ml

ห™x1 =  x2
ห™x2 =  โˆ’-gmx3-+  u-
        M      M
ห™x3 =  x4
ห™x  =  x  g(M+m-)-โˆ’ -u-
 4     3   Ml     Ml

Writing the above in the form Xห™ = AX  +  Bu  we obtain

pict

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 ๏ฌrst ๏ฌnd the equilibrium point. This is found by setting ห™x =  0  , and this results in x2 = 0,x3 = 0, x4 = 0  , i.e. xห™=  0,๐œƒ = 0,  and ห™๐œƒ = 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.

pict

Hence

     {                                              }
ฮป =    0,0,-1-โˆ˜M --gl(M--+-m-),โˆ’ -1-โˆ˜M --gl(M--+-m-)-
           M l                   M  l

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

pict

Hence Eq (7) becomes

pict

Therefore

pict

Hence

ฮป4 + ฮป3(f4-โˆ’-l-f2)+ ฮป2 (f3 โˆ’-M--g โˆ’-g-m-โˆ’-l-f1)+  ฮป-g-f2 + g-f1 = 0
          M   l                  M  l               M  l   M  l
(8)

We now need to determine f1,f2,f3   and f4   . Assume we require that the closed loop poles be located at

ฮป = { โˆ’ 1,โˆ’ 2,โˆ’ 1 + i,โˆ’ 1 โˆ’ i}

Hence, the characteristic polynomial is

pict

Compare Eqs (8,9)ย we obtain the following

pict

or

pict

Hence

pict

Therefore, given M, m, g, l  we can ๏ฌnd f1,f2,f3,f4   which will generate force u (t)  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, for                                       2
M  = 1kg, m  = 0.1kg,l = 1,g = 10m โˆ•s   , we obtain

pict

3 Comparing solution with and without stabilizing control law

We will now generate the solution x (t) ,๐œƒ(t)  for some initial conditions and plot these solutions against time. In the ๏ฌrst case, we assume u(t)  is zero. Hence we will observe that the system is unstable, i.e. ๐œƒ (t)  will grow away from the marginally stable position which is      0
๐œƒ = 0   and will not return back. Next, we will introduce u (t)  as determined in the previous section, and observe the new solution to see that it remains near or at the ๐œƒ = 00   position.

First, we need to decide on some initial conditions. These must be such that ๐œƒ(0)  close to zero and for x (0)  we can use zero  . Hence, let

pict

To determine y  , which is the solution of the system, we ๏ฌrst must solve equation (7) and (8) for the above IC.

The solution to (7) is given by solution to

ห™x =Ax
(10)

which is

x(t) = x (0)eAt

Where

       ( x  (t))
       |   1  |
       | x2 (t)|
x (t) = ||      ||
       ( x3 (t))
         x4 (t)

and

        (      )    (   )
        | x1(0)|    |  0|
        | x2(0)|    | xห™0|
x (0) = ||      ||  = ||   ||
        ( x3(0))    ( ๐œƒ0)
          x4(0)       ๐œƒห™0

Taking Laplace transform of (10) we obtain

pict

Hence

         โˆ’1[         โˆ’1]
x (t) = โ„’    (sI โˆ’ A )   x (0)

Therefore, the solution to

(    )    (                 ) (   )
  xห™1        0  1     0    0     x1
|    |    |        โˆ’-gm-     | |   |
|| xห™2 || =  || 0  0    M     0 || || x2||
|( xห™3 |)    |( 0  0     0    1 |) |( x3|)
                  g(M+m  )
  xห™4        0  0  --Ml--- 0     x4

is

pict

Therefore, the solution to x3 (t)  which is ๐œƒ (t)  is given by

                                          โˆ˜ ---------------
               โˆ˜ ----------------    sinh t   1-(M  g + gm )
๐œƒ(t) = ๐œƒ0cosh t  -1--(M g + gm ) + ห™๐œƒ0--โˆ˜-----Ml------------
                 M l                      -1-(M g + gm )
                                          Ml

Let ๐œƒ0 = ฯ€10, ห™๐œƒ0 = 1radโˆ• sec  , we plot the above solution for t = 0  up to 10  seconds


PIC


We plot the solution to (8), which is the state space equation with the stabilizing control law derived above,which is the following

(   )    (                                              )  (   )
  ห™x1          0       1              0              0        x1
||   ||    ||  -1       1-         1-     1-          -1   ||  ||   ||
| ห™x2|  = |  M f1     M f2       M f3 โˆ’ M gm        M f4 |  | x2|
|( ห™x3|)    |(    0       0              0              1   |)  |( x3|)
             -1-     -1-    1-g            -1-      1--
  ห™x4       โˆ’ Mlf1  โˆ’ Ml f2  M l (M +  m) โˆ’ Ml f3  โˆ’ Mlf4     x4

where

pict

Where the above values determined to cause the closed loop poles to be located at

{โˆ’ 1,โˆ’ 2,โˆ’ 1 + i,โˆ’ 1 โˆ’ i}

Hence

pict

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 โˆ•s2   , and we obtain

           (                                  ) โˆ’1 (   )
           |  s     โˆ’ 1         0          0  |    | 0 |
           | โˆ’ f1  s โˆ’ f2    1 โˆ’ f3      โˆ’ f4 |    | ห™x0|
x(t) = โ„’โˆ’ 1||                                  ||    ||   ||
           (  0      0          s         โˆ’ 1 )    ( ๐œƒ0)
              f      f    f  โˆ’ 10 (1.1 ) s + f        ห™๐œƒ
               1      2     3                4        0

and

pict

Hence

pict

Using ๐œƒ =  ฯ€-, ห™๐œƒ = 1radโˆ• sec, ห™x = 1m โˆ• sec,
 0   10  0              0  and solving for ๐œƒ(t)  we obtain

            (                                   ) โˆ’1(   )
            |  s     โˆ’ 1         0           0  |   |  0|
         โˆ’1 | โˆ’ 0.4 s โˆ’ 1      โˆ’ 20.4       โˆ’ 6 |   |  1|
x (t) = โ„’   ||                                   ||   ||  ฯ€||
            (  0      0          s          โˆ’ 1 )   (  10)
              0.4     1    21.4 โˆ’ 10(1.1)  s + 6       1

Using CAS system to matrix inverse the above and obtain the inverse Laplace transform, and pick the     ๐œƒ(t)  solution and plot it, we observe that now the system becomes stable as expected.

PIC

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 ๏ฌnal angle ๐œƒ  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 ๐œƒ =  0  position before it ๏ฌnally settles down at the stable position.

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