Unit 5.4: Models of Discrete-Time Systems#

An annotatable worksheet for this presentation is available as Worksheet 11 .

Scope and Background Reading#

In this section we will explore digital systems and learn more about the z-transfer function model.

The material in this presentation and notes is based on Chapter 9 (Starting at Section 9.7) of [Karris, 2012] . I have skipped the section on digital state-space models.

Agenda#

Discrete Time Systems#

In the lecture that introduced the z-transform we talked about the representation of a discrete-time (DT) system by the model shown below:

DT System

In this session, we want to explore the contents of the central block.

DT System as a Sequence Processor#

DT System as a Sequence Processor

What is the nature of the discrete time system?#

\[y_d[n] = h[n] * x_d[n]\] \[Y_d(z) = H(z) X_d(z)\]

Transfer Functions in the Z-Domain#

Let us assume that the sequence transformation is a difference equation of the form 2 :

Take Z-Transform of both sides#

From the z-transform properties

\[f[n-m] \Leftrightarrow z^<-m>F(z)\] \[Y(z) + a_1z^<-1>Y(z) + a_2z^Y(z) + \cdots + a_kz^Y(z) = . \] \[b_0 U(z) + b_1z^<-1>U(z) + b_2z^U(z) + \cdots + b_kz^U(z)\]

Gather terms#

\[\begin\begin \left( 1 + z^ + z^ + \cdots z^ \right)Y(z) = \\ \quad \left( b_0 + b_1 z^ + b_2 z^ + \cdots b_k z^ \right)U(z) \end\end\]

\[Y(z) = \left(\fracz^ + b_z^ + \cdots b_z^>z^ + a_z^ + \cdots a_z^ >\right) U(z)\]

Define the transfer function#

We define the discrete time transfer function \(H(z) := Y(z)/U(z)\) so…

\[H(z) = \frac = \fracz^ + b_z^ + \cdots b_z^>z^ + a_z^ + \cdots a_z^ >\]

… or more conventionally 3 :

\[H(z) = \fracz^ + b_z^ + \cdots b_z + b_>z^ + a_z^ + \cdots a_ z + a_>\]

DT impulse response#

The discrete-time impulse reponse \(h[n]\) is the response of the DT system to the input \(x[n] = \delta[n]\)

Last week we showed that

\[\mathcal\left\\]

was defined by the transform pair

\[\delta[n] \Leftrightarrow 1\] \[h[n] = \mathcal^\left\ = \mathcal^\left\\]

We will work through an example in class.

[Skip next slide in Pre-Lecture]

Example 5#

Karris Example 9.10:

The difference equation describing the input-output relationship of a DT system with zero initial conditions, is:

\[y[n] - 0.5 y[n-1] + 0.125 y[n-2] = x[n] + x[n -1]\]
  1. The transfer function \(H(z)\)
  2. The DT impulse response \(h[n]\)
  3. The response \(y[n]\) when the input \(x[n]\) is the DT unit step \(u_0[n]\)

5.1. The transfer function#

5.2. The DT impulse response#

\[\frac = \frac\]
MATLAB Solution#
clear all cd matlab pwd format compact open dtm_ex1_2 
ans = '/Users/eechris/code/src/github.com/cpjobling/eg-247-textbook/dt_systems/4/matlab'

The difference equation describing the input-output relationship of the DT system with zero initial conditions, is:

\[y[n] - 0.5 y[n-1] + 0.125 y[n-2] = x[n] + x[n -1]\]
Transfer function#

Numerator \(z^2 + z\)

Nz = [1 1 0]; 

Denominator \(z^2 - 0.5 z + 0.125\)

Dz = [1 -0.5 0.125]; 
Poles and residues#
[r,p,k] = residue(Nz,Dz) 
r = 0.7500 - 0.5000i 0.7500 + 0.5000i
p = 0.2500 + 0.2500i 0.2500 - 0.2500i k = 1
Impulse Response#
Hz = tf(Nz,Dz,1) hn = impulse(Hz, 15); 
z^2 + z
z^2 - 0.5 z + 0.125
Sample time: 1 seconds
Discrete-time transfer function.
Plot the response#
stem([0:15], hn) grid title('Example 5 - Part 2') xlabel('n') ylabel('Impulse response h[n]') 

../../_images/522f391695e8954db791876ed8b2f33ebccb29998c776161789d928484014ff8.png

Response as stepwise continuous y(t)#
impulse(Hz,15) grid title('Example 5 - Part 2 - As Analogue Signal') xlabel('nTs [s]') ylabel('Impulse response h(t)') 

../../_images/cb706451219234c483753b03e0483f6c5cf8f87317d054746e3cb9a10b5f2023.png

5.3. The DT step response#

\[u_0[n] \Leftrightarrow \frac\]

We will work through this example in class.

[Skip next slide in Pre-Lecture]

\[\begin\begin Y(z) = H(z)(z) &=& \frac.\frac\\ & = & \frac <(z^2 - 0.5z + 0.125)(z - 1)>\end\end\] \[\frac = \frac<(z^2 + 0.5 z + 0.125)(z - 1)>\]

