ECE 3100 Project 2 Aliasing Su 2015 Purpose: To examine the consequence of digitizing a continuous signal and reinforce the idea of prefiltering before A/D conversion. When an analog signal is captured and converted from Analog to Digital there can be unwanted effects which distort our signal of interest. In this project we will examine two effects which result from Analog to Digital conversion. Sample Rate: In a digital system the clock takes in a sample of the sine wave at specified intervals. Any values in between samples are lost. Holding the value constant until the next sample is taken is called a Sampleand-Hold and resulting waveform is shown below. This makes choosing the sample rate very important with we want to accurately capture the signal. The minimum sample rate which can resolve the oscillation of the sine wave is twice the largest frequency we need to resolve. This is called the Nyquist sample rate. The image below shows a 120Hz signal sampled at 240Hz. The digital system takes two samples in a single cycle of the sine wave. While we have lost almost all the detail of the original signal we can still accurately gage the frequency since there are two points in every cycle. If we want to really capture the sinewave in detail the solution appears to be to maximize the sample rate, but the file size of the digitized waveform can become unmanageably large. For example in single channel CD quality audio each sample is 16-bits at 44.1 kHz. The file size for 1min is: 44.1𝑘𝑠𝑎𝑚𝑝𝑙𝑒𝑠 60𝑠𝑒𝑐 𝐹𝑖𝑙𝑒𝑆𝑖𝑧𝑒 = 2𝑏𝑦𝑡𝑒𝑠 ∙ ∙ = 5.29𝑀𝑏𝑦𝑡𝑒𝑠 𝑠𝑒𝑐 1𝑚𝑖𝑛 To keep data sizes manageable we want a sample rate which adequately represents the frequencies of interest. There are digital processing techniques to deal with over sampling, which are outside the scope of this project. Aliasing: While we are trying to balance sampling rate and file size there is another problem to consider. When the sample rate is smaller than the frequency of interest only portions of the high frequency are captured. The digitized signal has a lower frequency then the original signal. The effect is called Aliasing. 1 ECE 3100 Project 2 Aliasing Su 2015 In the image above the high frequency signal is 2 kHz while the sampling frequency is 1.92 kHz. The resulting digitized signal appears as a lower frequency signal. The method to determine the new frequency is shown below. 𝜔𝑑 = 2𝜋 ∙ 𝑓𝑠𝑖𝑔 2𝜋 ∙ 2𝑘 = = 2.083̅𝜋 𝑓𝑠𝑎𝑚𝑝 1.92𝑘 𝑑 = cos(𝜔𝑑 𝑛) = cos(2.083̅𝜋 ∙ 𝑛) This is the normalized angular frequency (𝜔𝑑 ) and the new digitized signal is d. If 𝜔𝑑 is larger than 2𝜋, which is the case here, the continuous signal has been aliased. We look for the nearest even value of 𝜋 to find the new frequency. In this case that is 2𝜋. 𝜔𝑛 = 0.083̅𝜋 = 2.083̅𝜋 − 2𝜋 We want only the difference between the 2𝜋 and 2.083̅𝜋. This is the normalized angular frequency seen in the digitized signal. To translate back to frequency: 𝑓𝑑 = 𝑓𝑑 = 𝜔𝑛 ∙𝑓 2𝜋 𝑠𝑎𝑚𝑝 0.083̅𝜋 ∙ 1.92𝑘𝐻𝑧 = 82.3𝐻𝑧 2𝜋 Which is close to the frequency of the digitized sine wave in the picture above. The danger of Aliasing should be obvious. Are the signals we digitize really the waveforms in the range of interest or are they high frequency interference? Look at the picture below. The digitized waveform really a 200Hz signal sampled at 1.92kHz or is it a 19 kHz aliased signal? Without seeing the original continuous wave it is impossible to tell. 2 ECE 3100 Project 2 Aliasing 𝜔𝑑 = Su 2015 2𝜋 ∙ 19𝑘 = 19.7917𝜋 1.92𝑘 𝜔𝑛 = −0.20833𝜋 = 19.7917𝜋 − 20𝜋 𝑓𝑑 = 0.20833𝜋 ∙ 1.92𝑘 = 200𝐻𝑧 2𝜋 The solution to minimizing aliasing is to low pass filter the continuous signal before we sample it. A Low pass filter will reduce the contribution of his frequency signals while preserving the low frequencies. Pre-filtering is considered essential before digitizing any signal. Procedure: Sampling Rate Builder the circuit shown in the picture above. The Sample and Hold element is found in the component library under [Special Functions] -> Sample. It requires a clock which is the square wave seen in the bottom right (Vclk). We’re going to be cleaver and use variables to set the clock frequency. The Sample Period (Ts) is set using the .param directive. This will make changing the sampling period much easier. The input is a Behavioral Voltage Source (bv) and is a function of the voltage label 1 on source V1. Examine the effect the sampling rate has on the digitized circuit by adjusting the rate and view the effect on a 300Hz sine wave. Make a screen shot at 11.025 kHz and 600Hz. Explain what happens at 300 Hz. Estimate the file size for 16-bit at the sampling rate for 0.6sec of data. Sampling Freq 22.05 kHz 11.025 kHz 2.756 kHz 600 Hz 300 Hz Estimated File Size 3 ECE 3100 Project 2 Aliasing Su 2015 Procedure: Aliasing Using the same circuit from previous procedure set the sampling frequency to 3 kHz. We will examine the effects of aliasing when the input signal is greater than the sampling rate. Show printouts for 6.3 kHz and 8.5 kHz. Explain the results at 9 KHz. Source Freq Measure Freq Calculated Freq 5.8 kHz 6.3 kHz 8.5 kHz 9.0 kHz 9.6 kHz 14.5 kHz Procedure: Pre-Filtering Download the audio file data001.wav. The file is corrupted with high frequency noise which you can hear if you play the file with your PC’s media player. We are going to use some of LTSpice’s more advanced capabilities. Build the circuit in the figure below. The directives shown in the top right let LTSpice save our file as a .wav file. The input file data001.wav has a sample rate of 44.1 kHz, but the file is going to be saved with a sampling rate 11.025kHz. This will cause the high frequencies to alias into our signal. Design a 2nd order Sallen-Key pre-filter to reduce the high frequency signals in a separate LTSpice file. Set the corner frequency to 3 kHz and let C1 = 15nF. Examine the bode plot and make a printout. Run the simulation for 0.6sec and set the voltage source V1 to wavefile=“datafile001.wav”. Examine the pre-filtered signal against resampled output. Examine the FFT pre-filtered signal against resampled output. 4 ECE 3100 Project 2 Aliasing Su 2015 Deliverables: Make sure to have a cover page with your name, project title, and semester. Procedure: Sampling Rate Screen shots at 600 Hz and 11.025 kHz. Explanation of the 300 Hz sampling rate. Table of sampling rates and file size. Procedure: Aliasing Printouts for 6.3 kHz and 8.5 kHz. Explain the results at 9 KHz. Your table of measured and calculated aliased frequencies. Procedure: Pre-Filtering Your designed pre-filter components and bode plot. Printout of your pre-filtered signal and resampled output. Printout of the FFT pre-filtered signal and resampled output. 5