Free Essay

Inverted Pendulem

In:

Submitted By ashuelec
Words 6866
Pages 28
Standup and Stabilization of the Inverted Pendulum by Andrew K. Stimac
Submitted to the Department of Mechanical Engineering in Partial Fulfillment of the Requirements for the Degree of
Bachelor of Science at the
Massachusetts Institute of Technology
June 1999

© 1999 Andrew K. Stimac
All Rights Reserved.
The author hereby grants permission to MIT to reproduce and distribute publicly paper and electronic copies of this thesis document in whole or in part.

Signature of Author: ............................................................................................................
Department of Mechanical Engineering
May 5, 1999

Certified by: .........................................................................................................................
David L. Trumper
Associate Professor of Mechanical Engineering
Thesis Supervisor

Accepted by: ........................................................................................................................
Ernest G. Cravalho
Chairman, Undergraduate Thesis Committee
Department of Mechanical Engineering

Standup and Stabilization of the Inverted Pendulum by Andrew K. Stimac
Submitted to the Department of Mechanical Engineering on
May 5, 1999, in Partial Fulfillment of the Requirements for the Degree of
Bachelor of Science in Mechanical Engineering.
Abstract
The inverted pendulum is a common, interesting control problem that involves many basic elements of control theory. This thesis investigates the standup routine and stabilization at the inverted position of a pendulum-cart system. The standup routine uses strategic cart movements to add energy to the system. Stabilization at the inverted position is accomplished through linear state feedback. Methods are implemented using the Matlab Simulink environment, with a dSPACE DSP controller board for interaction with the physical system. Algorithms described in this report were successful and consistently produced the desired results. This report serves as a guide to the current working system and as background information on the inverted pendulum.
Thesis Supervisor: David L. Trumper
Title: Associate Professor of Mechanical Engineering

2

Table of Contents
1. Introduction .......................................................................................................
1.1 Purpose .........................................................................................................
1.2 Project Overview .........................................................................................
1.3 Organization .................................................................................................
1.4 Acknowledgements ......................................................................................

Page
6
6
6
7
7

2. Pendulum Cart Modeling and Dynamics ........................................................ 8
2.1 Lagrangian Dynamic Analysis ..................................................................... 8
2.2 Linearization and Transfer Function Generation ......................................... 12
2.3 State Space Representation .......................................................................... 17
3. Apparatus ...........................................................................................................

18

4. Controller Design ...............................................................................................
4.1 Linear Control (Pendulum at Upward Vertical) ..........................................
4.2 Standup Routine ...........................................................................................
4.2.1 Cart Position Control ..........................................................................
4.2.2 Motion Strategy: A Work Analysis ....................................................

22
22
24
24
26

5. Simulink Implementation ..................................................................................
5.1 General Simulink Techniques ......................................................................
5.2 Overview of the Simulink Model ................................................................
5.2.1 Top Level ............................................................................................
5.2.2 Measurements .....................................................................................
5.2.3 Filter Bank ..........................................................................................
5.2.4 Input ....................................................................................................
5.2.5 Linear Controller .................................................................................
5.2.6 Standup Routine ..................................................................................
5.2.7 Controller Select .................................................................................
5.2.8 Error Processor ....................................................................................
5.2.9 Control Effort ......................................................................................

33
33
36
38
40
41
42
43
43
53
54
55

6. Recommendations .............................................................................................. 56
Appendix A: Matlab Scripts and Function Files ................................................ 57
Appendix B: Operating the Pendulum-Cart System ......................................... 60
References ................................................................................................................ 62

3

List of Figures
2.1
2.2
2.3

Page
Schematic of Pendulum Cart ........................................................................ 8
Pole-zero and Bode Diagrams (Pendulum Down) ........................................ 14
Pole-zero and Bode Diagrams (Pendulum Up) ............................................. 16

3.1
3.2
3.3

Pendulum Cart System Block Diagram ........................................................ 18
Schematic of Pendulum Cart System ............................................................ 19
Photographs of Pendulum Cart ..................................................................... 20

4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
4.9
4.10

Resulting LQR Pole Placement .....................................................................
Simulated System Response .........................................................................
Bode Diagrams of Cart System .....................................................................
Lead Controller Design .................................................................................
Experimental Bode Plot of the Cart System .................................................
Coordinate System and Free Body Diagram of Pendulum Cart System ......
Ratio of Work to Acceleration as a Function of Pendulum Angle ...............
Cart Motion Strategy ....................................................................................
Cart Position versus Angle for the Pendulum Swinging to the Right ...........
Pendulum and Cart Motion at Start Angles of 40°, 100°, and 160° .............

23
23
25
25
26
26
28
29
30
31

5.1
5.2
5.3
5.4
5.5
5.6
5.7
5.8
5.9
5.10
5.11
5.12
5.13
5.14
5.15
5.16
5.17
5.18
5.19
5.20
5.21
5.22

Simulink Model Using Enables Subsystems to Choose an Output ..............
Multiport Switch Used to Choose an Output ................................................
Hold Maximum and Hold Minimum Simulink Constructions .....................
Hold Maximum with Reset ...........................................................................
Tree Diagram of Subsystem Hierarchy .........................................................
Top Level Simulink Model ...........................................................................
Measurements Subsystem .............................................................................
Filter Bank Subsystem ..................................................................................
Input Subsystem ............................................................................................
Linear Controller Subsystem ........................................................................
Standup Routine Subsystem .........................................................................
Position Generation Subsystem ....................................................................
Swing Sections ..............................................................................................
Info Subsystem .............................................................................................
Hold Max and Hold Min Subsystems ...........................................................
Amplitude Lookup Subsystem ......................................................................
Routine 1 Subsystem ....................................................................................
Routine 2 Subsystem ....................................................................................
Routine 3 Subsystem ....................................................................................
Controller Select Subsystem .........................................................................
Error Processor Subsystem ...........................................................................
Control Effort Subsystem .............................................................................

