BME3105
Last modified:
5 min read

Part 9 - Discrete Systems

Table of Contents

Introduction

All signals we have dealt with so far have been continuous-time signals, i.e., they are defined for all $-\infty < t < +\infty$

Each device in the system such as the controller, plant or a sensor can be viewed as a signal processor or filter.

The relation between input and output is described by a transfer fucntion in the $s$-domain or a differential equation in the time-domain.

Analog computers can be made by RLC (Resistor, Inductor, Capacitor) circuits plus OP-AMPs (Operational Amplifiers).

However, the cost of these devices are high, they’re heavy and bulky, and sensitive to noise. Too many drawbacks.

From Continuous to Discrete

Previously, all signals have been continuously variables (analogue) and defined for all instants in time.

Because controllers are now usually implemented on computers, we must deal with signal which are discrete in nature.

  • Discrete-time
    • Signals are determined only at certain instants in time (multiple of $T_U$).
  • Discrete-value
    • Signals are allowed only to have certain discrete values at any time step (multiples of $\Delta V$.

Discrete values levels arise because of fixed resolution of A-to-D (and D-to-A) converters.

Discrete times arise because of fixed update rate of computer-based controllers.

A/D Converter (ADC)

A/D converter is a device that converts a continuous-time signal $e(t)$ into a discrete-time signal.

Assume,

$$ e(t) = \begin{cases} \cos(t) & \quad t \geq 0 \ 0 & \quad t < 0 \end{cases} $$

Then, the discrete-time signal is,

$$ e(kT) = \begin{cases} \cos(kT) & \quad k = 0, 1, 2, \ldots \ 0 & \quad k = -1, -2, -3, \ldots \end{cases} $$

where $T > 0$ is called the sample period in seconds, $\frac{1}{T} > 0$ is called the sample rate in Hz.

Note that $e(kT)$ is only defined for integer values of $k$. It is undefined between $kT < t < (k + 1)T$, $k = 0, \pm 1, \pm 2, \ldots$.

Thus, $e(kT)$ is called discrete-time (DT) signal. We usually just write $e(k)$.

A digital processor is a discrete-time device that takes a discrete-time signal as input and produces a discrete-time signal as output according to a certain algortihm (difference equation, more on this later).

D/A Converter (DAC)

A D/A converter is a device that converts a DT signal into a CT signal.

An example is the zero-order hold DAC, in which the output is held constant between samples.

Difference Equation and Discrete-Time System

A discrete-time system is described by a difference equation of the form, $$ \begin{align*} y(k) & = b_0 u(k) + b_1 u(k - 1) + \ldots + b_n u(k - n) \newline & \quad - a_1 y(k - 1) - \ldots - a_n y(k - n) \quad k \geq 0. \end{align*} $$ where $b_0, \ldots, b_n, a_1, \ldots, a_n$ are real constants, and $a_n \neq 0$.

$u(k), k = 0, 1, \ldots$ is a given DT signal called the input of the system.

$y(k), k = 0, 1, \ldots$ is obtained by the above equation and is called the output of the system. We will assume $y(k) = 0, k < 0$.

$n$ is the order of the system.

The difference equation can also be written as,

$$ \begin{align*} y(k + n ) & = b_0 u(k + n) + b_1 u(k + n - 1) + \ldots + b_n u(k) \newline & \quad - a_1 y(k + n - 1) - \ldots - a_n y(k) \quad k \geq 0. \end{align*} $$

This is the same equation, but we have replaced $k$ with $k + n$.

Example

Consider the difference equation,

$$ y(k) = 2u(k) + 3y(k - 1) - 2y(k - 2) $$

where $u(k) \begin{cases} k & k \geq 0 \newline 0 & k < 0 \end{cases}$

By definition we have,

$$ \begin{align*} y(0) &= 2u(0) = 0 \newline y(1) &= 2u(1) + 3y(0) = 2 \newline y(2) &= 2u(2) + 3y(1) - 2y(0) = 10 \newline \end{align*} $$

We can also solve this with the $Z$-transform.

The $Z$-transform is a discrete counterpart of the Laplace transform.

Let’s first recall an important property of the Laplace transform. With continuous systems, $s$ is an *operator. Multiplying a signal by $s$ differentiates that signal in the time domain. Division by $s$ integrates the signal.

With discrete-time systems, $z$ is also an operator. Multiplying a signal by $z$ advance that signal one “tick” in time. Division by $z$ delays the signal by one “tick”.

Assume $\{f(k)\}$ is a discrete-time signal with $f(k) = 0, k < 0$. Then, $$ F(z) = \sum_{k=0}^{\infty} f(k)z^{-k} \triangleq \mathcal{Z}\{f(k)\} $$ where $z$ is a complex variable, and is called the $\mathcal{Z}$-transform of $f(k)$.

Remark: $F(z)$ is a power series of $z^{-1}$, which usually converges to a rational function.

Examples

Let’s start easy with the impulse function,

$$ f(k) = \begin{cases} 1 & k = 0 \newline 0 & k \neq 0 \end{cases} $$

Then,

$$ F(z) ) \sum_{k=0}^{\infty} f(k)z^{-k} = 1 $$

