*The result below is simply the Scilab version of the simulation in that article, using the same plant, but now with Xcos model files provided for your convenience. PID-related articles at www.controlsystemslab.com
Manual ZNFD MethodConsider a third-order lag plant with transfer function
(1)with PID feedback control in parallel form
(2)Using Xcos model pid_feedback.zcos shown in Figure 1, we can simulate step response of this closed-loop system. In order to do so, a user may want to achieve a good-enough set of PID parameters to begin with.
Turn off the I and D terms by setting an to zero. The control law reduces to just a proportional gain; i.e., .
Increase from a small value and observe the step response. Try to obtain the value that causes plant output oscillation. At this point the closed-loop system is marginally stable. Further increment destabilizes the system. Write down this value as ultimate gain .
Measure the oscillation period as ultimate period .
With the resulting values of and , compute the controller gains using Table 1.
PID Autotuning based on ZNFD methodWhen a relay is put in place of a controller, it could cause the plant output to oscillate. This is true for a plant with its Nyquist plot crossing the negative real axis. If this is not the case, a relay with hysteresis may be used. For the third-order lag plant (1), a simple relay can be applied. A relay is a nonlinear device. To analyze relay feedback as a linear system, a technique called describing function can be applied. See our previous article, or  for detailed analysis. Here we only summarize the result. For a non-hysteresis relay, its describing function is
(3)Where and are the relay amplitude and plant output magnitude of oscillation, respectively. At the oscillation point, the Nyquist curve must intersect the negative axis at . It concludes that the ultimate gain equals . can then be measured as before. Figure 5 shows an Xcos diagram of a modified PID feedback. pid_autotuning.zcos, equipped with a relay that can be switched in place of controller during tuning phase. Note that the relay is built using SIGN block in series with a gain block to adjust its output magnitude. At the relay input a small bias is needed so that the relay operation could start initially when the plant output is zero.
(4)which matches the value from manual ZNFD obtained earlier. By zooming in the oscillation waveform, it can be verified that oscillation period is close to 3.5 sec. So PID parameters can be computed form Table 1 as before. To summarize, the relay autotuning method helps us achieve the same and values as the manual ZNFD, without the risk of destabilizing the system. In a real application, and can be computed from data captured in real-time during the tuning phase, and the PID parameters computed according to Table 1. C code example is provided in our previous article .
Xcos files used in this article
pid_feedback.zcos : simple PID feedback fin Figure 1
pid_autotuning.zcos : PID feedback with autotuning relay in Figure 5
K.J.Astrom and T. Hagglund, PID Controllers, 2nd ed., Instrument Society of America, 1995.
V.Toochinda, Digital PID Controllers, www.controlsystemslab.com, 2011.