Solved by inverse Z-transform.

MATLAB Solution#
open dtm_ex1_3 
Results#

Results

Modelling DT systems in MATLAB and Simulink#

We will consider some examples in class

MATLAB#

Code extracted from dtm_ex1_3.m:

Ts = 1; z = tf('z', Ts); 
Hz = (z^2 + z)/(z^2 - 0.5 * z + 0.125) 
z^2 + z
z^2 - 0.5 z + 0.125
Sample time: 1 seconds
Discrete-time transfer function.
step(Hz) grid title('Example 1 - Part 3 - As Analogue Signal') xlabel('nTs [s]') ylabel('Step response y(t)') axis([0,15,0,3.5]) 

../../_images/0f97449211a2968c5b97f6ee4189e9da5a663675128a6b03e5039550e653ae94.png

Simulink Model#

Simulink model

Results#

Simulink results

Converting Continuous Time Systems to Discrete Time Systems#

In analogue electronics, to implement a filter we would need to resort to op-amp circuits with resistors, capacitors and inductors acting as energy dissipation, storage and release devices.

  • In modern digital electronics, it is often more convenient to take the original transfer function \(H(s)\) and produce an equivalent \(H(z)\) .
  • We can then determine a difference equation that will respresent \(h[n]\) and implement this as computer algorithm.
  • Simple storage of past values in memory becomes the repository of past state rather than the integrators and derivative circuits that are needed in the analogue world.

To achieve this, all we need is to be able to do is to sample and process the signals quickly enough to avoid violating Nyquist-Shannon’s sampling theorem.

Continuous System Equivalents#

  • There is no digital system that uniquely represents a continuous system
  • This is because as we are sampling, we only have knowledge of signals being processed at the sampling instants, and need to reconstruct the inter-sample behaviour.
  • In practice, only a small number of transformations are used.
  • The derivation of these is beyond the scope of this module, but in class we’ll demonstrate the ones that MATLAB provides in a function called c2d

MATLAB c2d function#

Let’s see what the help function says:

help c2d 
C2D Converts continuous-time dynamic system to discrete time. SYSD = C2D(SYSC,TS,METHOD) computes a discrete-time model SYSD with sample time TS that approximates the continuous-time model SYSC. The string METHOD selects the discretization method among the following: 'zoh' Zero-order hold on the inputs 'foh' Linear interpolation of inputs 'impulse' Impulse-invariant discretization 'tustin' Bilinear (Tustin) approximation. 'matched' Matched pole-zero method (for SISO systems only). 'least-squares' Least-squares minimization of the error between frequency responses of the continuous and discrete systems (for SISO systems only). 'damped' Damped Tustin approximation based on TRBDF2 formula (sparse models only). The default is 'zoh' when METHOD is omitted. The sample time TS should be specified in the time units of SYSC (see "Tim
eUnit" property). C2D(SYSC,TS,OPTIONS) gives access to additional discretization options. Use C2DOPTIONS to create and configure the option set OPTIONS. For example, you can specify a prewarping frequency for the Tustin method by: opt = c2dOptions('Method','tustin','PrewarpFrequency',.5); sysd = c2d(sysc,.1,opt); For state-space models, [SYSD,G] = C2D(SYSC,Ts,METHOD) also returns the matrix G mapping the states xc(t) of SYSC to the states xd[k] of SYSD: xd[k] = G * [xc(k*Ts) ; u[k]] Given an initial condition x0 for SYSC and an initial input value u0=u(0), the equivalent initial condition for SYSD is (assuming u(t)=0 for t<0): xd[0] = G * [x0;u0] . For gridded LTV/LPV models (see ssInterpolant), C2D discretizes the LTI model at each grid point and interpolates the resulting discrete-time data. To interpolate the continuous-time data instead, first convert the gridded model to LTVSS or LPVSS. For all other LTV/LPV mode
ls, C2D uses the Tustin method which amounts to fixed-step integration with the trapezoidal rule. See also C2DOPTIONS, D2C, D2D, SSINTERPOLANT, LTVSS, LPVSS, DYNAMICSYSTEM. Documentation for c2d doc c2d Other uses of c2d DynamicSystem/c2d ltipack.tfdata/c2d
doc c2d 

Example: Digital Butterworth Filter#

  • Design a 2nd-order butterworth low-pass anti-aliasing filter with transfer function \(H(s)\) for use in sampling music.
  • The cut-off frequency \(\omega_c = 20\) kHz and the filter should have an attenuation of at least \(-80\) dB in the stop band.
  • Choose a suitable sampling frequency for the audio signal and give the transfer function \(H(z)\) and an algorithm to implement \(h[n]\)

Solution#

First determine the cut-off frequency \(\omega_c\)

\[\omega_c = 2\pi f_c = 2\times \pi \times 20\times 10^3\;\mathrm\]
wc = 2*pi*20e3