8. Design of a digital controller#

8.1. Introduction#

During recent decades, the design procedures for analog control systems have been well formulated and a large body of knowledge accumulated. The analog-design methodology, based on conventional techniques of root locus and Bode plots or the timing method of Ziegler and Nichols, may be applied to designing digital control systems. The procedure would be to first design the analog form of the controller or compensator to meet a particular set of performance specifications. Having done this, the analog form can be transformed to a discrete-time formulation. This approach is based on the fact that a digital system with a high sampling rate approximates to an analog system. The justification for using digital control under these circumstances must be that the practical limitations of the analog controller are overcome, the implementation cheaper, or that the supervisory control and communications more easily implemented.

However, the use of high sampling rates wastes computer power, and can lead to problems of arithmetic precision, etc. One is therefore driven to find methods of design which take account of the sampling process.

The alternative approach is to design controllers directly in the discrete-time domain based on the time-domain specifications of closed-loop system response. The controlled plant is represented by a discrete-time model which is a continuous-time system observed, analyzed, and controlled at discrete intervals of time. Since the time response is the ultimate objective of the design. This approach, which we shall now consider, provides a direct path to the design of digital controllers. The features of direct digital design are that sample rates are generally lower than for discretized analog design, and the design is directly ‘performance based‘.

Figure 21 shows the basic structure of a digital control system. The design problem generally evolves around the choice of the control function D(z) in order to import a satisfactory form to the closed-loop transfer function. The choice is constrained by the form of the function \(G_{h0}G(z)\) representing the fixed process elements.

Digital controller

Fig.21 - Basic structure of a digital controller.

A wide variety of digital-design procedures is available; these fall into two categories:

  • direct synthesis procedures, and

  • iterative design procedures.

The direct synthesis procedures assume that the control function \(D(z)\) is not restricted in any way by hardware or software limitations and can be allowed to take any form demanded by the nature of the fixed process elements and the specifications of the required system performance. This design approach has found wider applications in digital control systems than has the equivalent technique used with the analog systems. In a digital control system, realization of the required \(D(z)\) may involve no more than programming a special purpose software procedure. With analog systems, the limitation was in terms of the complications involved in designing special purpose analog controllers.

The design obtained by a direct synthesis procedure will give perfect nominal performance. However, the performance may be inadequate in the field because of the sensitivity of the design to plant disturbances and modeling errors. It is important that a control system is robust in its behavior with respect to the discrepancies between the model and the real process and uncertainties in disturbances acting on the process. Robustness property of some of the standard control structures, such as a three-term (PID) control algorithm, has been very well established. The design of such algorithms calls for an iterative design procedure where the choice of control function D(z) is restricted to using a standard algorithm with variable parameters; the designer must then examine the effect of the choice of controller parameters on the system performance and make an appropriate final choice.

The iterative design procedures for digital control systems are similar to the techniques evolved for analog system design using root locus and frequency response plots.

This chapter is devoted to the design of digital control algorithms, both by iterative design and direct synthesis procedures.

8.2. Z-transformation#

8.3. Z-plane specifications of control system design#

Different properties that describe the performance of a feedback control system are listed below.

  • Stability

  • Steady-state accuracy

  • Transient accuracy

8.3.1. Stability#

Stability is a very important property of closed-loop systems. Almost every working system is designed to be stable. We seek to improve the system performance within the constraints imposed by stability considerations.

8.3.2. Steady-State Accuracy#

Steady-state accuracy refers to the requirement that after all transients become negligible. The error between the reference input \(r\) and the controlled output \(y\) must be acceptably small. The specification on steady-state accuracy is often based on polynomial inputs of degree k: \(r(t)= \frac{t^k}{k!}u(t)\). If \(k = 0\), the input is a step of unit amplitude; if \(k = 1\), the input is a ramp with unit slope; and if \(k=2\), the input is a parabola with unit second derivative. From the common problems of mechanical motion, these inputs are called, respectively, position, velocity, and acceleration inputs.

For quantitative analysis, we consider the unity-feedback discrete-time system shown in Fig. 22. The steady-state error is the difference between the reference input r(k) and the controlled output y(k) when steady-state is reached, i.e., steady-state error

\[\begin{align*} e_{ss}^* &= \lim_{k \to \infty}[r(k)-y(k)]\label{eq:f0} \tag{4.45} \end{align*}\]

Using the final value theorem in the Z-domain,

\[\begin{align*} e^*_{ss} &= \lim_{Z-\to 1} [ (z-1) E(z)] \label{eq:final} \tag{4.46} \end{align*}\]

provided that \((Z-1) E(z)\) has no poles on the boundary and outside of the unit circle in the z-plane.

For the system shown in Fig 21, define

