You are on page 1of 6

Implementation of PID Controller and Pre-Filter to

Control Non-Linear Ball and Plate System

Agung Adiprasetya/Telkom University Agung Surya Wibowo/Telkom University


Electrical Engineering Faculty Electrical Engineering Faculty
Bandung, Indonesia Bandung, Indonesia
agungadiprasetya@gmail.com agungsw@telkomuniversity.ac.id

authors want to begin from the basic and simple controller


(PID Controller).
Abstract—In this paper, the authors try to make PID controller The organization of this paper is as follows: the present Section
with Pre-filter that is implemented at ball and plate system. Ball and provides a brief introduction and literature review on the Ball
plate system will control the position of ball’s axis in pixels’ value and Plate System, Section II gives more detail about ball and
by using servo motor as its actuator and webcam as its sensor of plate system, Section III gives the methodology to design the
position. PID controller with Pre-filter will have a better response system, Section IV gives some experiment result and analysis
than conventional PID controller. Even though the response of PID
that has been done, finally Section V gives conclusion and
with Pre-filter is slower than conventional PID, Pre-filter in the
system will give the less overshoot response. suggestion for the future work in ball and plate system.

Keywords—PID, Pre-filter, Ball and Plate system


II. BALL AND PLATE SYSTEM
I. INTRODUCTION The block diagram and hardware of system will be showed
below. The system uses a single feedback to track the desired
The ball and plate system is very interesting to be designed. ball position.
The open loop system has instability and nonlinearity and it
is hard to be controlled. Ball is placed on the plate and its A. Block Diagram of Systems
coordinate or position can be set as a set point in pixels value. The block diagram of the ball and plate system can be
The actuator of this system is servo motor. The actuator will showed in figure 2 and 3. In figure 2. It uses PID controller to
be used to set how much the plate angle is. There are two control ball position on plate. Because there are two variables
motor servo built in plate in order to move the ball in x and y that must be controlled, so the system must have 2 PID. The first
direction. The sensor of this system is webcam. It will sense PID is used to control position in X axis, and another PID is used
where the ball’s position is. The ball and plate system is to control position in Y axis. In figure 3 the system is
showed in Fig.1. complemented by pre-filter block to reduce the overshoot.

Fig. 2. Block Diagram of Ball and Plate Control System without Pre-filter

The research of the control of ball and plate system has been
done by some researcher. The previous research about ball
and plate system can be seen in some papers with the tittle Fig. 3. Block Diagram of Ball and Plate Control System with Pre-filter
such as references number [1], [2], and [5]. In here, the
B. Hardware of System
The system consists of 3 main devices. The first device is PC ( ) = . ( )
1 −
that have multiple task such as to make the set point, compute
position error, process Pre filter and PID controller, and send ( )= (1 − ). ( ) (1)
serial data output PID to Arduino. The second device is Arduino.
The Arduino receives serial data from PC to move or set the
From (1) can be derived the difference equation in (2)
angle of servomotor. The last device is webcam as a ball position
sensor. Fig 4 show the hardware of system.
[ ]= [ ]+ [ ]+ [ ]

[ ]= . [ ]

[ ]= . [ ] + [ − 1]

