# ME 452 Course Project II

Rotary Inverted Pendulum
(Full Version)

Project Instructor: Xiumin Diao Advisor: Dr. Ou Ma

Department of Mechanical Engineering New Mexico State University July 2006

1. Objectives
Control of an inverted pendulum is one of the most interesting and classical problems for control engineering. The objective of this project is to design a controller which is capable of driving the pendulum from its “hanging-down” position to upright position and then holding it there. The experiment system, as shown in Fig. 1, consists of a vertical pendulum, a horizontal arm, a gear chain, and a servomotor which drives the pendulum through the gear transmission system. The rotating arm is mounted on the output gear of the gear chain. An encoder is attached to the arm shaft to measure the rotating angle of the arm. At the end of the rotating arm there is a hinge instrumented with an encoder. The pendulum is attached to the hinge.

Fig. 1 Rotary inverted pendulum system

On the project, you are asked to do the following: Derive a nonlinear model of the rotary inverted pendulum system. Derive a linearized model of the same system in the neighborhood of the upright position. Verify the linear and non-linear models to see if they are indeed true models of the physical system over a specific operating range. Design, implement, and simulate a stabilizing controller which maintains the pendulum in the upright position with some robustness for small disturbance to the pendulum. Design and implement a mode controller which activates the stabilizing controller when the pendulum is placed in a small neighborhood of the upright position. Design and implement a destabilizing controller which swings up the pendulum to near upright position, so that the stabilizing controller can be activated to stabilize the pendulum.

2. System requirements
To complete this project, the following hardware and software are required: 1) A Quanser UPM 1503 universal power module 2) A Quanser Q4 data acquisition card 3) A Quanser terminal card 3) A Quanser SRV02-ET servomotor and the geared driving unit 4) A Quanser rotary inverted pendulum

2

The xyz frame is fixed to the arm at point A . we assume that θ ≡ θ l where the latter has been used in Project I. the absolute We also know that the pendulum is also moving with the rotating arm at a rate of rθ velocity of the point B on the pendulum can be expressed as & − L cos(α )α & & B = rθ x (2) & & B = − L sin(α )α y 3 . 2. α and θ are employed as the generalized coordinates to describe the inverted pendulum system. For a complete listing of the symbols used in the math formulation. 2 Simplified model of the rotary inverted pendulum system 3. Referring back to Fig. 3. 3. Modeling of the inverted pendulum system The inverted pendulum (mechanical part only) is sketched in Fig. we notice that the velocity of point B on the pendulum relative to that of point A on the arm is & & BA = − L cos(α )α x & & y BA = − L sin(α )α (1) & . In this project. Thus. We assume the pendulum to be a lump mass at point B which is located at the geometric center of the pendulum. B Pendulum α & α L y arm θ A z r x O & θ Fig.5) A PC 6) Quanser’s WinCon 5. 2.1 Using Free Body Diagram method The Free Body Diagram of the inverted pendulum (mechanical part only) system is shown in Fig. we can draw the forces in these two planes only to simplify the drawing. Note that the arm rotates in the horizontal plane (xz plane) only and the pendulum rotates in the vertical plane (xy plane) only. The pendulum is displaced with a given α while the arm rotates an angle of θ .0 software 7) Matlab/Simulink and control system toolbox All of the above-mentioned hardware and software are provided in the Robotics lab (JH608). please refer to Appendix A.

