Module 4: PID ControlThis article is contained in Scilab Control Engineering Basics study module, which is used as course material for International Undergraduate Program in Electrical-Mechanical Manufacturing Engineering, Department of Mechanical Engineering, Kasetsart University.
Module Key Study Points
- understand the basics of PID control
- learn the effects of 3 parameters to system response
- learn how response is degraded by integrator windup
- How to tune PID parameters by Ziegler-Nichols Frequency Domain method
Different forms of PIDThe so-called “textbook” form of PID controller is described as follows
(1)This algorithm computes the control variable as output, given the input , the error between the command and plant output. We see that the control variable is a function of 3 terms: P (proportional to error), I (time integral of error), and D (derivative of error), with corresponding control parameters (proportional gain), (integral time), and (derivative time), respectively. Taking Laplace transform of (1), we have
(2)with the transfer function of PID controller
(3)Another common structure of PID algorithm is represented by
(4)In this form, the controller gains are distributed to each of the PID terms separately, with its transfer function
(5)For our discussion of PID controller, we focus on the form (4) and (5). Nevertheless, it is easy to convert between parameters of (1) and (4) by the relations
(6)Ex. 1: To get started with Xcos simulation of a PID feedback system, download file pid_feedback.zcos . This launches an Xcos diagram in Figure 1. This diagram can easily be constructed using Xcos standard palettes. It requires only a step_function, clock_c (from Sources palette), PID and CLR blocks (from Continuous time systems palette), SUMMATION (from Mathematical operations palette), MUX (from Signal Routing palette), and CSCOPE (from Sinks palette). The plant transfer function is a robot joint driven by DC motor model from module 1, with and .
(8)For example, suppose we select a critical-damped closed loop system , with natural frequency . From (8), this yields and . Table 1 below gives calculated P and D gain values for 3 selected natural frequencies.
(9)with the characteristic polynomial
(10)Applying Routh-Hurwitz criteria to (10), it can be concluded that, given all positive PID gains, the feedback system is stable if
(11)The same Xcos diagram in Figure 3 can be used by putting some positive integral gain in the PID block. Let us fix and , corresponding to natural frequency rad/s. Figure 5 shows the responses from setting some values of . We see that the steady-state error to command and disturbance is eliminated by increasing , though higher value could introduce more overshoot.
This can be verified by setting . The oscillating response in Figure 6 shows that the closed-loop system is at the brink of stability.
Effect from SaturationAnalysis of PID feedback control is often performed under the assumption that the system is purely linear. In real devices, nonlinear elements emerge at certain points in the feedback loop. Saturation is one of them that could cause undesirable system response. This nonlinear effect normally results from physical limits of signals and system parameters, say, maximum motor torque and current. Another common saturation is the input limit of servo amplifier. An industrial servo amp might allow input voltage command in the range volts, for example. Effect from saturation is more pronounced when integral term is used in PID. The response could have excessive overshoot due to error accumulation in the integral term. This is known as integrator windup. See  for more detail. Ex. 3: To see an effect from input saturation, construct an Xcos model as in Figure 7, or download pid_ilim.zcos. It represents a comparison of two closed-loop systems, which are basically the same except that the lower one has its input bounded between units.
Tuning the PID ParametersAs stated before, adjusting the PID gains from scratch to achieve a good response may not be trivial. As a result, most commercial PID controllers have functions to tune the 3 parameters automatically. This is normally called “autotuning” feature. One of autotuning methods suggested in the literature makes use of some relay feedback mechanisms, which is closely related to a manual tuning scheme known as Ziegler-Nichols Frequency Domain (ZNFD) method. Hence we discuss this ZNFD scheme in the last part of this module. Note: The original ZNFD method applies the “textbook” PID equation (1). But since (1) and (4) are closely-related by (6), here we make a conversion so that standard PID block in Xcos, which assumes the form (4), can be conveniently used. To tune a PID controller manually by ZNFD method, follow this procedure
- turn off both the integral and derivative terms; i.e., setting . So now the PID is left only with the proportional gain . We crank up to the point that the closed-loop system starts to oscillate. At this point, the plant output will swing in a constant sinusoid motion, not growing and not dying out. Write this value down on a paper as .
- Measure the period of oscillation. Write it down as .
- Use Table 2 to tune the controller parameters
(12)To simulate, construct an Xcos model in Figure 10, or download pid_znfd.zcos. With this model, we are ready to perform the ZNFD tuning procedure described above. Click on the PID block to set the I and D gains to zero. Then start increasing the P gain until the output oscillates. This is what you must do in a real application when the plant model is not known.
Then find the gain where the closed-loop pole touches the axis.
-->kp = 1; -->ki = 0; -->kd = 0; -->s=poly(0,'s'); -->P=syslin('c',1/(10*s^2+0.1*s)); // plant -->H = syslin('c',1/(1+0.0003*s)); // filter -->C=syslin('c',kp + ki/s + kd*s); // controller -->L = C*H*P; // loop t.f
resulting in . Verify this by setting the P gain to 333 in PID block. This yields the desired oscillatory response as shown in Figure 11. The oscillation period can be roughly measured from the plot to yield sec.
->[kmax,s]=kpure(L) s = 5.7735027i kmax = 333.33433
Setting these gains gives the response in Figure 12.
SummaryPID is a simple control structure that is still used widely in various industrial applications. It is a close relative to the lead-lag compensator explained in module 2, except that its functionality may be more user-friendly. With some knowledge and practice, an engineer or technician would be able to tune and operate a plant equipped with PID control. In this module we discuss the basics of PID feedback systems, with emphasis on Xcos simulations to show how the responses are related to three control parameters, as well as effect from input saturation that could worsen the response. Without some good starting values, tuning the PID gains can be cumbersome for a novice. So at the end, we mention a manual tuning procedure known as the Ziegler-Nichols frequency domain method. Some auto-tuning scheme of a commercial PID controller, such as the relay feedback method, is based on the ZNFD manual tuning.
- K.J. Astrom and T.Hagglund. PID Controllers, 2nd ed., Instrument Society of America, 1995.
- M.W.Spong, S. Hutchinson and M. Vidyasagar, Robot Modeling and Control. John Wiley & Sons. 2006.
- V. Toochinda. Digital PID Controllers, a previous online document available at controlsystemslab.com. 2009.
- V.Toochinda. Robot Analysis and Control with Scilab and RTSX. Mushin Dynamics, 2014.