Discrete-Time

David Johns and Ken Martin University of Toronto ([email protected]) ([email protected])

University of Toronto 1 of 40

© D. Johns, K. Martin, 1997 Overview of Some Signal Spectra

st() xn()= x ()nT c yn() ys()t ysh()t xc()t xs()t convert to convert to analog yc()t discrete-time DSP impulse hold low-pass sequence train filter

Conceptual

x ()t y ()t sh xn()= xc()nT yn() sh xc()t sample D/A analog A/D y ()t and DSP converter low-pass c converter hold with hold filter

Typical Implementation

University of Toronto 2 of 40

© D. Johns, K. Martin, 1997 Example Signal Spectra τxs()t A Xc()f xc()t f t fo f τ → 0 s A X ()f --- s T xn() f f o fs 2fs 4567 n A 0 12 3 --- X()ω T ω ()2πfo ⁄ fs 2π 4π xsh()t A X ()f t sh f f o fs 2fs time frequency

University of Toronto 3 of 40

© D. Johns, K. Martin, 1997 Example Signal Spectra

• Xs()f has same spectra as Xc()f but repeats every fs (assuming no occurs).

• X()ω has same spectra as Xs()f freq axis normalized.

sinx • Spectra for X ()f equals X ()f multiplied by ------sh s x response — in effect, filtering out high frequency images.

University of Toronto 4 of 40

© D. Johns, K. Martin, 1997 & Discrete-Time xc()t (all pulses) τxs()t

nT t 2T 3T T τ

(single pulse at nT) τxsn()t

• xs()t scaled by τ such that the area under the pulse at nT equals the value of xc()nT . • In other words, at tn= T , we have x ()nT x ()nT = ------c (1) s τ

University of Toronto 5 of 40

© D. Johns, K. Martin, 1997 Laplace Transform & Discrete-Time

• Thus as τ → 0 , height of xs()t at time nT goes to ∞ and so we plot τxs()t instead. • Define ϑ()t to be the step function,

 1 ()t ≥ 0 ϑ()t ≡  (2)  0 ()t < 0

• then single-pulse signal, xsn()t , can be written as x ()nT x ()t = ------c []ϑ()tnT– – ϑ()tnT– – τ (3) sn τ

and the entire signal xs()t as ∞

xs()t = ∑ xsn()t (4) n = –∞

University of Toronto 6 of 40

© D. Johns, K. Martin, 1997 Laplace Transform & Discrete-Time • Above signals are defined for all time — we can find Laplace transforms of these signals.

• The Laplace transform Xsn()s for xsn()t is –sτ 1 1 – e –snT X ()s = ---------x ()nT e (5) sn τs c

and X()s is simply a linear combination of xsn()t , which results in ∞ –sτ 1 1 – e –snT X ()s = ---------x ()nT e (6) s τs ∑ c n = –∞

University of Toronto 7 of 40

© D. Johns, K. Martin, 1997 Laplace Transform & Discrete-Time 2 x x • Using the expansion e = 1 ++x ----- +… , when τ → 0 , 2! the term before the summation in (6) goes to unity. • Therefore, as τ → 0 , ∞ –snT Xs()s = ∑ xc()nT e (7) n = –∞ • This Laplace transform only depends on sample points, xc()nT which in turn depends on the relative sampling-rate, T.

University of Toronto 8 of 40

© D. Johns, K. Martin, 1997 Spectra of Discrete-Time Signals

• xs()t spectra can be found by replacing sj= ω in (7) • However, a more intuitive approach is ... • Define a periodic pulse train, st() as ∞ st() = ∑ δ()tnT– (8) n = –∞ where δ()t is the unit impulse function.

• Then xs()t can be written as

xs()t = xc()t st() (9) 1 X ()jω = ------X ()jω ⊗ Sj()ω (10) s 2π c where ⊗ denotes convolution.

University of Toronto 9 of 40

© D. Johns, K. Martin, 1997 Spectra of Discrete-Time Signals • Since the Fourier transform of a periodic impulse train is another periodic impulse train we have ∞ 2π 2π Sj()ω = ------δω()– k------(11) T ∑ T k = –∞ • Thus, the spectra Xs()jω is found to be ∞ 1 jk2π X ()jω = --- X ()jω – ------(12) s T ∑ c T k = –∞ • or equivalently, ∞ 1 X ()f = --- X ()j2πfjk– 2πf (13) s T ∑ c s k = –∞

University of Toronto 10 of 40

© D. Johns, K. Martin, 1997 Spectra for Discrete-Time Signals