Another example is the unit step function,

$$ f(k) = \begin{cases} 1 & k = 0, 1, 2, \ldots \newline 0 & k < 0 \end{cases} $$

Then,

$$ F(z) = \sum_{k=0}^{\infty} f(k)z^{-k} = \sum_{k=0}^{\infty} z^{-k} = \frac{1}{1 - z^{-1}} = \frac{z}{z - 1}, $$

since the power series of $1 + x + x^2 + \ldots$ is $\frac{1}{1 - x}$.

Remark

We will assume that the discrete-time signal $f(k)$ is obtained by sampling a continuous-time signal $f(t)$, i.e., $f(k) \triangleq f(kT)$ where $T$ is the sample period. We will use the notation $\mathcal{Z}\{f(t)\}$ or $\mathcal{Z}\{F(s)\}$ or $\mathcal{Z}\{f(k)\}$ to mean $\sum_{k=0}^{\infty} f(kT) z^{-k}$.

Properties of the $\mathcal{Z}$-transform

  1. Linearity: Assume $\mathcal{Z}\{f_1(k)\} = F_1(z)$ and $\mathcal{Z}\{f_2(k)\} = F_2(z)$. Then, $$ \mathcal{Z}\{af_1(k) + bf_2(k)\} = aF_1(z) + bF_2(z) $$ for any constants $a$ and $b$.

  2. Shifting Theorem: Assume $\mathcal{Z}\{f(k)\} = F(z)$. Then for any positive integer $n$, $$ \mathcal{Z}\{f(k - n)\} \triangleq \sum_{k=0}^{\infty} f(k - n)z^{-k} = z^{-n}F(z) $$

  3. Final Value Theorem: Assume $X(z) = \mathcal{Z}\{x(k)\}$ and all the poles of $(1 - z^{-1})X(z)$ are inside the unit circle. Then, $$ \lim_{k \to \infty} x(k) = \lim_{z \to 1} (1 - z^{-1})X(z) $$

Transfer Function of a DT System

Given,

$$ \begin{align*} y(k) & = b_0 u(k) + b_1 u(k - 1) + \ldots + b_n u(k - n) \newline & \quad - a_1 y(k - 1) - \ldots - a_n y(k - n) \quad k \geq 0 \end{align*} $$

Assume $Y(z) = \mathcal{Z}\{y(k)\}, U(z) = \mathcal{Z}\{u(k)\}$. Then $\frac{Y(z)}{U(z)}$ is called the transfer function of the above difference equation, and,

$$ \frac{Y(z)}{U(z)} = \frac{b_0 + b_1 z^{-1} + \ldots + b_n z^{-n}}{1 + a_1 z^{-1} + \ldots + a_n z^{-n}} = \frac{b_0 z^n + b_1 z^{n - 1} + \ldots + b_n}{z^n + a_1 z^{n - 1} + \ldots + a_n} $$

Example

Let $y(k) = 2u(k) + 3y(k - 1) - 2y(k - 2)$

Then the transfer function is,

$$ \frac{Y(z)}{U(z)} = \frac{2}{1 - 3z^{-1} + 2z^{-2}} $$

Stability of DT Systems

We have discussed what BIBO stability means for continuous-time systems. We can define the same for discrete-time systems.

A DT system is said to be BIBO stable if, $$ |u(k)| < M_1 $$ for all $k$, and some finite $M_1$ implies, $$ |y(k)| < M_2 $$ for all $k$ and some finite $M_2$.

