Professional Documents
Culture Documents
Keywords: PID, controller, simulation, LabVIEW, appropriate model should describe the behaviour of the
Matlab/Simulink, dSpace, crane, inverted pendulum system within a specified accuracy. There are many models
available to simulate the system behaviour. The best
Abstract approximation is the simplest model that meets the demands.
In addition, especially in case of modelling known systems,
This paper describes the steps from data acquisition, the model parameters should represent meaningful
simulation of the system, development of the PID controller parameters.
circuit, and implementation of the controller applied to a real A simple practical approach has been used. This is also
system as a reference for control engineering studies at based on small inherent nonlinearities. A theoretical
Coventry University. The students of this subject should learn approximation e.g. based on root mean square errors (RMSE)
to use different programs for a control task of an electrical can be applied in further activities.
supplied mechanical system. In this laboratory the used pc is The system can be divided into sub parts, which makes it
equipped with a 6024 PCI data acquisition board from easier to develop the overall model.
National Instruments. LabVIEW provides an interface
between the program and the external control signals. The pc 1.1 Model of carriage
is also equipped with a DS1104 board from dSpace, which
provides also the facility to gather and generate digital as well For the model of the carriage it is necessary to eliminate the
as analogue signals. The system which should be simulated influences of the pendulum (to remove the pendulum from the
and controlled is the “Bytronic Pendulum Control System” carriage). The used system has a build in position controller.
with the “Bytronic Pendulum Control Unit” [1]. This system Based on the analogue position controller inside the control
can be used in crane mode and in inverted pendulum mode unit the carriage will reach the set point in dependence of the
which gives the opportunity of two different control tasks. settings of its gain and feedback values. It is not possible to
set the speed or acceleration of the motor directly. If the
position input value exceeds +7 or goes below −7 volts the
1 Modelling carriage will reach the limits of the usable mechanical range
of the rail. With the open loop response data from the carriage
To create a suitable model in Matlab/Simulink it is necessary it is possible to determine the transfer function of the build in
to collect reference data for design and approval. The position controller:
response of the system in open loop condition can be obtained 250
G CP ( s ) = (1)
using LabVIEW [2] or dSpace [3]. Typical methods to 0.8 ⋅ s + 18 ⋅ s + 250
2
analyse a system from gathered data is to calculate step and/or The relation between the position and the speed is:
frequency response functions. For statistically significance dx
and for reduction of measurement deviations, the data x& = (2)
dt
collection has to be repeated 3 to 5 times with the same input
This relation together with the transfer function of the
signal.
position controller leads to
Based on the reference data it is possible to decide the
250 ⋅ s
kind of transfer function, which has comparable GS ( s ) = (3)
characteristics. A comparison between simulated reference 0.8 ⋅ s + 18 ⋅ s + 250
2
data and the measured output signals of the model leads to as a function of the speed with the set position as the input
suitable parameter values of the transfer function. An parameter. To match the output value of the tachometer,
which is used to measure the speed, it is necessary to modify 1.4 Model of inverted pendulum
the equation to
−25 ⋅ s The pendulum is a stable system with a simplified transfer
GCS ( s ) = (4)
0.8 ⋅ s + 18 ⋅ s + 250
2 function of:
1 ω0 2
1.2 Model of pendulum Gp1 ( s) = = (8)
1 + s 2 / ω0 2 s 2 + ω0 2
A model describing the mechanical displacement of a The poles of the equation are on the left side of the imaginary
pendulum uses the period time T and the damping factor d. axis of the s plane and the parameters can be calculated using
With the measured time period it is possible to estimate the the measured time period.
natural frequency ω0. An inverted pendulum is an instable system, so at least
2⋅π one pole is on the right half of the s plane. Converting the
ω0 ≈ (5) transfer function provides two poles on the right side of the
T imaginary axis of the s plane based on the measured time
ω0 2 period and this leads to the transfer function of
Gp1 ( s ) = (6)
s 2 + 2 ⋅ d ⋅ ω0 ⋅ s + ω0 2 − ω0 2
The open loop step response of the pendulum as reference
Gip1 ( s ) = (9)
s 2 − ω0 2
data allows to adjust the value of the model parameter d.
for the inverted pendulum by disregarding the damping and
ω0 = 6.22 Î G ( s) = 38.7008
(7)
p2 the nonlinearly of the real system. To include damping the
d = 0.032 s + 0.2 ⋅ s + 38.7008
2
following transfer function can be used. This description has
only one pole on the right side of the s plane for a damping
1.3 Model of crane value above zero.
− ω0 2
After the definition of the models for the carriage and the Gip 2 ( s ) = 2 (10)
pendulum the next step is to include the influences of the s + 2 ⋅ d ⋅ ω0 ⋅ s − ω0 2
carriage to the pendulum. To eliminate the offset and to adjust
the right amplitude an additional gain to the model values of
the pendulum and a subtraction of the position from the 2 PID control implementation in
output values of the pendulum like in figure 1 can be used.
The plot shows that the output of the model matches the Simulink
reference output of the real system (reference angle).
This chapter describes the simulation of the PID control loop
for the crane and the inverted pendulum model.
With the settings for the two PID controllers the response of
the system looks like in the plot below. The plot in figure 3 2.2 Inverted pendulum model control loop
shows the changing position of the carriage with a small
overshoot together with the speed of the carriage. The output The problem for the inverted pendulum is nearly the same as
of the position controller sets the angle as shown in figure 3 for the crane. There is only one difference: the inverted
together with the measured angle of the pendulum. A faster pendulum is an instable system.
transition is possible with a larger usable angle but this Using only the first controller for the angle leads to the
depends on the allowed limits. correct angle. Based on the instability a small disturbance is
enough that the carriage must move to keep the pendulum in
the vertical position. Finally the carriage will reach the
mechanical limits and the pendulum will fall down. With the
second controller for speed and position the pendulum swings
more and more till it reaches the limits again.
One solution to get it stable is to separate the controller for
the speed and the position. At the end there is one controller
for the position with a speed output. The second controller for
the speed will produce the set angle. The third controller will
actually move the carriage to reach the set angle. With those
controllers it is possible to reach a position but the system
will oscillate around the set point.
By changing the limits of the speed controller it is
possible to observe that the oscillation will be less for smaller
limits. For a faster reaction higher limits are necessary. A
solution is to use variable limits, which are calculated using
the position difference. The whole system with the controller,
the variable limits and the model of the inverted pendulum is
shown in figure 4.
The plot shows similar traces of the set point behaviour of the
real system and the simulation. Reasons for the differences
could be the nonlinear influences of the real pendulum.
Based on the two controllers it has also a good response to
a disturbance. For a disturbance at the pendulum weight (hard
hit at the pendulum), the carrier ran in the same direction to
catch the pendulum (angle controller). With the values of the
speed and the wrong position of the weight the controller for
the position set the angle to move the weight back to the set
position as shown in figure 7.
3.1 Crane LabVIEW control Like the crane the program behaviour to control the inverted
pendulum as shown in figure 8 is also based on the solution of
The program behaviour shown in figure 6 is based on the the simulation with the measured angle for advanced
simulation. With the user interface it is possible to set the new adjustment. Figure 8 shows the set point following with an
position for the carrier and to change the gain values of the oscillation. The angle sensor causes a non-ideal behaviour. It
consists basically of a variable resistor. The output signal
depends on perpendicular movements of the desired direction
and its calibration is sensitive to mechanical stress like hitting
a border.
Acknowledgements
I thank my parents for unconditional support during my study
program and internship.
References
[1] Bytronic: http://www.bytronic.net/pcs.htm
[2] National Instruments: http://www.ni.com/labview/
[3] dSpace: http://www.dspace.de/
[4] Ken Dutton, Steve Thompson, Bill Barraclough (1997)
The Art of Control Engineering, Prentice Hall
[5] Matlab/Simulink help, examples and tutorials
[6] LabVIEW help, examples and tutorials
[7] dSpace help, examples and tutorials