1
Lecture 26 Emulation of Continuous Control by Discrete Control
In this lecture we focus on emulating a continuous feedback control system by a discrete one, as shown in Figure 8.1. The term emulation means to emulate = to behave as. Specifically, we desire to determine a difference equations to be acted upon by a digital computer, such that the behavior of the discretized control system will emulate the behavior of the analog one. This is illustrated in Figure 8.1 on .592. There are two key points in this figure:
(i) A ZOH D/A converter is used to transform numbers into voltages.
(ii)The ‘Difference equations’ block corresponds to a digital system transfer function.
Example [See EXAMPLE 8.1 and 8.2 and section 8.6.1]
(a)(i) Use the Tustin and ZOH methods to convert the analog controller to a difference equation forin the recursive form.
, so that c2d(Gc,T,’tustin’) gives . Hence,
, which gives , or
.
(ii)Use the ZOH method to convert the analog controller to a difference equation forin the recursive form.
c2d(Gc,T,’zoh’) gives . Hence,
, which gives , or
.
%(a):
Gp=tf(1,[1 1 0]);
Gc=10*tf([0.5 1],[0.1 1]);
K=10;
T=0.025;
z=tf('z',T); s=tf('s');
Gpz=c2d(Gp,T,'zoh');
GcTUS=c2d(Gc,T,'tustin');
GcZOH=c2d(Gc,T,'zoh');
(b)Overlay the three controller Bode plots, and discuss them.
The Bode plots at right are all very similar. The Tustin controller does a slightly better job than the ZOH controller. The high frequency gain of the latter is a bit high; as is the maximum phase.It should be noted that these plot relate only to the difference equations. They do not include the ZOH D/A circuit that follows them.
%(b): CONTROLLER OUTPUT BODE PLOT
figure(1)
bode(Gc,GcTUS,GcZOH)
legend('G_c','G_cTUS','G_cZOH')
grid
(c)For the plant , the open loop is . Develop the open loop transfer function (including the ZOH D/A converter) for the digital system using the Tustin digital controller.
.
To transform the term to the z-domain, we can use Table 8.1 on p.596, or we can use the e-table commands:
> Q=tf(1,[1 1 0 0]);
> Qz=c2d(Q,T,'imp')
Qz =(7.748e-06 z^2 + 7.684e-06 z + 1.885e-19)/( z^3 - 2.975 z^2 + 2.951 z - 0.9753)
Clearly, this does not have the form in Table 8.1: . Let’s see if we can reconcile the difference, by reducing this form to numbers for .
. Now, we can clearly ignore the 1.885e-19 term in Matlab’s form. After doing this, Matlab’s numerator becomes: . Regarding our denominator, we have
. This is nearly identical to Matlab’s denominator**. Hence, Matlab’s form becomes. The only remaining difference is in relation to the constant factors in the numerator. Recall that Table 8.1 does not include the factor of , whereas Matlab’s e-table does include it. If we include this factor, then our numerator changes from to , which is nearly the same as Matlab’s. Hence, we can conclude that Matlab’s e-table does, indeed, give the desired transfer function.Hence, the digital OL TF is . We can express this as
.(1)
The reason for formulating this expression is that we can arrive at the expression for very simply using the Matlab command: > R=c2d(Gp,T,'zoh') =(0.0003099 z + 0.0003073)/(z^2 - 1.975 z + 0.9753). This is exactly .
** While the denominators are the same, if we use the ‘roots’ command in relation to Matlab’s numerator we obtain:
> roots([1 -2.975 2.951 -.9753]) = [ 1.0344 +/- 0.0792i ; 0.9062]. Looks can be deceiving
The point of going through the above exercise was to verify the fact that Matlab’s c2d command with the ‘zoh’ flag can be used not only to arrive at a digital controller, but also to incorporate a real ZOH A/D converter, and then arrive at .In doing so, we also verified, again, that c2d the ‘imp’ flag is an e-table of Laplace/z-transforms (albeit, one that includes an extra factor of T relative to the table in the book).
(d) Overlay CL controller and command step responses of the analog system and the two digital systems. Then discuss them.
The CL controller output step responses at left show that both digital CL controller output systems respond similarly, and that they approximate the analog response fairly well. The same can be said for the CL command output step responses. Both have a slightly higher overshoot than the analog response.
%(d):
%Controller Output Step Response:
Wc=feedback(Gc,Gp);
WcTUS=feedback(GcTUS,Gpz);
WcZOH=feedback(GcZOH,Gpz);
figure(3)
step(Wc,WcTUS,WcZOH)
title('CL Controller Output Step Response')
legend('W','WTUS','WZOH')
grid
%Command Output Step Response:
G=Gc*Gp;
GzTUS=GcTUS*Gpz;
GzZOH=GcZOH*Gpz;
WzTUS=feedback(GzTUS,1);
WzZOH=feedback(GzZOH,1);
figure(4)
step(W,WzTUS,WzZOH)
title('CL Command Output Step Response')
legend('W','WTUS','WZOH')
grid
Remark 1. A careful inspection of the controller output and closed loop step responses of the digital controllers reveals the difference between the Tustin and ZOH controllers. The former hold the midpoint between each two successive values of the latter.
Remark 2. Matlab offers a variety of flags in the c2d command. One must be careful to choose the appropriate flag for a given task. For example, either of the ‘zoh’ and ‘tustin’ flags can be used to obtain the controller difference equation. When the task is to include the ZOH A/D converter in the forward loop, then one must use the ‘zoh’ flag when converting the analog plant to a digital one.
Remark 3. In relation to plotting time domain responses of digital systems, Matlab might plot them as staircase functions, or as continuous functions. In fact, they are discrete time responses. Hence, they should be plotted as points. For example, our controller output step responses are exactly those in the book’s Figure 8.9(b) and 8.10(b). In both figures, the digital controller responses should, ideally, be plotted as points. Moreover, in relation to the CL unit step responses, the book’s Figure 8.9(a) and Figure 8.10(a) plot the discrete responses as continuous functions. Ideally, they should also be plotted as points, if only to emphasize that they are, indeed, a valid comparison against the analog response only at the sample times. This distinction is highlighted in the book Figure 8.17.