33
34
35
35
36
39
40
41
42
43
43
45
45
47
47
48
49
50
52
53
54
55

4

List of Tables
5.1
5.2

Page
Subsystem Hierarchy and Function .............................................................. 37
Amplitude Lookup Tables ............................................................................ 49

5

1. Introduction
1.1 Purpose
This report explores the standup and stabilization of an inverted pendulum. It contains a theoretical analysis of the system dynamics and control methods, as well as a summary of the apparatus and implementation. There are two purposes of this report: to summarize and explain the methods of controlling this specific pendulum-cart system; and to explore and illustrate in general the inverted pendulum problem.
A major focus of this project was the use of Simulink software for control implementation. Simulink provides a block diagram representation of signal processing methods. Allowing for easy visualization, Simulink facilitates the design of complex control algorithms. While code scripts have been used previously for this project,
Simulink provides a more intuitive and organized solution.
1.2 Project Overview
This thesis covers several topics. Primarily, there are two control problems: the standup routine and the stabilization in the inverted position. Also important, however, is the implementation of these control algorithms in the Simulink environment.
The standup routine uses strategic cart movements to gradually add energy to the pendulum. This involves first placing the cart under position control. Then a routine is developed to prescribe the cart’s movement. This movement is such that the cart does work on the pendulum, in a consistent and efficient manner. It is also important to gradually reduce cart movement amplitude so that the standup routine delivers the pendulum to the inverted pendulum position with small angular velocity.
Inverted pendulum stabilization can be accomplished through several methods. This analysis uses state feedback to provide the desired response. Using LQR optimal design tools as a design hangle, the controlled system poles are placed to provide a fast, stable response. Simulink implementation requires the exploration of specific Simulink techniques.
While state feedback control is well suited to the Simulink environment, the standup routine includes some logic that would be more easily represented in a program script.
Adaptation to Simulink requires the generation of several information variables that describe the current system state. These variables are the processed with logical operators in order to determine current actions. The Simulink adaptation is slightly complex. However, the Simulink implementation is superior to a script in many areas because routines have little or no preset order, depending primarily on the present system state. 6

1.3 Organization
The sections of this report cover both the theoretical and experimental aspects of this project. Section 2 contains a theoretical discussion of the system dynamics. This analysis is necessary for system modeling, controller design, and for general background understanding of the pendulum-cart system. Section 3 describes the details of the apparatus, including modeling assumptions and specific parameter values. Section 4 explores the controller design, for both standup and stabilization. Stabilization is covered in Section 4.1, and involves linear state feedback methods. Standup is covered in Section
4.2, which explores the strategic cart motion that delivers energy to the pendulum.
Section 5 documents the specific Simulink implementation. This section seves as a user’s guide to the current functioning system, as well as a tutorial on Simulink methods.
Finally, Section 6 gives Recommendations for further improvements. Appendix A includes the Matlab files used and Appendix B contains simple instructions on how to operate the system.

1.4 Acknowledgments
I would like to voice my appreciation to everyone who helped me on this project. Special thanks to Professor Trumper for suggesting this thesis and for his guidance along the way, to Mike Liebman for his assistance and support in the Mechatronics Lab, and to
Steve Ludwick for sharing his understanding of the current project setup. Finally, many thanks to those who made contributions on this project before me, particularly Steve
Ludwick, Ming-chih Weng, and Pradeep Subrahmanyan, and Professor Will Durfee and his students who originally built the pendulum-cart experiment hardware at MIT.

7

2. Pendulum Cart Modeling and Dynamics
For the purpose of this report, it is necessary to understand the dynamics of the pendulum cart system. In the follow pages, a theoretical analysis is conducted, using the
Lagrangian approach to derive the state equations. The result is linearized around two points of operation, pendulum up and down, and transfer functions are derived and analyzed. This approach provides an in depth theoretical explanation for the dynamics of this system. Throughout this analysis, vector and matrix quantities are distinguished using bold text.
2.1 Lagrangian Dynamic Analysis
A complete theoretical model of the pendulum cart system can be done using Lagrangian
Dynamics. First we choose generalized coordinates, and then derive expressions for the generalized forces, energy functions, and Lagrangian. Finally, we can use Lagrange’s
Equation to derive the equations of motion [3].
A schematic of the system is shown in Figure 2.1. This model and coordinate system will be used in the analysis. For completeness, this derivation involves inertia about the pendulum center of mass, I, though in the case of a point mass this term becomes zero.

x

M

f(t)

l

b
^
j

c

^ i I,m q Figure 2.1: Schematic of Pendulum Cart. Model includes cart mass M, pendulum of mass m and inertia I about its center of mass, which is a distance l from the pendulum pivot. Also included is rotational and translational viscous damping coefficients b and c.

Generalized Coordinate System
The cart pendulum system has two degrees of freedom and can therefore be fully represented using two generalized coordinates. For this analysis, the generalized

8

coordinates are chosen as the horizontal displacement of the cart, x, and the rotational displacement of the pendulum, θ:

ξ j : x, θ

(2.1)

