Lab 3 - 4 Scilab

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 8
At a glance
Powered by AI
The key takeaways are to learn how to design and tune a PID controller for a given system and understand the effects of the P, I, and D terms on the controller performance.

The objectives of the lab are (i) to design a proportional-integral-derivative (PID) controller for closed loop control and (ii) to compare the performance of different controllers based on maximum overshoot, rise time, settling time and steady-state error.

The three terms of a PID controller are the proportional (P) term, the integral (I) term, and the derivative (D) term.

1.

Objectives
(i) (ii) To design proportional-integral-derivative (PID) controller for closed loop control. To compare the performance of different controllers based on maximum overshoot, rise time, settling time and steady-state error.

2. Introduction
In this lab, you will learn the characteristics of the each of the proportional (P), integral (I) and derivative (D) control terms, and how to use these terms to obtain a desired response. Consider the following unity feedback system: R + Figure 1 Plant: A system to be controlled Controller: Provides the excitation for the plant; designed to control the overall system behaviour The three-term PID controller The transfer function of the PID controller is K K s2 + KP s + K I GC ( s ) = K P + I + K D s = D s s where KP = proportional constant; KI = integral constant; and KD = derivative constant. The P term, I term and D term are given by P term: KP K I term: I s D term: KDs First, let's take a look at how the PID controller works in a closed loop system using Figure 1. The variable e = (R Y) represents the tracking error, which is the difference between the desired input value R and the actual output Y. This error signal e will be sent to the PID controller, and the controller computes both the derivative and the integral of this error signal. The control signal u produced by the controller is given by
u = K p e + K I e dt + K D de dt

Controller

Plant

The signal u will form the input to the plant, producing the output Y. The output Y will be 1

fedback (via a sensor) to allow the error signal e to be recalculated. The controller takes this new error signal and computes its derivative and its integral again. This process is continuous and goes on and on. The objective is to minimise e. In the ideal case, e = 0 and Y = R. The characteristics of P, I and D controllers A proportional controller will have the effect of reducing the rise time and will reduce, but never eliminate, the steady-state error. An integral controller will have the effect of eliminating the steady-state error, but it may make the transient response worse. A derivative controller will have the effect of increasing the stability of the system, reducing the overshoot, and improving the transient response. The general effects of increasing each of KP, KI and KD on a closed loop system are summarised in Table 1. Table 1 CLOSED LOOP OVERSHOOT RESPONSE KP Increase KI Increase KD Decrease RISE TIME Decrease Decrease Small Change SETTLING TIME Small Change Increase Decrease STEADY-STATE ERROR Decrease Eliminate Small Change

Note that these correlations may not be exactly accurate, because the effects of KP, KI and KD are dependent on one another. Changing one of these variables can change the effects of the other two. For this reason, Table 1 should only be used as a reference when you are determining the values for KP, KI and KD. Time domain performance measures Maximum overshoot: Let ymax denote the maximum value of y(t) and yss be the steady-state value of y(t) and ymax yss. The maximum overshoot of y(t) is defined as Maximum overshoot = ymax - yss Rise time: The rise time is defined as the time required for the step response to rise from 10% to 90% of its final value. Settling time: The settling time is defined as the time required for the step response to reach and stay within a specified percentage (5%) of its final value.

3. Example system
Suppose we have a simple mass, spring, and damper system as in Figure 2. b x F

M k Figure 2 The physical equation of this system is

Taking the Laplace transform and assuming zero initial conditions,


M s
2

M x + b x+ k x= F

X ( s ) +bsX ( s ) +kX ( s ) = F ( s )

The transfer function between the displacement X(s) and the input F(s) then becomes
X ( s) 1 = 2 F ( s ) Ms + bs + k

Let M = 1kg b = 10 N.s/m k = 20 N/m F(s) = 1/s F is a step input of magnitude 1


X (s) 1 = 2 F ( s ) s + 10 s + 20

Substituting these values into the above transfer function gives

The objective of this example is to tune KP, KI and KD to obtain Fast rise time and settling time Minimum overshoot No steady-state error

4. Procedures
4.1 Open loop system (i) To view the open loop step response, first create a new SCE-file by clicking Editor in the SCILAB command window. A SCILAB editor/debugger window known as SciPad will pop up. (ii) In this window, type the following codes and save the file.
s=%s; num = 1; den = (1*s^2 + 10*s + 20); t=linspace(0,2,200); tf = num/den; rsys = syslin('c',tf); stepresp=csim('step',t,rsys); plot2d(t,stepresp); xgrid();