\[\begin{align*} G_{h0}G(z) &= (1-z^{-1})\mathcal{Z} \left [ \frac{G(s)}{s} \right ] \end{align*}\]

Then we have \(\frac{Y(s)}{R(z)}= \frac{G_{h0} G(z)}{1+G_{h0} G(z)}\) and

\[\begin{align*} E(z)=R(z)-Y(z)&= \frac{R(z)}{1+G_{h0} G(z)} \label{eq:err} \tag{4.47}. \end{align*}\]

By substituting Eqn. \(\ref{eq:err}\) into Eqn. \(\ref{eq:final}\) we obtain

\[\begin{align*} e_{ss}^*&= \lim_{Z-\to 1} [ (z-1) E(z)] \nonumber \\ &= \lim_{Z-\to 1} \left [ (z-1) \frac{R(z)}{1 + G_{h0} G(z)} \right] \label{eq:lim_ess} \tag{4.48} \end{align*}\]

Thus, the steady-state error of a discrete-time system with unity feedback depends on the reference input signal R(z), and the forward-path transfer function \(G_{h0}G(z)\). By the nature of the limit in Eqn. \(\ref{eq:lim_ess}\), we see that the result of the limit can be zero or can be a constant different from zero. Also the limit may not exist, in which case the final-value theorem does not apply. However, it is easy to see from basic definition (\(\ref{eq:f0}\)) that \(e^*_{ss}=\infty\) in this case anyway because E(z) will have a pole at Z= 1 that is of order higher than one.

Discrete-time systems having a finite nonzero steady-state error when the reference input is a zero-order polynomial input (a constant) are labeled ‘Type-0‘. Similarly, a system that has finite nonzero steady-state error to a first-order polynomial input (a ramp) is called a ‘Type-1‘ system, and a system with finite nonzero steady-state error to a second-order polynomial input (a parabola) is called a ‘Type-2‘ system.

The steady state errors for Type 0,1,2 systems to a step, ramp or parabolic input are summed up in the table shown below

Type of input

Type-0 system

Type-1 system

Type-2 system

Unit-step

\(\frac{1}{1+K_p}\)

0

0

Unit-ramp

\(\infty\)

\(\frac{1}{K_v}\)

0

Unit-parabolic

\(\infty\)

\(\infty\)

\(\frac{1}{Ka}\)

8.3.3. Transient Accuracy#

Specifications of transient performance may be made in the time domain in terms of rise time, peak time, peak overshoot, settling time. etc. The use of root locus plots for the design of digital control systems necessitates the translation of time-domain performance specifications into desired locations of closed-loop poles in the Z-plane. Whereas the use of frequency response plots necessitates the translation of time-domain specifications in terms of frequency response features such as bandwidth, phase margin, gain margin, resonance peak. resonance frequency, etc.

8.3.4. Specifications in terms of root locations in Z-plane#

Our approach is to first obtain the transient response specifications in terms of characteristic roots in the s-plane, and then use the relation

(8.1)#\[\begin{align} z&=e^{sT} \label{eq:map} \end{align}\]

to map the s-plane characteristic roots to the Z-plane.

The unit-step response of an underdamped second-order system

\[\begin{equation*} \frac{Y(s)}{R(s)} = \frac{\omega_n^2}{s^2+2 \zeta \omega_n s + \omega_n^2} \label{eq:2eorde} \tag{4.50} \end{equation*}\]

where \(\zeta =\) damping ratio, and \(\omega_n=\) undamped natural frequency.

The transient response specifications in terms of rise time \(t_r\), peak time \(t_p\), peak overshoot \(M_p\), and settling time \(t_s\), can be approximated to the parameters \(\zeta\) and \(\omega_n\), of the second-order system defined by Eqn. (\(\ref{eq:2eorde}\)). These relationships are already explained in a previous section.

The specification on speed of response in terms of \(t_r,t_p\), and/or \(t_s\), should be consistent as all these depend on \(\zeta\) and \(\omega_n\). The greater the magnitude of \(\omega_n\) when \(\zeta\) is constant, the more rapid the response approaches the desired steady-state value. The value of \(\omega_n\), is limited by measurement noise considerations - a system with large \(\omega_n\) has large bandwidth and will therefore allow the high frequency noise signals to affect its performance.

Z-domain mapping

Fig.21 - Mapping of s-plane patterns on the Z-plane.

Figure 22 illustrates the translation of specifications on \(\zeta\) and \(\omega_n\), to the characteristic root locations in the Z-plane. The s-plane poles

(8.2)#\[\begin{equation} s_{1,2}= -\zeta \omega_n \pm j \omega_n \sqrt{1-\zeta^2} = -\zeta \omega_n \pm j \omega_d \nonumber \end{equation}\]