• The spectra for the sampled signal xs()t equals a sum of shifted spectra of xc()t .

• No aliasing will occur if Xc()jω is bandlimited to fs ⁄ 2 .

• Note that xs()t can not exist is practice as it would require an infinite amount of power (seen by integrating Xs()f over all frequencies).

University of Toronto 11 of 40

© D. Johns, K. Martin, 1997 Spectra Example

xn() X ()f , X()ω x ()t s c τxs()t t f 0.25 0.5 1Hz 4Hz 8Hz ()n ()ω ()1 ()2 ()0.5π ()2π ()4π

xn() Xs2()f , X2()ω xc()t τxs()t f t 1Hz 12Hz 24Hz 0.25 0.5 ()n π ()3 ()6 --- ()2π ()4π ()ω 6

University of Toronto 12 of 40

© D. Johns, K. Martin, 1997 Z-Transform • The z-transform is merely a shorthand notation for (7). • Specifically, defining sT ze≡ (14) • we can write ∞ –n Xz()≡ ∑ xc()nT z (15) n = –∞ • where X()z is called the z-transform of the samples xc()nT .

University of Toronto 13 of 40

© D. Johns, K. Martin, 1997 Z-Transform • 2 properties of the z-transform are: –k — If xn()↔ Xz() , then xn()– k ↔ z Xz() — Convolution in the time domain is equivalent to multiplication in the frequency domain.

X()z is not a function of the sampling-rate! • A 1Hz signal sampled at 10Hz has the same transform as a similar 1kHz signal sampled at 10kHz