Here, num denotes the numerator polynomial and den denotes the denominator polynomial. linspace, syslin, csim, plot2d and xgrid are SCILAB functions. To find out more about these functions, type help function_name at the SCILAB command prompt. (iii) Run the SCE-file by clicking Execute Load into Scilab in the SCILAB editor/debugger window. You should get the plot shown in Figure 3.

Figure 3 (iv) Check the final value using Final Value Theorem. An example is shown in Table 2. (v) From the response obtained, find the maximum overshoot, rise time and settling time. Complete the relevant parts in Table 3. (The steady-state error should be calculated based on Final Value Theorem.)

4.2 Proportional control (i) The closed loop transfer function of the above system with a proportional controller is
Kp X ( s) = 2 F ( s ) s + 10 s + ( 20 + K p )

(ii)

Show the derivation of the closed loop transfer function in Table 2. Let the proportional constant KP equal 300 and change the SCE-file to the following:
s=%s; Kp=200; num = Kp; den = (1*s^2 + 10*s + (20+Kp)); t=linspace(0,2,200); tf = num/den; rsys = syslin('c',tf); stepresp=csim('step',t,rsys); plot2d(t,stepresp); xgrid();

(iii) Run this SCE-file to obtain the step response plot. The plot should show that the proportional controller reduces the rise time, the settling time and the steady-state error, but increases the overshoot. (iv) Complete the relevant entries in Tables 2 and 3. 4.3 Proportional-Derivative control (i) Derive the closed loop transfer function of the given system with a PD controller and record this in Table 2. (ii) Let KP equal 300 as before and let KD equal 10. Create a new SCE-file, type the necessary codes and run the SCE-file. (iii) Complete the relevant entries in Tables 2 and 3. 4.4 Proportional-Integral control (i) Derive the closed loop transfer function of the given system with a PI controller and record this in Table 2. (ii) Reduce KP to 30, and let KI equal 70. Create a new SCE-file, type the necessary codes and run the SCE-file. Note that we have reduced the proportional constant because the integral term also reduces the rise time and increases the overshoot as the proportional term does (double effect). (iii) Complete the relevant entries in Tables 2 and 3. 4.5 Proportional-Integral-Derivative control (i) Derive the closed loop transfer function of the given system with a PID controller and record this in Table 2. (ii) There are several methods to choose the parameters KP, KI and KD. One of the methods is by trial and error using Table 1 as a guide. Try at least 4 sets of values for KP, KI and KD and note the closed loop step responses. When choosing the values of KP, KI and KD, try to vary one parameter at a time, in order to see the effects of changing the parameter. Record 5

these in Table 3. (iii) Repeat using KP = 350, KI = 300 and KD = 50. (iv) Complete the relevant entries in Tables 2 and 3. Table 2 4.1 Open loop Transfer function:
X (s) 1 = 2 F ( s ) s + 10 s + 20

No. of finite zeros = 0 No. of poles = 2 System order = 2

Final value: lim x (t ) = lim sX ( s )


t > s >0

1 1 1 = lim s 2 = s >0 s s + 10 s + 20 20

4.2 P control

Transfer function:

No. of finite zeros = No. of poles = System order =

Final value:

4.3 PD control

Transfer function:

No. of finite zeros = No. of poles = System order =

Final value:

4.4 PI control

Transfer function:

No. of finite zeros = No. of poles = System order =

Final value:

4.5 PID control Transfer function:

No. of finite zeros = No. of poles = System order =

Final value:

Table 3 Controller 4.1 Open loop 4.2 P 4.3 PD 4.4 PI 4.5 PID KP 300 300 30 KI 70 KD 10 Maximum overshoot Rise time (s) Settling time (s) Steadystate error

350

300

50

5. Exercises
1. Perform a block diagram reduction to obtain a single transfer function for the system with P control. 2. For the system with PD control, calculate the closed loop system poles. Hence, state whether the closed loop system is overdamped, critically damped or underdamped. 3. Explain why there is no steady-state error when using PI control. 4. Give some advantages of minimizing the settling time. 5. Find the system type for the system without any controller, and the systems with P, PD, PI and PID controllers.

6. Discussion
In this lab, you have learned how to design a PID controller for a given system. You have also seen the effects of varying each of the P, I and D terms on the controller performance. In general, when designing a PID controller for a given system, follow the steps shown below to obtain a desired response: 1. Obtain an open loop response and determine what needs to be improved. 2. Add a proportional term to improve the rise time. 3. Add a derivative term to improve the overshoot. 4. Add an integral term to eliminate the steady-state error. 5. Adjust each of KP, KI and KD until you obtain a desired overall response. Please keep in mind that you do not need to implement all three terms (proportional, derivative and integral) into a single system. For example, if a PI controller gives a sufficiently good response (like in the above example), then you do not need to implement a derivative term in the system. Keep the controller as simple as possible.

You might also like