You are on page 1of 8

Pendulum Cart Position Control UKM

Pendulum Cart Position Control

1. Objectives
1. To investigate the function and the relationship of Proportional-Integral-Derivative (PID)
controller gains to the output response of a closed loop system.
2. To tune the gains of the PID controller to minimize rise-time, overshoot, settling time and

2. Introduction
Figure 1 illustrates the closed-loop of the pendulum cart position control system. The position
error is obtained by comparing a reference (desired position) with the output position. The
error is fed to the PID block which acts as compensator to produce the control signal to adjust
the position of the cart (the plant); the looping process minimizes the error up to a steady
state point where the cart reaches and maintains the desired position.

Figure 1: Cart Position Closed-Loop Control System

The control signal produced by the PID has the following equation:

By inputting a static desired position; say 0.1m to the right of the centre of the cart railing,
one are effectively inputting step input of 0.1 of amplitude to the close loop system. Figure 2
illustrate a typical response of the closed loop system to a step input. There are four
parameters to be measured (refer to Figure 2 on how to measure the parameters):

1. Rise-time : Time taken from 10% to 90% of the final position (0.1 to 0.9

).
2. Overshoot:

Z6-1
Pendulum Cart Position Control UKM

3. Settling-time : the time taken for the response to reach within 2% of the final value

(1.02 or 0.98 ).

4. Steady state error: absolute error between the desired position and the output position

Figure 2: Step Response of 2nd order PID close-loop controller (Source: )

The following Table 1 summarizes the typical effect of each of the PID controller gain on the
closed loop system:

Derivative, Kd Small Change Decrease Decrease No Change

There are several methods to tune the gains of the PID controller, the common methods
includes the Ziegler-Nichols and the Tyreus-Luyben method; both are a systematic trial and

Z6-2
Pendulum Cart Position Control UKM

error method which are particularly useful in situation where the transfer function of the plant
is unknown. The Tyrues-Luyben method could be implemented as following:

1. Set both Ki and Kd to zero, only turn on Kp the proportional gain.

2. Increase the proportional gain Kp in step increments and observe the response.
3. When a value Kp result in sustained periodic oscillation, record the value and label
this Kp value as the ultimate gain Ku.
4. Measure the period of the sustained oscillation Pu.
5. Calculate the Tyreus-Luyben PID gains as the following:

3. Pre-Laboratory
1. What is a closed loop system? Describe the concept of PID controller.
2. Describe the effect of each of the gains of PID controller (Kp,Ki,Kd) to the step
output response.
3. In Tyreus-Luyben tuning method, what does sustained periodic oscillation imply?

4. Experiment
A. Experiment 1 : PID Controller Gains

1. Objective

The objective of this part of experiment is to investigate the relationship of each of the PID
controller gains to the output characteristic of the controller. As such, each of the gains
(namely proportional gain Kp, derivative Kd, integral Ki) shall be varied linearly and the
effect on the output response are to be observed and measured. By the end of this experiment
one should be able to explain the function of each of the gains of the PID controller.

2. Experiment Description

The experiment will employ the use of a closed loop pendulum cart system which is based on
a PID controller. The position of the cart on the rail is controlled based on the reference set by
the end user. In this experiment, the reference position of the cart shall be set to a square
wave; which mimics an alternating step input to the controller. In short, this experiment shall
investigate the response of the control loop system to a step input under varying gains of the
PID.

3. Equipment

Z6-3
Pendulum Cart Position Control UKM

1 x Pendulum Cart System

1 x Computer with MATLAB 7.0

4. Procedure

Important Notes:

IN CASE OF EMERGENCY HIT THE RED EMERGENCY BUTTON TO STOP

OPERATION. DO NOT HESITATE TO HIT THE BUTTON IF THE SYSTEM GOES
OUT OF CONTROL

The pendulum cart system should be calibrated before commencing the experiment. A
calibrated system should have an opened MATLAB window along with the workspace.
Check with the technician/demonstrator if the system has not been calibrated. Ensure that the
pendulum is removed from the cart prior to experiment; the controller compensator does not
include the effect of the pendulum swing to the position error of the cart.

1. Turn ON the system by pressing the RED button on the systems interface box. An
illuminated Red LED indicates that it is ready for operation.

2. Open the model file KL3162. File > Open > work (directory) > KL3162 (mdl file). The
file contains the model of the controller designed specifically for this experiment.

3. Minimize the Monitor window and maximize the KL3162 Simulink window, one should
be able to see the following:

Figure 3: Cart PID Position Closed Loop Controller

4. Explain based on block diagrams in Figure 3 the operation of the controller; identify the
desired input, the compensator, the plant and the output.

Z6-4
Pendulum Cart Position Control UKM

5. Set the reference position of the cart to 10cm and -10cm. This could be done by double
clicking the Generator block, and setting the parameters as square function with
amplitude 0.1 and frequency of 0.025 Hz.

Note: negative value corresponds to positions left of the centre and positive corresponds
to right of the centre. These settings will oscillate the cart position between 10cm to
-10cm at 0.025 Hz of frequency.