for constant \(\zeta\), lie along a line in the s-plane (21.a). In the Z-plane,

(8.3)#\[\begin{equation} z_{1,2} = e^{-\zeta \omega_n T} e^{\pm j \omega_n \sqrt{1-\zeta^2}} = r e^{j \theta} \nonumber \end{equation}\]

The magnitude of Z-(i.e., the distance to the origin) is \(r=e^{-\zeta \omega_n T}\) and the angles with the positive real axis of the Z-plane, measured positive in the counterclockwise direction, are \(\theta= \omega_n T \sqrt{1-\zeta^2}\).

It should be observed that the Z-plane pole locations depend on the s-plane positions as well as the sampling interval T.

As \(\omega_n\) increases for a constant \(\zeta\) the magnitude of Z-decreases and the phase angle increases; constant-\(\zeta\) locus is a logarithmic spiral in the Z-plane (Fig. 21). Increasing \(\omega_n\) negatively, gives the mirror image.

8.4. Digital compensator design using frequency response plots#

8.4.1. Design using the Pade approximation:#

Padé approximation is an extension of the concept of Taylor approximation with rational functions rather than polynomials. The basic premise is that the approximation is made by matching derivatives at a particular point. Padé approximants are often associated with dead time approximation.

We will approximate a Laplace time delay:

\[\begin{equation*} H_{delay}(s)=e^{-Ts}, \end{equation*}\]

the magnitude and the phase for a frequency \(\omega\) is equal to

\[\begin{align*} |H_{delay}(j\omega)|&=1 \\ \angle H_{delay}(j\omega)&= -T\omega \end{align*}\]

This can be approximated by a first order Padé approximation:

\[\begin{equation*} H_{pade}(s)=\frac{2-Ts}{2+Ts}. \end{equation*}\]

the magnitude and the phase for a frequency \(\omega\) is equal to

\[\begin{align*} |H_{pade}(j\omega)|&=1 \\ \angle H_{pade}(j\omega)&= \arctan(\frac{-T\omega}{2}) - \arctan(\frac{T\omega}{2}). \end{align*}\]

If \(\frac{T\omega}{2}<0.2\) then \(\arctan(\frac{T\omega}{2}) \approx \frac{T\omega}{2}\) leading to

\[\begin{align*} \angle H_{pade}(j\omega)& \approx \frac{-T\omega}{2} - \frac{T\omega}{2}\\ &\approx -T\omega \end{align*}\]

The pade approximation is implemented in the Python control library.

from control import pade,tf,bode

dt=1

[num,den] = pade(dt,1)
pd = tf(num,den)
print(pd)
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[1], line 1
----> 1 from control import pade,tf,bode
      3 dt=1
      5 [num,den] = pade(dt,1)

ModuleNotFoundError: No module named 'control'

8.4.2. Design in the Z-domain#

All the frequency response methods of continuous-time systems are directly applicable for the analysis and design of digital control systems. For a system with closed-loop transfer function

(8.4)#\[\begin{equation} \frac{Y(z)}{R(z)} = \frac{G_{h0}(z) G(z)}{1+G_{h0}(z) G(z)} \nonumber \end{equation}\]

the absolute and relative stability conditions can be investigated by making the frequency response plots of \(G_{h0}G(z)\). The frequency response plots of \(G_{h0}G(z)\) can be obtained by setting

(8.5)#\[\begin{equation} z=e^{j \omega T} ; \ \ \rm{T=sampling \ \ interval} \nonumber \end{equation}\]

and then letting the frequency \(\omega\) vary from \(-\omega_s/2\) to \(\omega_s/2\), \(\omega_s=2\pi/T\).

Since the frequency appears in the form \(Z= e^{j \omega T}\), the discrete-time transfer functions are typically not rational functions and the simplicity of Bode’s design technique is all together lost in the Z-plane. Computer assistance is normally required to make the frequency response plots.

Example: Plot the Bode diagram of the following discrete transfer function:

\[\begin{align*} H(z) = \frac{z^2+z}{z^2+4z-1} \end{align*}\]
from scipy import signal
import matplotlib.pyplot as plt

sys = signal.TransferFunction([1,1,0], [1, 4, -1], dt=0.05)

w, mag, phase = signal.dbode(sys)

fig,(ax1,ax2) = plt.subplots(1,2,figsize=(10,5))

ax1.semilogx(w,mag) # Bode magnitude plot
ax1.set_xlabel("frequency [rad/sec]")
ax1.set_ylabel("magnitude")
ax2.semilogx(w,phase) # Bode phase plot
ax2.set_xlabel("frequency [rad/sec]")
ax2.set_ylabel("phase [degrees]")
Text(0, 0.5, 'phase [degrees]')
../../_images/37edb6d9c300f3190a7dd932b85a7035dec948092012da4a974d8387950c46ed.png