The positive direction of x is to the right and the positive direction of θ is clockwise, measured from the downward position. Positive θ was chosen in the clockwise direction so that x and θ are both measured to the right when the pendulum is in its inverted position. A complete and indepentent set of the associated admissible variations is given by ξ j : δx, δθ

(2.2)

so the system is holonomic.

Generalized Forces
An expression for the generalized forces, Ξj, can be derived from the nonconservative work, given by
N

n

i =1

j =1

δW nc = ∑f nc • δR i = ∑Ξ j δξ j

(2.3)

where Ri is the position vector where the ith nonconservative force acts. The nonconservative forces in this case result from the input force and the system damping,

&
&
δW nc = f (t )δx − cxδx − bθδθ

(2.4)

Comparing Equations 2.3 and 2.4 yields expressions for the generalized forces:

&
Ξ x = f (t ) − cx
&
Ξ = −bθ

(2.5)

θ

Kinetic and Potential Energy Functions
The kinetic coenergy function for the cart mass is simply

1
*
&
TM = Mx2
2

9

(2.6)

For the pendulum, the coenergy function can be derived from

1
1
*
Tm = mv c • v c + Iω2
2
2

(2.7)

where I is the moment of inertial around the pendulum’s center of mass and vc is the velocity of the pendulum’s center of mass. This velocity can be related to the position of the pendulum’s center of mass,

rc = ( x − l sin θ)ˆ − l cosθˆ i j

(2.8)

by

vc =

drc
& i
&j
&
= ( x − l cosθθ)ˆ + l sin θθˆ dt (2.9)

The angular velocity of the pendulum is simply

& ω= θ

(2.10)

Substituting Equations 2.9 and 2.10 into Equation 2.7 yields

1 &
1
*
&
&
&
&
&
Tm = m( x 2 − 2xl cosθθ + l 2 cos2 θθ2 + l 2 sin2 θθ2 ) + Iθ2
2
2

(2.11)

which, upon simplifying, becomes

1 &
1
*
&
&
&
&
Tm = m( x 2 − 2xl cosθθ + l 2 θ2 ) + Iθ2
2
2

(2.12)

The total kinetic coenergy is

1
1
1 &
*
*
&
&
&
&
&
T * = TM + Tm = Mx 2 + m( x 2 − 2xl cosθθ + l 2 θ2 ) + Iθ2
2
2
2

(2.13)

Since the cart moves only in the horizontal direction, the potential energy of the system is determined entirely by the angle of the pendulum, given by

V = −mgl cosθ

10

(2.14)

Lagrangian
From the kinetic coenergy and potential energy functions, the Lagrangian is given by

L = T * −V

(2.15)

Using Equations 2.13 and 2.14, the Lagrangian can be written as

1
1
1 &
&
&
&
&
&
L = Mx 2 + m( x 2 − 2xl cosθθ + l 2 θ2 ) + Iθ2 + mgl cosθ
2
2
2

(2.16)

Lagrange’s Equation
State equations can be generated using Lagrange’s Equation:

d  ∂L  ∂L

−
= Ξj
&
dt  ∂ξ j  ∂ξ j



(2.17)

d  ∂L  ∂L
= Ξx
 −
&
dt  ∂x  ∂x

(2.18)

The equation for x is

Using Equation 2.16 and evaluating the partial derivatives yields

d
&
&
&
&
(Mx + mx − ml cosθθ) − 0 = f (t ) − cx dt (2.19)

&
&
(M + m)&& − ml cosθ&& + ml sin θθ2 = f (t ) − cx x θ

(2.20)

which reduces to

The equation for θ is

d  ∂L  ∂L
 &  − = Ξθ dt  ∂θ  ∂θ

(2.21)

Using Equation 2.16 and evaluating the partial derivatives yields

d
& &
&
&
&
&
(−mlx cosθ + ml 2 θ + Iθ) − (mlx sin θθ − mglsin θ) = −bθ dt 11

(2.22)

which reduces to

&
&
&
&
&
(ml 2 + I )&& − ml&&cosθ + mlx sin θθ − mlx sin θθ − mgl sin θ = −bθ θ x

(2.23)

Simplifying and rearranging, the system state equations are

&
(M + m)&& + cx − ml cosθ&& + ml sin θθ2 = f (t ) x & θ 

− ml&&cosθ + (ml 2 + I )&& + bθ + mglsin θ = 0 x θ &


(2.24)

2.2 Linearization and Transfer Function Generation
Before proceeding with further analysis, we must linearize the state equations. There are two equilibrium points: θ=0 (pendulum down, stable) and θ=π (pendulum up, unstable).
Focusing on small variations of θ about the equilibrium point θo:

θ = θ0 + ε
& & θ=ε (2.25)

From a Taylor Series expansion, a first order approximation of any function of θ is

f (θ) ≈ f (θ0 ) + ε

df dθ θ0

(2.26)

Also, because higher order terms are neglected,

& ε2 ≈ 0

(2.27)

2.2.1 Pendulum Down (θ=0)
For θ=0, Equation 2.26 yields to first order

cosθ ≈ cos(0) + θ[− sin(0)] = 1 sin θ ≈ sin(0) + θ[cos(0)] = θ

(2.28)

Substituting these linearizations into the system state equations (Equation 2.24) and neglecting the higher order term yields

 x & θ (M + m)&& + cx − ml&& = f (t )

− ml&& + (ml 2 + I )&& + bθ + mglθ = 0 x θ &


12

(2.29)

Taking the Laplace Transform
2
2

