lab 5: second order ct and dt filters, dtmf project (first...

13
ECEN 3300 Linear Systems Spring 2010 03-29-10 P. Mathys Lab 5: Second Order CT and DT Filters, DTMF Project (First Draft) 1 Introduction Second order systems with complex-conjugate poles are the fundamental building blocks from which higher order infinite impulse response (IIR) filters are made. Using the Laplace transform, the frequency domain characterization of second order CT (continuous time) systems in terms of the (undamped) resonant frequency ω 0 and the damping ratio ζ is reasonably straightforward and intuitive. Direct frequency domain analysis of second order DT (discrete time) systems is complicated by the fact that their frequency response is periodic and needs to be evaluated along a circle rather than a straight line. However, using the bilinear transformation s =2F s (1-z -1 )/(1+z -1 ) with sampling rate F s , a DT system can be transformed into an intermediate CT system for analysis and design purposes, and then the results are transformed back to characterize the DT system. One application for second order CT or DT bandpass filters (BPF) is the decoding of DTMF (dual tone multi-frequency) tones that are used for dialing telephone numbers. In this case each 0 ... 9 digit (and some additional symbols) is transmitted using a pair of frequencies, one from a low group of four frequencies and one from a high group of four frequencies. The receiving end then uses a total of 8 BPFs to determine which combination of frequencies from the low and the high frequency group were transmitted and maps the result back into the corresponding digit (or symbol). On goal of this lab is to design and implement DT BPFs for the purpose of receiving and decoding DTMF signals. 1.1 Second Order CT Lowpass Filters The system function of a CT lowpass filter (LPF) with unit gain at dc is H (s)= ω 2 0 s 2 +2ζω 0 s + ω 2 0 , where ω 0 is the (undamped) resonant frequency and ζ is the damping ratio. The frequency response of the LPF is H ()= ω 2 0 ω 2 0 - ω 2 + j 2ζω 0 ω , with magnitude (squared) and phase |H ()| 2 = ω 4 0 (ω 2 0 - ω 2 ) 2 +4ζ 2 ω 2 0 ω 2 , and H ()= - tan -1 2ζω 0 ω ω 2 0 - ω 2 . 1

Upload: others

Post on 22-Mar-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lab 5: Second Order CT and DT Filters, DTMF Project (First ...ecee.colorado.edu/~mathys/ecen3300/pdf/lab05.pdf · Lab 5: Second Order CT and DT Filters, DTMF Project (First Draft)

ECEN 3300 Linear Systems Spring 201003-29-10 P. Mathys

Lab 5: Second Order CT and DT Filters, DTMF Project

(First Draft)

1 Introduction

Second order systems with complex-conjugate poles are the fundamental building blocksfrom which higher order infinite impulse response (IIR) filters are made. Using the Laplacetransform, the frequency domain characterization of second order CT (continuous time)systems in terms of the (undamped) resonant frequency ω0 and the damping ratio ζ isreasonably straightforward and intuitive. Direct frequency domain analysis of second orderDT (discrete time) systems is complicated by the fact that their frequency response is periodicand needs to be evaluated along a circle rather than a straight line. However, using thebilinear transformation s = 2Fs(1−z−1)/(1+z−1) with sampling rate Fs, a DT system canbe transformed into an intermediate CT system for analysis and design purposes, and thenthe results are transformed back to characterize the DT system.

One application for second order CT or DT bandpass filters (BPF) is the decoding of DTMF(dual tone multi-frequency) tones that are used for dialing telephone numbers. In this caseeach 0 . . . 9 digit (and some additional symbols) is transmitted using a pair of frequencies,one from a low group of four frequencies and one from a high group of four frequencies. Thereceiving end then uses a total of 8 BPFs to determine which combination of frequenciesfrom the low and the high frequency group were transmitted and maps the result back intothe corresponding digit (or symbol). On goal of this lab is to design and implement DTBPFs for the purpose of receiving and decoding DTMF signals.

1.1 Second Order CT Lowpass Filters

The system function of a CT lowpass filter (LPF) with unit gain at dc is

H(s) =ω2

0

s2 + 2ζω0 s + ω20

,

where ω0 is the (undamped) resonant frequency and ζ is the damping ratio. The frequencyresponse of the LPF is

H(jω) =ω2

0

ω20 − ω2 + j 2ζω0ω

,

with magnitude (squared) and phase

|H(jω)|2 =ω4

0

(ω20 − ω2)2 + 4ζ2ω2

0ω2

, and ∠H(jω) = − tan−1( 2ζω0ω

ω20 − ω2

).

1

Page 2: Lab 5: Second Order CT and DT Filters, DTMF Project (First ...ecee.colorado.edu/~mathys/ecen3300/pdf/lab05.pdf · Lab 5: Second Order CT and DT Filters, DTMF Project (First Draft)

At ω = ω0,

|H(jω0)| =1

2ζ, and ∠H(jω0) = −π/2 .

One way to measure ω0 and ζ for a given second order CT LPF is therefore to find thefrequency ω0 at which the phase shift between input and ouptut is −90 and then measure|H(jω0)| to find ζ = 1/(2 |H(jω0)|).Depending on the value of ζ, the maximum Hmx over all ω of |H(jω)| may be larger thanthe dc gain |H(0)|. To determine Hmx = maxω |H(jω)|, look at

d|H(jω)|2

dω=

d

[ω4

0

((ω2

0 − ω2)2 + 4ζ2ω20ω

2)−1]

=4ω4

0ω((1− 2ζ2) ω2

0 − ω2)(

(ω20 − ω2)2 + 4ζ2ω2

0ω2)2 .

Setting the last expression to zero yields two solutions for ω as

ω = 0 , and ω2 = (1− 2ζ2) ω20 =⇒ ω =

√1− 2ζ2 ω0 .

Since ω has to be real, ωmx, the value of ω at which |H(jω)| is maximized, is

ωmx =

0 , if ζ ≥ 1/

√2 ,√

1− 2ζ2 ω0 , if ζ < 1/√

2 .

At ω =√

1− 2ζ2 ω0,

|H(jω)|2∣∣∣ω=√

1−2ζ2 ω0

=ω4

0(ω2

0 − (1− 2ζ2) ω20

)2+ 4ζ2ω2

0 (1− 2ζ2) ω20

=1

4ζ2 (1− ζ2)

=⇒ Hmx =1

2ζ√

1− ζ2, if ζ < 1/

√2 .

Another important quantity to characterize a filter is the -3dB frequency ω3. For a CT LPFwith gain 1 at dc, ω3 is defined implicitly as

|H(jω3)|2 =w4

0

(ω20 − ω2

3)2 + 4ζ2ω2

0 ω23

=1

2.

Multiplying both sides by the product of the denominators yields the equation

ω43 − 2 (1− 2ζ2) ω2

0 ω23 − ω4

0 = 0 =⇒ ω3 =

√√1 + (1− 2ζ2)2 + (1− 2ζ2) ω0 ,

which expresses ω3 in terms of ω0. If ω3 is given, then ω0 can be computed from

ω40 + 2 (1− 2ζ2) ω2

3 ω20 − ω4

3 = 0 =⇒ ω0 =

√√1 + (1− 2ζ2)2 − (1− 2ζ2) ω3 .

2

Page 3: Lab 5: Second Order CT and DT Filters, DTMF Project (First ...ecee.colorado.edu/~mathys/ecen3300/pdf/lab05.pdf · Lab 5: Second Order CT and DT Filters, DTMF Project (First Draft)

1.2 Second Order DT Lowpass Filters

To obtain a DT LPF with damping ratio ζ and normalized (undamped) resonant frequencyΩ0 = ω0/Fs, where Fs is the sampling rate of the DT system, use the prewarping function

ωx = 2Fs tan(Ω0

2

), or Ωx = 2 tan

(Ω0

2

).

Then apply the bilinear transformation

s = 2Fs1− z−1

1 + z−1to H(s) =

ω2x

s2 + 2 ζωx s + ω2x

,

to obtain

H(z) =ω2

x(2Fs

1− z−1

1 + z−1

)2

+ 2 ζωx 2Fs1− z−1

1 + z−1+ ω2

x

=Ω2

x

4 + 4ζΩx + Ω2x

1 + 2 z−1 + z−2

1 +2 (Ω2

x − 4)

4 + 4ζΩx + Ω2x

z−1 +4− 4ζΩx + Ω2

x

4 + 4ζΩx + Ω2x

z−2

,

where Ωx = ωx/Fs.

To design a second order DT LPF with sampling rate Fs, damping ratio ζ, and normalized-3dB frequency Ω3 = ω3/Fs, use the prewarping function

ωy = 2Fs tan(Ω3

2

), or Ωy = 2 tan

(Ω3

2

).

Then compute the normalized (undamped) resonant frequency Ωx from Ωy and ζ as

Ωx =

√√1 + (1− 2 ζ2)2 − (1− 2 ζ2) Ωy .

Now H(z) is obtained as shown earlier using this value for Ωx and the given ζ.

1.3 Second Order CT Bandpass Filters

The system function of a second order bandpass filter (BPF) with (undamped) resonantfrequency ω0 and daping ratio ζ is

H(s) =2 ζω0 s

s2 + 2 ζω0 s + ω20

.

The frequency response of the BPF is

H(jω) =j 2ζω0 ω

ω20 − ω2 + j 2ζω0 ω

,

3

Page 4: Lab 5: Second Order CT and DT Filters, DTMF Project (First ...ecee.colorado.edu/~mathys/ecen3300/pdf/lab05.pdf · Lab 5: Second Order CT and DT Filters, DTMF Project (First Draft)

with magnitude (squared) and phase

|H(jω)|2 =4 ζ2ω2

0 ω2

(ω20 − ω2)2 + 4 ζ2ω2

0 ω2and ∠H(jω) =

π

2− tan−1

( 2 ζω0 ω

ω20 − ω2

).

Note that H(jω0) = 1, i.e., the gain of the BPF at ω0 is equal to one and the phase at ω0 isequal to zero.

The first derivative of |H(jω)|2 is

d|H(jω)|2

dω=

d

[4 ζ2ω2

0 ω2((ω2

0 − ω2)2 + 4 ζ2ω20 ω2

)−1]=

8 ζ2ω20 ω (ω4

0 − ω4)((ω2

0 − ω2)2 + 4 ζ2ω20 ω2

)2 .

The maximum of |H(jω)| for real ω > 0 therefore occurs at ω = ω0 and maxω |H(jω)| = 1.

The -3dB frequencies that characterize the bandwidth of the BPF are implicitly defined by

|H(jω3)|2 =4 ζ2ω2

0 ω23

(ω20 − ω2

3)2 + 4 ζ2ω2

0 ω23

=1

2.

Multiplying both sides of the last equality by the product of the denominators yields

8 ζ2ω20 ω2

3 = (ω20 − ω2

3)2 + 4 ζ2ω2

0 ω23 =⇒ ω2

3 ± 2 ζω0 ω3 − ω20 = 0 .

The positive solutions for ω3 are

ω3 =(√

1 + ζ2 ∓ ζ)ω0 .

The lower and upper -3dB frequencies ω1 and ω2 are therefore

ω1 =(√

1 + ζ2 − ζ)ω0 and ω2 =

(√1 + ζ2 + ζ

)ω0 ,

and the bandwidth of the BPF is 2 ζ ω0. Note that ω0 and ζ can be expressed in terms ofω1 and ω2 as

ω0 =√

ω1 ω2 , and ζ =ω2 − ω1

2√

ω1 ω2

.

1.4 Second Order DT Bandpass Filters

To obtain a second order DT BPF with damping ratio ζ and normalized (undamped) resonantfrequency Ω0 = ω0/Fs, where Fs is the sampling rate of the DT system, use the prewarpingfunction

ωx = 2Fs tan(Ω0

2

), or Ωx = 2 tan

(Ω0

2

).

Then apply the bilinear transformation

s = 2Fs1− z−1

1 + z−1to H(s) =

2 ζωx s

s2 + 2 ζωx s + ω2x

,

4

Page 5: Lab 5: Second Order CT and DT Filters, DTMF Project (First ...ecee.colorado.edu/~mathys/ecen3300/pdf/lab05.pdf · Lab 5: Second Order CT and DT Filters, DTMF Project (First Draft)

to obtain

H(z) =2 ζωx 2Fs

1− z−1

1 + z−1(2Fs

1− z−1

1 + z−1

)2

+ 2 ζωx 2Fs1− z−1

1 + z−1+ ω2

x

=4ζΩx

4 + 4ζΩx + Ω2x

1− z−2

1 +2 (Ω2

x − 4)

4 + 4ζΩx + Ω2x

z−1 +4− 4ζΩx + Ω2

x

4 + 4ζΩx + Ω2x

z−2

,

where Ωx = ωx/Fs.

To design a second order DT BPF with sampling rate Fs, normalized lower -3dB frequencyΩ1 = ω1/Fs and normalized upper -3dB frequency Ω2 = ω2/Fs, use the prewarping functions

ωa = 2Fs tan(Ω1

2

), and ωb = 2Fs tan

(Ω2

2

).

Then use the fact that for a second order CT BPF with -3dB frequencies ωa and ωb

ωx =√

ωa ωb , and ζ =ωb − ωa

2√

ωa ωb

,

where ωx is a prewarped (undamped) resonant frequency. Define Ωx = ωx/Fs to obtain theset of design equations

Ωa = 2 tan(Ω1

2

), Ωb = 2 tan

(Ω2

2

)=⇒ Ωx =

√Ωa Ωb , ζ =

Ωb − Ωa

2√

Ωa Ωb

.

Now use Ωx and ζ to obtain the system function H(z) as shown earlier.

1.5 Signal Power

Definition: The average power of a CT signal x(t) in the time interval [t1, t2) (i.e.,t1 ≤ t < t2) is the quantity

Px(t1, t2) =1

t2 − t1

∫ t2

t1

|x(t)|2 dt ,

where |x(t)|2 is the instantaneous power of x(t). The average power Px for all times −∞ <t <∞ is the quantity (if it exists)

Px = limT→∞

1

2T

∫ T

−T

|x(t)|2 dt .

For periodic signals with period T0 this simplifies to

Px =1

T0

∫T0

|x(t)|2(t) dt ,

5

Page 6: Lab 5: Second Order CT and DT Filters, DTMF Project (First ...ecee.colorado.edu/~mathys/ecen3300/pdf/lab05.pdf · Lab 5: Second Order CT and DT Filters, DTMF Project (First Draft)

where the integral is taken over one period starting at any point in time.

Definition: The root-mean-square (rms) value of a CT signal x(t) in the time interval[t1, t2) is the quantity

Xrms(t1, t2) =√

Px(t1, t2) =

√1

t2 − t1

∫ t2

t1

|x(t)|2 dt ,

i.e., Xrms(t1, t2) is proportional to the voltage (or current) that delivers average powerPx(t1, t2) to a resistive load. The rms value Xrms for all times −∞ < t <∞ is the quantity(if it exists)

Xrms =√

Px =

√lim

T→∞

1

2T

∫ T

−T

|x(t)|2 dt ,

which reduces to

Xrms =

√1

T0

∫T0

|x(t)|2 dt ,

when x(t) is periodic with period T0.

Example: Consider the sinusoidal signal x(t) = A cos(ω0t + θ) with period T0 = 2π/ω0.The average power of x(t) is

Px =A2

T0

∫ T0

0

cos2(ω0t + θ) dt =A2

2 T0

∫ T0

0

(1 + cos(2ω0t + 2θ)

)dt =

A2

2.

The rms value of x(t) is therefore Xrms = A/√

2. This is the value that a (true rms) acmultimeter displays when measuring the waveform x(t).

Definition: The average power of a DT sequence xn in the index interval n1 ≤ n < n2 isgiven by

Px[n1, n2] =1

n2 − n1

n2−1∑n=n1

|xn|2 ,

and, for −∞ < n <∞, (if it exists)

Px = limN→∞

1

2N + 1

N∑n=−N

|xn|2 .

The quantity |xn|2 is the instantaneous power of xn at index n.

If a CT signal x(t) is sampled with sampling rate Fs = 1/Ts and xn = x(nTs) is the n-thsample of x(t), then the power Px(t1, t2) of x(t) and the power Px[n1, n2] of xn are related by

Px(t1, t2) =1

t2 − t1

∫ t2

t1

|x(t)|2 dt ≈ 1

(t2 − t1) Fs

n2−1∑n=n1

|xn|2 ≈ Px[n1, n2] ,

if n1 ≈ t1 Fs and n2 ≈ t2 Fs, and Fs is chosen large enough for the given x(t).

6

Page 7: Lab 5: Second Order CT and DT Filters, DTMF Project (First ...ecee.colorado.edu/~mathys/ecen3300/pdf/lab05.pdf · Lab 5: Second Order CT and DT Filters, DTMF Project (First Draft)

Practical Measurement of Px and Xrms for Sinusoids. Let x(t) = A cos(ω0t + θ) be asinusoidal CT signal. The instantaneous power of x(t) is

w(t) = x2(t) = A2 cos2(ω0t + θ) =A2

2

(1 + cos(2ω0t + 2θ)

).

Thus, if w(t) is lowpass filtered with a LPF at ωL that suppresses the frequency 2ω0 suffi-ciently (e.g., by selecting ωL 2ω0), then

wLP (t) ≈ A2

2= Px =⇒ Xrms ≈

√wLP (t) .

The figure below shows the computation of wLP (t) ≈ Px from x(t) in blockdiagram form.

x(t) (.)2 LPFat ωL

wLP (t)w(t)

If x(t) = a(t) cos(2ω0t+θ) and the amplitude a(t) of the sinusoid is varying slowly comparedto the period T0 = 2π/ω0, then

Px(t− k T0, t) =1

k T0

∫ t

t−k T0

a2(τ) cos2(ω0τ + θ) dτ

=1

2k T0

∫ t

t−k T0

a2(τ)(1 + cos(2ω0τ + 2θ)

)dτ ≈ Pa(t− k T0, t) ,

where k is either a small integer value or any large number (e.g., greater than about 10).Thus, by choosing ωL larger than the main frequency components in a(t) and smaller than2ω0, the blockdiagram given above can be used to compute the average power Pa(t − T, t)in the time interval [t− T, t) where T is proportional to 2π/ωL.

Application: Detection of weather radio warning alarm tone (WAT). NOAA weather radiouses a tone of 1050 Hz (in addition to some digital signals) before weather warnings to alertreceivers of areas where severe weather is expected. To detect this tone, a second orderDT BPF with -3dB frequencies of 1040 Hz and 1060 Hz can be used. The magnitude andthe phase of such a BPF, obtained using the bilinear transformation with Fs = 8000 Hz,Ωx = 0.2785 π and ζ = 0.0107, is shown in the graphs below.

7

Page 8: Lab 5: Second Order CT and DT Filters, DTMF Project (First ...ecee.colorado.edu/~mathys/ecen3300/pdf/lab05.pdf · Lab 5: Second Order CT and DT Filters, DTMF Project (First Draft)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

0.2

0.4

0.6

0.8

1

|H(e

jΩ)|

f [Hz]

DT BPF for Weather Radio Alert Tone at 1050 Hz, Ωx=0.278*π, ζ=0.0107, F

s=8000 Hz

0 200 400 600 800 1000 1200 1400 1600 1800 2000−100

−50

0

50

100

∠H

(ejΩ

) [d

eg]

This is a nice narrowband BPF for the detection of the 1050 Hz tone. In the time domainthis looks as follows if the test signal in DTbpf_test001.wav (speech signal plus segmentsof 1050 Hz tone) is applied to the input r(t) of the BPF and the resulting ouptut v(t) isobserved.

0 1 2 3 4 5 6−1

−0.5

0

0.5

1

t [sec]

Sig

nal r

(t)

Test Signal r(t) from ’DTbpf_test001.wav’ and Signal v(t) after BPF

0 1 2 3 4 5 6

−0.4

−0.2

0

0.2

0.4

0.6

t [sec]

Sig

nal v

(t)

afte

r B

PF

8

Page 9: Lab 5: Second Order CT and DT Filters, DTMF Project (First ...ecee.colorado.edu/~mathys/ecen3300/pdf/lab05.pdf · Lab 5: Second Order CT and DT Filters, DTMF Project (First Draft)

From the lower graph it is easy to see that the 1050 Hz tone appears at ≈ 1.1 sec for thefirst time, then at ≈ 3 sec for the second time, and at ≈ 5.2 sec for the third time. It canalso be seen that some parts of the speech signal, e.g., at ≈ 0.6 sec also have a non-negligiblecontent at 1050 Hz. For this reason the 1050 Hz signal actually has to be present for atleast 5 sec in a real weather radio broadcast before the receiver is supposed to react to it.Zooming in on v(t) yields the following graph.

1.1 1.105 1.11 1.115 1.12 1.125 1.13 1.135 1.14 1.145 1.15

−0.4

−0.2

0

0.2

0.4

0.6

t [sec]

Sig

nal v

(t)

afte

r B

PF

Test Signal r(t) from ’DTbpf_test001.wav’ and Signal v(t) after BPF

The output of the BPF is a sinusoid at 1050 ± 10 Hz. To convert this into a signal thatcould activate a warning light or a siren, the average power (or the rms value) of the BPFoutput signal v(t) has to be computed, e.g., using the blockdiagram with squaring followedby lowpass filtering. Using the bilinear transformation with Fs = 8000 Hz, ΩxLP = 0.0233 πand ζLP = 0.6556 (corresponding to a LPF with ωL = 200 π) yields the following graphs forr(t), v(t), and the average power y(t) at 1050 Hz.

0 1 2 3 4 5 6−1

−0.5

0

0.5

1

t [sec]

Sig

nal r

(t)

Test Signal r(t) from ’DTbpf_test001.wav’, Signal v(t) after BPF, and Power y(t)

0 1 2 3 4 5 6

−0.5

0

0.5

t [sec]

Sig

nal v

(t)

afte

r B

PF

0 1 2 3 4 5 6

−0.1

−0.05

0

0.05

0.1

t [sec]

y(t)

: Avg

Pow

er o

f v(t

)

9

Page 10: Lab 5: Second Order CT and DT Filters, DTMF Project (First ...ecee.colorado.edu/~mathys/ecen3300/pdf/lab05.pdf · Lab 5: Second Order CT and DT Filters, DTMF Project (First Draft)

Now y(t) is clearly a signal that could be used to turn some alerting device.

1.6 Dual Tone Multi-Frequency Signaling

Dual Tone Multi-Frequency (DTMF) signaling was developed around 1960 by AT&T as a“modern” alternative to pulse dialing. As the name suggests, a DTMF signal is a sum oftwo tones (or sinusoids), one from a low group of four frequencies (697, 770, 852, 941 Hz)and one from a high group of four frequencies (1209, 1336, 1477, 1633 Hz). The frequencieswere chosen so that they can be transmitted in the voice band (approximately 300 to 3000Hz) and that they are not harmonically related. For instance, 2 × 697 = 1394 Hz, whichfalls between the 1336 and 1477 Hz frequencies. Selecting one tone from the low group of 4frequencies and one from the high group of 4 frequencies allows for 16 unique combinations.Ten of these are used to represent the numbers from 0 to 9, two to represent the specialcharacters ’*’ and ’#’, and the remaining four to represent special signaling codes labeledA, B, C, D. The corresponding keypad buttons are arranged in a matrix as shown in thetable below so that each key selects one tone from the low group and one tone from the highgroup.

DTMF Signaling, High Group Tones

Low Group Tones fh1 = 1209 Hz fh2 = 1336 Hz fh3 = 1477 fh4 = 1633 Hz

f`1 = 697 Hz 1 2 3 A

f`2 = 770 Hz 4 5 6 B

f`3 = 852 Hz 7 8 9 C

f`4 = 941 Hz * 0 # D

The special signals A, B, C, D were originially envisoned to be used as menu selections whenaccessing computers by phone. This feature was rarely used and most keypads omit this4’th column.

At the receiver, a valid DTMF signal is detected if exactly one frequency from each group ispresent for at least 50 ms and the amplitude at all other frequencies is at least 20 dB downfrom the amplitude of the present tones. Since two tones are involved for each signal, animportant quantity is the “twist” between the two tones, defined as

twist = 20 log10

(A`

Ah

)[dB] ,

where A` is the amplitude of the tone from the low group and Ah is the amplitude of thetone from the high group. On the transmit side a twist of -2dB (Ah = 1.26 A`) is often usedas pre-emphasis to compensate for the higher attenuation of telephone lines for signals fromthe high group. At the receiver a twist in the range of −4 . . . + 8 dB should be toleratedfor the decision that indeed one tone from each frequency group is present. The frequencytolerance for detection of each of the eight tones is ±1.5% from the nominal value. Finally,in a sequence of DTMF signals, there must be a pause of at least 45 ms (and at most 3 sec)between successive signals.

10

Page 11: Lab 5: Second Order CT and DT Filters, DTMF Project (First ...ecee.colorado.edu/~mathys/ecen3300/pdf/lab05.pdf · Lab 5: Second Order CT and DT Filters, DTMF Project (First Draft)

1.7 Second Order DT System Implementation in Matlab

In general it is faster and more convenient to design and implement DT filters in Matlab,rather than use Simulink. A DT filter is generally defined in terms of its system functionH(z) with numerator polynomial b(z) = b0 + b1 z−1 + b2 z−2 + . . . + bM z−M of degree M anddenominator polynomial a(z) = a0 + a1 z−1 + a2 z−2 + . . . + aN z−N of degree N . In Matlabthe numerator and denominator polynomials are represented as vectors

bDT = [b0,b1,b2,...,bM] , and aDT = [a0,a1,a2,...,aN] .

To evaluate the frequency response H(ejΩ) of a DT system use the Matlab command

HejW = freqz(bDT,aDT,WW);

where WW is a vector containing the values of Ω for which H(ejΩ) is computed, e.g., set upusing WW = linspace(0,pi,200).

To compute the time domain response yn when the sequence xn is applied to the input ofthe DT system defined by H(z), use the Matlab command

yn = filter(bDT,aDT,xn);

Example:

0 200 400 600 800 1000 1200 1400 1600 1800 20000

0.2

0.4

0.6

0.8

1

f [Hz], Ω=2π*f/Fs

|H(e

jΩ)|

BPF at fh2

=1336 Hz, bDT

=[0.0155,0,−0.0155], aDT

=[1,−0.981,0.969], Ωx=0.368*π, ζ=0.0181, F

s=8000

—- To be completed —-

2 Prelab Questions

P1. Analysis/Design of Second Order CT/DT LPF. (a) Determine ω0 and ζ of thesecond order CT LPF with frequency response as shown below.

11

Page 12: Lab 5: Second Order CT and DT Filters, DTMF Project (First ...ecee.colorado.edu/~mathys/ecen3300/pdf/lab05.pdf · Lab 5: Second Order CT and DT Filters, DTMF Project (First Draft)

0 1000 2000 3000 4000 5000 6000 7000 80000

0.2

0.4

0.6

0.8

1

1.2

1.4

f [Hz] (ω=2π f)

|H(jω

)|

Frequency Response of Second Order CT LPF

0 1000 2000 3000 4000 5000 6000 7000 8000−200

−150

−100

−50

0

f [Hz], (ω=2π f)

∠H

(jω)

[deg

]

(b) Design a DT LPF with the same ζ and ω0 → Ω0 = ω0/Fs as in (a). Use Fs = 8000 Hzand determine the coefficients of the numerator and the denominator of H(z).

P2. Amplitude/Power Measurement with Second Order DT LPF. The rms (root-mean-square) value xrms(t) in time span [t− T, t) of a signal x(t) is defined as

xrms(t) =

√1

T

∫ t

t−T

|x(τ)|2 dτ .

Thus, x2rms(t) is the average power of x(t) in time span [t−T, t). A simple data transmission

system, for example, can use a tone generator with frequency fm that is turned on and offto transmit Morse code signals. The receiver then detects the average power r2

rms(t) of thereceived signal r(t) near the frequency fm of the tone generator at the transmitter. Notethat in this example the averaging time constant T has to be chosen long enough to averageover one or more periods of the signal from the tone generator and short enough to capturethe on and off periods of the Morse signal.

(a) Let x(t) = a(t) cos(2πfmt + θ) be a sinusoidal signal with time varying amplitude a(t).It is proposed to use the following blockdiagram to obtain an estimate for a2

rms(t) from y(t).

12

Page 13: Lab 5: Second Order CT and DT Filters, DTMF Project (First ...ecee.colorado.edu/~mathys/ecen3300/pdf/lab05.pdf · Lab 5: Second Order CT and DT Filters, DTMF Project (First Draft)

x(t) (.)2 LPFat fL

y(t)w(t)

For fm in the range 200 . . . 2000 Hz, design a second order CT LPF with as large a cutoff(-3dB) frequency fL as possible such that y(t) ≈ a2

rms(t) ± 10%. Specify the LPF in termsof ω0 and ζ and explain your reasoning for the values you chose.

(b) Convert the CT LPF in (a) to a second order DT LPF using a sampling rate Fs of 8000Hz. Determine the numerator and denominator coefficients of the system function H(z).

P3. Design of Second Order DT BPF. Design a second order DT BPF for detection ofthe DTMF frequency fH1 = 1209 Hz. Use Fs = 8000 Hz and -3dB frequencies of fH1±1.5%,and determine the numerator and denominator coefficients of H(z).

3 Lab Experiments

E1. Design and Test of Second Order DT LPF/BPF. (a) Use the freqs and thefreqz commands in Matlab to verify parts (a) and (b) of prelab problem P1. Adjust yourestimates of ω0, ζ and the coefficients of H(z) as necessary.

(b) Use the freqz command in Matlab to verify your BPF design in prelab problem P3.Use the results from prelab problem P2 to measure the average power at the output of theBPF. Choose T such that a step change in average power is detected within 10 ms and theaverage power measurement is accurate to within about ±1%. Test you overall design witha sinusoid at fH1 = 1209 Hz that is switched on and and off. Use the y=filter(b,a,x)

command in Matlab to process the time domain signal x with the DT filter characterized bythe numerator and denominator coefficients b and a, respectively, and to produce the timedomain signal y as output.

E2. DTMF Receiver and Decoder Design Project. The goal of this project is toreceive and decode a DTMF signal such as a telephone number that is dialed using thenumeric keypad of a telephone. A test signal is available in the file DTMFtest001.wav. Todemonstrate the operation of your DTMF decoder, decode the signals in DTMF sample filesposted on the html lab page.

This experiment is intended to be a design project where you have to decide yourself whichsteps are necessary to obtain a system which performs the desired functions. In your labreport you have to explain your design strategy and document your implementation. Youalso have to explain what steps you took to verify the correct operation of your system andshow the results of measurements and tests that you made for this purpose.

c©2002–2010, P. Mathys. Last revised: 03-28-10, PM.

13