ee128Fa08-Lab2-SOLUT..

advertisement
EE128 Fall 2008
University of California, Berkeley
Lab 2 SOLUTIONS
Rev. 1.00
CONFIDENTIAL
Lab 2: Introduction to MATLAB Real Time Workshop and Inverted
Pendulum Dynamics
SOLUTIONS
I. Prelab SOLUTIONS
1. Inverted Pendulum Dynamics
Figure 1. Inverted Pendulum Free Body Diagram
Step 1. Applying Newton’s law to the cart:
mc x   F
 Fa  N
(0)
Step 2. Equations of motion for the pendulum using the pendulum free body diagram.
Horizontal:
mp x  N
d2
 x  Lp sin( )   N
dt 2
d
 mp
x  L p cos( )  N
dt
 mp




m p x  L p sin( )( ) 2  L p cos( )  N
(1)
EE128 Fall 2008
University of California, Berkeley
Lab 2 SOLUTIONS
Rev. 1.00
CONFIDENTIAL
Vertical:
mp y  P  mp g
d2
 Lp cos( )   P
dt 2
d
 mp g  mp
 sin( )  P
dt
 mp g  mp




m p g  m p  sin( )  cos( )( ) 2  P
(2)
Step 3: Moment of inertia computations: For this part, it will be helpful to do a moment
diagram so you can clearly see the torques acting on the pendulum. The moment diagram
is shown in figure 2.
Figure 2. Moment diagram for the pendulum
Based on figure 2, we can see that using the right-hand rule, torque N causes a clockwise
rotation of the pendulum about the pivot and hence this torque is negative. Torque P
causes a counter-clockwise rotation about the pivot and hence this torque is positive.
I  PLP sin( )  NLP cos( )
(3)
Step 4: Substituting equation (1) in equation (0) and simplifying, we get:
Fa = (mc+mp)x''+mpLpcos(θ)θ''-mpLpsin(θ)(θ')2
(4)
This is equation (1) in the lab guide.
Substituting equations (1) and (2) in equation (3), we get:
Iθ''=mpgLpsin(θ)-mpx''Lpcos(θ)-mpLp2 θ''
This is equation (2) in the lab guide.
(5)
EE128 Fall 2008
University of California, Berkeley
Lab 2 SOLUTIONS
Rev. 1.00
CONFIDENTIAL
2. Linearization of Inverted Pendulum Dynamics
The states of the system are defined as x  [ x; x; ; ] . The mathematical procedure for
linearizing a system about an equilibrium point is called Jacobi Linearization.
However, for this simple system, we can simply use the following approximations (the
Jacobi Linearization will simplify to these approximations):
sin( )  
cos( )  1
 
Ignore nonlinear term: 
2
Notice that since we defined the pendulum angle as being from the vertical (instead of the

horizontal), we avoided an offset of .
2
Using the approximations above and ignoring the moment of inertia, equations (4) and
(5) above simplify to:
Fa = (mc+mp)x''+mpLpθ''
0 = mpgLpθ-mpx''Lp-mpLp2 θ''
(6)
(7)
Notice that (7) can be further simplified to:
0 = gθ-x''-Lp θ''
(8)
Using the definition of the state vector and the given information that the outputs are the
cart position (x) and pendulum angle (θ), we get the following state space representation
of the system:
0

 x 
  0
x
x  
   0
  
  
0

1
0
0
0
0
 0 

m p
 x   1 

g
0  
 x  mc 
mc
  
 Fa
0
1    0 
     1 
(mc  m p )
g 0


mc LP

 mc LP 
0
 x
 
1 0 0 0   x 
y
 0.Fa

0 0 1 0    
 
 
Notice that the system is a “SIMO” (Single Input, Multiple-Output) system.
EE128 Fall 2008
University of California, Berkeley
Lab 2 SOLUTIONS
Rev. 1.00
CONFIDENTIAL
3. Motor Dynamics
Using the directions given in the lab guide, simple algebra gives the following
relationship between the motor voltage and the applied force:
Fa 
Km K g
K
V
m
Kg 
2
x
Rm  r
Rm  r 2
Substituting Fa in your state space description and simplifying gives you the model of
your plant:
0

 x 
  0
x
x  
   0
  
  
0

1

(Km K g )
0
0





m p
 x   1 Km K g 

g
0  
 x  m R r 
mc
   c m
V
0
1   
0

  


K
K
(mc  m p )
   1 m g 
g 0

mc LP
 mc LP Rm  r 
0
2
mc  Rm  r 2
0
( K m K g )2
mc  Lp  Rm  r 2
 x
2
 
K K
Km K g 

1 0 0 0   x 
m
g
y
 0. 
V

 Rm  r
Rm  r 2
0 0 1 0    

 
 
II. Lab SOLUTIONS

x


1, 2 and 3. Inverted Pendulum Dynamics
Here are the parameters for the inverted pendulum system [2] for use by the students
while designing the controller.
Parameter
Back EMF
Motor coil resistance
Gearbox ratio
Motor pinion diameter
Cart mass
Pendulum mass
Pendulum half length
Symbol
Km
Rm
Kg
r
mc
mp
Lp
Value
0.00767
2.6
3.7
0.00635
0.815
0.210
0.305
Units
V/rad.sec-1
Ω
None
m
Kg
Kg
m
Some other useful parameters are the motor pinion teeth # = 24, Rack pitch = 6.01
teeth/cm, Cart encoder teeth # = 56, Cart encoder resolution = 512*4 count/revolutions,
Cart encoder calibration constant = 0.00454 cm/count, pendulum angle encoder
resolution = 1024*4 count/rev and pendulum angle calibration constant = 0.08789
deg/count
EE128 Fall 2008
University of California, Berkeley
Lab 2 SOLUTIONS
Rev. 1.00
CONFIDENTIAL
4. Demonstration of Quanser System
Demonstrate the simple sinusoidal motion of the cart by using the demo Simulink
program in the ee128Fa08 folder on the desktop (ee128Fa08\motorSine). The model can
be opened in simulink.
The important settings that you need to be aware of in Simulink are:
1. Under Simulation→Parameters→Real-Time Workshop, make sure the “System
Target File” is set to: wincon.tlc –aAllSignals=1 –aAllParameters=0 (section 4.2
in [3]).
2. Under Simulation→Parameters→Real-Time Workshop, make sure the “Template
Makefile” is set to: wc95_msvc.tmf (section 4.2 in [3]).
3. Under Simulation→Parameters→Real-Time Workshop, make sure the “Make
Command” is: make_wc (section 4.2 in [3]).
4. Under Tools→External Mode Control Panel→Target Interface, make sure the
“MEX file for external interface” is set to: wc_comm (section 4.3 in [3]).
III. Revision History
Semester
Summer 2008
Author(s)
Bharathwaj Muthuswamy
Comments
1. Typed up solutions
IV. References
1. Franklin, Gene F., Powell, David J. and Emami-Naeini Abbas. Feedback Control
of Dynamic Systems. 5th Edition. 2006, Prentice-Hall Inc.
2. Quanser Consulting Inc. Self Erecting IP User’s Manual, 1996.
3. Quanser Consulting Inc. WinCon 3.0.02a User's Manual, 1996
Download