(M + m)s X (s) + csX (s) − mls Θ(s) = F (s)

− mls2 X (s) + (ml 2 + I )s 2 Θ(s) + bsΘ(s) + mglΘ(s) = 0


(2.30)

Using substitution to eliminate either X(s) or Θ(s) yields two transfer functions:

X (s) a2 s2 + a1s + a0
G1 (s) =
=
F (s) b4s4 + b3s3 + b2 s2 + b1s
Θ(s)
c2 s
G2 (s) =
= 3
F (s) b4s + b3s2 + b2 s + b1

(2.31)

where

a2 = ml 2 + I ≈ ml 2 a1 = b a2 = mgl

b4 = (M + m)(ml 2 + I ) − m2l 2 ≈ Mml2 b3 = (M + m)b + (ml 2 + I )c ≈ (M + m)b + ml 2 c b2 = (M + m)mgl + bc b1 = mglc c2 = ml
The approximations shown in the coefficients above are for I=0, which is the ideal case where the pendulum is constructed from a point mass and massless rod, so that it has no moment of inertia about its center of mass. Using this approximation, the transfer functions reduce to:

X (s) ml 2 s 2 + bs + mgl
=
G1 (s) =
F (s) Mml2 s 4 + [(M + m)b + ml 2 c]s 3 + [(M + m)mgl + bc]s 2 + mglcs
(2.32)
Θ(s) mls =
G2 (s) =
F (s) Mml2 s 3 + [(M + m)b + ml 2 c]s 2 + [(M + m)mgl + bc]s + mglc
The pole-zero plots and bode diagrams for these transfer functions are shown in
Figure 2.2.

13

Cart Position Pole Zero Plot

Pendulum Angle Pole Zero Plot

5
Imag Axis

10

5
Imag Axis

10

0
-5

-5
-10
-15

-10
-5
0
Real Axis
Cart Position Bode Diagrams
0

-100
-200
0
-50
-100
-150
-1

10

0

1

10

10

2

10

Phase (deg); Magnitude (dB)

-10
-15
Phase (deg); Magnitude (dB)

0

-10
-5
0
Real Axis
Pendulum Angle Bode Diagrams
-20
-40
-60
-80
50
0
-50
-100
-150
-1

10

Frequency (rad/sec)

0

10

1

10

2

10

Frequency (rad/sec)

Figure 2.2: Pole-zero plots and Bode diagrams with the system linearized around θ=0
(Pendulum down)

2.2.2 Pendulum Up (θ=π)
For θ=π, Equation 2.26 yields to first order

cosθ ≈ cosπ + (π − θ)(− sin π) = −1 sin θ ≈ sin(π) + (π − θ) cos(π) = π − θ

(2.33)

Analysis is simplified by defining a new coordinate [1]

θ′ = θ − π

(2.34)

This is nothing more than θ measured clockwise from the up pendulum position. Now

sin θ ≈ π − (θ′ + π) = −θ′

14

(2.35)

From here on in the analysis, θ′ will be written as θ, but it should be noted that θ now measures from a new reference. Note also that

& & θ′ = θ and &&′ = && θ θ

(2.36)

so this substitution does not have any other effects on the state equations.
Substituting these linearizations into the system state equations and neglecting the higher order term:

(M + m)&& + cx + ml&& = f (t ) x & θ 

ml&& + (ml 2 + I )&& + bθ − mglθ = 0 θ &
 x

(2.37)

Taking the Laplace Transform

(M + m)s 2 X (s) + csX (s) + mls2 Θ(s) = F (s)

 2
mls X (s) + (ml 2 + I )s 2 Θ(s) + bsΘ(s) − mglΘ(s) = 0


(2.38)

Using substitution to eliminate either X(s) or Θ(s) yields two transfer functions:

G1 (s) =

X (s) a s2 + a s + a
= 4 2 3 1 20
F (s) b4s + b3s + b2 s + b1s

Θ(s) c2 s
G2 (s) =
= 3
F (s) b4s + b3s2 + b2 s + b1

(2.39)

where

a2 = ml 2 + I ≈ ml 2 a1 = b a2 = −mgl

b4 = (M + m)(ml 2 + I ) − m2l 2 ≈ Mml2 b3 = (M + m)b + (ml 2 + I )c ≈ (M + m)b + ml 2 c b2 = −(M + m)mgl + bc b1 = −mglc c2 = −ml
The approximations shown above are for I=0, which is the ideal case where the pendulum is constructed from a point mass and massless rod, so that it has no moment of inertia

15

about its center of mass. Using this approximation, the transfer functions reduce to:

