You are on page 1of 7

The Implementation of PID Controller in the Pick and Place

Robot
H. Ferdinando, H. Wicaksono and R. Wibowo
Dept. of Electrical Engineering, Petra Christian University, Indonesia

Abstract – A control system for pick and place robot section, then it comes the design of the system for
is implemented. The control algorithm uses the PID mechanics, hardware and software part. It continues with
(Proportional-Integral-Derivative). The system 3-DOF experiment for the system and conclusion closes this
robot with specific task, i.e. to pick certain a letter paper.
blocks and places it to the desired location. The robot
is controlled with the AT89S51 microcontroller. The
command for the specific letter blocks comes from a III. THE PID CONTROLLER – BRIEF INTRODUCTION
computer. The computer and the AT89S51 are
connected via RS-232. The time sampling of the system The PID controller combines three control algorithms,
is 5ms. After tuning the PID’s constants, the ratio of i.e. Proportional, Integral and Derivative controllers. Each
the constant for P, I and D is 20:0.1:34. The controller has its own constant to adjust the output of the
experiments show that the rise time of the system is controller based on the error signal. Each controller has
1.41s; the settling time is 4.03s and the maximum different contribution to the response of the system.
overshoot is 1.62%. It is recommended that the To get a good PID controller system, one must tune
constant for Proportional controller is between 2 and the constants. Although it seems independent, the
70, the greater the constant the longer the rise time. constants do not. This gives complexity in tuning them.
Big value of the constant also contributes to the The tune process, however, can be done via several
number of oscillation. For the Integral controller, it is algorithms such as Ziegler-Nichols, Cohen-Coen, etc [1].
10 and 50, the greater the constant the more the Each algorithm has its own advantages and disadvantages.
oscillation occurred. This makes the motor run The power of the PID controller lies on its simplicity.
abruptly. One only set three constants in order to get good response.
It is simple for the number of parameter is only three.
Keywords – PID, pick and place robot, AT89S51 Besides, it can be implemented without digital controller.
I. One can make the PID controller with Operational
Amplifier and several passive components. Off course this
II. INTRODUCTION kind of PID controller has limited capabilities, but one can
use it to control simple system.
The PID (Proportional-Integral-Derivative) controller The more complex PID controller uses digital
is the most popular control algorithm in industries. The controller such as microcontroller, PC (personal
power of this controller lies on the simplicity of the computer) or PLC (programmable logic controller). These
control algorithm. Although there are many new control equipments give better PID controller but with higher
algorithms developed nowadays, this controller still exists. cost. The chosen controller is based on the complexity of
There are many applications of the PID controller in the plant.
industries, e.g. robotic arm, conveyor, heating process,
etc. The goal is one, i.e. to reach the setting point fast with
small overshoot. IV. PICK AND PLACE ROBOT
This paper discusses the role of the PID controller in
controlling pick and place robotic arm. The robot will pick A pick and place robot is a material handling robot that
certain block of letter and then place it in the desired can work 24 hours a day without worries or fatigue [2].
place. The control algorithm is applied to the movement This robot is a common robot in industries. The task is to
of the main body. The controller is the AT89S51 pick some object and place it in the desired place.
microcontroller. It receives command from computer via When it is controlled, then the position control is the
RS-232. The final goal is to get system with fast rise time, main issue. It must be controlled such that the robot can
fast settling time and minimum overshoot. pick the object at certain place accurately and place it at
This paper is organized as follow; the first section the desired place accurately as well. It is the role of the
gives introduction to the project. The PID controller is controller to achieve this goal. One can use many
discussed briefly on the next section. For those who do not algorithms to achieve it but the goal is one, i.e. to pick and
familiar with pick and place robot can read the following place object accurately, fast and with small overshoot.
The application of the pick and place robot is in
assembling production process, for example. Here, the
letter
robot must pick certain part and place it to the specific
place. The assembling process of the cassette uses this
robot. arm
Another application is insert machine for the electronic
printed circuit board (pcb). Here, the robot picks the
component, inserts it to the hole, cuts the lead and bends
it. The insert machine can finish the whole component in a
pcb fast, compare to the human.

V. MECHANICS DESIGN
place/slot
Fig. 3. Base place (top view)
The mechanic design is based on figure 1. The primary
and secondary arms can rotate 300o and the gripper can
move up and down (see figure 2). VI. HARDWARE DESIGN

