Topic 8 Lecture: VN XN N VN
Topic 8 Lecture: VN XN N VN
Topic 8 Lecture: VN XN N VN
1 Noise Reduction In this application, a digital FIR filter removes noise in the signal that is contaminated by noise existing in the broad frequency range. In real world application, the desired signal usually occupies certain frequency range. We can design a digital filter to remove frequency components other than the desired frequency range. In a data acquisition system, we record a 500 Hz sine wave at a sampling rate of 8000 Hz. The signal is corrupted by broadband noise v(n) x(n) = 1.4141 sin(2 500n / 8000) + v(n) The 500 Hz signal with noise and its spectrum are plotted in Figure 1a. The spectrum is also displayed to give better understanding of the noise frequency level. Assuming the desired signal only has the frequency range form 0 Hz to 800 Hz, hence we can filter noise ranging from 800 Hz beyond. A lowpass filter would complete such task. Lowpass filter specifications: Passband frequency range: 0 Hz to 800 Hz with the passband ripple less than 0.02 dB Stopband frequency range: 1 kHz to 4 kHz with the 50 dB attenuation
4 Sample value Sample value 2 0 -2 -4 4 M=66 2 0 -2 -4
50
200
250
50
200
250
1.5
0.5
0.5
0 0 500 1000 1500 2000 2500 Frequency (Hz) 3000 3500 4000
500
1000
3000
3500
4000
(a) Figure 1
(b)
Based on the specifications, an FIR filter is designed with a Hamming window, cut off frequency of 900 Hz, and estimated filter length of 133 taps. The enhanced signal is depicted in Figure 1b, where the clean signal can be observed. The amplitude spectrum for the enhanced signal is also plotted. As shown in the spectral plot, the noise level is almost neglected between 1 kHz to 4 kHz.
ECET-350
Topic 8
DeVry University
Li Tan
Page 1 of 15
2. Speech Noise Reduction In a speech recording system, we digitally record a speech in the noisy environment at a sampling rate of 8000 Hz. Assuming the recoded speech contains information within 1800 Hz, we can design a lowpass filter to remove the noise beyond 1800 Hz to the Nyquist limit (folding frequency of 4000 Hz). Filter type: lowpass FIR filter Passband frequency range: 0 1800 Hz Passband ripple: 0.02 dB Stopband frequency range: 2000 4000 Hz Stopband attenuation: 50 dB According to these specifications, we can determine the following parameters for filter design: Window type: Hamming window Number of filter tap: 133 Lowpass cut-off frequency: 1900 Hz Figure 2a shows the plots of the recorded noisy speech and its spectrum. After applying the designed lowpass filter, we plot the filtered speech and its spectrum shown in Figure 2b, where the clean speech is clearly identified while the spectrum shows that the noise components above 2 kHz are completely removed.
ECET-350
Topic 8
DeVry University
Li Tan
Page 2 of 15
x 10
x 10
0.05
0.2
0.25
0.05
0.2
0.25
800 Amplitude |X(f)| 600 400 200 0 Amplitude |Y(f)| 0 500 1000 1500 2000 2500 Frequency (Hz) 3000 3500 4000
500
1000
3000
3500
4000
(b)
A typical two-band digital crossover can be designed as shown in Figure 3. There are two speaker drivers. The woofer is for responding low frequencies and the tweeter is for responding high frequencies. The incoming digital audio is split into two bands by using a lowpass filter and high pass filter in parallel. We then amplify the separated audio signals and send them to the corresponding speaker drivers, respectively. Hence, the objective is to design the lowpass filter and highpass filter such that their combined frequency response is flat while keeping transition as sharp as possible to prevent the audio signal distortion in the transition frequency range.
yH(n)
Gain_H
Lowpass filter
yL(n)
Gain_L
ECET-350
Topic 8
DeVry University
Li Tan
Page 3 of 15
Given the following crossover system specifications: Sampling rate: 44100 Hz Crossover frequency: 1000 Hz (cut-off frequency) Transition band: 600 Hz to1400 Hz Lowpass filter: passband frequency range from 0 to 600 Hz with a ripple of 0.02 dB and stopband edge at 1400 Hz with the attenuation of 50 dB. Highpass filter: passband frequency range from 1400 Hz to 44.1 kHz with ripple of 0.02 dB and stopband edge at 600 Hz with the attenuation of 50 dB. One possibility is to use the FIR filter since it provides a linear phase for audio system. However, other type filter such as IIR type could be an alternative. Based on the transition band of 800 Hz and ripple and stopband attenuation requirements, the Hamming window is chosen for both lowpass and highpass filters, we can determine the number of filter taps as 183 each with a cut-off frequency of 1000 Hz. The frequency responses for the designed lowpass filter, highpass filter are given in Figure 4a, respectively, and the lowpass filter, highpass filter, and combined responses appear in Figure 4b. As we can see, the crossover frequency for both filters is at 1000 Hz, and the combined frequency response is perfect flat.
Magnitude response (dB) 0 -50 -100 Magnitude response (dB) -150 -200 0 10
1 2 3 4
20 Combined 0 -20 -40 -60 -80 -100 -120 -140 -160 -180 10
1
LPF
HPF
10
10 10 Frequency (Hz)
10
10 10 Frequency (Hz)
10
-200 0 10
10
10 10 Frequency (Hz)
10
(a) Figure 4
(b)
4 Digital Audio Equalizer For an audio application such as the CD player, the digital audio equalizer is used to make the sound as one desires by changing filter gains for different audio frequency bands. Other applications include adjusting sound source to take into account for room acoustics, removing undesired noise, or boosting the desired signal in the specified passband. The simulation is based on the consumer digital audio processor such as CD player handling the 16 bit digital samples with a sampling rate of 44.1 kHz, and the audio signal bandwidth is 22.05 kHz. A block diagram of the digital audio equalizer is depicted as following ECET-350 Topic 8 DeVry University Li Tan Page 4 of 15
bandpass filter g0
y 0 ( n)
x (n)
bandpass filter
y1 (n) g1
+
x ( n)
y (n)
bandpass filter
g6
y 6 ( n)
Figure 5 Simplified block diagram of the audio equalizer. A seven band audio equalizer is adopted for discussion. The center frequencies are listed in Table 1. The 3-dB bandwidth for each bandpass filter is chosen to be 50% of the center frequency, respectively. As shown in Figure 5, g 0 through g 6 are the digital gains for each banspass filter output, and could be adjusted to make sound effects while y0 (n) through y6 (n) digital amplified bandpass filter outputs, respectively. Finally, the equalized signal is the sum of the amplified bandpass filter outputs and itself. By changing the digital gains of the equalizer, many sound effects could be produced. Table 1 Specifications for an audio equalizer to be designed Center frequency (Hz) 100 200 400 1000 2500 Bandwidth (Hz) 50 100 200 500 1250
6000 3000
15000 7500
To complete the design and simulation, the 2nd order IIR bandpass Butterworth filters are chosen for the audio equalizer, the coefficients are achieved using the bilinear transform method, and given in the following table Table 2 Designed filter banks Filter banks: Coefficients for the numerator: Bandpass filter 0 0.0031954934, 0, -0.0031954934 Bandpass filter 1 0.0063708102, 0, -0.0063708102 Bandpass filter 2 0.0126623878, 0, -0.0126623878 Bandpass filter 3 0.0310900413, 0, -0.0310900413
ECET-350 Topic 8 DeVry University
Coefficients for the denominator: 1,-1.9934066716 , 0.9936090132 1, -1.9864516324, 0.9872583796 1, -1.9714693192, 0.9746752244 1, -1.9181849043, 0.9378199174
Li Tan Page 5 of 15
The magnitude responses for each filter bank are plotted in Figure 6a for design verification. We will perform simulation next.
10
0
Audio spectrum
10
-1
10
10 Filter Gain
-2
10
-3
10
10
10
10
10
10 10
-5
10
-6
10
10
10 Frequency (Hz)
10
10
10
10
10 Frequency (Hz)
10
10
(a) Figure 6
(b)
Simulation in the MATLAB environment is based on the following setting. The audio test signal having frequency components of 100 Hz, 200 Hz, 400Hz, 1000 Hz, 2500 Hz, 6000 Hz, and 15000 Hz is generated from the following Equation: x(n) = sin(200 n / 44100) + sin(400 n / 44100 + /14) + sin(800 n / 44100 + / 7) + sin(2000 n / 44100 + 3 /14) + sin(5000 n / 44100 + 2 / 7) + sin(12000 n / 44100 + 5 /14) + sin(30000 n / 44100 + 3 / 7) The gains set for the filter banks are listed below g0=10; g1=10; g2=0; g3=0; g4=0; g5=10; g6=10; After simulation, we notice that the frequencies at 100 Hz, 200 Hz, 6000 Hz, and 15000 Hz will be boosted by 20 log10 10 = 20 dB. Figure 8.5.3 shows the spectrum for the audio test signal while the second plot depicts the spectrum for the equalized audio test signal. As shown in Figure 6b, before audio digital equalization, the spectral peaks at all bands are at the same level; and after audio digital equalization, the frequencies at the bank 0, band 1, band 5 and bank 6 are amplified. Therefore, as we expected, the operation of the digital equalizer is to boost the low frequencies and high frequencies.
ECET-350
Topic 8
DeVry University
Li Tan
Page 6 of 15
ECET-350
Topic 8
DeVry University
Li Tan
Page 7 of 15
5. 60-Hz Hum Eliminator and Heart Rate Detection Using Electrocardiogram Humming noise created by poor power supplies, transformers, or electromagnetic interference (EMI) sourced by a power supply is characterized by a 60-Hz tone and its harmonics. If this noise interferes with a desired signal such as audio signal or biomedical electrocardiogram (ECG), the desired signal could be corrupted. The corrupted signal is useless without signal processing. It is sufficient to eliminate the 60-Hz hum frequency, with its second and third harmonics in most practical applications. We can complete this by cascading the notch filters with the notch frequencies of 60 Hz, 120 Hz, and 180 Hz, respectively. Figure xxx depicts the functional block diagram.
Digital signal input Digital signal output
Notch filter 60 Hz
0
Gain (dB)
30 60 60
Input signal spectrum
f Hz 120 180
60 Hz Hum 120 Hz Harmonic 180 Hz Harmonic
f Hz 60 120 180
Figure 7 a. 60-Hz Hum eliminator; b. the filter frequency response of the eliminator, and c. the input signal spectrum corrupted by the 60-Hz hum and its second and third harmonics. An ECG is a small electrical signal captured from an ECG sensor. The ECG is produced due to the activity of human heart thus can be used for heart-rate detection, fetal monitoring, and diagnostic purposes. The single pulse of the ECG is depicted in Figure 8, where it shows that the ECG is characterized by five peaks and valleys labeled with the letters P, Q, R, S, and T. The highest positive wave is the R wave. Shortly before and after the R wave are negative waves, called Q and S waves, respectively. There is a P wave before the Q wave and a T wave after the S wave. The Q, R, and S together are called the QRS complex. The properties of the QRS complex with its rate of occurrence and the time, heights, and widths, provide information to cardiologists on various pathological conditions of the heart. The reciprocal of the time-period between R-to-R peaks (milliseconds) multiplied by 60000 gives instantaneous heart rate in terms of beats per ECET-350 Topic 8 DeVry University Li Tan Page 8 of 15
minute. In a modern ECG monitor, the acquired ECG signal is displayed for diagnostic purposes.
0.8 R
0.2
-0.2
Q S
-0.4
-0.6
50
100
150
200
250 n
300
350
400
450
500
Figure 7 The Characteristics of the ECG pulse. In this application, we focus on ECG enhancement for heart-rate detection. To reduce the 60-Hz interference significantly, we apply the following signal enhancement in the ECG recording system as shown in Figure 8.
Enhanced ECG signal Input ECG signal 60-Hz eliminator Bandpass filtering Passband: 0.25 Hz to 40 Hz Signal for heart-rate detection
Figure 8 ECG signal enhancement system. a. The 60-Hz eliminator removes the 60-Hz interference including the capability to reduce its second harmonic of 120 Hz and third harmonic of 180 Hz. b. The next objective is to detect the heart rate using the enhanced ECG signal. c. We need to remove DC drift and to filter out muscle noise, which may occur at approximately 40 Hz or more. If we consider the lowest heart rate as 30 beats per minutes, the corresponding frequency is 30/60=0.5 Hz. Choosing the lower cut-off frequency of 0.25 Hz should be reasonable. Thus, a bandpass filter with a passband from 0.25 Hz to 40 Hz (range from 0.67 Hz to 40 Hz, suggested in the book by Webster, 1998), either FIR or IIR filter type, could be designed to reduce such effects. The resultant ECG signal is only valid to be applied to detect the heart rate.
ECET-350
Topic 8
DeVry University
Li Tan
Page 9 of 15
60 Hz (fundamental) 120 Hz (second harmonic) 180 Hz (third harmonic) 3 dB bandwidth for each filter: 4 Hz Sampling rate: 600 Hz Notch filter type: second-order IIR notch filter
2. Bandpass filter: Passband frequency range: Passband ripple: Filter type: Design method: DSP sampling rate:
For the first section with the notch frequency of 60 Hz, applying bilinear transform design yields
H1 ( z ) = 0.9792 1.5844 z 1 + 0.9792 z 2 1 1.5844 z 1 + 0.9584 z 2
Similarly, we obtain the transfer functions and difference equations for the second section and third section as follows: Second section:
H 2 ( z) = 0.9794 0.6053z 1 + 0.9794 z 2 1 0.6053 z 1 + 0.9588 z 2
Third section:
H 3 ( z) = 0.9794 + 0.6053z 1 + 0.9794 z 2 1 + 0.6053z 1 + 0.9588 z 2
The cascaded frequency responses are plotted below. As we can see, each notch frequency rejection is below 50 dB. The frequency responses of three cascaded notch filters are given in Figure 9.
ECET-350
Topic 8
DeVry University
Li Tan
Page 10 of 15
50
-50
-100
50
100
250
300
50
100
250
300
The second-stage design using the BLT design gives the bandpass filter transfer function and difference equation below.
H 4 (z) = 0.0464 0.0927z 2 + 0.0464z 4 1 3.3523z 1 + 4.2557z 2 2.4540z 3 + 0.5506z 4
Figure 10 depicts the processed results at each stage. The first plot shows the initial corrupted ECG data, which includes the 60-Hz interference and its 120-Hz and 180-Hz harmonics, and muscle noise. The second plot shows that interferences of 60 Hz, and its harmonics of 120 Hz and 180 Hz are removed. Finally, the third plot describes the result after the bandpass filter. As we expected, the muscle noise is removed and the enhanced ECG signal is observed.
ECET-350
Topic 8
DeVry University
Li Tan
Page 11 of 15
1 (a)
-1 1 (b)
0.5
1.5
2.5
-1 1 (c)
0.5
1.5
2.5
-1
0.5
1 Time (sec.)
1.5
2.5
Figure 10 Results of ECG signal processing. a. Initial corrupted ECG data; b. ECG data enhanced by removing the 60-Hz interference; c. ECG data enhanced with DC blocking and muscle noise removal.
With the enhanced ECG signal, a simple zero-crossing algorithm can be designed to detect the heart rate. Based on Figure 11, we use a threshold value of 0.5 and continuously compare two consecutive samples with the threshold, respectively. If both results are opposite, a zero cross is detected. Each zero crossing measure is given by
zero crossing = cur _ sign pre _ sign 2
where cur _ sign and pre _ sign are determined based on the current input, past input x( n 1) , and the threshold value as follows: If x( n) > threshold cur _ sign = 1 else cur _ sign = 1 If x( n 1) > threshold pre _ sign = 1 else pre _ sign = 1 Figure 11 summarizes the algorithm as shown below:
ECET-350
Topic 8
DeVry University
Li Tan
Page 12 of 15
Start
threshold=0.5 zerocrossing=0 Get enhanced ECG data array x(n) with N data pre_sign=-1 and cur_sign=-1 get x(n) and x(n-1) if x(n-1))>threshold then pre_sign=1 if x(n)>threshold then cur_sign=1
zerocrossing=zerocrossing+ abs(cur_sign-pre_sign)/2 No
After detecting the total number of zero-crossings, the number of the peaks will be a half of the number of the zero crossing. The heart rate can be calculated as: heart rate =
zero crossing number 2 Number of enhanced ECG data fs 60
pulses per
minute In our simulation, we have 6 zero-crossings using 1500 captured data samples at a sampling rate of 600 Hz. Hence, the heart pulse rate is determined as follows: pulse rate= =
60 6 = 72 pulses per minute 1500 2 600
ECET-350
Topic 8
DeVry University
Li Tan
Page 13 of 15
MATLAB program for ECG signal enhancement load ecgbn.dat; % load noisy ECG recording (located in e-college) b1=[0.9792 -1.5844 0.9792]; %Notch filter with the notch frequency of 60 Hz a1=[1 -1.5844 0.9584]; b2=[0.9794 -0.6053 0.9794]; %Notch filter with the notch frequency 120 Hz a2=[1 -0.6053 0.9588]; b3=[0.9794 0.6053 0.9794]; %Notch filter with the notch frequency of 180 Hz a3=[1 0.6053 0.9588]; y1=filter(b1,a1,ecgbn); %1st section filtering y2=filter(b2,a2,y1); %Second section filtering y3=filter(b3,a3,y2); %Third section filtering %Bandpass filter fs=600; T=1/600; wd1=2*pi*0.25; wd2=2*pi*40; wa1=(2/T)*tan(wd1*T/2); wa2=(2/T)*tan(wd2*T/2); [B,A]=lp2bp([1.4314], [1 1.4652 1.5162],sqrt(wa1*wa2),wa2-wa1); [b,a]=bilinear(B,A,fs); %b =[ 0.046361 0 -0.092722 0 0.046361 ]; Calculated from MATLAB %a =[1 -3.352292 4.255671 -2.453965 0.550587]; Calculated from MATLAB y4=filter(b,a,y3); %Bandpass filtering T=1/600; t=0:T:1499*T; % Recover time subplot(3,1,1);plot(t,ecgbn);grid;ylabel('(a)'); subplot(3,1,2);plot(t,y3);grid;ylabel('(b)'); subplot(3,1,3);plot(t,y4);grid;ylabel('(c)'); xlabel('Time (sec.)'); %Zero cross algorithm zcross=0.0;threshold=0.5 for n=2:length(y4) pre_sign=-1;cur_sign=-1; if y4(n-1)>threshold pre_sign=1; end if y4(n)>threshold cur_sign=1; end zcross=zcross+abs(cur_sign-pre_sign)/2; end zcross rate=60*zcross/(2*length(y4)/600)
ECET-350
Topic 8
DeVry University
Li Tan
Page 14 of 15
6. Summary 1. Real-life DSP applications such as noise reduction system and digital audio crossover system are investigated. 2. Simple audio equalizer uses bandpass IIR filter banks to create sound effects. 3. The 60-Hz interference eliminator is to enhance the biomedical ECG signal for heart rate detection.
ECET-350
Topic 8
DeVry University
Li Tan
Page 15 of 15