6. Set the cart position PID controller as Kp = -0.1, Ki = Kd = 0. This is done by double
clicking the Controller PID block and type in the gains value in Cart PID Parameters box.
For example, to set Kp = -0.1, Ki = Kd = 0, one has to type in [-0.1 0 0].

WARNING: DO NOT SET POSITIVE GAIN VALUE

7. Press the Connect To Target button and to start the real-time code. Double click
on the Monitor block to observe the response of the system in relation to the reference.

Note: One should notice the cart position would alternately change from 10cm to -10cm.
The position of the cart is set by the reference in the generator block; the positions could
be adjusted by varying the value of the reference.

8. Adjust the value of Kp from -0 to -2.0 while keeping the integral and derivative gain
constant at Ki = Kd = 0. Measure the characteristics of the controller as in Table 2. One
might need to stop the real-time code and use the zoom tools to take measurements.

Proportional Rise-time Overshoot Settling Time

Gain (seconds) (%) (seconds)
Kp
-0
-0.6
-1.2
-2.0
WARNING: DO NOT SET POSITIVE GAIN VALUE

9. Explain based on the data in Table 2 the relationship of rise-time, overshoot, settling time
and steady state error as proportional gain Kp increases.

10. Adjust the value of Kd from -0.1 to -0.3 while keeping the proportional and integral gain
constant at Ki = 0, Kp = -2.0. Obtain the following characteristics of the controller as in
Table 3:
Table 3: Increasing Derivative Gain Response

Derivative Rise-time Overshoot Settling Time

Gain (seconds) (%) (seconds)
Kd
-0.1
-0.2

Z6-5
Pendulum Cart Position Control UKM

-0.3
WARNING: DO NOT SET POSITIVE GAIN VALUE

11. Explain based on the data in Table 3 the relationship of rise-time, overshoot, settling time
and steady state error as derivative gain Kd increases. Compare the data of Table 3 (both
Kp and Kd) to Table 2 (only Kp)

12. Adjust the value of integral gain Ki from -0.26 to -0.8 while keeping the proportional and
derivative gain constant at Kd = -0.3, Kp = -2.0. Obtain the following characteristics of
the controller as in Table 4:

Integral Gain Rise-time Overshoot Settling Time

Kd (seconds) (%) (seconds)
-0.26
-0.53
-0.80
WARNING: DO NOT SET POSITIVE GAIN VALUE

13. Explain based on the data in Table 4 the relationship of rise-time, overshoot, settling time
and steady state error as integral gain Ki increases. Compare the data of Table 4 (with Kp,
Ki, Kd) to Table 3 (only Kp and Kd) and Table 2 (only Kp).

14. Compare the findings of Tables 2, 3 and 4 with Table 1. Do the relationships agree with
each other? If not comment on the differences.

B. Experiment 2 : Tuning the PID Controller

1. Objective

The objective of this part of the experiment is to tune the PID controller so that the following
specifications are obtained:

Table 5: Response Specification

Responses Specification

Steady State Error Less than 0.5%

Z6-6
Pendulum Cart Position Control UKM

2. Experiment Description

Ideally, it is desirable that output response would have instantaneous (or zero) rise-time, zero
overshoot, zero settling time and zero error. In easier words; an ideal condition would mean
that if one is to put in a step input to the closed loop system, one would obtain a perfect step
output. In the first experiment (Section 4A) the function and the relationship of each of the
gains of the PID controller to the output response have been investigated, therefore it should
now be possible to design a PID controller that produces output that is as close as the ideal
condition described earlier; output that has the least rise time, least overshoot, least settling
time and the least steady state error.

3. Equipment

1 x Pendulum Cart System

1 x Computer with MATLAB 7.0

4. Procedure

1. Maintain the reference setting parameters as square function with amplitude 0.1 and
frequency of 0.025 Hz.

2. Either by trial-and-error OR by the Tyreus-Luyben Method described in Section 2, tune

the PID controller (find the combination of Kp, Kd, Ki) to produce responses that meets
the specification described in Table 5.

3. Print-screen the output response of the tuned PID controller to show the rise-time,
overshoot, settling time and steady state error.

4. State the combinations of gain used.

5. State the rise-time, overshoot, settling time and the steady state error of the tuned PID
controller.

6. Described the method or process used to achieve the tuned PID controller.

WARNINGS:

INITIALLY IT IS LIKELY TO GET WRONG GAIN COMBINATION WHICH MIGHT

CAUSE THE SYSTEM TO GO OUT OF CONTROL. SHOULD THIS HAPPEN HIT THE
EMERGENCY BUTTON TO STOP OPERATION

5. References
 N. Nise, Control Systems Engineering, International Student Version, John Wiley &
Sons, 2008.

Z6-7
Pendulum Cart Position Control UKM

 Control Tutorial for Matlab and Simulink, Introduction PID Controller Design,
retrieved 9 February 2014 from: http://ctms.engin.umich.edu/CTMS/index.php?
example=Introduction&section=ControlPID

Z6-8