Lecture 2: PID Control of a cart

advertisement
Lecture 2: PID Control of a cart
Venkata Sonti∗
Department of Mechanical Engineering
Indian Institute of Science
Bangalore, India, 560012
This draft: March 12, 2008
1
Proportional Integral Derivative (PID) Control
PID control is a very useful method used in feed-back control systems. The error generated after
the comparison between the measured signal and the target signal is proportionally multiplied
(proportional), integrated (integral) and differentiated (derivative) and the outputs of the three
operators are linearly summed to generate the signal applied to the actuator. This is shown in
figure 1.
r(t)=10
R(s)
+
-
1
kp + kI+ kds
s
ms+b
c(t)
C(s)
Figure 1: Block diagram for a PID controller.
Before starting, for the closed loop system shown in figure 2 the transfer function between
output and input is given by
G
TF =
1 + GH
2
PID cruise control of a cart
Problem statement:A constant force F is applied on a cart of mass m as shown in figure 3. There
is a drag force on the cart which is proportional to the velocity. For m = 1000, b = 50N sec/m and
F = 500N the design specification is that the cart should reach 10m/sec in less than 5 seconds;
with less than 10% overshoot and less than 2% steady state error.
Solution:The equation of motion can be written for the velocity and is as follows
mV̇ (t) + bV (t) = F
∗
1
(1)
r(t)
+
-
c(t)
G
H
Figure 2: Closed loop system transfer function
V
V
bv
M
F
Figure 3: A force applied to a cart. Cruise control.
y(t) = V (t)
(2)
Taking the LT of the above equations we get
msV (s) + bV (s) = F (s)
(3)
Y (s) = V (s)
F (s)
Y (s) =
ms + b
(4)
The block diagram and the step response for this open loop system are shown in figure 4.
It can be seen that the cart reaches the velocity of 10m/sec at around 100 secs. In order to
reach the design spec., let us attempt a simple proprtional controller the block diagram for which
is shown in figure 5.
2.1
Proportional controller
The closed loop transfer function after applying the proportional controller is given by
Y (s) =
Kp
R(s),
ms + (b + Kp)
where Kp is the proportional gain and R(s) = 1/s, the LT of a step input. It can already be seen
that for very large Kp, Y (s) = R(s). Lets see the step response of the proportional controller for
a Kp = 100 and Kp = 600.
2
Step Response
From: U(1)
10
r(t)
R(s)
actuator
1
ms+b
6
To: Y(1)
Amplitude
8
4
c(t)
2
C(s)
0
0
20
40
60
Time (sec.)
80
100
120
Figure 4: Step response of the cart. open loop.
10
Step Response
Proportional Controller Kp=100 and Kp=600
Kp=600
r(t)=10
+
R(s) -
Kp
1
ms+b
c(t)
C(s)
6
Kp=100
To: Y(1)
Amplitude
8
4
2
0
0
5
10
15 20 25
Time (sec.)
Figure 5: Proportional controller. Kp=100 and 600.
3
30
35
40
Figure 5 shows the response after proportional control for the two values of Kp = 100, 600.
It can be seen that there is a steady state error which can be reduced by increasing the gain Kp.
Thus, a proportional controller itself should ’ideally’ suffice. However, the Kp value needed is
actually very large for 2% steady state error, which may not be deliverable by your amplifier. And
even if one has such an amplifier, in actuality there are a large number of noise sources corrupting
the signals which when amplified will send the system to instability. (large gain can make the
system unstable).
Note, that at steady state, if we use the Final Value Theorem and drop the ms term, then
Y (s)b = (R(s) − Y (s)Kp,
which means Kp has to be infinite for R − Y to be zero. Y (s)b is the drag force. Thus, the
proportional force is used up in overcoming the drag force. If the target value is reached by Y(s)
then error is zero, and the proportional force is zero. In the absence of any force, the velocity will
reduce due to drag. It will reduce till a balance is reached as in the above equation.
2.2
Proportional-Integral controller
In order to remove the steady state error, we use an Integral controller. The block diagram is
given in figure 6.
r(t)=10
1
ms+b
k
kp + sI
+
R(s) -
c(t)
C(s)
Figure 6: Block diagram for a PI controller.
The resulting closed loop transfer function is given by
Y (s) =
ms2
Kps + Ki
R(s)
+ (b + Kp)s + Ki
The immediate observation from the above transfer function is that the Integral controller raises
the order of the system (no. of poles). We will also see that it completely eliminates the steady
state error (even for a small value of Ki). The curves in figure 7 show the response for the PI
controller for Ki = 5, 40, 200 and Kp = 600. The response for a Ki = 5 is going towards 10m/sec
at a slow rate. The right figure is a zoomed version of the left side curve.
It is worth noting that along with eliminating the steady state error, Ki reduces rise time
(response is quicker), but causes an overshoot (which may be undesirable).
Let us find the error expression, E(s) = R(s)-Y(s)
E(s) = R(s) −
ms2
Kps + Ki
R(s)
+ (b + Kp)s + Ki
4
(5)
Prop−Int Kp=600 and Ki=5,40,200
Prop−Int Controller Kp=600 and Ki=5,40,200
From: U(1)
12
12
Kp=600, Ki=200
Kp=600, Ki=40
Kp=600, Ki=200
Kp=600, Ki=40
10
10
Kp=600, Ki=5
Kp=600, Ki=5
Amplitude
To: Y(1)
Amplitude
8
6
To: Y(1)
8
6
4
4
2
2
0
0
50
100
Time (sec.)
150
200
0
0
5
10
Time (sec.)
15
20
Figure 7: PI controller. Kp=600,Ki=5,40,200.
=
=
(ms2 + (b + Kp)s + Ki)R(s) − (Kps + Ki)R(s)
ms2 + (b + Kp)s + Ki
(ms2 + bs)
R(s)
ms2 + (b + Kp)s + Ki
The integral controller, integrates this error. Integration is multiplication by 1/s in the Laplace
domain. And then replace R(s) with 10/s, then take the final value theorem.
IE(s) =
(ms2 + bs)
10
1
s ms2 + (b + Kp)s + Ki s
Taking the final value theorem
Lim s − − > 0 sIE(s) = Lim s − − > 0
(ms + b)
10
ms2 + (b + Kp)s + Ki
This is 10b/Ki, which when multiplied by Ki (to get the integral controller force) is 10b=500N!
3
PID Controller
The full PID controller is shown in figure 8 and is compared with the previous PI controller. The
effect of the derivative controller is seen as a damping effect, reducing the overshoot and also
reducing the settling time.
After experimenting with gain values we can even achieve the following. Using the values
given the following response is obtained. (figure 9). This meets all the specs.
4
Behavior of the PID controller gains
In this section we will try to get a first cut understanding of why the PID gains have the effects
that they do.
5
PID controller Kp=600, Ki=200, Kd=400
12
Kp=600, Ki=200
Kp=600, Ki=200, Kd=400
10
Amplitude
8
r(t)=10
R(s)
+
-
4
c(t)
C(s)
1
kp + kI+ kds
s
6
ms+b
2
0
0
5
10
Time (sec.)
15
20
Figure 8: PID controller. Kp=600, Ki=200, Kd=400.(compared with the previous PI controller).
Step response with PID, Kp=1500,Ki=100,Kd=400
12
10
Amplitude
8
6
4
2
0
0
5
10
15
20
25
30
Time (sec.)
Figure 9: PID controller. Kp=1500, Ki=100, Kd=400.(compare with the previous PID controller).
Table 1: PID gains and their effects on second order response characteristics.
PID Gain Rise Time Overshoot Settling Time
SS-Error
Kp
decrease
increase
small effect
decrease
Ki
decrease
increase
increase
eliminate
Kd small effect
decrease
decrease
small effect
6
4.1
The proportional gain Kp
The proportional controller gives an output directly porportional to the error between r(t) and
c(t) and hence it should reduce the rise time tr and the steady state error. It does not eliminate
the steady state error and we will answer this later. If the error goes to zero E(s) is zero then
output of the controller is zero and the system will slow down with damping. There could be a
response C(s) such that (R(s)-C(s)) Kp is such that it is equal to C(s)*(Ms+b). This is the value
at which the system stabilizes with a non-zero steady state error.
It also causes an overshoot which is understandable. Only when the sign on the error has
changed that the Kp begins to reduce the overshoot which is a little late. Kp does not anticipate
an overshoot and reduce the applied force.
4.2
The integral gain Ki
step response, error and derivative of error
1.6
B
1.4
1.2
A
E
0.8
To: Y(1)
Amplitude
1
Step response
C
D
0.6
0.4
D
0.2
0
Error
A
E
C
−0.2
Derivative of error
−0.4
B
0
0.2
0.4
0.6
0.8
1
Time (sec.)
Figure 10: Explanation for Ki and Kd behavior.
The integral controller reduces the rise time, causes an overshoot, increases the settling time
(reduces damping) and most importantly eliminates the steady state error.
If the zero error point is reached, i.e., or r(t) = c(t) and the system say (hypothetically)
remains there steadily, then the proportional controller does not apply any force, nor does the
derivative controller and so the response will slowly fall because of zero force. For example, in the
cart example, if the final velocity is reached and the external force stops acting, the drag force
will slowly stop the cart. Hence, even when the error is zero a steady force needs to be applied.
The integral controller does this.
The integral controller integrates the error e(t) = r(t) − c(t) and then multiplies it with a
gain Ki . At time t = 0, the initial error e(t) is large since the system starts from zero response
c(t) = 0 and so the integral quickly rises which in turn increases c(t) till it reaches r(t) at point A
(figure 10). At this instant e(t) is zero but not its integral which actually has its maximum value
say φ. However, due to inertia, c(t) crosses r(t) and error becomes negative. Let us suppose that
this positive value φ is sufficient to hold the steady value of 10m/sec. However, as the overshoot
7
has occurred, and in parallel the integral value (and the applied force) starts to decrease, the
applied force is insufficient to hold the overshot velocity value at point B (drag is high due to
high velocity and force is low). The insufficient force and drag bring velocity down. Since, by
overshooting, the total integral value falls below φ, even 10m/sec cannot be held (because 10m/sec
can be held by φ). The velocity has to fall and settle below the r(t) = 10 value. Here, the error
turns positive and the cycle begins again.
It should be noted that the sign of e(t) cannot remain either positive or negative for long. The
integral controller will not allow that. Let us say (hypothetically) that the velocity falls below
the value at B, but does not cross over to below r(t). Then, error remains negative and when
integrated over a long time, the force due to the integral controller will become negative. This
should result after a while in a negative velocity. A negative velocity compared with r(t) becomes
r − (−c) = r + c a positive error which should integrate to a positive force leading to a forward
velocity.
This also tells us why an overshoot occurs. At the initial stage when the response begins at
c(t) = 0, the error e(t) being maximum, the controller output is not just a proportional multiplier
but an integrator. This integral of the error rises faster than a mere proportional multiplication.
And although when c(t) rises and crosses r(t) for the first time, the e(t) = 0, the integral by no
means is zero and so gives an overshoot. This is also the reason for a reduced rise time tr and
increased settling time.
4.3
The derivative gain Kd
Kd is the derivative control gain. At steady state, since the derivative is zero the output of
derivative controller is zero. Thus, Kp and Kd are more active at high transients, i.e., at the
initial response stage.
The important function of Kd is to reduce overshoot and reduce settling time. Right at the
start of response, the error is positive and it remains so till pt. A. However, from start to pt. A,
the error derivative is negative. At pt. A, the e(t) changes sign which causes the Kp and Ki terms
to retard the motion and even here the Kd remains negative assisting Kp and Ki, thus reducing
overshoot. Finally at the response peak, pt. B as the response starts accelerating downwards, Kd
just turns positive retarding this negative acceleration and continues to do so till the negative peak
D is reached. At D, the response is building for a positive acceleration and Kd become negative
to counter this. Thus, Kd damps out developing-accelerations in an anticipatory manner. For the
same reason, Kd reduces settling time.
8
Download