[ ]= ( [ ] − [ − 1] (2)

Finally, we have code in C++ for digital PID controller


implementation from (2).

TABLE I. KP, KI, AND KD VALUE


Fig. 4. The Harware of System PID Kp, Ki, and Kd
Table
Kp Ki Kd
C. Mathematical Modelling.
1. 1,5 0,005 10
The model of system can be simply derived like the model
of ball and beam system or we can use detail modelling. Detail
modelling has been derived in [6] “Modelling and Control of
Ball and Plate System”. Modelling of this system is not effective B. Pre-Filter Design
if we use PID method for its controller. In this paper we will not Pre-filter used in the system is a low pass filter 1st order. The
find mathematical modelling for designing the PID controller. purpose of pre-filter in here, is to reduce high overshoot of the
Modelling in system is sensed by intuition that the system is response. Example of the pre-filter that be used in continuous
type-1, because of the same characteristic with the position system can be shown in (3)
control system. When the system type is known as system type-
1, the control strategy is chosen to focus on the Kp gain constant ( )= (3)
and Kd gain constant. Finally, if there is still some error steady
state, we can put a little Ki gain constant to our controller.
The transfer function of pre-filter must have dc-gain equal to
1. We want to make the output of the pre-filter block will have
III. BALL AND PLATE SYSTEM DESIGN METHOD the same value with the set point at the steady state. The idea is
to give the set point to system little by little so that the error in
A. PID Design the system is not so big.
The parameter of the PID controller in the system is found Implementation of pre-filter is done by software as a digital
by trial and error method. Firstly, we focus on proportional gain. low pass filter. Digital low pass filter that have a dc gain equal
Proportional gain must be big enough so that the ball on plate to one will have a transfer function like Eq.(4). The variable ‘a’
can move freely. Proportional gain cannot big too much, must have a value |a|<1 so that we have a stable pre-filter system.
because it will cause very high fluctuation and make the
response is hard to achieve steady state. Then, we add derivative ( ) =
( )
(4)
gain to reduce the response fluctuation. The ratio between
proportional gain and derivative gain usually has value about
eight or ten times. Finally, we add a little integral gain to reduce
the error steady state.
The transfer function of digital PID can be written in (1)

( )= ( )+ ( )+ ( )

( )= ( )
From (4), the difference equation can be derived to be (5). Then, we can make the implementation of digital pre filter
from (5) by code in C++. Sampling time that we used in pre-
( ) 1−
( ) = = filter is different from sampling time in PID. We want to make
( ) (1 − ) the transition in pre-filter is moving slowly. The sampling time
[ ]− . [ − 1] = (1 − ). [ ] (5) in pre-filter is set ten times than digital PID sampling time.

C. Ball’s Position Sensing Method

Fig. 5, and Fig. 6, is explain about how the camera can detect
and tracking the ball.

Fig. 5. Personal Computer Flowchart (With Pre – Filter)


Fig. 6. Personal Computer Flowchart (Without Pre – Filter)

From Fig. 5, explain that the ball was detected by its color.
Image are captured from camera is converted into HSV image.
From HSV image, image is converted again into black and
white image by applying the threshold value. So, the color of
the ball became a white color and the plate is a black color.

The image that processed by computer is a white color. From


the white color, computer is calculating the coordinate. The
coordinate is calculated with filter and PID controller. If the
system is not use pre-filter, as in Fig. 6, the coordinate is only
calculated with PID controller. Output value from PID
calculation are sent to microcontroller via serial
communication.

Fig. 7. Microcontroller Flowchart


Fig. 7. is explain how the servo motor can move. The output
PID from calculation on computer, is received by Arduino
UNO. Type of received data is a string, so microcontroller must 600
convert data from string into number to be processed to move
the servo motor. The numerical data is then mapped to degree, 400
so the servo motor can move to stabilize the position of the ball.
200

IV. EXPERIMENTS RESULT AND ANALYSIS


The experiments performed on the system that use pre-filter
and non-pre-filter. There are two types of test that performed on
ball and plate system. The first test is the test using set point in
X and Y axis with fixed value. The second test is using set point
in X and Y axis that switch every 20 seconds. In the second test, Fig. 10. Graph with Pre-Filter (Switch Set Point)
the test using 4 spot of set point, so the ball can move on the
square track. 700
600
A. Experiment Using Fixed Set Point 500
In this test, the system using set point in X axis and Y axis 400
value by 300 pixels. 300
800 200
600 100
400 0
1
47
93
139
185
231
277
323
369
415
461
507
553
599
645
691
737
783
829
200
0 X Axis Y Axis X Set Point Y Set Point
1
28
55
82
109
136
163
190
217
244
271
298
325
352
379
406
433
460
487

Fig. 11. Graph without Pre – Filter (Switch Set Point)


X Axis Y Axis X Set Point Y Set Point
Based on ball movement on graphics in Fig. 10. and Fig. 11.,
Fig. 8. Graph with Pre - Filter
there’s some differences. On the Fig. 10, the overshoot that
800 happen when the ball move to the other point is small, about 5
600 – 10 pixels. Very different with non – pre – filter system is very
big, about 50 – 100 pixels even more. From the explanation,
400
system using pre – filter is better for damping the overshoot than
200 non – pre – filter.
0 The other differences that occurred is the rise time. The rise
1
36
71
106
141
176
211
246
281
316
351
386
421
456
491
526
561
596
631

tome when system using pre – filter is very slow, about 5


seconds. This happens because of a change set point made by
X Axis Y Axis X Set Point Y Set Point the system slowly transformed by the filter. So, the movement
Fig. 9. Graph without Pre - Filter of the ball is slow but the overshoot is very small.
Very different with non – pre – filter system. The movement
Based on ball movement on graphic in Fig. 8. and Fig. 9., non – pre – filter system is very fast. That happens because there
there’s no significant differences. Both system can control the no filter so the ball can move fast. Less than 2 seconds. But,
ball very well, so the position of the ball can be around the set because of fast movement, the system can make a big overshoot.
point, although there some small error. Error that occurred about The trajectory of the ball’s movement is shown in Fig. 12.
10 – 20 pixels. and Fig. 13.

B. Experiment Using Switch Set Point


In this test, the system using four spot of set point. There are,
(100,100), (100,400), (500,400), and (500,100). That point can
make a square track.
500

400 [4] Muhammad Asif Rana, Zubair Usman, Zeeshan Shareef, “Automatic
Control of Ball and Beam System Using Particle Swarm
300 Optimization,” 12th IEEE International Symposium on Computational
Intelligence and Informatics (CINTI), Budapest Hungary,.21-22
200 November 2011.
[5] Manashita Borah, Lalbahadur Majhi, P. Roy and B.K.Roy, “Design of
100 a Fractional Order PD Controller Tuned by Firefly Algorithm for
Stability Control of the Nonlinear Ball and Plate System,” Conference
0 Paper, May 2014.
0 100 200 300 400 500 600 [6] Mohammad Nokhbeh, Daniel Khashabi,” Modelling and Control of
BallPlate System”, Final Project Report, Amirkabir University of
Ball Movement Set Point Technology 2011.
[7] Putri Mahanani R, Fernando Ardilla S, and Setiawardhana,” Tracking
Fig. 12. Trajectory of ball’s movement with Pre – Filter (Switch Set Point) Object Menggunakan Metode Counterpropagation”, Final Project
Report, Institut Teknologi Sepuluh Nopember.
500 [8] Chan Ham and Mohsin Mohammad Taufiq,”Development of a Ball
and Plate System”, 122nd ASEE Annual Conference & Exposition,
400 2015.
[9] Hani Hunud A. Kadouf and Yasir Mohd Mustafah,”Colour – based
300 Object Detection and Tracking for Autonomous Quadrotor UAV”, 5th
International Conference on Mechatronics (ICOM’ 13), 2013.
200
100
0
0 200 400 600 800

Ball Movement Set Point

Fig. 13. Trajectory of the ball’s movement without Pre – Filter (Switch Set
Point)

V. CONCLUSION AND FUTURE WORKS


In this paper, implementation of PID controller with pre
- filter to control nonlinear ball and plate system has been
done successfully. Actually, we propose two design method
for controlling the ball and plate system, there are the system
with conventional PID controller and PID controller with Pre-
filter. The result show that PID controller with Pre-filter will
have a better response for tracking position of the ball in
square trajectory or balancing position of the ball in the center
of the plate.
For the future works, we suggest for another method
design for controller design. Other method that can be
proposed such as FLC Fuzzy Logic Controller, or adaptive
control for nonlinear system because in fact the ball and plate
system is nonlinear system.

REFERENCES

[1] Miad Moarref, Mohsen Saadat, and Gholamreza Vossoughi,


“Mechatronic Design and Position Control of a Novel Ball and Plate
System,” 16th Mediterranean Conference Control and Automation,
Congress Center, Ajjacio, France, June 25-27, 2008
[2] Diego Col´on , Jos´e M. Balthazar , C´elia A. dos Reis, Atila M. Bueno
´ ,Ivando S. Diniz and Su´elia de S. R. F. Rosa, “Control Design and
Robustness Analysis of A Ball and Plate System By Using Polynomial
Chaos”, Conference Paper, July 2014.
[3] M. Amjad, KashifM.I., S.S Abdullah, Z.Shareef, “A Simplified
Intelligent Controller For Ball and Beam System,” 2nd International
Conference On Education Technology and Computer (ICETC), June
2010.

You might also like