X (s) ml 2 s 2 + bs − mgl
=
G1 (s) =
F (s) (Mml2 s 4 + [(M + m)b + ml 2 c]s 3 + [−(M + m)mgl + bc]s 2 − mglcs
(2.40)
Θ(s)
− mls
=
G2 (s) =
F (s) Mml2 s 3 + [(M + m)b + ml 2 c]s 2 + [−(M + m)mgl + bc]s − mglc
The pole-zero plots and bode diagrams for these transfer functions are shown in
Figure 2.3.

Cart Position Pole Zero Plot

Pendulum Angle Pole Zero Plot

0.5
Imag Axis

1

0.5
Imag Axis

1

0
-0.5

-0.5

-10
0
10
Real Axis
Cart Position Bode Diagrams

-20
-40
-60
-80
-100
-150
-1

10

0

10

1

10

2

10

-1
-20
Phase (deg); Magnitude (dB)

-1
-20
Phase (deg); Magnitude (dB)

0

Frequency (rad/sec)

-10
0
10
Real Axis
Pendulum Angle Bode Diagrams

-60
-80
80
60
40
20
-1

10

0

10

1

10

2

10

Frequency (rad/sec)

Figure 2.3: Pole-zero plots and Bode diagrams with the system linearized around θ=π
(Pendulum up).

16

2.3 State Space Representation
For linear state control of the inverted pendulum, it is necessary to convert the state equations to state space representation in the form

& x = Ax + Bu

(2.41)

For the state vector x a change in variable notation is needed, defined by

 x1   x 
   
&
 x   x x = 2=  x θ
 3  
 x   θ
&
 4  

(2.42)

Referring back to the linearized state equations for Pendulum Up (Equation 2.37), and neglecting I, this change of variables leads to

&
&
(M + m) x2 + cx2 + mlx4 = f (t )

2
&
&
mlx2 + ml x4 + bx4 − mglx3 = 0

(2.43)

From the variable definitions:

& x1 = x2
&
x3 = x4

(2.44)

&
&
Expressions for x2 and x4 can be found by using substitution to eliminate
&
& either x4 or x2 from Equation 2.43. The result, in matrix form, is given by

1
0
0
 x1  0
 x1   0 
  
 x   1/ M  b / Ml
− mg / M d  x2  0 − c / M
 f (t ) (2.45)
 2  + 
 x  = 0
 x3   0 
0
0
1
dt 3
 
  
 x  0 c / Ml (M + m) g / Ml − (M + m)b / Mml2  x  − 1/ Ml

 4  
 4 

17

3. Apparatus
A real pendulum-cart system was used for this thesis project. This system includes the necessary equipment to constrain motion, apply force, measure states, and implement control schemes.
A block diagram of the system is shown in Figure 3.1, with a full schematic in Figure 3.2.
The components involved are a current amplifier, DC motor with gearing, a cart with pendulum, an array of feedback instruments, and a computer with Simulink software for signal processing.

Input

Controller

Current
Amplifier

Motor

Calibration

Pendulum
Cart

Output

Sensors

Simulink

Figure 3.1: Pendulum Cart System Block Diagram.

Current is amplified using an Aerotech 4020 DC Servo Controller in current mode. This amplifier has a gain of 2 A/V, with a bandwidth of 2 kHz. Maximum ratings at 25° C are
40 V, 5 A continuous, and 20 A peak (2 seconds). The amplifier input power required is
100-125 V at 50-60 Hz, which is taken directly from an electrical outlet. For general operation, amplifier dynamics are negligible and the amplifier is modeled as a single gain
Ka=2 A/V.
The driving motor is an Aerotech Permanent Magnet DC Servo Motor, Model 1135
Standard. The motor has a torque constant Kt=0.17 N-m/A, inertia J=3.6×10-4 kg-m2, and viscous damping b=0.007 N-m/krpm. Because this motor is driven by a current amplifier, the back emf, Kb=18.2 V/krpm, need not be considered. Electrical dynamics can also because of the current drive. In any case, the electrical time constant is τe=2.2 ms, which is small compared to the mechanical time constant of τm=16 ms.
Armature resistance, 1.4 Ω, is not important because a current drive is used. The motor torque is connected directly to the cart using a chain drive with a radius of 4 cm.
Including this gearing, the total motor gain can be expressed as Km=4.25 N/A. Motor inertia and damping is lumped with parameters of the pendulum cart. This motor is also equipped with a tachometer with constant Ktach=3 V/krpm, used for cart velocity feedback. 18

Figure 3.2: Schematic of Pendulum-Cart System.

A photograph of the pendulum-cart system is shown in Figure 3.3. Rod mass and inertia about the pendulum center of mass are small and can be neglected. The pendulum is thus approximated as a point mass m=0.15 kg on a massless rod of length l=0.314 m. The pendulum is attached to the cart with a pivot joint that allows full rotational motion with very low viscous friction. The cart is mounted on a horizontal track, which constrains cart motion to one dimension. The track imposes some sliding friction (modeled approximately as viscous damping) and has end stops that limit travel to 0.323 m. Force can be applied to the cart through the chain drive.
For low frequency operation, including the frequencies of interest herein, the cart mass and motor inertia are not independent because the chain and gearing that connects them are relatively rigid. Motor inertia can thus be expressed as an equivalent mass. Using the relations between torque T, force F, angular

19

Figure 3.3: Photographs of the Pendulum Cart with pendulum down (left) and up (right). velocity ω, and velocity v for a wheel of radius R:
&
T = FR = Jω = J
F=
M eq

& v R

J
&
v
R2
J
= 2
R

(3.1)
(3.2)
(3.3)

For the actual values, this equivalent mass is Meq=0.225 kg, which is added to the mass of the cart (1.3 kg) for a total effective mass M=1.525 kg. Higher frequency operation would require more detailed theoretical analysis, but this is well above system crossover and therefore does not warrant consideration.
Cart position and velocity and pendulum angular position are measured directly for feedback. Pendulum angular position (θ) and cart position (x) are measured using two mechanical encoders mounted at the pendulum joint and motor shaft. Both encoders have 4000 counts per revolution. Considering the setup and gearing, this gives a resolution of 63 µm in cart position x and 1.57×10-3 rad or 0.09° in pendulum angle θ.
Cart velocity is measured using the tachometer on the motor shaft. This signal is processed using a voltage follower and a unity gain low pass filter with a bandwidth
2 kHz.
Simulink software, with a dSPACE controller board, is used for signal processing and controller implementation. Signals to and from the hardware are connected using a
DS1102 interface card and processed digitally. Simulink is used to manage and calibrate

20

the array of feedback signals, and to implement both the standup routine and linear controller. The sampling rate as implemented was 2000 Hz, which is high enough to produce negligible phase loss at crossover.

21

4. Controller Design
Control algorithms for this project had two functions: 1) to gradually swing the pendulum to the inverted position and then 2) to balance the pendulum at this unstable equilibrium point. The first requires a routine of precision cart movement that gradually adds energy to the system. The second is solved using state feedback. This section focuses on both the theoretical design and experimental results, as these topics are frequently inseparable in controller design. The specific Simulink implementation is covered later in section 5.