8.4.3. Design in the \(w\)-domain#

Since the frequency appears in the form \(Z-= e^{j \omega T}\), the discrete-time transfer functions are typically not rational functions and the simplicity of Bode’s design technique is all together lost in the Z-plane. The simplicity can be regained by transforming the discrete-time transfer function in the Z-plane to a different plane (called \(w\)) by the bilinear transformation

\[\begin{equation*} z= \frac{1+wT/2}{1-wT/2} \label{eq:w0} \tag{4.45} \end{equation*}\]

By solving Eqn. \(\ref{eq:w0}\) for \(w\), we obtain the inverse relationship

\[\begin{equation*} w = \frac{2}{T}\frac{z-1}{z+1}\label{eq:w1} \tag{4.56} \end{equation*}\]

Through the Z-transformation and the \(w\)-transformation, the primary strip of the left half of the s-plane is first mapped into inside of the unit circle in the Z-plane, and then mapped into the entire left half of the w-plane. The two mapping processes are depicted in Fig. 22.

Digital controller

Fig.22 - Diagrams showing mapping from s-plane to Z-plane and from Z-plane to w-plane.

Notice that as s varies from 0 to \(j\omega_s/2\) along the j\(\omega\)axis in the s-plane, Z-varies from 1 to \(\infty\) along the unit circle in the Z-plane, and w varies from 0 to on along the imaginary axis in the w-plane.

The bilinear transformation (\(\ref{eq:w0}\)) does not have any physical significance in itself and therefore all w-plane quantities are fictitious quantities that correspond to the physical quantifies of either the s-plane or the Z-plane. The correspondence between the real frequency \(\omega\) and the fictitious w-plane frequency, denoted as \(\nu\), is obtained as followed:

(8.6)#\[\begin{equation} j w = \frac{2}{T} \frac{e^{j \omega T} -1}{e^{j \omega T} +1} =\frac{2}{T} \frac{e^{j \omega T/2} - e^{-j \omega T/2}}{e^{j \omega T/2} + e^{-j \omega T/2}} = \frac{2}{T} j \tan \frac{\omega T}{2} \nonumber \end{equation}\]

or

(8.7)#\[\begin{equation} w =\frac{2}{T} \tan \frac{\omega T}{2} \nonumber \end{equation}\]

Digital controller

Fig.23 - Relationship between the fictitious frequency \(\nu\) and actual freqcuency \(\omega\) .

Note that for relatively small \(\frac{\omega T}{2} < 17^0\) (or about 0.3 rad),

(8.8)#\[\begin{equation} w =\frac{2}{T} \tan \frac{\omega T}{2} \approx \frac{2}{T} \left ( \frac{\omega T}{2} \right ) \approx \omega \nonumber \end{equation}\]

and the ‘warping’ effect on the frequency response is negligible.

Example: Consider a process with transfer function

(8.9)#\[\begin{equation} G(s) = \frac{10}{s(\frac{1}{5}s+1)} \nonumber \end{equation}\]

a ZOH process with sampling time of 0.1 seconds is used. Compare the Bode diagram in the W-domain with the original Laplace domain. do the same comparison for a sampling time of 2 seconds.

First we determine the ZOH approximation of the continuous system:

(8.10)#\[\begin{equation} G_{h0}G(z) = (1-z^{-1}) \mathcal{Z} \left[ \frac{50}{s^2(s+5)} \right] = \frac{0.213(z+0.85)}{(z-1)(z-0.61)}\label{eq:ex_w0} \end{equation}\]
from control import c2d,tf,bode
import harold

G = harold.Transfer([1], [1/5, 1, 0])

#Gz = c2d(G,0.1)
Gz =  harold.discretize(G, dt=0.1, method='zoh')
print("Polynomial nominator of Gz", Gz.polynomials[0][0])
print("Polynomial denominator of Gz", Gz.polynomials[1][0])
Polynomial nominator of Gz [0.02130613 0.0180408 ]
Polynomial denominator of Gz [ 1.         -1.60653066  0.60653066]

Using the bilinear transformation

(8.11)#\[\begin{equation} z = \frac{1+\frac{wT}{2}}{1-\frac{wT}{2}}= \frac{1+0.05w}{1-0.05w} \nonumber \end{equation}\]

\(G_{h0}G(z)\) can be transformed into \(G_{h0}G(w)\) given below:

