Figure 1 shows a more complicated Xcos PID diagram advpid.zcos used for simulation. The diagram has 2 feedback loops for comparison. The upper loop contains a simple PID block provided by Xcos. The controller used in the lower loop, on the other hand, is an advanced PID with the following additional features
To lessen the effect of measurement noise, derivative part is implemented as a filter with parameter
Back calculation anti-windup scheme is implemented with tracking gain
Setpoint weightings for proportional and derivative paths can be adjusted via and , respectively
The user interface should appear, with some default values for the parameters and their ranges. You can edit the script file to put in your choice of values. Note also that running the script file closes all other graphic windows. If that is undesirable, remove the command xdel(winsid()); at the top. A nicer way to override the parameter values is to create another setup file with your plant and parameters tailored to that plant. The script advpid.sce contains the following commands that create a plant and parameters tuned by ZNFD method.
Launch this script
s = poly(0,'s'); // plant used in Astrom and Hagglund book P = syslin('c',1/(s+1)^3); // pid gains for above plant // tuned by ziegler nichols frequency response method ku = 8; // ultimate gain tu = 3.5; // ultimate period kp = 0.6*ku; ki = kp/(0.5*tu); kd = 0.125*kp*tu; N = 10; // kt = 1.2; // back calculation gain for anti-windup
and import parameter values into PIDGUI by clicking the [Restore] button. Now launch the Xcos model advpid.zcos in Figure 1. Click Simulation-Start. We would see a response comparison between the upper loop (standard PID) and lower loop (advanced PID) . They do not differ much at this time because the saturation limits are large. Try reducing them to, say, a limit for 12-bit DAC. In the Saturation Limits section of PIDGUI, put -2047 and 2047 to the lower and upper edit boxes, respectively. Run the simulation again. You ‘d see the result shown in Figure 3.
Change the variable names in Scilab To Workspace blocks for each simulation run, and plot them after finished.
Saturation EffectsAt first launch, the saturation limits are set to +/- 1e6, which are so high like there is virtually no limit. Reduce them to +/- 10000, 5000, 2000, 1500, while maintaining other parameters. Figure 4 shows that saturation effects in this case does not cause larger overshoot, but introduce lags in the response.
Anti-Windup PerformanceThe plot shown in Figure 6 of our article PID Anti Windup Schemes can be observed by adjusting the back calculation gain , click [update] and run the simulation.
Proportional Setpoint WeightingIn a sense, setpoint weighting can be thought of as a modest feedforward control. In the Xcos diagram, the error input to the proportional section of the controller is
(1)i.e., the command is weighted by , with range 0 – 1. Figure 5 shows the responses with 5 values of : 1, 0.75, 0.5, 0.25, 0. We see that decreasing could improve overshoot, though too small a value worsens the rise time.
Derivative Setpoint WeightingSimilar to the proportional case above, the error input entering the derivative part is given by
(2)with ranges between 0 – 1 as well. Figure 6 shows the responses with = 1, 0.75, 0.5, 0.25, 0. From this result, the advantage of using derivative weight on this plant and PID gain setup is not obvious.
ConclusionWe call this controller a decorated PID because it contains a couple more features than standard PID controller. The anti-windup function makes this controller nonlinear. This fact makes feedback analysis more challenging, but at least simulation results could help with the learning process. PIDGUI is a simple user interface designed to aid parameter adjustments before simulation, so the reader could concentrate more on feedback system behavior. All files are provided below for you to download and experiment by yourself. The Xcos file accepts any continuous-time plant transfer function P created by syslin command.
SupplementScilab and Xcos files used in this article
pidgui.sce the user interface in Figure 2
advpid.sce setup file for Xcos model
advpid.zcos Xcos simulation model in Figure 1