The stability criterion for DT systems is the following.

Let, $$ D(z) = \frac{\beta(z)}{\alpha(z)} = \frac{b_0 z^n + b_1 z^{n - 1} + \ldots + b_n}{z^n + a_1 z^{n - 1} + \ldots + a_n} $$

Assume $z_1, \ldots, z_n$ are the poles of $D(z)$, i.e., $\alpha(z_i) = 0, i = 1, \ldots , n$. Then $D(z)$ is (BIBO) stable if,

$$ |z_i| < 1, i = 1, \ldots, n $$

and $D(z)$ is not (BIBO) stable if there exists at least one i such that,

$$ |z_i| \geq 1 $$

In reality, if a pole lies on the unit circle, we have a marginally stable system, but we will consider these as unstable for simplicity.

Relation of Poles of $F(s)$ and $F(z)$

Consider,

$$ f(t) = \begin{cases} e^{-at} & t \geq 0 \newline 0 & t < 0 \end{cases} $$

Then,

$$ F(s) \triangleq \mathcal{L}\{f(t)\} = \frac{1}{s + a}. $$

We can see this has a pole at $s = -a$.

On the other hand, let,

$$ F(z) = \mathcal{Z}\{e^{-akT}\} = \frac{z}{z - e^{-aT}} $$

which has a pole at $z = e^{-aT}$.

Conclusion: Given $f(t)$ and sampling period $T$, assume $F(s) = \mathcal{L}\{f(t)\}$ and $F(z) = \mathcal{Z}\{f(k)\}$. Then the poles of $F(s)$ and $F(z)$ are related by, $$ z = e^{sT} $$

Let $s = \sigma + j \omega$. Then $z = e^{\sigma T} e^{j \omega T}$. Clearly,

$$ |z| < 1 \quad \text{if and only if} \quad \sigma < 0 $$

Thus a DT system is (BIBO) stable if and only if all its poles are strictly inside the unit circle.

From Continuous to Discrete

Tustin’s approximation is a method to convert a continuous-time transfer function to a discrete-time transfer function.

$$ z = e^{sT} = \frac{e^{sT/2}}{e^{-sT/2}} \approxeq \frac{1 + sT/2}{1 - sT/2} $$

where $s$,

$$ s = \frac{2}{T} \frac{z - 1}{z + 1} $$

Example

Let $G(s) = \frac{(1 + 3.2s)}{(1 + 0.2s)}$ with an update-time of $T = 0.2s$

Firstly,

$$ s = \frac{2}{0.2} \frac{z - 1}{z + 1} = 10 \frac{z - 1}{z + 1} $$

Then,

$$ G(z) = \frac{(1 + 3.2(10(z - 1)/(z + 1)))}{(1 + 0.2(10(z - 1)/(z + 1)))} = \frac{(1 + 32(z - 1)/(z + 1))}{(1 + 2(z - 1)/(z + 1))} = \frac{(z + 31)}{(z + 3)} $$

If this transfer function represents the relationship between an output signal $C(z)$ and an input signal $E(z)$, then the expression,

$$ \frac{C(z)}{E(z)} = \frac{(z + 31)}{(z + 3)} $$

We can rewrite this as,

$$ C(z)(z + 3) = E(z)(z + 31) = zC(z) + 3C(z) = zE(z) + 31E(z) $$

This is the difference equation of the system. Let’s take the inverse $z$-transform of this equation.

$$ c(k + 1) + 3c(k) = e(k + 1) + 31e(k) $$

Controller Design

Given a continuous plant $G(s)$, a reference input $r(t)$, and some control specifications, find a digital controller (A/D, difference equation, D/A), such that the control specifications are satisfied.

One can do this in two following ways.

  1. Emulation
    • Design a continuous controller $D(s)$ (differential equation).
    • Approximate $D(s)$ by a difference equation.
  2. Discrete Design
    • Design difference equation directly without designing $D(s)$ first.

Design by Emulation

Given an analog controller $D(s)$, find $T$ and $D(z)$ such that the digital implementation of $D(s)$ has an input-output relation similar to that of $D(s)$.

In other words, $T$ and $D(z)$ are subject to $u_d(t) \approx u(t)$ for the same $e(t), t \geq 0$