(8.12)#\[\begin{align} G_{h0}G(w) &=\frac{0.213(\frac{1+0.05w}{1-0.05w} +0.85)}{(\frac{1+0.05w}{1-0.05w} -1)(\frac{1+0.05w}{1-0.05w} -0.61)} \nonumber \end{align}\]
Gw = harold.undiscretize(Gz, method='tustin')
print("Polynomial nominator of Gw", Gw.polynomials[0][0])
print("Polynomial denominator of Gw", Gw.polynomials[1][0])
Polynomial nominator of Gw [-1.01626752e-03 -2.24593312e-01  4.89837325e+00]
Polynomial denominator of Gw [ 1.00000000e+00  4.89837325e+00 -6.96100706e-14]
from control.matlab import tf,bode

GwC = tf( Gw.polynomials[0][0],Gw.polynomials[1][0])
[mag,phase,w]=bode(GwC)

GC = tf([1], [1/5, 1, 0])

[mag,phase,w]=bode(GC)
../../_images/9bb062cc42e77d04d91db9cda965c189d75fe9bbe6a89c6aea8affcf93bb655c.png

8.5. Digital compensator design using root locus plots#

Design of compensation networks using the root locus plots is a well established procedure in analog control systems. This is essentially a trial-and-error method whereby varying the controller parameters, the roots of the characteristic equation are relocated to favorable locations.

The characteristic equation of a discrete-time system can always be written in the form

\[\begin{equation*} 1 + F(z) = 0 \label{eq:RLZ1} \tag{4.64} \end{equation*}\]

where F(z) is a rational function of z. From Eqn. \(\ref{eq:RLZ1}\), it is seen that the roots of the characteristic equation (i.e… the closed-loop poles of the discrete-time system) occur only for those values of Z-where

\[\begin{equation*} F(z) =-1 \label{eq:RLZ2} \tag{4.65} \end{equation*}\]

Sinze Z-is a complex variable, Eqn. \(\ref{eq:RLZ2}\) is converted into two conditions given below.

  • Magnitude condition: \(|F(z)| = 1\)

  • Angle condition: \(\angle F(z) = \pm 180^0(2q+1); \ \ q=0,1,2, \ldots\)

8.5.1. Root-locus plots with software#

In plotting root loci deal with the system equation given in the form of Equation \(\ref{eq:RLZ1}\), which may be written as

(8.13)#\[\begin{equation} 1 + K \frac{\rm{num}}{\rm{den}} =0 \end{equation}\]

where num is the numerator polynomial and den is the denominator polynomial. Note that both vectors num and den must be written in descending powers of z.

A software command used for plotting a discrete root loci is

TF=tf(num,den,T) rlocus(TF)

where T represents the sampling time.

With this command, the root-locus plot is drawn on the screen. The gain vector K is automatically determined. Note that command

rlocus(TF, K)

utilizes the user-supplied gain vector K. (The vector K contains all the gain values for which the closed-loop poles are to be computed.)

If the preceding two commands are invoked with left-hand arguments, that is

[r,K]= rlocus(TF) [r,K]= rlocus(TF,K)

the matrix r has length K rows and length den-1 columns containing the locations of complex roots and gain vector K. The plot command

plot(r,‘-’)

plots the root loci. Note that, the gain vector is determined automatically.

Example: Consider a system whose open-loop transfer function G(s)H(s) is

(8.14)#\[\begin{equation} G(s)H(s) =\frac{4}{s(s+2))} \nonumber \end{equation}\]

which when preceded by a zero-order hold (T=0.2 sec) has the discrete function

\[\begin{align*} G_{h0}G(z) &= (1-z^{-1}) \mathcal{Z} \left[ \frac{K}{s^2(s+2)} \right] \\ &= \frac{ 0.01758 Z-+ 0.01539}{z^2 - 1.67 Z-+ 0.6703} \end{align*}\]

We can determine the root locus diagram in Python

from control import rlocus,tf
import numpy as np

GH = tf([4],[1,2,0])

GHz = c2d(GH,0.2)
K=np.linspace(0,0.01,1000)
r,k = rlocus(GHz)
plt.xlim([-2,2])
(-2.0, 2.0)
../../_images/be9b2eca849f2338fd776f8cf102542c568ed416d1b7c097623b23ff9e533551.png

8.6. Z-plane synthesis#

Much of the style of the transform domain techniques we have been discussing in this chapter grew out of the limitations of technology which was available for realization of the compensators with pneumatic components or electric networks and amplifiers. In the digital computer, such limitations on realization are of course, not relevant, and one can ignore these particular constraints.

One design method which eliminates these constraints begins from the very direct point of view that we are given a process (plus hold) transfer function \(G_{h0}G(z)\). that we want to construct a desired transfer function, M(z), between input r and output y and that we have the computer transfer function, D(z), to do the job as per the feedback control structure of Fig. 24.

Digital controller 1

Fig.24 - A feedback system with digital compensation.

The closed-loop transfer function is given by the formula

