PROJECT 2: FREQUENCY-DOMAIN VIEW OF SAMPUNG When a continuous-time
signal is sampled, its spectrum shows the aliasing effect because
regions of the frequency domain are shifted by an amount equal to the
sampling frequency. To show this effect in reality, an oscilloscope is
needed. In MIATLAB the effect can only be simulated, and that is the
goal of this project. The simulation will consist of a sampling
operation, followed by D/A conversion (including a reconstruction
filter). This simple system will be driven by sinusoids with different
frequencies, and the Fourier transform of the analog signals at the
input and output will be compared. The different exercises treat each
part of the sampling and reconstruction process. They should be combined
into one M-file script that will do the entire simulation.
To simulate the analog signals, a very high sampling rate will have to be used—at least five times the highest frequency that any analog signal will be allowed to have. Thus there will be two “sampling rates” in the problem—one for the actual sampling under study and the other for simulating the continuous-time signals. A second issue is how to display the Fourier transform of the continuous-time signals. Again, this can only be simulated. The following M-file should be used to plot the analog spectra. Notice that one of its inputs is the dt for the simulation.
function fmagplot( xa, dt ) %FM.AGPLOT % fmagplot( xa, dt xa: the “ANALOG” signal dt: the sampling interval for the simulation of xa(t) L = length(xa); Nfft = round( 2 .^ round(log2(5*L)) ); %,– next power of 2
Xa = fft(xa,Nfft); range = 0:(Nfft/4); ff = range/Nfft/dt; plot( ff/1000, abs( Xa(1:range) ) ) title(‘CONT-TIME FOURIER TRANSFORM (MAG)’) xlabel(‘FREQUENCY (kHz)’), grid pause
Signal Generation To show the aliasing effect we need a simple analog input signal to run through the system. We will use sinusoids, but after you have the simulation working you may want to try other signals. To get started, you must pick a “simulation sampling frequency”; take this to be fim = 80 kHz.
a. Generate a simulated analog signal that is a cosine wave with analog frequency f,.
x(t) = cos (2,-r f,t 4))
0 Take the phase to be random. Generate samples (at the rate Lim) over a time interval of length T. Choose the signal length T so that you get about 900 to 1000 samples of the simulated analog signal.
b. Plot the time signal with plot so that the samples are connected. Make sure that you label the time axis with the true analog time. c. Plot the Fourier transform of this signal (see fmagplot above).
A/D Conversion The A/D converter takes samples spaced by T. It is simulated by taking a subset of the samples generated for x(t). To avoid unnecessary complications, the ratio of to the sampling rate of the A/D converter, f1, should be an integer e. Then every eth sample of the (t) vector can be selected to simulate the A/D conversion.
a. Plot the resulting discrete-time signal when f, = 8 kHz.
b. Compute the DTFT of the discrete-time signal and explain how it is related to the Fourier transform of the analog signal in Exercise 2.1 (c).