4.1 Linear Control (Pendulum Inverted)
In the inverted position, the pendulum is unstable without control. The transfer function between cart position x and control input contains both a pole and a zero in the right half plane. Because of the proximity of this pole zero pair, it is difficult to obtain a stable response through classical feedback methods.
Instead, stabilization of the pendulum is conducted through full state feedback. Using this method, the system poles can be placed arbitrarily.
For a Linear Time Invariant System
&
x = Ax + Bu

(4.1)

the system poles are given by the eigenvalues of A, defined as the solutions λ to

λI − A = 0

(4.2)

where I is the identity matrix of proper dimension and the symbol ‘| |’ refers to the matrix determinant. An array of negative feedback gains is used, so that the input u is proportional to the given states:

u = −(k 1 x 1 + k 2 x 2 + L + k n x n ) = −Kx

(4.3)

where

K = [k 1

k2 L kn]

(4.4)

For systems with single inputs, u and k1 through kn reduce to scalar quantities, and K is a row vector. Substituting Equation 4.3 into Equation 4.1,
&
x = Ax − BKx = ( A − BK )x

22

(4.5)

Analysis is simplified by defining the controlled state matrix
A c = A − BK

(4.6)

& x = Acx

(4.7)

yielding

Now the system poles are given by the eigenvalues of Ac, defined by

λI − A C = 0

(4.8)

It can be shown for most systems that by choosing the proper gain matrix, the eigenvalues of Ac, which are the controlled system poles, can in theory be placed anywhere. Using this method, a fast, stable response can be accomplished.
Actually performance is limited by the physical hardware, which includes terms such as friction, finite track length, and amplifier saturation. Best results are achieved by optimizing between response speed and control effort. This was accomplished numerically using a linear-quadratic regulator (LQR) method. The Matlab function ‘lqr’ performs this operation, and allows for weighting of both the state errors and the control effort. Figure 4.1 shows the original and controlled pole placement. Figure 4.2 shows a simulated response to an initial error in theta under this control scheme.
System Poles

Initial Condition Results

15

-3

x 10

To: Y2

0

-5

To: Y3

Amplitude

5

To: Y4

-10

To: Y5

Imaginary Axis

10

-15
-20

4
2
0
0.04
0.02
0 x 10-3
10
5
0
-5
0
-0.05
-0.1
To: Y1

Original
Controlled

-15

-10

-5
Real Axis

0

5

10

3
2
1
0
0

0.5

1

1.5

Time (sec.)

Figure 4.1: Resulting LQR Pole Placement.

23

Figure 4.2: Simulated system response for an initial error in θ. From top to bottom,
&
& output shown is x, x , θ, θ , and control effort.

4.2 Standup Routine
The pendulum begins at rest, hanging downward in a stable equilibrium. The standup routine raises the pendulum to the inverted position, where the linear controller can stabilize it. It is important that the standup routine delivers the pendulum to the inverted position in a controlled, predictable fashion and at small angular velocity.
The basic strategy is to move the cart in such a motion that energy is gradually added to the pendulum. This first requires putting the cart under position control. Then a routine is needed to drive the cart’s position.
It is critical that this cart motion is synchronized with the pendulum swing. Precalculated movements and pauses will not suffice, being prone to system disturbances and uncertainty. Instead, a control method is needed which reacts to the current system state, and prescribes cart position accordingly.

4.2.1 Cart Position Control
The control of the cart position is straight forward, and will only be covered briefly.
There exist many position control schemes alternate to what is presented here. However, it is required only that this controller act fast compared to pendulum movement and reject the disturbance forces caused by the pendulum swing. Significant overshoot is undesirable because it causes unpredictability.
For the design of this controller, pendulum motion is ignored. This results in a simple cart model two pole system with mass and damping. A bode plot is shown in Figure 4.3.
It can be seen that even at low frequencies, both poles contribute a significant phase shift.
Higher crossovers can be achieved using a lead compensator with proportional gain.
Bode plots of the suggested controller and the resulting transfer function are shown in
Figure 4.4. The controller shown provides an additional 42° phase margin for a closed loop system crossover at 40 rad/s with 55° total phase margin.
Experimental results differed significantly from the theoretical modeling. An experimental bode plot (Figure 4.5) shows reduced amplitude and further phase degradation. Significant care was taken to ensure that this discrepancy is not a calculation error. Direct measurements of closed loop force vs. displacement show that all gains are accounted for correctly. Instead, the difference must lie in modeling assumptions and parameter values. In practice, it was necessary to significantly increase the proportional gain in order to produce the desired crossover.

24

Bode Diagrams of Cart

Phase (deg); Magnitude (dB)

0
-20
-40
-60

-100
-120
-140
-160
-1