(8.15)#\[\begin{equation} M(z) = \frac{D(z)G_{h0}G(z)}{1+D(z)G_{h0}G(z)} \nonumber \end{equation}\]

from which we get the design formula

\[\begin{equation*} D(z) = \frac{1}{G_{h0}G(z)} \left [ \frac{M(z)}{1-M(z)} \right] \label{eq:DZ5} \tag{4.69} \end{equation*}\]

As is seen from Eqn. \(\ref{eq:DZ5}\), the controller transfer function consists of the inverse of the plant transfer function and the additional term which depends on the system closed-loop transfer function. Thus the design procedure outlined above looks for a D(z) which will cancel the process effects and add whatever is necessary to give the desired performance.

For prescribing the required closed-loop transfer function M(z), the following restrictions have to be noted.

8.6.1. Realizability of digital Controller#

Assume that a digital controller

(8.16)#\[\begin{equation} D(z) = \frac{Q_v(z)}{P_{\mu}(z)} = \frac{q_0 z^{\nu}+q_1 z^{\nu-1}+ \ldots + q_{\nu} }{z^{\mu}+p_1 z^{\mu-1}+ \ldots + p_{\mu} } \nonumber \end{equation}\]

is cascaded with the process

(8.17)#\[\begin{equation} G_{h0}G(z) = \frac{B_m(z)}{A_n(z)} = \frac{b_0 z^m + b_1z^{m-1}+ \ldots + b_m}{z^n+a_1z^{n-1}+ \ldots + a_n}; m \leq n \nonumber \end{equation}\]

in the control loop given by Fig. 24.

For D(z) to be physically realizable, \(\nu \leq \mu\). The closed loop transfer function

(8.18)#\[\begin{equation} M(z) = \frac{D(z)G_{h0}G(z)}{1+D(z)G_{h0}G(z)} = \frac{Q_v(z) B_m(z)}{P_{\mu}(z) A_n(z) +Q_v(z) B_m(z) } = \frac{N_{\nu+m}(z)}{D_{\mu+n}(z)} \nonumber \end{equation}\]

The order of the numerator polynomial of M(z) is \(\nu + m\), and the order of the denominator polynomial of M(z) is \(\mu+n\). The pole excess of M(z) is therefore \(\{(\mu- \nu)+(n-m)\}\)

This means that because of the condition of realizability of digital controller, the pole excess of the closed-loop transfer function \(M(z)\) has to be greater than or equal to the pole excess of the process transfer function \(G_{h0}G(z)\).

If the digital controller D(z) given by Eqn. \(\ref{eq:DZ5}\) and the process \(G_{h0}G(z)\) are in a closed loop, the poles and zeros of the process are canceled by the zeros and poles of the controller. The cancellation is perfect if the process model \(G_{h0}G(z)\) matches the process exactly. Since the process models used for design practically never describe the process behavior exactly, the corresponding poles and zeros will not be canceled exactly; the cancellation will be approximately.

For poles and zeros of \(G_{h0}G(z)\) which are sufficiently spread in the inner of the unit disc in the Z-plane, the approximation in cancellation leads to only small deviations of the assumed behavior M(z) in general. However, one has to be careful if \(G_{h0}G(z)\) has poles or zeros on or outside the unit circle. Imperfect cancellation may lead to weakly damped or unstable behavior. Therefore the design of digital controllers according to Eqn. \(\ref{eq:DZ5}\) has to be restricted to cancellation of poles and zeros of \(G_{h0}G(z)\) located inside the unit circle. This imposes certain restrictions on the desired transfer function M(z) as is seen below.

Assume that \(G_{h0}G(z)\) involves an unstable (or critically stable) pole at \(z= \alpha\). Let us define

(8.19)#\[\begin{equation} G_{h0}G(z) = \frac{G_1(z)}{z- \alpha} \nonumber \end{equation}\]

were \(G_1(z)\) does not include a term that cancels with \((Z-- \alpha)\). Then the closed-loop transfer function becomes

(8.20)#\[\begin{equation} M(z) = \frac{D(z) \frac{G_1(z)}{z- \alpha} }{1+ D(z) \frac{G_1(z)}{z- \alpha}} \label{eq:MZ2} \tag{62} \end{equation}\]

Since we require that no new zero of D(z) to cancel the pole of \(G_{h0}G(z)\) at \(Z-= \alpha\), we must have

(8.21)#\[\begin{equation} 1- M(z) = \frac{1}{1+D(z)\frac{G_1(z)}{z- \alpha}} = \frac{z-\alpha}{z-\alpha + D(z) G_1(z)} \nonumber \end{equation}\]

that is, \(1 - M(z)\) must have \(Z-= \alpha\) as a zero. This argument applies equally if \(G_{h0}G(z)\) involves two or more unstable (or critically stable) poles.

