2013
Digital Pendulum Control Experiments
Ahmed Zia Sheikh 2010030
M. Salman Khalid 2010235
Suleman Belal Kazi 2010341
EE-341L CONTROL SYSTEMS LAB
1
TABLE OF CONTENTS
ABSTRACT ..........................................................................................................................................2
PENDULUM OVERVIEW ......................................................................................................................3
EXERCISE 1 – NONLINEAR MODEL .......................................................................................................3
EXERCISE 2 – LINEAR MODEL ..............................................................................................................5
EXERCISE 3 – STATIC FRICTION COEFFICIENTS......................................................................................6
EXERCISE 4 – CART MODEL IDENTIFICATION .......................................................................................7
EXERCISE 5 – CRANE LINEAR MODEL IDENTIFICATION .........................................................................9
EXERCISE 6 – INVERTED PENDULUM LINEAR MODEL IDENTIFICATION ............................................... 12
EXERCISE 7 – PID CONTROL OF CART MODEL POSITION (SIMULATED) ................................................ 12
EXERCISE 8 – PID CONTROL OF CART MODEL POSITION (REALTIME) .................................................. 15
EXERCISE 9 – MODEL SWING UP CONTROL (SIMULATION): ................................................................ 16
EXERCISE 10 –SWING UP CONTROL (REAL-TIME): .............................................................................. 16
EXERCISE 11 – PENDULUM STABILIZATION USING THE NONLINEAR MODEL (SIMULATION) ................ 17
EXERCISE 12 – PENDULUM REAL TIME STABILIZATION ...................................................................... 17
EXERCISE 13 – CRANE CONTROL ....................................................................................................... 18
EXERCISE 14 – SWING UP AND HOLD CONTROL ................................................................................. 20
EXERCISE 15 – UP AND DOWN .......................................................................................................... 23
2
ABSTRACT
The Digital Pendulum is a modern version of a classical control problem; that of erecting and balancing a
free swinging pendulum in its inverted position or moving a hanging pendulum in a controlled manner.
The cart on the track is digitally controlled to swing up and to balance the pendulum into an upright
sustained position or to move the cart with pendulum in an unperturbed down position. The cart track is
of limited length, imposing constraints on the control algorithm.
In pendulum mode the system is used to control the twin arm pendulum from an initial position,
hanging at rest with the cart in the center of its travel along the track, to a final position with the
pendulum upright and the cart restored to its central position. In crane mode the control problem is to
move the position of the cart without undue movement of the pendulum. This problem is typical of that
experienced when controlling a gantry crane.
.
3
PENDULUM OVERVIEW
Exercise 1 – Nonlinear model
In this experiment, the pendulum is modeled in Simulink using it’s equations of motions and then
simulated to see the output.
Equations of the pendulum (Non-Linear) from Instruction manual:
In the simulation no voltage is given to the motor, and only an initial angle is set, below are the results
Figure 1 Results for an initial angle of zero (Inverted Pendulum)
4
The pendulum parameters in the simulation were adjustable; all of the graphs were obtained using the
approximate values specified in the datasheet as shown below
Figure 2 Initial Angle of 0.01 (Very slight disturbance from vertical)
Figure 3 Pendulum Simulation Parameters
5
Exercise 2 – Linear model
For small values of theta, the equations of motion in Exercise 1 take on the form:
In this experiment, the pendulum is modelled using non-linear equations for both theta=0 and theta=pi
i.e. Inverted and hanging respectively. Results for both are shown below:
As can be seen the linear model applies very well to small oscillations about the theta=pi position.
The next graph shows the linear model for a small disturbance for theta=0
Figure 4 Linear Model for initial angle =π (Crane Mode)
6
In this case the linear model fails as the system is unstable and a small disturbance causes a large change
in theta thus making our assumptions void.
Exercise 3 – Static Friction Coefficients
Figure 5 Linear Model for inverted Pendulum theta=0
Figure 6 Static Friction Offsets
7
Because of the static friction forces (also called stiction); with very small values of control signal the cart
will not move. Furthermore the static friction force may not be symmetrical. We can compensate for
that simply by adding an additional voltage offset value to the cart control signal. Measurement of the
value of the offset is the purpose of this exercise.
RESULTS: Static friction in: Positive Direction: 0.2 Negative direction: -0.4757 PROBLEMS: Several problems were faced in this experiment, according to the manual the values of the friction in both directions should have been almost the same however even after numerous attempts and readjustments of the pendulum our values differed by almost 100%, moreover upon further experimentation it was found that the pendulum was behaving erratically using these values, so the values used in all subsequent experiments were: Positive Direction: 0.1 Negative directions: 0.4
Exercise 4 – Cart model identification
In this experiment we identify the linear model between the control signal u and the cart position x
Figure 7 Experiment To Identify Cart Model
8
After using the real-time model to get the required data, Matlab identification interface was used to
get the transfer function of the cart.
Figure 8
Figure 9
9
The pendulum had to be immobilized or else the cart would veer off to one direction due to excess
swing.
Finally, the transfer function for the cart, generated using Matlab was:
Exercise 5 – Crane linear model identification
“Crane” refers to the pendulum in the stable position (theta=pi), in this experiment a transfer function
for the crane mode is found.
The excitation signal is applied for the first 10 seconds then the pendulum is allowed to swing freely for
80 seconds to identify the damping effect.
Figure 10
10
The transfer function derived in Matlab for the crane mode:
Figure 11 Crane Identification experiment
Figure 12 Measured Vs. Estimated Response
11
Figure 13 Peak Shows Natural Frequency
Figure 14 Pole Zero Plot: Poles slightly to right of jw axis show error
12
Exercise 6 – Inverted pendulum linear model identification
In the case of this experiment, a vital file “Mextract.m” which was required for extracting the transfer
function of the inverted pendulum was missing; we tried to use a file of the same name from the Maglev
experiment but failed.
We emailed Feedback systems about this omission, they have not replied till the publishing of this
report.
Since we could not develop a model for the inverted pendulum, due to which some of the further
experiments of the inverted pendulum control were performed using the pre-specified model.
Exercise 7 – PID control of cart model position (SIMULATED)
Using the cart model identified in previous experiments, a PID controller was designed for controlling
the cart position. Various values of PID were tested for different experiments.
Figure 15 Response of inverted Pendulum
13
Figure 17 Root Locus Of the Cart System after adjustment
Figure 16 Unmodified Root Locus
14
Figure 16 Simulated Step Response of the adjusted system
P=27.84 I=36 D= 4.5
Figure 17 Response of the PID Compensated system
15
Exercise 8 – PID control of cart model position (REALTIME)
Figure 18 Real Time Results with P=10 I=25 D=2
Figure 19 Real Time Results with P=27.84 I=36 D=4.5
16
Exercise 9 – Model swing up control (SIMULATION):
Exercise 10 –Swing up control (REAL-TIME):
Figure 20 Simulation of Model Swing up control with default parameters
Figure 21 Real Time Swing up Control
17
Exercise 11 – Pendulum stabilization using the nonlinear model (SIMULATION)
Exercise 12 – Pendulum real time stabilization
Figure 22 Pendulum Stabilization (Simulation) Assuming pendulum is at 0 degrees whilst starting
Figure 23 Real Time Pendulum Stabilization
18
Exercise 13 – Crane control
SIMULATION:
Figure 24 Desired Angle is pi (perfectly still pendulum)
19
Figure 25 Simulation for another control Signal
REAL-TIME:
Figure 26 Default Settings: Sine wave 0.1 Hz, 0.2v Amplitude
20
Exercise 14 – Swing up and hold control
Figure 27 Sawtooth 0.2Hz 0.4v Amplitude
Figure 28 Square 0.1Hz, 0.2 Amplitude
21
Figure 29 Simulation Results
Figure 30 Real Time Trial 1 (FAILURE) Cart hits end of track
22
In the real time trials it was observed that as the initial voltage of the square wave which slowly
increases the pendulum’s oscillations is increased two things occur:
1. The pendulum reaches the top point more quickly.
2. The pendulum becomes less stable at the top inverted position, and in extreme cases fails to
balance
Figure 32 First Success Swing up and Hold in Real Time
Figure 31 Swing up and hold with decreased initial voltage, extremely stable
23
Exercise 15 – Up and down
This is the final experiment in the study of the inverted pendulum and involves a combination or
culmination of all previous experiments into one. First the pendulum is started from a rest position and
made to balance in the inverted position after which it is allowed to fall down into the crane mode and
settled as quickly as possible.
Figure 33 Graph of Final Experiment