0

10

1

10

2

10

10

Frequency (rad/sec)

Figure 4.3: Bode Diagrams of Cart System.
Controller

Loop Transmission

50

Phase (deg); Magnitude (dB)

Phase (deg); Magnitude (dB)

55

50

45

40
30

0

-50

-100
-120

20

-140

10

-160
0

10

1

10

2

10

3

-1

10

10

Frequency (rad/sec)

0

10

1

10

2

10

Frequency (rad/sec)

Figure 4.4: Lead Controller Designed for Crossover at 40 rad/sec.

25

3

10

Experimental Bode Diagrams

Magnitude (dB)

-40
-50
-60
-70
-80
-90
1
10

2

10
Frequency (rad/sec)

Phase (deg)

-120
-140
-160
-180
-200
1
10

2

10
Frequency (rad/sec)

Figure 4.5: Experimental Bode Plot of the Cart System.

4.2.2 Motion Strategy: A Work Analysis
With the ability to prescribe cart motion, we should now explore how to best add energy to the pendulum. We desire a cart trajectory that raises the pendulum efficiently, consistently, and predictably.

x

^ j ^ i l

Fr m q
F
g

Figure 4.6: Coordinate System and Free Body Diagram of Pendulum Cart System.

26

Using a Newtonian approach, expressions can be derived relating pendulum and cart motion. With the cart under position control, it is natural to think of cart position, velocity, and acceleration all as input parameters which we can prescribe. Figure 4.6 shows again a diagram of the pendulum, with the same coordinates used earlier, and a free body diagram. Using Cartesian coordinates, the motion and forces on the pendulum can be described. Throughout this analysis, bold characters are used to denote vector quantities, while non-bold characters represent scalar quantities. Velocity and acceleration of the pendulum can be found by differentiating position: r = ( x − l sin θ)ˆ − l cos θˆ i j dr & i
&j
& v= = ( x − l cos θθ)ˆ + l sin θθˆ dt dv
&
& a= = ( && + l sin θθ 2 − l cos θ&&)ˆ + (l cos θθ 2 + l sin θ&&ˆ x θi θj dt

(4.9)
(4.10)
(4.11)

Two forces act on the pendulum mass: the force of the rod,
Fr = Fr (sin θˆ + cos θˆ) i j

(4.12)

Fg = − mgˆ j (4.13)

∑ F = ma

(4.14)

and the force of gravity,

Using Newton’s Law,

&
&
Fr sin θˆ + ( Fr cos θ − mg )ˆ = m( && + l sin θθ 2 − l cos θ&&)ˆ + m(l cos θθ 2 + l sin θ&&)ˆ (4.15) i j x θi θ j

This can be rewritten as two equations, one for each direction:

& θ Fr sin θ = m( && + l sin θθ2 − l cos θ&&) x 2
&
θ
F cos θ − mg = m(l cos θθ + l sin θ&&)

(4.16)

r

This can produce several results. Using substitution to eliminating Fr and rearranging, an expression is found that relates the relative movements of the cart and pendulum:
&& − x l&& θ − g tan θ = 0 cos θ

(4.17)

Examining Equation 4.17, several points can be made. Without cart acceleration, this system is a simple pendulum, with gravity causing pendulum rotational acceleration at a magnitude increasing with swing angle. Cart acceleration also causes pendulum rotation,

27

in addition to the effects of gravity. It can be seen that the direction of pendulum rotational acceleration depends on the direction of cart acceleration and whether the pendulum angle is above or below 90°. The effect of a cart acceleration on pendulum rotation is greatest when θ=0° (pendulum down) and at θ=180° (pendulum up).
Alternatively, Equation 4.16 can be solved for Fr, by eliminating && : θ Fr = m(sin θ&& + lθ2 + g cos θ) x &

(4.18)

It is desirable to know how much work is done on the system when the cart is moved a small distance. This is simply the component of the force that is in the direction of movement, times the small displacement,
&
δW = Fr • ∂x = Fr sin θ∂x = m(sin 2 θ&& + l sin θθ2 + g sin θ cos θ)δx x (4.19)

Equation 4.19 shows three terms contributing to the force in the rod, and therefore contributing to the work done: an inertial force, a centripetal force, and a gravitational force. These components have their maximum work contributions at ±90°, ±90°, and
±45°, respectively.
The first term in Equation 4.19 is of great importance, as it describes the work effect of a given acceleration at any angle. Figure 4.6 shows a plot of this term. For θ near ±90°, a given acceleration and displacement will do a lot of work; for θ near 0°, hardly any work is done. If the acceleration and displacement are in the same direction, the work done is positive and energy is added to the system. If the acceleration and displacement are in opposite directions (deceleration), the work done is negative and energy is taken out of the pendulum.
Normalized Work vs. Pendulum Angle
1
0.9

Work per Unit Mass Acceleration

0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
-200

-150

-100

-50
0
50
Pendulum Angle (deg)

100

150

200

Figure 4.7: Ratio of Work to Acceleration as a Function of Pendulum Angle.

28

The strategy is to prescribe a cart trajectory that is driven by θ. Because the cart track is of finite length, the trajectory must contain both acceleration and deceleration. To maximize the positive work done on the pendulum, the trajectory should be such that the cart accelerates when there is high work transfer (θ near ±90°) and decelerates when there is low work transfer (θ near 0°). Figure 4.8 depicts a strategy that provides acceleration and deceleration in the proper regions.

I

I

III

III
II

II

Figure 4.8: Cart Motion Strategy: Accelerate the cart when the pendulum is in region I, decelerate when the pendulum reaches region II, and then wait while the pendulum goes through region III until it changes direction. Deceleration in region III is undesirable because it will do negative work, taking energy out of the pendulum.

Because track length is limited, a cart position is specified instead of acceleration. The position trajectory must be chosen to have appropriate acceleration characteristics, accelerating and decelerating at the correct sections of the pendulum swing. One suitable trajectory is to use half a period of a cosine wave, adjusted to fit a section of the pendulum,  θ x d = A cos
θ
 max

 π 


& for 0 < θ < θ max and θ < 0

(4.20)

where A is the amplitude and θmax is the angle at which motion starts and should be an angle with high positive work transfer. If the pendulum is not yet swinging past 90°, θmax should be the highest point in the swing. Once the pendulum swings out of this region, to θ= 0

c4

ge

c
<
100*pi/180

AND
4

le

high angle

and
<

section
1-4

2
Gain

le1
<
0

Sum

ge1

c1

>
-100*pi/180

AND
1

le2

low angle

c2 and1 1 routine 1-3

z
Unit Delay1

>
100*pi/180
g

OR

<
-100*pi/180

max hold max2
1

le3

100 deg

2 done1 >

or

l

Sum1

-100 deg1

Figure 5.14: Info Subsystem.

The Info Subsystem (Figure 5.14) generates four variables, which are used to calculate and select output trajectories.
The variables theta_max and theta_min are used to remember the highest point of the last swing. These calculations are done in the Hold Max and Hold Min Subsystems
(Figure 5.15), which involve the hold reset mechanism that was discussed in Section 5.1.

46

Hold Max holds the greatest positive value of theta, representing a swing to the left, while Hold Min holds the greatest negative value of theta, representing a swing to the right. Both measurements are reset to zero in between swings, at a time when they are not being used for computation. As Hold Max represents the highest point left, it is reset when the pendulum crosses zero moving left, so each time a new maximum is recorded.
Likewise, Hold Min is reset when the pendulum crosses zero moving right. The reset point is specified by the conditions in the Hit block, which uses a ODE solver to detect crossing of a specific value in a specific direction of the input variable. When output of the Hit block goes high, output is forced to zero through the Not and Product blocks.
NOT
1 theta NOT
1

Hit

Not

theta

Hit

1

max
Product

max

Not
1

min

t_max

Product

min

1

1

z
Unit Delay

z
Unit Delay

Figure 5.15: Hold Max (left) and Hold Min (right) Subsystems

The section 1-4 variable is an integer from 1 to 4 representing the present swing section of the pendulum, as shown earlier in Figure 5.13. Output can be understood from the 4input Sum block. This block adds integers that check a series of logical conditions. The first Sum input insures that Sum output is 1 when none of the conditions are met. The third sum input adds 2 if the pendulum is on the right side (θ

Similar Documents

Free Essay

Nursing and Midwifery Contribution to Public Health

...This essay explains, reflects and analyses a critical incident which occurred on a postnatal ward during my first clinical placement as a student midwife. The incident relates to breastfeeding practices on the ward and is classed as critical because it triggered an instinctual response in me which made me feel it was not right or helpful. My response and feelings at the time were not grounded in theoretical knowledge but rather an instinctual feeling. As a result of this instinctual feeling, the incident was explored. This exploration opened up a flood gate of information regarding what could be learned from this incident and ways to improve practice. What was learnt from this incident will be discussed with the use of relevant literature. Discussion of the following topics will facilitate reflection and evaluation of the critical incident, maternal (breastfeeding) instinct, the use of skin-to-skin contact, using baby slings, co-sleeping, baby-led attachment and use of the hands-off technique (HOT), ways to empower mothers, positive reinforcement, the Baby Friendly Hospital Initiative (BFHI) and ethical, legal and competency aspects of this critical incident. The incident unfolded as follows. Ellen was a twenty-seven year old primipara who had been on the postnatal ward for five days. It was handed over that she was having difficulty breastfeeding due to large breasts and flat nipples and as a result the baby (Harry) wouldn’t attach and was very unsettled. My first contact with...

Words: 421 - Pages: 2

Free Essay

News Writing

...33 CHAPTER Newswriting basics Ready to write a simple news story? This chapter introduces you to the concepts and formulas all reporters have learned to rely upon. IN THIS CHAPTER: 34 Just the facts Be aware of what’s factual — and what’s opinion. 36 The five W’s The essentials: who, what, when, where, why. 38 The inverted pyramid How to write stories so the key facts come first. 40 Writing basic news leads Putting your opening paragraphs to work in the most informative, appealing way. 42 Beyond the basic news lead Not every story needs to start with a summary of basic facts; you have other options. 44 Leads that succeed A roundup of the most popular and dependable categories of leads. 46 After the lead . . . what next? A look at nut grafs, briefs, brites — and ways to outline and organize stories efficiently. 48 Story structure How to give an overall shape to your story, from beginning to middle to end. 50 Rewriting First you write. Then you rethink, revise, revamp and refine until you run out of time. 52 Editing Reporters have a love-hate relationship with editors. But here’s why you need them. 54 Newswriting style Every newsroom adapts its own rules when it comes to punctuation, capitalization, etc. 56 Making deadline When you’re a reporter, you live by the clock. How well will you handle the pressure? 58 66 newswriting tips A collection of rules, guidelines and helpful advice to make your stories more professional. ...

Words: 13302 - Pages: 54