Also note from Eqn. \(\ref{eq:MZ2}\) that if poles of D(z) do not cancel zeros of \(G_{h0}G(z)\), then the zeros of \(G_{h0}G(z)\) become zeros of M(z).

Let us summarize what we have stated concerning cancellation of poles and zeros of \(G_{h0}G(z)\).

  • Since the digital controller D(z) should not cancel unstable (or critically stable) poles of \(G_{h0}G(z)\), all such poles of \(G_{h0}G(z)\) must be included in \(1 - M(z)\) as zeros.

  • Zeros of \(G_{h0}G(z)\) that lie on or outside the unit circle should not be canceled with poles of D(z); all such zeros of \(G_{h0}G(z)\) must be included in M(z) as zeros.

The design procedure thus essentially involves the following three steps:

  • The closed-loop transfer function M(z) of the final system is determined from the performance specifications, and the fixed parts of the system,i.e. \(G_{h0}G(z)\)

  • The transfer function D(z) of the digital controller is found using the design formula \(\ref{eq:DZ5}\).

  • The digital controller D(z) is synthesized.

Step 1 is certainly the most difficult one to satisfy. In order to pass step 1, a designer must fulfill the following requirements.

  1. The digital controller D(z) must be physically realizable.

  2. The poles and zeros of on \(G_{h0}G(z)\) or outside the unit circle should not be canceled by D(z).

  3. The system specifications on transient and steady-state accuracy be satisfied.

For common types of specifications (error constants, stability margins, speed of response. etc.), these requirements are usually easily satisfied. However, we can ask for more than what has been achieved earlier by compensation techniques based on root locus and frequency response plots. Design examples will best illustrate this point.

Example: The plant of sampled-data system of Fig. 22 is described by the transfer function

(8.22)#\[\begin{equation} G(s) = \frac{1}{s(10s+1)} \nonumber \end{equation}\]

The sampling period is 1 sec.

The problem is to design a digital controller D(z) to realize the following specifications:

  1. \(K_v \geq 1\)

  2. \(\zeta = 0.5\), and

  3. \(t_s\)(2% tolerance band) \(\leq\) 8 sec.

The selection of a suitable M(z) is described by the following steps.

  1. The z-transfer function of the plant is given by

(8.23)#\[\begin{eqnarray} G_{h0}G(z) &=& (1-z^{-1}) \mathcal{Z} \left [ \frac{1}{s^2(10s+1)} \right] \\ &=& 0.04837 \frac{(z+0.9672)}{(z-1)(z-0.9048)} \nonumber \end{eqnarray}\]

Since \(G_{h0}G(z)\) has one more pole than zero, M(z) must have a pole excess of at least one.

from control import c2d,tf

G = tf([1],[10,1,0])
print(G)

GhoG = c2d(G,1)
print(GhoG)
    1
----------
10 s^2 + s


 0.04837 z + 0.04679
----------------------
z^2 - 1.905 z + 0.9048

dt = 1

2.\(G_{h0}G(z)\) has a marginally stable pole at \(z=1\). This must be included in \(1-M(z)\) as zero. i.e…

\[\begin{equation*} 1-M(z) = (z-1)F(z) \label{eq:DZ1} \tag{4.59} \end{equation*}\]

where F(z) is a ratio of polynomials of appropriate dimensions.

3.The transient accuracy requirements are specified as \(\zeta=0.5\), \(\omega_n=1\) (\(t_s=4/(\zeta\omega_n)\)). With a sampling period T=1 sec, this maps to a pair of dominant closed-loop poles in the z-plane with

(8.24)#\[\begin{eqnarray} |z_{1,2}|&=&e^{-\zeta \omega_n T} = 0.6065 \nonumber \\ \angle z_{1,2} &=& \pm \omega_n T \sqrt{1-\zeta^2} = \pm \frac{0.866 \times 180}{3.14} = \pm 49.64^0 \nonumber \end{eqnarray}\]

This corresponds to

(8.25)#\[\begin{equation} z_{1,2} = 0.3928 \pm j 0.4621 \nonumber \end{equation}\]

The closed-loop tranfer function M(z) should have dominant poles at the root of the equation

\[\begin{equation*} \Delta(z) = z^2 - 0.7856 z + 0.3678 \label{eq:DZ2} \tag{4.81} \end{equation*}\]
import numpy as np 
from control.matlab import zpk2tf,minreal,series,step,stepinfo  
from Mycode import response

zeta =0.5 
ts =8 #sec 
T=1 #samplng time 

omega_n = 4/(zeta*ts)

r = np.exp(-zeta*omega_n*T)
theta = + omega_n*T*np.sqrt(1-zeta**2)