we will get the acceleration of the point B && + L sin(α )α & 2 − L cos(α )α && & &B = rθ x & 2 − L sin(α )α && & &B = − L cos(α )α y (3) Applying Newton’s 2nd Law to the pendulum in x direction. we obtain && = ∑ M B ⇒ J Bα 1 && = Ax L cos(α ) + Ay L sin(α ) m(2 L) 2 α 12 1 && = Ax L cos(α ) + Ay L sin(α ) ⇒ mL2α 3 (6) Applying the Euler’s Equation to the rotational motion of the arm about point O .B. of Arm Ay (b) F. of Pendulum Fig. we obtain & 2 − mL sin(α )α && = Ay − mg &B = ∑ Fy ⇒ −mL cos(α )α m& y & 2 − mL sin(α )α && = Ay ⇒ mg − mL cos(α )α (5) Applying Euler’s Equation to the rotational motion of the pendulum about point B . we are left 4 . we obtain && + mL sin(α )α & 2 − mL cos(α )α && = Ax &B = ∑ Fx ⇒ mrθ m& x (4) Applying Newton’s 2nd Law to the pendulum in y direction.D. we obtain && = ∑ M ⇒ J θ && = T − B θ & J Oθ O eq l eq − Ax r (7) Substituting (4) and (5) into (6).D.B. we are left 1 2 && + mL sin(α )α && = (mrθ & 2 − mL cos(α )α &&) L cos(α ) mL α 3 & 2 − mL sin(α )α &&) L sin(α ) + (mg − mL cos(α )α 1 && + mL2 sin(α ) cos(α )α && = (mLr cos(α )θ & 2 − mL2 cos 2 (α )α &&) ⇒ mL2α 3 & 2 − mL2 sin 2 (α )α &&) + (mgL sin(α ) − mL2 sin(α ) cos(α )α && + 4 mL2α && − mgL sin(α ) = 0 ⇒ −mLr cos(α )θ 3 (8) Substituting (4) into (7).Ax θ A z & θ x Arm B Pendulum y α & α mg Ox Beqθ& Tl O Oz Ax A x (a) F. 3 Free Body Diagram of the rotary inverted pendulum system Differentiating (2) with respect to time.

.2 Using Lagranian Formulation The kinetic energy of the mechanical system arising from the rotating arm and pendulum is T= 1 1 & 2 + 1 m( x &2 &B2 + y & B 2 ) + J Bα J eqθ 2 2 2 1 1 & 2 + 1 m[(rθ & − L cos(α )α & ) 2 + (− L sin(α )α & ) 2 ] + J Bα &2 = J eqθ 2 2 2 1 & 2 + 2 mL2α &α & 2 − mLr cos(α )θ & = ( J eq + mr 2 )θ 2 3 (11) where J B = 1 1 m(2 L) 2 = mL2 is the moment of inertia of the pendulum about its center of mass. we obtain the motion of equation of the system && − mLr cos(α )α & && + mLr sin(α )α & 2 = Tl − Beqθ ( J eq + mr 2 )θ && + 4 mL2α && − mgL sin(α ) = 0 − mLr cos(α )θ 3 (10) 3. the only potential energy in the mechanical system is gravity. i. θ and α . we therefore have two equations according to Lagrangian Formulation d ∂T ∂T ∂V & + = Tl − Beqθ ( )− & dt ∂θ ∂θ ∂θ d ∂T ∂T ∂V + ( )− =0 & dt ∂α ∂α ∂α (13) Substituting (11) and (12) into (13).e. we have known that the output torque of the driving unit on the load shaft is && ) Tl = η g K g (Tm − J mθ m &&) = η g K g (η m K t I m − J m K g θ = η mη g K t K g = & Vm − K m K g θ Rm Vm − 2 && −ηg K g J mθ (14) η mη g K t K g Rm 2 Km & η mη g K t K g 2 && θ −ηg K g J mθ Rm Substituting (14) into (10). we obtain the motion of equation of the system (10) as expected. Taking 12 3 the horizontal plane where the arm lies as the datum plane.&& = T − B θ & && &2 && J eqθ l eq − ( mrθ + mL sin(α )α − mL cos(α )α ) r 2& && = T − B θ & & &2 && ⇒ J eqθ l eq − ( mr θ + mLr sin(α )α − mLr cos(α )α ) (9) && − mLr cos(α )α & && + mLr sin(α )α & 2 = Tl − Beqθ ⇒ ( J eq + mr 2 )θ Combining (8) and (9). we obtain the nonlinear model of the system as follows: && − b cos(α )α & = fV && + b sin(α )α & 2 + eθ aθ m && + cα && − d sin(α ) = 0 − b cos(α )θ (15) where 5 . From Project I. V = mgL cos(α ) (12) Since we have two generalized coordinates.

6 . we want to eliminate Θ( s ) from (20) bfs 2 Α( s) = Vm (s) (ac − b 2 )s 4 + ces 3 − ads 2 − des (21) From the above transfer function. we get the linearized model as follows: Linearizing (15) under the assumption that α ≈ 0 and α & & & && + eθ = fVm aθ − bα (17) & & && − dα = 0 − bθ + cα && .2 a = J eq + mr 2 + η g K g Jm b = mLr c= 4 2 mL 3 d = mgL (16) 2 g e = Beq + f = η mη g K t K K m Rm η mη g K t K g Rm & ≈ 0 . we need to take the Laplace transformation of it. Since we are interested in the angle α . it can be seen that there is a pole and a zero at the origin. Note that this transfer function represents the linearized model only. The transfer function relates the variation from the desired position of the pendulum to the input voltage of the motor. we find the solution from the linearized model as follows: && and θ Solving (17) for the two accelerations α && = θ & + fV − eθ 1 m 2 ac − b dα −b 1 & + cfV ) (bdα − ceθ = m ac − b 2 c & + fV a − eθ 1 1 m & + bfV ) && = = (adα − beθ α m 2 ac − b − b ac − b 2 dα (19) To obtain the transfer function of the linearized system equations (17) analytically. we obtain the solution from the nonlinear model below: && and θ Solving (15) for the two accelerations α & + fV − b cos(α ) & 2 − eθ − b sin(α )α 1 m && = θ 2 2 ac − b cos (α ) d sin(α ) c = && = α = 1 & + cfV ) & 2 + bd sin(α ) cos(α ) − ceθ (−bc sin(α )α m ac − b cos2 (α ) & + fV & 2 − eθ a − b sin(α )α 1 2 m (18) ac − b 2 cos2 (α ) − b cos(α ) d sin(α ) 1 & + bf cos(α )V ) & 2 − be cos(α )θ (ad sin(α ) − b 2 sin(α ) cos(α )α m ac − b 2 cos2 (α ) && . aΘ( s) s 2 − bΑ(s) s 2 + eΘ(s )s = fVm ( s) − bΘ( s)s 2 + cΑ( s)s 2 − dΑ(s) = 0 (20) In the above the initial conditions have been assumed zero. They can be canceled from each other and the resulting transfer function becomes Α( s ) bfs = Vm ( s) (ac − b 2 ) s 3 + ces 2 − ads − de (22) This is our final model of the inverted pendulum system for designing the controller. namely.

α is given an initial condition ( 0. The main Simulink diagram of comparing the linear model with the nonlinear model is shown in Fig. but also establish a threshold for us to know the threshold (on α ) of the linear model. 5 and 6. the linear model correctly depicts the motion of the pendulum for the first 1.4.00001 (rad ) ) and thus the pendulum is allowed to fall. 7. respectively. 4. Verification of the mathematical model 4. 5 Diagram of the nonlinear model 7 . we are going to simulate the dynamics of the system using both the linear and non-linear models and then compare their simulation outputs. As one can see from the simulation results shown in Fig. The nonlinear and linear models are shown in Figs. Fig.4 seconds and then begin to break down.1 Verification of the linear model against the nonlinear model In order to get some sense about how well the linearized model represents the original nonlinear system. The simulation will not only verify the linear model. we saw that the linear model quite accurately described the system for the first 15 degrees and then began to diverge from the actual motion.4 seconds. Zooming in the plots around 1. 4 Main diagram of verifying the linear model Fig.

7 Overlapped plots of the simulation outputs from the linear and nonlinear models 4. we do the experiment near the “hanging-down” position.2 1.4 0.4 0.Fig.8 1 Time (s) 1.8 1 Time (s) 1.2 0.4 1.6 0.2 Verification of both linear and nonlinear models against hardware In order to get some sense about how well the dynamics models represent the real hardware system.2 1. we get the corresponding linearized model Linearizing (23) under the assumption that α ≈ 0 and α 8 . we are going to compare the outputs of both the linear model and the nonlinear model with hardware data. we obtain the nonlinear model of the pendulum system at the “hanging-down” position: && = θ 1 & + cfV ) & 2 + bd sin(α ) cos(α ) − ceθ (bc sin(α )α m ac − b 2 cos2 (α ) 1 & − bf cos(α )V ) && = & 2 + be cos(α )θ α (−ad sin(α ) − b 2 sin(α ) cos(α )α m ac − b 2 cos2 (α ) (23) & ≈ 0 .6 1. 6 Diagram of the linear model 60 40 Linear Nonlinear θ (deg) 20 0 -20 0 0.8 250 200 Linear Nonlinear α (deg) 150 100 50 0 0 0.8 Fig.2 0. To simplify the verification.6 1. Replacing α with α + π in (18).6 0.4 1.

10 and 11. 9.&& = θ 1 & + cfV ) (bdα − ceθ m ac − b 2 1 & − bfV ) && = α (−adα + beθ m ac − b 2 (24) The main Simulink diagram of comparing both the linear and nonlinear models with the data measured from the physical system is shown in Fig. 8. as shown in Figs. 9 Interface to the inverted pendulum system 9 . Fig. 8 Main diagram of verifying both the linear model and the nonlinear model Fig. are created according to (23) and (24) respectively. The interface to the inverted pendulum system is shown in Fig. The linear model and the nonlinear model.

10 . as shown in Fig.Fig. They have almost the same shape. 10 Liner model of the inverted pendulum system Fig. is used as the input voltage of the system. 11 Nonliner model of the inverted pendulum system In the experiment. as shown in Fig. The responses of the physical system have some delay due to the friction in the physical system as explained in project I. From the plots of θ and α . 12. we can see that the responses of the models are similar to these of the physical system. a ramp signal with a slope of 2. 13.

Destabilizing controller The controller of the whole system consists of three parts: destabilizing controller.8 0.2 0.4 0.8 0. stabilizing controller.9 Fig.5 0 0 0.6 Time (s) 0.3 0.7 0.2 0.5 Time (s) 0.4 0.6 0. 12 Input voltage of the experiment 80 Linear model Nonlinear model Physical system 60 θ (deg) 40 20 0 0 0.8 1 1.4 0. 13 Plots of the verifying both the linear model and the nonlinear model with the physical system 5. The destabilizing controller.2 0. Then the stabilizing controller is turned on to stabilize the pendulum in its 11 . oscillates the arm until it has built up enough energy to break the initial stable (hanging-down) state and get the pendulum into an almost upright but unstable state. and mode controller.1 0.3 0.2 Fig.5 Time (s) 0.7 0.1 0.2.5 2 Input Voltage (V) 1. as the name implies.5 1 0.6 0.9 0 Linear model Nonlinear model Physical system -2 α (deg) -4 -6 -8 0 0.

Hence. The mode controller determines when to switch between the destabilizing controller and stabilizing controller.1 Position controller 5. the first thing we need to do is to design a position controller which can swing the arm to achieve the destabilizing goal. It simply makes sense that.512 (rad/s). Thus the natural frequency for small oscillations of the pendulum is given by ωp = mgL = IA 3g = 6.780 where %OS is the maximum overshoot of the response for a step input. by moving the arm back and forth strongly enough.628 (rad/s ) 4L (25) where I A is the mass moment of inertia of the pendulum about point A . we design a PD control law (26) & Vm = K p (θ d − θ ) − K vθ (27) This is a position control loop that controls the voltage applied to the motor so that θ tracks θ d with zero desired velocity. We will discuss the design and implementation of the destabilizing controller in this section.335 (m) and its center of mass is located at its geometric center. The mode controller and the stabilizing controller will be discussed in the next two sections. it can eventually swing up the pendulum. 5. ζ = 0. Therefore the closed-loop response of the arm should be considerably faster than the natural frequency of the pendulum. The closed-loop transfer function of the input and output is η gη m K g K t K p θ = 2 θ d J eq R m s 2 + ( Beq R m + η g η m K m K t K g + η gη m K g K t K v ) s + η g η m K g K t K p (28) Comparing it with the standard transfer function of a second order system (see Section 5-3 of the textbook) we have 2 + η gη m K g K t K v Beq Rm + η gη m K m K t K g J eq Rm = 2ω n ζ (29) η gη m K g K t K p J eq Rm Solving (29). For the arm to track the desired position.upright sate.1.1 Design of the position controller The pendulum in the system has a length of 2 L = 0. Destabilizing controller will essentially drive the position of the arm in order to get away from the stable “hanging-down” position of the pendulum. %OS = 2% or ω n = 26. It would then be reasonable to design a closed-loop controller for the arm position which has the following specifications ω n = 4ω p . Now we need to determine K p and K v according the above defined specifications (26). we obtain =ω 2 n 12 . We want the arm to react to these movements.

3 0. So the position controller meets the required specifications.9 1 Fig. 16 Control signal of the system 13 .512 (rad/s).612 η gη m K g K t With these values of the control grains. Given the required specifications ω n = 26.189 second.2 0. 15 Model of the servomotor and gear transmission system 8 6 Control signal (V) 4 2 0 -2 0 0.Kv = 2 2ω n ζJ eq Rm − Beq Rm − η gη m K m K t K g η gη m K g K t = 0. 14 and the Simulink diagram of the servomotor and gear transmission system is shown in Fig. 17. 14 Main diagram for simulation of the position controller Fig. %OS = 2% .585 (30) 2 ωn J eq Rm Kp = = 19. Fig.1 0. we expect the arm tracks the desired position and velocity with the required specifications.1.8 0. the step response of the closed-loop system is shown in Fig.5 Time (s) 0.4 0. We can see that the response has a maximum overshoot of 2% and the first peak at 0. 5. 15.7 0.6 0.2 Simulation of the position controller The main Simulink diagram of the simulation of the position controller is shown in Fig.

In this example.3 Implementation of the position controller The main Simulink diagram of the implementation of the position controller is shown in Fig. An example step response of the system is shown in Fig.2 0. 15.1.6 0. the desired angular position of the arm is set to 20 degrees.4 0.1 0.5 Time (s) 0. 19.3 0. 17 System response due to a step input 5.9 1 Fig. The model of the servomotor and gear transmission system is shown in Fig.8 0. 21. 19 Interface to the servomotor and gear transmission system 14 . 18 and the interface to the servomotor and gear transmission system is shown in Fig.7 0. Fig. 18 Main diagram for implementation of the position controller Fig.25 Load shaft position (deg) 20 15 10 5 0 System reponse Input command 0 0.

5 4 4. 20 Simulated and real control signals for the position control experiment 25 Load shaft position (deg) 20 15 10 5 0 Input command Simulated position Measured position 0 0.5 5 Fig. This means that we want to command the arm based on the position and velocity of the pendulum.5 Time (s) 3 3. The main Simulink diagram of the destabilizing controller using positive feedback is shown in Fig.25 seconds. by limiting θ d . Then the feedback & θ d = Pα + D α (31) can be made to destabilize the system with the proper choice of the gains P and D ..5 1 1. we choose P = 0. we can see that the pendulum is brought up (the curve passing through the α = 0 line) in about 1.8 6 Control signal (V) 4 2 0 -2 Simulated control signal Measured control signal 0 0.5 (deg/deg) and D = 0. One can tune the value of D to adjust the “damping” in the system. The gains P and D are crucial in bring up the pendulum smoothly. Based on the experiment. the table). we can ensure that the arm does not reach a position that will cause a collision with the nearby hardware (e. Assume the arm position can be commanded via θ d . 15 . 24. Notice that we have a useful application of positive feedback here.2 Destabilizing controller Many schemes can be devised to gradually swing up the pendulum. 21 Simulated and real dynamic responses of the system to a step input 5. In this project we will design a positive feedback controller to destabilize the pendulum and eventually swing up it.5 2 2. Moreover.5 4 4.5 2 2.00001 deg/(deg/s) . From the plot of alpha in Fig.5 1 1.5 5 Fig.5 Time (s) 3 3. The diagram of the rotary inverted pendulum is shown in Fig. 22. 23.g.

5 1 Time (s) Fig.Fig.5 2 2. 22 Main diagram of the Destabilizing controller using positive feedback Fig. 25 Plot of theta during the pendulum swing-up motion under the destabilizing control 1.5 1 Time (s) 1. 24 Plot of alpha during the pendulum swing-up motion under the destabilizing control 30 20 10 θ (deg) 0 -10 -20 -30 0 0.5 2 2.5 16 . 23 Interface to the rotary inverted pendulum system 200 100 α (deg) 0 -100 -200 0 0.5 Fig.

5 Time (s) 3 3..5 4 4. Assuming the pendulum is almost upright. the input voltage of the motor) is then given by (33) u = alpha _ u − theta _ u Based on the experiment.5 5 Mode signal Input signal Fig. Stabilizing controller by feeding back both θ and α If we can feed back both θ and α angles. The PD controller for θ is (32) & theta _ u = theta _ K p (θ d − θ ) + theta _ K d θ where θ d is the desired position of the rotating arm after balancing. two PD controllers can be implemented to maintain it at the upright position (capable of rejecting disturbances up to a certain extent). This controller is to be enabled when α is in the neighborhood of zero.6.5 1 1. The control signal (i. Fig. The PD controller for α is & alpha _ u = alpha _ K p (α d − α ) + alpha _ K d α where α d ≡ 0 . Mode controller The purpose of the mode controller is to track the pendulum angle α and facilitate switching between the destabilizing controller and stabilizing controller. It output 1 when α ≤ 10 degrees and 0 when α > 10 degrees .5 2 2. we choose (34) 17 . The Simulink diagram of the simulation of the mode controller is shown in Fig. From the simulation results shown in Fig. 27 we can see that the mode controller works very well. 27 Plots of the input signal and the mode signal 7. we can calculate the control signal using both of them. 26 Simulink diagram of the mode controller 15 10 5 0 -5 -10 -15 0 0. within the threshold of α (currently set to 10 degrees).e. 26.

Fig. An impulse disturbance with amplitude of 5 degrees and period of 5 seconds is added to the measured alpha in Fig. The stabilizing controller can also maintain the pendulum in the upright position and keep it stable.0.1. the Simulink diagram shown in Fig. 6. The rotary inverted pendulum model is shown in Fig. The same impulse disturbance is added to the measured theta in Fig. 28 Diagram of the simulation of the stabilizing controller 18 . We can see that the stabilizing controller is good enough to maintain the pendulum in the upright position and keep it there stably. (35) To simulate the stabilizing controller.9 One can adjust these four parameters to obtain a better stabilizing controller.2. 30. 29. alpha _ K p = 21. 28 is created. alpha _ K d = 2. theta _ K d = 2.theta _ K p = 2.

and alpha when theta has an impulse disturbance 19 . and alpha when alpha has an impulse disturbance 20 Control signal (V) 0 -20 -40 -60 0 2 4 6 8 10 Time (s) 12 14 16 18 20 50 θ (deg) 0 -50 0 2 4 6 8 10 Time (s) 12 14 16 18 20 10 0 α (deg) -10 -20 -30 0 2 4 6 8 10 Time (s) 12 14 16 18 20 Fig. theta. 29 Plots of control signal.50 Control signal (V) 0 -50 -100 0 2 4 6 8 10 12 14 16 18 20 40 20 θ (deg) 0 -20 -40 0 2 4 6 8 10 12 14 16 18 20 10 0 α (deg) -10 -20 -30 0 2 4 6 8 10 Time (s) 12 14 16 18 20 Fig. 30 Plots of control signal. theta.

Note that the pendulum has some small oscillations (see Fig. Fig. brought upright and maintained in the inverted position. The diagrams of the three sub-controllers. we can see that the pendulum is destabilized in the “hanging-down” position. etc. The implementation of the sevomotor and gear transmission system is shown in Fig. 31. Implementation of the whole system by feeding back both θ and α The main Simulink diagram of the implementation of the rotary inverted pendulum system is shown in Fig. the mode controller and the stabilizing controller are shown in Figs. the friction in the hardware. 35) in the inverted position due to the errors in the mathematical model and the controller. the vibration of the experiment table. namely. 32-34. 23. 33 Diagram of the mode controller 20 . respectively. 32 Diagram of the destabilizing controller Fig. the destabilizing controller. 31 Main diagram of the rotary inverted pendulum system Fig.8. From the experiment.

36 Plot of the theta angle after balancing in the upright position 9.Fig.5 α (deg) 0 -0. Using the SISO Design Tool in the Control System Toolbox. As shown in Fig. we cannot maintain the pendulum in the upright position if we feed back α only. 35 Plot of the alpha angle after balancing in the upright position 4 2 θ (deg) 0 -2 -4 -6 0 1 2 3 4 5 Time (s) 6 7 8 9 10 Fig. 37. In general. Stabilizing controller by feeding back α only The rotary inverted pendulum system has two degrees of freedom. we can design a stabilizing (PID) controller for the system described by the transfer function in (22).5 -1 0 1 2 3 4 5 Time (s) 6 7 8 9 10 Fig. the controller can be C (s) = 2 × ( s + 20)(s + 10) s 2 + 30s + 200 = 2× s s (36) Comparing to the standard PID controller 21 . 34 Diagram of the stabilizing controller 1 0.

38 was created. 37 Design of the PID controller using SISO Design Tool 22 . K p = 30. 6. K i = 200. but the rotating arm will rotate crazily if we feed back α only. Fig. From the simulation results shown in Figs. The rotary inverted pendulum model is shown in Fig. K d = 1 (38) To simulate the stabilizing controller by feeding back α only. we can see that the pendulum can reject a pulse disturbance.C (s) = K c × Kd s2 + K p s + Ki s (37) we get K c = 2. the main Simulink diagram shown in Fig. 39 and 40.

39 Plot of alpha when there is a pulse disturbance in alpha 200 Feedback α only 150 Feedback α and θ θ (deg) 100 50 0 -50 0 1 2 3 4 5 Time (s) 6 7 8 9 10 Fig. 38 Simulink diagram for simulating the stabilizing controller 5 0 α (deg) -5 Feedback α only Feedback α and θ -10 0 1 2 3 4 5 Time (s) 6 7 8 9 10 Fig.Fig. 40 Plot of theta when there is a pulse disturbance in alpha 23 .

215 2.00767 0.81 ----0.0035842 --3.Appendix A: Nomenclature of the System Symbol Description X component of the action force exerted on the pendulum at point A by the arm Y component of the action force exerted on the pendulum at point A by the arm Pendulum position Pendulum velocity Pendulum acceleration Equivalent viscous damping coefficient Gravity acceleration Current in the armature circuit Moment of inertia of the pendulum about its center of mass Moment of inertia of the arm and pendulum about the axis of θ Moment of inertia of the arm and pendulum about the axis of θ l Moment of inertia of the rotor of the motor SRV02 system gear ratio (motor -> load) Back-emf constant Motor-torque constant Half length of the pendlum Armature inductance Mass of pendulum X component of the action force exerted on the arm at point MATLAB Variable ----------Beq g ----Jeq --Jm Kg Km Kt L --m ----r Rm --------------Nominal Value (SI Units) ----------0.1675 --0.125 ----0.004 9.00767 0.87e-7 70 ( 14 × 5 ) 0.6 --------------- Ax Ay α & α && α Beq g Im JB J eq Jl Jm Kg Km Kt L Lm m Ox Oz r Rm Tl Tm O by the base of the motor Z component of the action force exerted on the arm at point O by the base of the motor Rotating arm length Armature resistance Torque applied to the load Torque generated by the motor Load shaft position Load shaft velocity Load shaft acceleration Angular position of the arm Load shaft velocity θ θ& && θ θl & θ l 24 .

&& θ l Load shaft acceleration Motor shaft position Motor shaft velocity Motor shaft acceleration Motor back-emf voltage Input voltage of the armature circuit X component of the velocity of point B on the pendulum relative to point A on the arm Y component of the velocity of point B on the pendulum relative to point A on the arm Velocity of pendulum center of mass in X direction Velocity of pendulum center of mass in Y direction Acceleration of pendulum center of mass in X direction Acceleration of pendulum center of mass in Y direction Gearbox efficiency Motor efficiency ------------------------Eff_G Eff_M ------------------------0.9 0.69 θm & θ m && θ m V emf Vm & BA x & BA y &B x &B y & &B x & &B y ηg ηm 25 .