Discrete-Time David Johns and Ken Martin University of Toronto (johns@eecg.toronto.edu) (martin@eecg.toronto.edu) University of Toronto 1 of 40
Overview of Some Signal Spectra x c () t st () x s () t xn ( ) x c ( nt) yn ( ) y s () t y sh () t convert to discrete-time sequence DSP convert to impulse train hold analog low-pass filter y c () t Conceptual x c () t sample and hold x sh () t xn ( ) x c ( nt) yn ( ) A/D converter DSP D/A converter with hold y sh () t analog low-pass filter y c () t Typical Implementation University of Toronto 2 of 40
τx s () t τ 0 xn ( ) 0 1 2 3 x c () t Example Signal Spectra 4 5 6 7 x sh () t time t n t A A -- T A -- T A X c () f f o X s () f f o X( ω) ( 2πf o ) f s f o X sh () f f s 2π f s frequency f s 2f s 4π 2f s f f ω f University of Toronto 3 of 40
Example Signal Spectra X s () f has same spectra as X c f but repeats every (assuming no aliasing occurs). () f s X( ω) has same spectra as X s () f freq axis normalized. Spectra for X sh () f equals X s () f multiplied by --------- sinx x response in effect, filtering out high frequency images. University of Toronto 4 of 40
Laplace Transform & Discrete-Time x c () t τx s () t (all pulses) τ 2T 3T T nt t τx sn () t (single pulse at nt) x s () t scaled by τ such that the area under the pulse at nt equals the value of x c ( nt). In other words, at t nt x s ( nt), we have x c ( nt) -------------- τ (1) University of Toronto 5 of 40
Laplace Transform & Discrete-Time Thus as τ 0, height of x s () t at time nt goes to and so we plot τx s () t instead. Define ϑ() t to be the step function, ϑ() t 1 ( t 0) 0 ( t < 0) (2) then single-pulse signal, x sn () t, can be written as x sn () t and the entire signal x s () t as x c ( nt) -------------- [ ϑ( t nt) ϑ( t nt τ) ] τ x s () t x sn () t n (3) (4) University of Toronto 6 of 40
Laplace Transform & Discrete-Time Above signals are defined for all time we can find Laplace transforms of these signals. The Laplace transform X sn () s for x sn () t is X sn () s 1 -- 1 e sτ ------------------ xc ( nt)e snt τ s and X() s is simply a linear combination of x sn () t, which results in X s () s 1 -- 1 e sτ ------------------ x τ s c ( nt)e snt n (5) (6) University of Toronto 7 of 40
Laplace Transform & Discrete-Time Using the expansion e x 1 + x + ---- +, when τ 0, the term before the summation in (6) goes to unity. Therefore, as τ 0, This Laplace transform only depends on sample points, x c ( nt) which in turn depends on the relative sampling-rate, T. x 2 2! X s () s x c ( nt)e snt n (7) University of Toronto 8 of 40
Spectra of Discrete-Time Signals x s () t spectra can be found by replacing s jω in (7) However, a more intuitive approach is... Define a periodic pulse train, st () as st () δ( t nt) where δ() t is the unit impulse function. Then x s () t can be written as X s ( jω) where denotes convolution. n x s () t x c ()st t ----- 1 X 2π c ( jω) Sjω ( ) (8) (9) (10) University of Toronto 9 of 40
Spectra of Discrete-Time Signals Since the Fourier transform of a periodic impulse train is another periodic impulse train we have Sjω ( ) Thus, the spectra X s ( jω) is found to be X s ( jω) or equivalently, X s () f 2π ----- δω k 2π T ( ----- ) T k -- 1 X T c ( jω ---------- jk2π ) T k 1 -- X T c ( j2πf jk2πf s ) k (11) (12) (13) University of Toronto 10 of 40
Spectra for Discrete-Time Signals The spectra for the sampled signal x s () t equals a sum of shifted spectra of x c () t. No aliasing will occur if X c ( jω) is bandlimited to f s 2. Note that x s () t can not exist is practice as it would require an infinite amount of power (seen by integrating X s () f over all frequencies). University of Toronto 11 of 40
Spectra Example 0.25 0.5 ( 1) ( 2) xn ( ) x c () t τx s () t t ( n) X s () f, X( ω) 1Hz 4Hz 8Hz ( 0.5π) ( 2π) ( 4π) ( ω) f xn ( ) x c () t τx s () t X s2 () f, X 2 ( ω) 0.25 0.5 ( 3) ( 6) t ( n) 1Hz π -- 6 12Hz 24Hz ( 2π) ( 4π) ( ω) f University of Toronto 12 of 40
Z-Transform The z-transform is merely a shorthand notation for (7). Specifically, defining we can write z where X() z is called the z-transform of the samples x c ( nt). e st Xz () x c ( nt)z n n (14) (15) University of Toronto 13 of 40
Z-Transform 2 properties of the z-transform are: ( ) z k Xz If xn ( ) Xz (), then xn k () 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, x c ( nt) while X s s is the Laplace transform of the signal x s () t as τ 0. Think of the series of numbers as having a samplerate normalized to T 1 (i.e. f' s 1Hz). () University of Toronto 14 of 40
Z-Transform Such a normalization results in X s () f X( ------- 2πf ) or equivalently, a frequency scaling of ω 2πf ------- f s f s (16) (17) 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
Example Sinusoidal Signals xn ( ) xn ( ) 1 5 10 15 n 0 rad/sample 0 cycles/sample 10 15 1 5 n π 8 rad/sample 1 16 cycles/sample xn ( ) xn ( ) 5 15 1 10 n 15 1 5 10 n π 4 rad/sample 1 8 cycles/sample π 2 rad/sample 1 4 cycles/sample University of Toronto 16 of 40
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
Downsampling n 0 4 8 0 1 2 L L 4 n π -- 6 2π ω 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. 0 4π ----- 6 2π ω University of Toronto 18 of 40
Upsampling 0 1 2 n L L 4 0 4 8 n 0 4π ----- 6 2π Insert L 1 zero values between samples ω π -- π 6 The frequency axis is scaled by L such that 2π now occurs where L2π occurred in the original signal. No worry about aliasing here. 2π University of Toronto 19 of 40
Discrete-Time Filters un ( ) Hz () yn ( ) yn ( ) (discrete-time filter) hn ( ) un ( ) ( equals if is an impulse) An input series of numbers is applied to a discretetime 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
Cont-Time Transfer-Function Low-pass continuous-time filter, H c () s, H c () s 4 ------------------------- s 2 + 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. (18) University of Toronto 21 of 40
Cont-Time Frequency Response high-frequency s-plane jω jω (poles) dc jω 0 Poles and zeros plotted in the s-plane. Substitution s jω 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
Discrete-Time Transfer-Function Hz () 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 circle contour is used, 0.05 ------------------------------------- z 2 1.6z + 0.65 z e jω (19) University of Toronto 23 of 40
Discrete-Time Frequency Response ω π 2 j e jω z-plane -1 ω ω 0 ω π -j 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. ω 1 ----- 3π 2 ω 2π University of Toronto 24 of 40
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 ω f 2π is equivalent to the sampling-rate speed (i.e. ) for X s () f. f s 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
Stability of Discrete-Time Filters yn ( + 1) b xn ( ) yn ( ) z 1 To realize rational polynomials in z, discrete-time filters use delay elements (i.e. z 1 building blocks) much the same way that analog filters can be formed using integrators (i.e. s 1 building blocks). The result is finite difference equations describing discrete-time filters a University of Toronto 26 of 40
Stability of Discrete-Time Filters A finite difference equation can be written for above system In the z-domain, this equation is written as We find Hz () given by y( n + 1) bx( n) + ay( n) zy() z bx() z + ay() z Hz () Yz () Xz --------- () b ---------- z a which has a pole on the real axis at z a. (20) (21) (22) University of Toronto 27 of 40
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) b + ak y( 2) ab + a 2 k y( 3) a 2 b + a 3 k y( 4) a 3 b + a 4 k : University of Toronto 28 of 40
Stability of Discrete-Time Filters The response, hn ( ), is seen to be given by hn ( ) 0 ( n < 1) ( a n 1 b + a n k) ( n 1) (23) 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
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 finiteprecision effects such as limit-cycles. University of Toronto 30 of 40
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 yn ( ) 1 -- ( xn ( ) + xn ( 1) + xn ( 2) ) 3 Hz () 1 3 -- z i i 0 Has poles but they all occur at z 0. FIR filters are always stable and exact linear phase filters can be realized. 2 (24) (25) University of Toronto 31 of 40
Bilinear Transform Consider H c ( 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 ---------- z + 1 The inverse transformation is given by, 1 + p z ----------- 1 p The z-plane locations of 1 and -1 (i.e. dc and f s 2 ) are mapped to p-plane locations of 0 and, respectively. (26) (27) University of Toronto 32 of 40
Bilinear Transform The unit circle, z, in the z-plane is mapped to the entire jω axis in the p-plane. e jω p e j ω 2 ( ) e j( ω 2) e j( ω 2) e jω 1 ( ) ---------------- e jω ------------------------------------------------------------------ + 1 e j( ω 2) ( e j( ω 2) + e j( ω 2) ) 2j ---------------------------- sin( ω 2) jtan( ω 2) 2cos( ω 2) Results in the following frequency warping. Ω tan( ω 2) (28) (29) (30) University of Toronto 33 of 40
Bilinear Transform Filter Design Design a continuous-time transfer-function, H c ( p), and choose the discrete-time transfer-function, Hz (), such that Hz () H c (( z 1) ( z + 1) ) (31) so that He jω ( ) H c ( jtan( ω 2) ) (32) The response of Hz () is seen to be equal to the response of H c ( p) except with a frequency warping Order of the cont-time and discrete-time also same. University of Toronto 34 of 40
Bilinear Design Example Find a first-order Hz () that has a 3db frequency at f s 20, a zero at -1 and a dc gain of one. Using (30), the frequency value, f s 20, or equivalently, ω ( 2π) 20 0.314159 is mapped to Ω 0.1584. Thus, H c ( 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
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 Hz () kz ( + 1) ------------------------ 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. (33) University of Toronto 36 of 40
Sample-and-Hold Response A sample-and-held signal, x sh () t, is related to its sampled signal by the mathematical relationship, x sh () t x c ( nt) [ ϑ( t nt) ϑ( t nt T) ] n x sh () t is well-defined for all time and thus the Laplace transform can be found to be equal to X sh () s 1 e st ------------------ x s c ( nt)e snt n 1 e st ---------------- X s s () s (34) (35) University of Toronto 37 of 40
Sample-and-Hold Response The hold transfer-function, H sh () s H sh () s 1 e st ------------------ s, is equal to The spectra for H sh s is found by substituting () s jω (36) H sh ( jω) 1 e jωt jωt --------- sin ------- ωt 2 2 --------------------- T e -------------------- jω ωt ------- 2 (37) University of Toronto 38 of 40
Sample-and-Hold Response The magnitude of this response is given by sin ωt ------- 2 H sh ( jω) T----------------------- ωt ------- 2 or sin πf ---- f s H sh () f T--------------------- πf ---- f s and is often referred to as the response. sinx --------- x or sinc (38) University of Toronto 39 of 40
Sample-and-Hold Response H sh ( jω) 3f s 2f s f s 0 f s 2f s 3f s f 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