print("Absolute value of closed loop pole",r)
print("Phase angle of closed loop pole [in degrees]",theta/np.pi*180)

#the denominator is z^2+ 2*r*cos(theta)*z + r^2 
den=[1,-2*r*np.cos(theta),r**2 ]
print("Polynomial terms of denominator of closed loop transfer function",den)
Absolute value of closed loop pole 0.6065306597126334
Phase angle of closed loop pole [in degrees] 49.61960058796129
Polynomial terms of denominator of closed loop transfer function [1, -0.7858931116687105, 0.36787944117144233]

The steady-state accuracy requirements demand that steady-state error to unit-step input is zero, and steady-state error to unit-rump input is less than \(1/K_v\)

(8.26)#\[\begin{eqnarray} E(z) &=& R(z) - Y(z) = R(z)[1-M(z)] = R(z) (z-1) F(z) \nonumber \\ e_{ss}^*|_{unit \ step} &=& \lim_{Z-\to 1}(z-1) \frac{z}{z-1} (z-1) F(z) = 0 \nonumber \end{eqnarray}\]

Thus, with the choice of M(z) given by Eqn. \(\ref{eq:DZ1}\). the steady-state error to unit step input is always zero.

\[\begin{align*} e_{ss}^*|_{ramp} &= \lim_{Z-\to 1} (z-1) \frac{Tz}{(z-1)^2} (z-1) F(z) = T F(1) = 1/K_v \nonumber \\ T&=& 1 \ and \ K_v=1 \nonumber \\ F(1) &= 1 \ \label{eq:DZ3} \tag{4.83} \end{align*}\]

From Eqn. \(\ref{eq:DZ1}\) and \(\ref{eq:DZ2}\), we observe that

(8.27)#\[\begin{equation} F(z) = \frac{z-\alpha}{z^2-0.7856z+0.3678} \nonumber \end{equation}\]

meets the requirements on reliability of D(z), cancellation of poles and zeros of \(G_{h0}G(z)\) , and transient accuracy.

The requirement on steady-state accuracy is also met if we choose \(\alpha\) such that (refer Eqn. \(\ref{eq:DZ3}\))

(8.28)#\[\begin{equation} \frac{1-\alpha}{1-0.7856+0.3678} = 1 \nonumber \end{equation}\]

This gives \(\alpha=0.4178\).

# Based on steady state criterium we add in zero in alpha:

alpha = 0.4178

Therefore

(8.29)#\[\begin{eqnarray} F(z) &=& \frac{z-0.4178}{z^2-0.7856z+0.3678} \nonumber \\ 1-M(z) &=& \frac{(z-1)(z-0.4178)}{z^2-0.7856z+0.3678} \nonumber \\ M(z) &=& \frac{0.6322z-0.05}{z^2-0.7856z+0.3678} \label{eq:DZ4} \nonumber \end{eqnarray}\]

Now turning to the basic design formula \(\ref{eq:DZ5}\), we compute

(8.30)#\[\begin{eqnarray} D(z) &=& \frac{1}{G_{h0}G(z)} \left [ \frac{M(z)}{1-M(z)} \right] \nonumber \\ &=& \frac{(z-1)(z-0.9048)}{(0.04837)(z+0.9672)} \left [ \frac{0.6322z-0.05}{(z-1)(z-0.4178)} \right ] \nonumber \\ &=& 13.07 \frac{(z-0.9048)(z-0.079)}{(z+0.9672)(z-0.4178)} \nonumber \end{eqnarray}\]

A plot of the step response of the resulting design in the figure below shows the control effort.

b,a = zpk2tf([alpha,1],[],1)

Mz =minreal(1-tf(b,den,T))

Dz = minreal(series(1/GhoG*Mz/(1-Mz))) 

print(Dz)


yout,t =step(Mz)

plt.figure(1) 
plt.plot(t,yout)
plt.grid()
print("Steady state error closed loop unit step response error :%2.2f"%(1-yout[-1])) 


S=stepinfo(Mz)

print("Percentage overshoot:%.2f" % S.get("Overshoot"),"%")
print("Rise time:%.2f" % S.get("RiseTime"), "sec.")
print("Settling time:%.2f" % S.get("SettlingTime"),"sec" )
0 states have been removed from the model
3 states have been removed from the model

13.06 z^2 - 12.85 z + 0.9338
----------------------------
  z^2 + 0.5494 z - 0.4041

dt = 1

Steady state error closed loop unit step response error :-0.00
Percentage overshoot:19.72 %
Rise time:1.00 sec.
Settling time:8.00 sec
../../_images/e6a3783ac44ef2cd5e4bc89c077738ae906d11315699dfc30a9a309f57d2d412.png