Figure 4 shows the block diagram of the system. The


system uses several additional circuits. They are discussed
in this section.
primary
arm
motor 2 Potentiometer2
gear box motor 1
secondary
arm ADC0809 Potentiometer1

motor 3 main body


PC RS-232 AT89S51 Limit switches

DAC0808
Fig. 1. Mechanic diagram of the robot

Comparator H-bridge

2 Triangle wave
generator

1 Fig. 4. Block diagram of the system

The position sensor for the system is a potentiometer.


It is a linear ten turn potentiometer. The PID controller is
implemented in a microcontroller MCS-51 family, i.e.
AT89S51 [3]. The number of position sensors is two, one
3 for the primary arm and the other for the secondary arm.
The gripper uses two limit switches. Figure 1 shows the
position of the potentiometer (close to the motor 1 and 2)
To read the current position, the AT89S51 needs A/D
converter. The ADC0809 is used. The signals, however,
cannot be read directly for the signal range does not match
Fig. 2. How the robot move to the range of the ADC0809 [4]. For this reason, an
The robot is supported by a main body. The main body additional circuit is used. It is called zero and span circuit.
has base plate. On the base plate the letter blocks are The arms must be able to turn CW and CCW. For this
placed. Figure 3 shows the whole base plate from top. The purpose, an H-bridge is used to drive the motors. The H-
letter block is picked one by one and placed at the desired bride uses LM298N [5]. This chip can provide current up
place to 3A.
The movement of the arms must be able to be the system is idle, waiting for the next interrupt timer.
controlled. It means when the current position is far from Figure 6 shows the part of interrupt timer routine.
the desired position, then the arm must move fast, and
vice versa. For the motor is DC motor, it needs to control void InitCounter(void){
the voltage drop at the motor terminal. This leads to the Counter=0;
EA=0; // disable all interrupts
PWM (Pulse Width Modulation) system. TH0=256-18;// TL0 = 238
The PWM circuit using a simple triangle wave TMOD=0x22; // chose mode 2 setiap timer
generator, an input reference signal and a comparator. The PT0=1; // bit prioritas timer0
comparator will give output either HIGH or LOW ET0=1; // enable interrupt of timer0
according to the status of both inputs. The input reference TR0=1; // start timer
signal is produced by the AT89S51 via DAC0808. For the EA=1; // enable all interrupts
output of the DAC0808 is current [6], then the current to }
voltage converter is used. The DAC0808 gets data from
void Counter_Bit() interrupt 1 using 1 {
the AT89S51. Figure 5 shows the simplified PWM circuit. Counter++;
The frequency of the PWM signal is 1kHz. This frequency if (Counter==0){
depends on the frequency of the triangle wave. This value SamplingPID=1;
is chosen for the motor will turn abruptly in low frequency }
of PWM. }

Fig. 6. Part of interrupt timer routine

The flag SamplingPID guards the main program such


that when the time is come, then the PID process will run.
As soon as the process starts, then this flag will be cleared.
This makes the main program waits until the next time
sampling.

B. PID Controller

The constants of PID parameter could have floating


point value. For this reason, the implementation uses C
Fig. 5. Simplified PWM circuit language.
To make the system simple and easy for modification, the
constants are floating point. Figure 7 shows the PID
VII. SOFTWARE DESIGN controller implementation in the AT89S51.

The software in the AT89S51 is written in C [7] for void CalCulatePID(void){


YN1=Y;
the computation uses floating point number. To use ErrN2=ErrN1;
assembly language can lengthen the development time. ErrN1=Err;
The AT89S51 receives command from a computer. User Err=SetPoint-CurPoint;
inputs the command using the HyperTerminal. The T=0.005;
command is simply one letter. It means the robot must Y= YN1 + KP*(Err-ErrN1) + KI*Err*T +
pick that letter and place it at the pre-set place. ((KD/T)*(Err+ErrN2-2*ErrN1));
The robot moves its arm one by one instead of if (Y>255) Y=255;
simultaneously. This makes the implementation simple. if (Y<-255) Y=-255;
}
A. Time Sampling Fig. 7. PID controller in the AT89S51

The control algorithm uses PID. For this purpose, there