• X()z is only related to the numbers, xc()nT while Xs()s is the Laplace transform of the signal xs()t as τ → 0 . • Think of the series of numbers as having a sample- rate normalized to T = 1 (i.e. f's = 1Hz ).

University of Toronto 14 of 40

© D. Johns, K. Martin, 1997 Z-Transform • Such a normalization results in 2πf Xs()f = X()------(16) fs or equivalently, a frequency scaling of 2πf ω = ------(17) fs • Thus, discrete-time signals have ω in units of radians/sample. • Continuous-time signals have frequency units of cycles/ second (hertz) or radians/second.

University of Toronto 15 of 40

© D. Johns, K. Martin, 1997 Example Sinusoidal Signals xn() xn()

10 15 1 5 n 1 5 10 15 n

0 rad/sample= 0 cycles/sample π ⁄ 8 rad/sample = 116⁄ cycles/sample xn() xn()

5 15 15 1 10 n 1 5 10 n

π ⁄ 4 rad/sample = 18⁄ cycles/sample π ⁄ 2 rad/sample = 14⁄ cycles/sample

University of Toronto 16 of 40

© D. Johns, K. Martin, 1997 Example Sinusoidal Signals • A continuous-time sinusoidal signal of 1kHz when sampled at 4kHz will change by π ⁄ 2 radians between each sample. • Such a discrete-time signal is defined to have a frequency of π ⁄ 2 rad/sample . • Note that discrete-time signals are not unique since the addition of 2π will result in the same signal. • For example, a discrete-time signal having a frequency of π ⁄ 4 rad/sample is identical to that of 9π ⁄ 4 rad/sample. • Normally discrete-time signals are defined to have frequency components only between –π and π rad/sample.

University of Toronto 17 of 40

© D. Johns, K. Martin, 1997 Downsampling

n n L 0 4 8 0 1 2 L = 4

ω ω π 4π --- 2π 0 ------2π 6 6 • Keep every L ‘th sample and throw away L – 1 samples. • It expands the original spectra by L . • For aliasing not to occur, original signal must be bandlimited to π ⁄ L .

University of Toronto 18 of 40

© D. Johns, K. Martin, 1997 n n L 0 1 2 0 4 8 L = 4

ω 4π π 0 ------2π --- π 2π 6 6 • Insert L – 1 zero values between samples • The frequency axis is scaled by L such that 2π now occurs where L2π occurred in the original signal. • No worry about aliasing here.

University of Toronto 19 of 40

© D. Johns, K. Martin, 1997 Discrete-Time Filters

un() Hz() yn() (yn() equals hn() if un() is an impulse) (discrete-time filter)

• An input series of numbers is applied to a discrete- time filter to create an output series of numbers. • This filtering of discrete-time signals is most easily visualized with the shorthand notation of z-transforms . Transfer-Functions • Similar to those for continuous-time filters except instead of polynomials in “s ”, polynomials in “z ” are obtained.

University of Toronto 20 of 40

© D. Johns, K. Martin, 1997 Cont-Time Transfer-Function

• Low-pass continuous-time filter, Hc()s , 4 H ()s = ------(18) c 2 s ++2s 4 • The poles are the roots of the denominator polynomial • Poles: – 1.0 ± 1.7321j for this example. • Zeros: Defined to have two zeros at ∞ since the den poly is two orders higher than the numerator poly.

University of Toronto 21 of 40

© D. Johns, K. Martin, 1997 Cont-Time high-frequency s-plane jω∞= jω

dc (poles) jω = 0

• Poles and zeros plotted in the s -plane. • Substitution sj= ω is equivalent to finding the magnitude and phase of vectors from a point along the jω axis to all the poles and zeros.

University of Toronto 22 of 40

© D. Johns, K. Martin, 1997 Discrete-Time Transfer-Function 0.05 Hz()= ------(19) 2 z – 1.6z + 0.65 • Poles: 0.8± 0.1j in the z -plane and two zeros are again at ∞ . • To find the frequency response of Hz() , the poles and zeros can be plotted in the z -plane, and the unit jω circle contour is used, ze=

University of Toronto 23 of 40

© D. Johns, K. Martin, 1997 Discrete-Time Frequency Response jω ωπ= ⁄ 2 e z-plane j

ω = 0 -1 ω

1 ω = 2π ωπ= -j 3π ω = ------2 • Note that poles or zeros occurring at z = 0 do not affect the magnitude response of Hz() since a vector from the origin to the unit circle always has a length of unity. However, they would affect the phase response.

University of Toronto 24 of 40

© D. Johns, K. Martin, 1997 Discrete-Time Frequency Response • z = 1 corresponds to the frequency response at both dc (i.e. ω = 0 ) and for ω = 2π . • The time normalization of setting T = 1 implies that ω = 2π is equivalent to the sampling-rate speed (i.e. ff= s ) for Xs()f . • As with cont-time filter, if filter coefficients are real, poles and zeros occur in complex-conjugate pairs — magnitude is symmetric, phase is anti-symmetric. • Going around the circle again would give the same result as the first time implying that the frequency response repeats every 2π .

University of Toronto 25 of 40

© D. Johns, K. Martin, 1997 Stability of Discrete-Time Filters yn()+ 1 b –1 xn() z yn()

a • To realize rational polynomials in “z ”, discrete-time –1 filters use delay elements (i.e. “z ” building blocks) much the same way that analog filters can be formed –1 using integrators (i.e. “s ” building blocks). • The result is finite difference equations describing discrete-time filters

University of Toronto 26 of 40

© D. Johns, K. Martin, 1997 Stability of Discrete-Time Filters • A finite difference equation can be written for above system y()n + 1 = bx() n + ay() n (20) • In the z -domain, this equation is written as zY() z = bX() z + aY() z (21) • We find Hz() given by Yz() b Hz()≡ ------= ------(22) Xz() za– which has a pole on the real axis at z = a .

University of Toronto 27 of 40

© D. Johns, K. Martin, 1997 Stability of Discrete-Time Filters • To test for stability, let the input xn() be an impulse y()0 = k where k is some arbitrary initial state value for y . y()1 = bak+ 2 y()2 = ab+ a k 2 3 y()3 = a ba+ k 3 4 y()4 = a ba+ k :

University of Toronto 28 of 40

© D. Johns, K. Martin, 1997 Stability of Discrete-Time Filters • The response, hn() , is seen to be given by

  0 ()n < 1 hn()= (23)  n – 1 n  ()a ba+ k ()n ≥ 1  • This response remains bounded only when a ≤ 1 for this first-order filter and is unbounded otherwise.

• In general, a linear time-invariant discrete-time filter, Hz() , is stable if and only if all its poles are located within the unit circle.

University of Toronto 29 of 40

© D. Johns, K. Martin, 1997 IIR Filters • Infinite-Impulse-Response (IIR) filters are those discrete-time filters that when excited by an impulse, their outputs remain non-zero assuming infinite precision arithmetic. • The above example is IIR when a ≠ 0 • IIR filters can be more efficient when long impulse responses are needed. • They have some unusual behaviors due to finite- precision effects such as limit-cycles.

University of Toronto 30 of 40

© D. Johns, K. Martin, 1997 FIR Filters • Finite-Impulse-Response (FIR) filters are those discrete-time filters that when excited by an impulse, their outputs go precisely to zero (and remain zero) after a finite value of n . • Example — running average of 3 1 yn()= ---()xn()++xn()– 1 xn()– 2 (24) 3 2 1 –i Hz()= --- z (25) 3 ∑ i = 0 • Has poles but they all occur at z = 0 . • FIR filters are always stable and exact linear phase filters can be realized.

University of Toronto 31 of 40

© D. Johns, K. Martin, 1997 Bilinear Transform

• Consider Hc()p as a continuous-time transfer-function (where “p ” is the complex variable equal to σp + jΩ ), the bilinear transform is defined to be given by, z – 1 p = ------(26) z + 1 • The inverse transformation is given by, 1 p z = ------+ - (27) 1 – p

• The zf -plane locations of 1 and -1 (i.e. dc and s ⁄ 2 ) are mapped to p -plane locations of 0 and ∞ , respectively.

University of Toronto 32 of 40

© D. Johns, K. Martin, 1997 Bilinear Transform jω • The unit circle, z = e , in the z -plane is mapped to the entire jΩ axis in the p -plane.

jω j()ω ⁄ 2 j()ω ⁄ 2 –j()ω ⁄ 2 e 1 e ()e – e p ==------– ------(28) jω j()ω ⁄ 2 j()ω ⁄ 2 –j()ω ⁄ 2 e + 1 e ()e + e 2jsin()ω ⁄ 2 ==------jtan()ω ⁄ 2 (29) 2cos()ω ⁄ 2 • Results in the following frequency “warping”. Ωω= tan()⁄ 2 (30)

University of Toronto 33 of 40

© D. Johns, K. Martin, 1997 Bilinear Transform Filter Design

• Design a continuous-time transfer-function, Hc()p , and choose the discrete-time transfer-function, Hz() , such that

Hz()≡ Hc()()z – 1 ⁄ ()z + 1 (31) so that jω He()= Hc()jtan()ω ⁄ 2 (32) • The response of Hz() is seen to be equal to the response of Hc()p except with a frequency “warping” • Order of the cont-time and discrete-time also same.

University of Toronto 34 of 40

© D. Johns, K. Martin, 1997 Bilinear Design Example • Find a first-order Hz() that has a 3db frequency at fs ⁄ 20, a zero at -1 and a dc gain of one.

• Using (30), the frequency value, fs ⁄ 20 , or equivalently, ω ==()2π ⁄ 20 0.314159 is mapped to Ω = 0.1584.

• Thus, Hc()p should have a 3dB frequency value of 0.1584 rad/s. • Such a 3db frequency value is obtained by having a p-plane zero equal to ∞ and pole equal to -0.1584.

University of Toronto 35 of 40

© D. Johns, K. Martin, 1997 Bilinear Design Example • Transforming these continuous-time pole and zero back using (27) results in a z -plane zero at -1 and a pole at 0.7265. • Therefore, Hz() appears as kz()+ 1 Hz()= ------(33) z – 0.7265 • The constant k can be determined by setting the dc gain to one, or equivalently, H()1 = 1 which results in k = 0.1368.

University of Toronto 36 of 40

© D. Johns, K. Martin, 1997 Sample-and-Hold Response

• A sample-and-held signal, xsh()t , is related to its sampled signal by the mathematical relationship, ∞

xsh()t = ∑ xc()nT []ϑ()tnT– – ϑ()tnT– – T (34) n = –∞

• xsh()t is well-defined for all time and thus the Laplace transform can be found to be equal to ∞ –sT 1 – e –snT X ()s = ------x ()nT e sh s ∑ c n = –∞ sT 1 – e = ------Xs()s s (35)

University of Toronto 37 of 40

© D. Johns, K. Martin, 1997 Sample-and-Hold Response

• The hold transfer-function, Hsh()s , is equal to –sT 1 – e H ()s = ------(36) sh s

• The spectra for Hsh()s is found by substituting sj= ω

jωT ωT –jωT –------sin ------1 – e 2 2 H ()jω ==------Te××------(37) sh jω ωT ------2

University of Toronto 38 of 40

© D. Johns, K. Martin, 1997 Sample-and-Hold Response • The magnitude of this response is given by ωT sin------2 H ()jω = T------sh ωT ------2

πf sin----- f or H ()f = T------s sh πf ----- f s (38) sinx • and is often referred to as the “------” or “sinc” x response.

University of Toronto 39 of 40

© D. Johns, K. Martin, 1997 Sample-and-Hold Response

Hsh()jω

f –3fs –2fs –fs 0 fs 2fs 3fs • This frequency shaping of a sample-and-hold only occurs for a continuous-time signal. • Specifically, a sample-and-hold before an A/D converter does not aid in any anti-aliasing requirement since the A/D converter has a true discrete-time output.

University of Toronto 40 of 40

© D. Johns, K. Martin, 1997