Controller Design For A SISO System
Controller Design For A SISO System
Joshua Gonsalves
11848759
Table of Contents
1 Introduction .............................................................................................................. 3
1.1 Background .................................................................................................................................3
1.2 Purpose .......................................................................................................................................4
2 Equipment ................................................................................................................ 5
2.1 Ball & Hoop Mechanical System .................................................................................................5
2.2 Ball & Hoop Apparatus ...............................................................................................................6
2.3 ModCon ......................................................................................................................................7
2.4 Other ...........................................................................................................................................8
3 Calculations .............................................................................................................. 9
3.1 Hoop Angle Transducer ..............................................................................................................9
3.2 Slop Angle Transducer ............................................................................................................. 10
3.3 Motor Drive Step Response ..................................................................................................... 11
3.4 Ball Oscillations ........................................................................................................................ 12
3.5 Motor Drive vs Hoop Accelerator ............................................................................................ 13
3.6 Ball Motion Modelling ............................................................................................................. 13
4 Implementation........................................................................................................ 15
4.1 Controller Design ..................................................................................................................... 15
4.2 Continuous PID parameters..................................................................................................... 16
4.3 Discreet PID parameters .......................................................................................................... 17
4.4 CodeWarrior Implementation ................................................................................................. 19
5 Discussion ................................................................................................................ 20
5.1 Results...................................................................................................................................... 20
5.2 Observations ............................................................................................................................ 22
5.3 Summary of problems ............................................................................................................. 22
6 Conclusion ............................................................................................................... 23
7 References ............................................................................................................... 23
10 Appendices .......................................................................................................... 25
2
1 Introduction
1.1 Background
This project is designed to show students how to design and implement a control system to
meet certain specifications. Our project is based on the CE9 Ball and Hoop apparatus. We
had to measure the behaviour of the apparatus as it was, to obtain its characteristics. From
here, we designed a control system to meet the specification we were given. It imitates
what it would be like to work in control engineering, where we would be given hardware
and system requirements, and would be required to design a controller that meets those
requirements.
3
1.2 Purpose
The Ball and Hoop system is about the dynamics of a steel ball, which sits inside the hoop.
The exact location of the ball is measured by a pendulum. When an external force moves
the ball, the ball moves up and down the inside of the hoop, and the slop angle oscillates as
the ball goes up and down. This is a small-scale representation of the slosh and slop
phenomena. The slosh and slop phenomena relates to liquid oscillations. Engineers over the
years have designed control systems to minimise liquid oscillations in places such as trucks
transporting liquids, and of liquid fuel in missiles.
To explain, in cargo trucks that carry petrol, when the truck makes a sharp turn, the petrol
inside will ‘slosh’ and ‘slop’ around the truck, which would reduce the stability of the truck,
and could potentially be dangerous. In order to reduce the liquid oscillations, the container
would need to be controlled to rotate in relation to the oscillation of the liquid, in an
attempt to reduce the oscillations, stabilising the truck quickly. (Teaching Equipment, n.d.)
(Wellstead, 1983) (Wellstead, 1983)
In our project, the ball represents the liquid, and the hoop represents our container. Figure
2 shows a cross section comparison between a cylindrical container containing oscillating
liquid, and the relative representation of the ball and hoop model.
4
2 Equipment
2.1 Ball & Hoop Mechanical System
Figure 3 shows the front of the ball and hoop system, whist figure 4 shows the back.
Figure 4 – Front view of Ball & Hoop Figure 3 - Rear view of Ball & Hoop
The transducers convert the angles of their respective components (hoop and ball) to a
voltage. When the angle of the ball is 0 degrees, the slop angle output is 0V. Similarly, when
the angle of the hoop is at 0 degrees, the hoop angle output is 0V.
5
2.2 Ball & Hoop Apparatus
The ball and hoop mechanical system is controlled by the Ball and Hoop apparatus, as
shown in figure 5.
One thing to note: all the grounding ports are common, so we only needed to have one port
grounded at all times, which would act as ground for all other outputs. The three black
knobs adjust the reference voltages for their respective transducers (slop angle, hoop angle,
and motor input).
6
2.3 ModCon
The modcon controller is the bridge between the PC and the ball and hoop apparatus. It is a
Freescale microcontroller, which runs the real-time task of controlling the ball and hoop
system. Figure 6 shows the modcon I/O interface.
7
Freescale’s codewarrior software is used to create programs that are implemented in
modcon to control the systems in real time based on the inputs and outputs. For the ball
and hoop, we only needed 2 inputs working in real time, and one real time output.
ModCon acts as both a controller, and as a function generator. So it can be used to test the
parametes of the system (eg step response), and control the system too.
2.4 Other
• Other equipment used included:
• PC running Windows
• Oscilloscope
• CodeWarrior 5.1 software
• ModCon PC Controller v1.19a software
• Banana cables
• Matlab & Simulink
8
3 Calculations
To begin our project, we started measuring characteristics of our control system to see what
we could obtain, and to try and get an overall transfer function.
9
As shown in figure 10, the hoop angle voltage increases linearly from 0 to 270-300 degrees,
and then drastically drops down to 0 towards the higher angles. This meant that the hoop
angle transducer was malfunctioning, creating a ‘dead zone’ of measurement in the higher
degrees. Due to this, we decided to not incorporate the hoop angle transducer
characteristics into our project, as the system would be instable due to it.
Because the line is only linear between 35 and -35 degrees, the control system will only
work correctly when the ball is within that specification. We originally had acquired a line
for +-180 degrees, but the voltage line was not linear past 35 degrees, so we set the
requirements to only work between positive and negative 35 degrees. In a real world
scenario, it would be highly unlikely that a truck with a container of liquid would turn so
drastically that the liquid oscillated more than 35 degrees.
10
3.3 Motor Drive Step Response
In order to derive the motor speed response, we inputted a step response into the motor
drive. We then used the gain and time constant to calculate our transfer function.
11
3.4 Ball Oscillations
In order to calculate the characteristics of the ball oscillating (slosh & slop), we manually
rested the ball at -35 degrees, let go of the ball, and recorded the oscillations of the slop
angle.
12
3.5 Motor Drive vs Hoop Accelerator
Finally, we obtained a linear line that represented steady state motor speed based on a
reference voltage. In order to calculate this, we set an input voltage of 1V into the motor
input, let the motor velocity hit steady state, then as soon as steady state was hit, increase
the input voltage by 1. We did this 7 times, and obtained the gradient of the line. By
calculating rise over run, we calculated the gradient of the line to be 0.3077.
13
Equation 3 - Transfer function of ball motion (Wellstead, 1983)
• br = 0.00000497307 (friction)
• g = 9.81 (gravity)
• R = 0.0876 (hoop radius)
• rb = 0.00953 (ball radius)
• r = 0.0094m (rolling radius)
• m = 0.0281kg (ball mass)
The measured values were measured by Gideon & myself, with the exception of br, which
we found online. The expanded explanation of the derivation of the transfer function is
linked in the references, and included in the appendix.
Inputting our values into the characteristic equation gave us the final ‘S’ domain transfer
function of:
0.4𝑠 2 + 2.003𝑠
1.411𝑠 2 + 2.003𝑠 + 111.986
14
4 Implementation
Due to the incorporation of modern technologies and software such as Matlab and Simulink,
we found that the controller design component of this project to be, dare we say it,
relitavely easy. This was due to simulink’s ‘tune’ function.
Once this was designed, we used simulink’s ‘tuning’ function to generate our Kp, Ki, and Kd
values for the PID controller.
Our PID controller needed to fit the following criteria, as specified in the ball & hoop project
requirements:
Overshoot < 25%; setting time < 10 s; steady state accuracy < 10%.
Along with this, we set a personal objective of reducing the number of oscillations by 1
before hitting steady state.
15
4.2 Continuous PID parameters
Using the tune function in Simulink, we got the following parameters for our continuous PID
controller:
16
4.3 Discreet PID parameters
Once we did this, we used matlab’s c2d to convert all our transfer functions to the Z
domain. This would give us discreet control system. The sample time used was 0.1 seconds.
g1 =
3.97
----------
0.56 s + 1
g2 =
0.307
-----
s
g3 =
0.4 s^2 + 2 s
-------------------------
1.411 s^2 + 2.003 s + 112
g1z =
0.3254 z + 0.3254
-----------------
z - 0.8361
g2z =
0.01535 z + 0.01535
-------------------
z-1
g3z =
0.2791 z^2 - 0.4466 z + 0.1675
------------------------------
z^2 - 1.263 z + 0.8882
17
Please note that all matlab code is included in the appendix.
Using the discreet transfer functions, we remade the controller in Simulink, this time with
discrete characteristics.
With all these values, we were finally able to start programming our microcontroller!
18
4.4 CodeWarrior Implementation
Codewarrior allowed us to implement our controller by using C to program the
microcontroller. Using X1 & X2 as inputs, and Y1 as an output, we were able to implement
our digital controller through the use of temporary variables, and the controller parameters.
The ‘guts’ of the code is as follows.
From here, we were able to build the bin file to be imported into ModCon and programmed
into the Freescale microcontroller.
19
5 Discussion
5.1 Results
Our digital controller successfully met all project requirements, and we were able to fulfil
our personal goal of reducing the oscillation of the ball by one. Figure 21 shows the
oscillations of the ball when being let go from -35 degrees with the controller was off. The
green line represents the slop angle, whilst the red line represents the controller output.
Figure 22 shows the same thing, but with the controller on. Note the controller reacting to
the oscillations of the ball, and note the number of oscillations dropped to 4.
20
We performed one more test, and that was to manually accelerate the ball from its
grounded position by hitting it to approximately -30 degrees.
We did the test again, but this time with the controller on.
Please note in all of these tests, the controller is scaled to be twice that of the slop angle, to
allow us to observe the effects of the controller better.
21
5.2 Observations
In figure 21, there are 5 oscillations of the ball with the controller off. When implementing
the controller, there are 4 oscillations before the ball hits steady state, as shown in figure
22.
In figure 23, there are 5, almost 6 oscillations before the ball hits steady state, whilst in
figure 24, there are only 4, which is a great improvement.
Note that these results were not achieved on the first go, we had to play around slightly
with our control parameters, varying the numbers slightly to achieve the lowest number of
ball oscillations, whilst keeping the system stable.
One final test we did was to hit the ball over 35 degrees, however this test failed, as we had
not designed our controller to work at this specification. The controller went unstable, and
the hoop motor began spinning out of control.
One last observation we made was that due to such low control parameters, we did not
actually need to use a PID controller, a PI controller would have been sufficient enough.
However, by the time we made this observation, it was too late to go back, and the PID
controller ended up working fine.
22
6 Conclusion
Through linking this project to a real world example (liquid oscillations in a cargo truck), I
managed to link a lot of the knowledge gained in this subject into some of my other
subjects, such as Data Acquisition.
This project was very fun to do, and with a bit more time and maybe an extra group
member, we would have also been able to implement an analogue controller. However, we
were very happy with our digital controller, even though it had its limitations. With our
continuous transfer functions and a bit more time, we could have created an analogue
controller too.
7 References
McLean, P. (2008). MODular CONtroller User Guide. University of Technology, Sydney,
School of Electrical, Mechanical and Mechatronic Systems, Sydney.
Nguyen, H. (2008). Analogue and Digital Control. University of Technology, Sydney, Faculty
of Engineering, Sydney.
Teaching Equipment. (n.d.). Retrieved June 10, 2017, from Control Systems Principals:
http://www.control-systems-principles.co.uk/images/Ball%20and%20Hoop.jpg
Wellstead, P. (1983). Ball & Hoop. Cheshire: TQ Education.
8 Table of Equations
Equation 1 - Transfer function of motor drive .........................................................................11
Equation 2 - Ball slop characteristics .......................................................................................12
Equation 3 - Transfer function of ball motion (Wellstead, 1983) ............................................14
Equation 5 - Characteristic transfer function of PID (Nguyen, 2008) ......................................15
23
9 Table of Figures
Figure 1 - The Lab ....................................................................................................................... 3
Figure 2 - Cross section of vessel vs Ball & Hoop (Wellstead, 1983) ......................................... 4
Figure 4 - Rear view of Ball & Hoop ........................................................................................... 5
Figure 3 – Front view of Ball & Hoop ......................................................................................... 5
Figure 5 - Ball & Hoop Apparatus............................................................................................... 6
Figure 6 - ModCon I/O ............................................................................................................... 7
Figure 7 - ModCon PC Interface ................................................................................................. 7
Figure 8 - Diagram of ModCon interaction (McLean, 2008) ...................................................... 8
Figure 9 – Principal dynamics of the system (Wellstead, 1983) ................................................ 9
Figure 10 - Hoop angle vs hoop angle voltage output ............................................................... 9
Figure 11 - Slop angle vs slop angle voltage ............................................................................10
Figure 12 - 5V step response on motor drive ..........................................................................11
Figure 13 - Voltage of slop angle oscillations ..........................................................................12
Figure 14 - Motor drive vs hoop velocity .................................................................................13
Figure 15 - Ball & Hoop dynamics (Wellstead, 1983) ..............................................................13
Figure 16 - S domain controller designed in simulink..............................................................15
Figure 17 - Simulink tuning in S domain ..................................................................................16
Figure 18 - Continuous controller response ............................................................................16
Figure 19 - Discrete controller design ......................................................................................18
Figure 20 - Simulink tuning of discrete controller ...................................................................18
Figure 21 - -35 degree drop, no controller ..............................................................................20
Figure 22 - -35 degree drop, controller on ..............................................................................20
Figure 23 - Tapping the ball no controller ...............................................................................21
Figure 24 - Tapping the ball with controller ............................................................................21
24
10 Appendices
Ball motion model equation
25
26
Matlab code
%Gs = tf([ 0. 42 0 0],[ 0. 42 0 112. 1])
% Gz = c2d( Gs, 0. 1)
27