are three constants for the controller. It also needs a time VIII. EXPERIMENTS
sampling in the computation. The time sampling is 20ms.
It is assumed that the motor has slow response for the load A. PWM Circuit
is big.
The AT89S51 must be set such that it will repeat a The frequency of the PWM signal is 921.66Hz (period
bunch of task every 20ms. The interrupt timer is used for = 1.085ms). It depends on the triangle wave. Figure 8
this purpose. Those tasks are reading the current position shows several PWM signal with various duty cycle, 25%,
of the primary arm, compare it with the desired position 50%, 75% and 100%.
from PC (via RS-232), calculate the PID control action
and drive the robot. When there is time remaining, then
Rise time, settling time and maximum overshoot are
3.36s, 32.62s and 30% respectively. This result is not
good. The rise time must be small and so must the settling
time. The maximum overshoot is too big for control
(a) position.
To change the constant to 2.3, 70 and 0.001 for P, I
and D respectively does not give better results. This
combination makes the oscillation continue forever.
Figure 10 shows it.
(b)

A
D
C

v
(c) a
l
u
e

Time (s)

(d) Fig. 10. Bad combination of PID parameters

Fig. 8. PWM signal for duty cycle (a) 25% (b) 50% (c) 75% (d) 100% This combination should not be used for the settling
time is at infinity, although the rise time is good. The
The experiments show that the duty cycles do not fit to system becomes unstable for the Derivative constant is too
the design. For 25%, 50%, 75% and 100%, the small.
implementation results 25.34%, 50.23%, 75.57% and
99.53% respectively. C. Sampling Time
The problem of those deviations is that there is small
error in the frequency of the triangle wave. If the triangle These results indicate that the PID constants must be
wave is 1 kHz exactly then the duty cycle of both design tuned in order to get good performance. It is also
and implementation will be the same. This deviation is not interesting to see how the sampling time influences the
major problem since the controller will compensate it. The system. It uses the best combination of the PID controller.
problem is how to find good combination of PID’s
constants which can compensate that deviation. Good Time Sampling 20ms: The PID constants are 9, 8.5 and
compensation is shown when the system can reach the 0.026 for P, I and D respectively. Figure 11 shows the
goal of the design related to rise time, settling time and result. The orise time is 2.98s with settling time and
maximum overshoot. maximum overshoot are 6.28s and 0.9%. The result is
better than that of figure 9. But the rise time, however, is
B. PID Controller still not satisfying. Also the settling time is considered
slow.
The initial constant for PID controller in 20ms time Kp=9 Ki=8.5 Kd=0.026
sampling is 2.3, 3.5 and 0.026 for P, I and D respectively.
Figure 9 shows the result. 120
A100
D
C 80
A 60
v
D a 40
C l 20
u
v e 0
a 0 2 4 6 8 10 12 14 16
l
u Time (s)
e Fig. 11. One of response system with sampling time 20ms

From many experiments later, it is difficult to find