There are two methods to do this

  1. Tustin’s Method (as we have seen)
  2. Matched Pole-Zero (MPZ) Method
Tustin’s Method

Tustin’s method is defined as, $$ D(z) = D(s) \Big|_{s = \frac{2}{T} \frac{z - 1}{z + 1}} $$

We call $s = \frac{2}{T} \frac{z - 1}{z + 1}$ as a bilinear transformation or Tustin’s transformation.

We also call the above equation as Tustin’s method for designing digital controllers.

Remark: For Tustin’ts method, the task at each step is to use a trapezoidal integration, that is, to approximate $e(t)$ by a straight line between two samples.

Let’s see an example.

Given $D(s) = 70 \frac{s + 2}{s + 10}$ and $T = \frac{1}{15}$.

Firstly,

$$ s = \frac{2}{T} \frac{z - 1}{z + 1} = 30 \frac{z - 1}{z + 1} $$

Then,

$$ D(z) = D(s) \Big|_{s = 30 \frac{z - 1}{z + 1}} = 70 \frac{30 \frac{z - 1}{z + 1} + 2}{30 \frac{z - 1}{z + 1} + 10} = 70 \frac{30z + 28}{30z + 40} $$

Matched Pole-Zero (MPZ) Method

Given a CT controller,

$$ D(s) = \frac{k_c(s + a)}{s + b}, \quad a > 0, b > 0 $$

Find a DT controller of the form,

$$ D(z) = \frac{k_d(z - z_a)}{z - z_b} $$

so that the behavior of the DT controller is similar to that of the CT controller.

To find this, we do the following.

Map poles and zeroes according to,

$$ z = e^{sT} $$

wich gives $z_a = e^{-aT}$ and $z_b = e^{-bT}$.

Thus,

$$ D(z) = \frac{k_d(z - e^{-aT})}{z - e^{-bT}} $$

Then we need to determine $k_d$ such that,

$$ \text{DC gain of } D(s) = \text{DC gain of } D(z) $$

Thus,

$$ \begin{align*} \text{DC gain } & = \lim_{s \to 0} sY(s) = \lim_{s \to 0} sD(s) U(s) \newline & = \lim_{s \to 0} s \frac{k_c(s + a)}{s + b} \frac{1}{s} = D(0) = \frac{k_c a}{b} \end{align*} $$

For DT systems, the DC gain is also defined as the final value of the output under the unit step input.

Thus,

$$ \begin{align*} \text{DC gain } &= \lim_{z \to 1} (1 - z^{-1})D(z)U(z) \newline &= \lim_{z \to 1} (1 - z^{-1}) \frac{k_d(z - e^{-aT})}{z - e^{-bT}} \frac{1}{1 - z^{-1}} \newline &= \lim_{z \to 1} k_d \frac{z - e^{-aT}}{z - e^{-bT}} = D(1) = \frac{k_d (1 - e^{-aT})}{1 - e^{-bT}} \end{align*} $$

Thus,

$$ \frac{k_c a}{b} = \frac{k_d (1 - e^{-aT})}{1 - e^{-bT}} $$

and we can solve for $k_d$,

$$ k_d = \frac{k_c a (1 - e^{-bT})}{b (1 - e^{-aT})} $$

Let’s see an example.

Given $G(s) = \frac{1}{s^2}$, design a digital controller so that the closed-loop system has a natural frequency $\omega_n = 0.3 \frac{rad}{s}$ and a damping ratio $\zeta = 0.7$.

Suppose a CT controller has been designed as,

$$ D(s) = 0.81 \frac{s + 0.2}{s + 2}. $$

We first need to find $T$. A rule of thumb of $T$ is that the sample rate satifes,

$$ \omega_s \triangleq \frac{2 \pi}{T} > 20 \omega_n $$

Letting $\frac{2 \pi}{T} = 20 \omega_n = 6$, thus $T \approx 6$.

Which means $e^{-aT} = 0.82$ and $e^{-bT} = 0.135$.

Finally, we can find $k_d$,

$$ k_d = \frac{0.81 \cdot 0.2 \cdot (1 - 0.135)}{2 \cdot (1 - 0.82)} = 0.1 $$

Thus,

$$ D(z) = 0.1 \frac{z - 0.82}{z - 0.135} $$