Experiment 2 Effects of Filtering INTRODUCTION This experiment demonstrates the relationship between the time and frequency domains. A basic rule of thumb is that the wider the bandwidth allowed for the information signal, the faster the information can change value. Filtering will limit the bandwidth available for a signal, constraining how fast information can be passed from the transmitter to receiver. Filtering can also reduce the noise energy that the channel may have introduced. Reducing noise reduces errors in the receiver s estimation of the information sent. However, there are limits to how useful filtering may be. As will be demonstrated in this experiment, a filter will also reduce the amount of energy in the information signal. Filtering will also distort the signal. A very narrow filter will obliterate the data signal. The design of any communications system makes use of the fact that the noise and the signal are affected to different degrees by filtering. A properly designed filter will distort the signal only slightly while significantly reducing noise. This leads to the possibility of an optimum or matched filter. Matched filters will be discussed in detail later in the course. You will also discover later in this course that the relative energy in the data signal versus the noise power determines the probability of error in the data link. There are a multitude of filter types and topologies. The main types of filter are: low pass, high pass, band pass and notch. The topologies commonly used in digital, discrete sampled signal work are Infinite Impulse Response (IIR) and Finite Impulse Response (FIR). The topologies differ in the way they process the samples. The key differences are that an IIR filter produces phase distortion and both filters delay the signal by a certain amount which is dependent on the filter parameters. This will be explored in the experiment. Two parameters which you will be using to specify the filter are Fpass and Fstop. Fpass is(are) the frequency or frequencies which define the edges of that part of the response which passes a signal with little or no attenuation. Fstop is(are) the frequency or frequencies where the filter response reaches the minimum specified response. This is not the minimum response of the filter. There may be ripples in the response, but they will not exceed the minimum specified response. The response of a typical low pass filter available in MATLAB is shown below with Fpass and Fstop indicated. Fpass Fstop
PRE-LAB 1. Calculate the first seven exponential Fourier series coefficients for a square wave. Calculate the average power in a square wave. Using the Fourier coefficients, determine the number of harmonics that have to be included so that the sum of their powers is 90 per cent of the total average power of the square wave. For your power calculations, assume a 1 ohm load. PROCEDURE 1. Create the Simulink model shown below for this experiment. 2. Generate a pseudorandom binary sequence at 0.5 seconds per bit. Set the Unipolar to Bipolar Convertor to M-ary Number = 2. Set the Rectangular Filter Block to increase the sampling rate to 10 samples/bit. Open the Spectrum scope window and set the FFT Length to 1024. Remember you must buffer the Spectrum Scope input. A good buffer length is the same as the FFT length. Set Overlap to 0. 3. Run the simulation for 200 seconds and observe the FFT spectrum. Note the locations of the nulls. Between which nulls is most of the energy? 4. Place a Scope on the output of the Rectangular Pulse Filter. Run the simulation for 10s. Verify the shape of the edges of the pulses is square. 5. Insert a Lowpass Filter as shown below:
Set the filter parameters as follows: Impulse response: IIR Frequency units: Hz Input Fs: (calculate the sampling rate at the input of the filter) Fpass: 4 Fstop: 8 Design Method: Butterworth (default) Leave the rest of the values as their defaults. Click Apply and then View Filter Response. Confirm that the frequency response curve is as expected. What is the 3dB frequency for this filter? What happens to the magnitude response for frequencies above Fstop? In the Filter Response window there are a number of other responses available for view. Find and plot the Phase Response. Is the phase response linear over frequency? Find and plot the Group Delay. Note both the magnitude and shape of the group delay. Run the simulation again for 10s. Note the shape of the waveform on the Scope. What accounts for the change? What has happened to the edges of the signal? How are they affected by the filter Fpass? Run the simulation for 50s. and observe the spectrum scope. How is the spectrum being affected? Note these observations and repeat this entire step for the following filter parameters: Fpass Fstop 3 6 2 4 1 2.5 1 What happens to the group delay as Fpass is varied? 6. Repeat Step 5 for the frequencies listed (including Fpass = 4 and Fstop = 8), but set the Impulse response to FIR. And Design Method to Equiripple. Be sure to note the phase and group delay responses and the magnitude response s -3dB point and behavior above Fstop. Note any
differences in the wave shape between these responses and those from Step 5. How does the group delay vary with Fpass for the FIR filter? 7. We can use the zero volt level as a decision point to determine the polarity of the original pulse. To do this, insert a Sign block in the path between the output of the low pass filter and the Scope. Add a second input to the Scope and tie this to the input of the low pass filter. Set the Lowpass filter s Impulse response to FIR and Fpass = 4 and Fstop = 8. Run the simulation again for 10s and carefully compare the two waveforms. Are they identical? What is different about them? 8. Leave or set the filter s Impulse responses to FIR and set Fpass = 4 and Fstop = 8. Use the Find Delay block and a Display block to measure the delay between the two signals. Connect the input to the low pass filter to the sref input of the Find Delay block and the output of the sign block to the sdel input. The Display will show the delay of the output signal in samples. Repeat this for the rest of the filter pass and stop frequencies listed in Step 5. What can you say about the general relationship between the Fpass frequency and the delay? How does this value compare to the group delays you observed in Step 6? Simulation for Step 8. 9. Rearrange the blocks and insert the AWGN (Additive White Gaussian Noise) Channel block before the low pass filter. Add an Integer Delay block, Add Block, RMS Block, and another Display Block as shown below.
Open the AWGN block and set the parameters as follows: Eb/No = 100 db (this effectively turns off the noise) Symbol Period = 0.5s Set the Signs parameter in the Add Block to +-. Set the Simulation time to 50. Set the filter to Fpass =4Hz and Fstop = 8Hz. Open the RMS block and check Running RMS. Run the simulation and note the Delay display. Open the Integer Delay block and set the delay to this value. Run the simulation again and verify that the Error display is 0.1 or less. This simulation compares the signal before it enters the AWGN channel with the signal as it emerges from the sign block. After the delay is compensated for, the two signals are subtracted and the RMS value of the difference is taken. If they are identical, the Error display shows zero or nearly zero. If they are not, the Error display will show a number proportional to the amount of average difference or error in the signal output from the AWGN channel. This is a simple and crude measurement. In future experiments you will use a special block to compute the Bit Error Rate (BER) which is the performance standard for any data channel. 10. Set the Eb/No parameter in the AWGN block to 10 db. This will now add noise on top of the signal, simulating what might happen in a real channel. a) Set the lowpass filter Fpass =4 and Fstop =8. b) Run the simulation and note the Delay. c) Set the Integer Delay block to this value. d) Run the simulation again and note the error. Repeat steps a through d using the lowpass filter frequencies from step 5. Which set of frequencies gives the least error? THOUGHTS FOR CONCLUSION In your conclusion you should think about the following: Is it important for the digital signal to remain completely undistorted after it passes through a filter?
For a given kind of signal, do you think there is an optimum filter which would remove the most noise while leaving the most data signal, i.e. yield the best signal to noise ratio? In the real world, what are some sources of noise in a system? What are sources of delay? Is a delayed signal really an erroneous form of the original signal? The procedure to measure error in this experiment compared the signal at every sample of a bit. Is that a good way to compare signals? Is every sample during a single bit important? Again, do not limit your conclusion to these questions.