Time (s)
good combination of PID’s parameter in order to have
Fig. 9. Response of the system
good performance. The hypothesis is that the sampling insight about the PID’s parameters in the pick and place
time is too slow. With sampling time 20ms, the system robot.
gets control action every 20ms. This makes the system One parameter will be varied while the other two
cannot response as fast as possible. Therefore, to choose parameters are constant. The sampling time is 2ms.
20ms as sampling time is not good. It is necessary to use
smaller sampling time. Proportional Parameter: the starting point of this
experiment is the result from figure 13. The I and D
Time Sampling 5ms: from the previous sub-section, the parameters are 34 and 0.1 respectively with variation in P
new sampling time is 5ms. 5ms is chosen for the motor is parameter.
loaded with its arm. The arm is little bit heavy. So 5ms is Figure 14 shows the result of this variation. The
enough to get better performance. experiment shows that the smaller the value of P
The PID constants are 15, 10 and 0.1. Figure 12 shows parameter, the better the rise time. It is shown that the rise
the result. time is better than Kp=20 with sampling time 5ms, it is
Kp=15 Ki=10 Kd=0.1 around 0.4s. The settling time is also improved, i.e.
A
around 0.5s.
140
D
120
C A 140
100
D 120
v 80
C 100
60
a
40 80
l v
u 20 60
a
e 0 l 40
0 1 2 3 4 5 6 7 8 u 20
Time (s) e 0
Fig. 12. Response of the system with sampling time 5ms; Kp=15, Ki=10 0 500 1000 1500 2000 2500 3000
and Kd=0.1
Time (ms)
Fig. 14. Result of the P parameter variation (black: Kp=2, white: Kp=35,
The rise time is 2.43s, the settling time is 5.82s and the grey: Kp=70)
maximum overshoot is 2.43%. The result is better
compare to the previous sub-section. But it is still Integral Parameter: the starting point of this experiment
important to improve its performance. is the result from figure 13. The P and D parameters are
Figure 13 shows another experiment with different 20 and 0.1 respectively with variation in I parameter.
combination of the PID’s parameter. The chosen Figure 15 shows the result of this variation. From rise
parameters are 20, 34, 0.1. The rise time of the system is time point of view, the system with big I parameter has
1.41s with settling time 4.03s and maximum overshoot fast response. Small value needs longer time to reach the
1.62%. The performance of the system is improved again. setting point.
Although the PID’s parameters seem independent,
140
they do not. This makes the tuning process more difficult. A
D 120
Kp=20 Ki=34 Kd=0.1 C 100
80
v 60
140 a
A
D 120 l 40
C 100 u 20
e 0
80 0 500 1000 1500 2000 2500 3000
v
a 60 Time (ms)
l 40
u Fig. 15. Result of the I parameter variation (dark grey: Ki=10, white:
e 20 Ki=20, light grey: Ki=50)
0
0 1 2 3 4 5 6 Derivative Parameter: the starting point of this
Time (s)
experiment is the result from figure 13. The P and I
Fig. 13. Response of the system with sampling time 5ms; Kp=20, Ki=34 parameters are 20 and 34 respectively with variation in D
and Kd=0.1 parameter.
Figure 16 shows the result of this variation. The plot of
D. PID’s Parameters Exploration the response for several experiments is difficult to see.
The responses are almost the same, except that the D
It is necessary to explore the PID’s parameters on this parameter cannot be greater than 1. With D parameter is
robot. The purpose of this experiment is to get some equal to 1; the response has large steady-state error.
180 TABLE 1
A160 PERFORMANCE OF THE SYSTEM FOR EACH LETTER WITH TIME
D140 SAMPLING 20ms
C120
100 Letter Rise Time Max. Over Shoot Settling Time
v
a 80 position (s) (%) (s)
l 60 A 2.92 0.00 3.90
u 40 B 3.14 0.00 10.96
e 20
C 3.02 2.83 38.10
0
0 500 1000 1500 2000 2500 D 2.86 3.01 11.62
E 2.84 1.06 7.46
Time (ms)
F 2.68 0.00 3.92
Fig. 16. Result of the D parameter variation G 2.48 0.00 3.12
H 2.50 0.00 2.90
E. Overall Response I 2.46 0.00 2.94
J 2.31 14.54 21.36
After all explorations of the PID parameter, it is K 2.24 6.38 12.14
necessary to see the overall response of the system. For L 2.22 0.27 6.36
the robot is positioned to pick and place a letter block, the M 2.04 21.21 30.72
experiments is about the performance of the robot to pick N 3.3 21.92 39.40
the letter block for each letter only. O 2.14 27.61 20.66
The initial position is between 5th and 6th slots in the P 2.24 7.40 9.32
base plate (see figure 3). The slot is a place where the Q 3.66 10.00 17.6
letter block is placed. The primary arm will move to the
R 2.54 19.69 16.84
target letter and the performance is measured. The
S 2.64 10.81 7.1
performance of the system is represented by rise time (0-
T 2.66 3.33 6.50
90%), settling time (5%) and maximum overshoot.
U 4.20 8.51 6.80
Time Sampling 20ms: Table 1 shows the summary of V 2.44 4.25 10.34
this experiment with time sampling 20ms. The PID W 4.26 14.00 27.42
parameters are from sub-section 7.3.1, i.e. Kp=9, Ki=8.5 X 3.22 4.67 6.80
and Kd=0.024. Y 3.24 7.01 15.22
From table 1, it shown that the further the letter, the Z 3.56 4.13 26.86
longer the rise time. But this is not always the case. A and
Z as the furthest letter do not have the largest rise time. Time Sampling 5ms: Table 2 shows the summary of this
The largest rise time for the left hand side is for letter experiment with time sampling 5ms. The PID parameters
‘B’. If letter ‘B’ is omitted, then the rise time is increasing are from sub-section 7.3.2, figure 13, i.e. Kp=20, Ki=34
from letter ‘M’ to ‘A’. This is the desired situation. The and Kd=0.1
anomaly of rise time for letter ‘B’ could be due to the The overall performance is better than the previous
mechanic, since the mechanic is not balance. experiment. From the experiments, it was known that
The maximum overshoot of the system for the left sampling time 5ms has better performance than that of
hand side is also varied. Letter ‘M’ has the largest value. with sampling time 20ms.
This is due to its position. To set the P parameter smaller Here the rise time for both sides seems random, i.e.
will solve this problem but the rest of the letter will have there is no specific pattern. But the largest rise time for the
bad performance. left hand side is still letter ’M’. The rise time for the right
For the settling time, there is no specific information, hand side has almost the same pattern as in the sub-section
except that the settling time for letters between ‘J’ and ‘D’ 7.5.1.
has small value. That phenomenon is also happened for the maximum
The rise time for the right hand side letters is wore overshoot and the settling time. This makes the analysis
than the left hand side is. Here, the rise time changes about mechanic instability must be considered.
abruptly from letter to letter. The stability of the mechanic
gives its contribution for this problem.
The maximum overshoot is interesting. The value is IX. CONCLUSIONS
large for the letter close to the initial point. To reduce the
P parameter value will solve this problem but the overall • The time sampling of the system determines the
performance will be bad. performance of the system. Choosing suitable
The settling time for the right hand side seems random. time sampling makes the tuning process easier.
There is no specific pattern. The comparison between 20ms and 5ms shows
that time sampling 5ms is better than the other.
REFERENCES
TABLE 2
PERFORMANCE OF THE SYSTEM FOR EACH LETTER WITH TIME [1] Katsuhiko Ogata. Modern Control Engineering 5th ed. Prentice-
SAMPLING 5ms Hall Inc.
[2] Pick and Place Robot Work Cell [http://www.robots.com/pick-
Letter Rise Max. Over Settling Time and-place-robot.htm]
position Time Shoot (s) [3] Atmel Corporation. AT89S51 Datasheet. January 3, 2005
(s) (%) [http://www.atmel.com/dyn/resources/prod_documents/doc2487.p
df]
A 1.62 0.83 8.05 [4] National Corporation. ADC0809 Datasheet. October 18, 1999
B 1.76 0.00 2.43 [http://www.national.com/ds.cgi/ad/adc0808.pdf]
C 1.70 4.71 4.90 [5] L298 Datasheet. Italy: StMicroelectronics. October 6, 2000
D 1.64 0.00 3.99 [6] National Corporation. DAC0808 Datasheet. January 3, 2005
E 1.67 0.00 8.00 [http://www.national.com/ds.cgi/da/dac0808.pdf]
F 1.62 0.00 2.22 [7] Hartanto, Budi. Pembuatan Program C, Yogyakarta: ANDI, 2003
G 1.86 9.21 5.31
H 1.58 1.42 8.37
I 1.44 1.58 5.41
J 1.79 14.5 1.49
K 1.24 0.00 1.37
L 1.59 17.5 2.96
M 1.89 30.3 9.59
N 1.74 0.00 2.45
O 1.46 14.8 6.46
P 2.05 3.70 3.36
Q 1.43 10.0 2.80
R 1.40 0.00 5.61
S 1.40 10.8 78.20
T 1.91 12.5 44.20
U 1.20 0.00 11.55
V 1.43 1.06 37.65
W 1.58 30.0 24.51
X 1.42 6.48 11.05
Y 1.33 8.77 10.69
Z 1.41 5.78 16.16

• Different time sampling has different PID


parameter combination. So, to change the time
sampling means to tune the combination of the
PID parameters.
• The mechanic gives contribution due to its
stability. Small instability can be compensated by
the controller but it is difficult to compensate the
large instability.
• Large P parameter value makes the system has
large rise time. This is interesting for many
literatures state that large P parameter value will
give small rise time [1]
• The I parameter value must be large in order to
get smaller settling time. I parameter contributes
to the elimination of the steady-state error.
• The D parameter value does not have big
influence, except that the value must be smaller
than 1.
• The combination of PID parameters for time
sampling 5ms is Kp=20, Ki=34 and Kd=0.1.

You might also like