python
9/15/2018 cls:dsp:cec411:lab2 [Class Wiki at erau.us]
http://www.erau.us/clswiki/doku.php/cls/dsp/cec411/lab2 1/4
Class Wiki at erau.us
Lab 2: Producing/Displaying Waveforms and Spectra of AM and FM Signals
Learning outcomes:
1. Review functions for generating sinusoidal signals. 2. Review functions for FFT spectrum calculation. 3. Learn/review mathematical expressions of AM and FM signals. 4. Reinforce the understanding of time-domain signals and their spectra.
1 Introduction
We have learned in the previous lab that any signal has two aspects: waveform in time domain and spectrum in frequency domain. We have also learned how to produce and display the waveforms and spectra of single frequency and multi-frequency sinusoidal signals.
In this lab, we consider two very important multi-frequency sinusoidal signals, an Amplitude Modulated (AM) signal and a Frequency Modulated (FM) signal, which are widely used in broadcasting and other applications. An AM signal due to a single frequency sinusoidal modulating signal is expressed below
where , , and are the amplitude, frequency, and phase of the modulating signal, respectively, and and are the frequency and phase of the carrier signal, respectively.
An FM signal due to a single frequency sinusoidal modulating signal is given as:
where is the peak deviation (about half of the bandwidth of the FM signal), is the frequency of the modulating signal, and is the same as that defined above. Note that we have ignored the phases of the modulating and carrier signals for the FM signal for convenience.
In this lab, we will produce and display the waveforms and spectra of the AM and FM signals using the techniques we have practiced in Lab 1 using the following parameters.
SAVE_FIG = 1 # Flag to control the saving of figures: 1 -> save, 0 -> otherwise. pi = np.pi R_ds = 10 # Ratio of dense and sparse sampling Nd = 1000 # d stands for dense sampling---for continuous waveform Rsmp = 4 # Ratio of the sample rate and the center frequency Fc = 2500 # Carrier frequency of both the AM and FM signals Ns = Nd / R_ds # s stands for sparse sampling---for sampling display Ns2 = int(Ns // 2) # Ns/2, to be used as the index for array Nd2 = int(Nd // 2) # Nd/2, to be used as the index for array # Definitions for AM parameters Aam = 0.5 # Amplitude of the AM modulating signal Fam = 320 # Frequency of the AM modulating signal Pam = pi/3 # Phase of the AM modulating signal Pc = pi/3 # Phase of the AM carry signal # Definitions for FM parameters Fmod = 100 # Frequency of the FM modulating signal Fdt = 1000 # F_Delta, the peak frequency deviation of the FM signal # Definitions of variables for sampling rate and display Fs_d = Rsmp*R_ds*Fc # Sample rate for dense sampling Fs_s = Rsmp*Fc # Sample rate for sparse sampling t_d = np.arange(Nd)/Fs_d # Sample times for dense sampling t_s = np.arange(Ns)/Fs_s # Sample times for sparse sampling Fdspl_d = np.arange(-Nd2, Nd2) Fdspl_d = Fdspl_d * Fs_d / Nd # Frequencies for spectrum display---dense Fdspl_s = np.arange(-Ns2, Ns2) Fdspl_s = Fdspl_s * Fs_s / Ns # Frequencies for spectrum display---sparse
(t) = (1 + cos(2π t + )) cos(2π t + ),xAM AAM FAM ϕAM FC ϕC (1)
AAM FAM ϕAM FC ϕC
(t) = cos(2π t + cos(2π t)),xFM FC fΔ
fFM FFM (2)
FΔ FFM FC
9/15/2018 cls:dsp:cec411:lab2 [Class Wiki at erau.us]
http://www.erau.us/clswiki/doku.php/cls/dsp/cec411/lab2 2/4
Note that the above parameters in the code snippet are related to the parameters in Eqns. and \eqres{Eqn_fm} as follows:
= Fc = Pc
= Fam = Pam
= Fdt = Fmod
2 Lab instructions
The correct results of the lab, as evaluated using the figures discussed below, have a total score of 70 points, and a good commenting and nice and clean code have a total score of 30 points. Note that if the GIT history does not indicate an independent piece of work, ZERO point will be given.
Task 1. Generating/displaying the waveforms and spectra of an AM signal
(40 points) Modify the code of Lab 1 to produce the waveforms of the AM signal using Eqn. with dense and sparse sampling rates. Display the results as shown in figure 1. The waveforms, both dense and sparse as well as the envelop (think about how to generate it) are displayed in the top subplot; the spectrum from the dense waveform is displayed in the center subplot; and the spectrum from the sparse waveform is displayed in the bottom one. Your figures should be as close to those in figure 1 as possible.
We should be able to observe that the dense sampling is good at displaying the waveform; the sparse one will lost the envelop information. We should also be able to observe that the sparse sampling is good at display the spectrum, with details being shown more clearly when using the same number of points for the FFTs.
(1)
FC ϕC FAM ϕAM FΔ FFM
(1)
9/15/2018 cls:dsp:cec411:lab2 [Class Wiki at erau.us]
http://www.erau.us/clswiki/doku.php/cls/dsp/cec411/lab2 3/4
Fig. 1: Waveform and spectrum of an AM signal.
Task 2. Generating/displaying the waveforms and spectra of an FM signal
(30 points) (Modify the code of Task 1 to produce the waveforms of the FM signal using Eqn. with dense and sparse sampling rates. Display the results as shown in figure 2. Again, your figures should be as close to those in figure 2 as possible.
(2)
9/15/2018 cls:dsp:cec411:lab2 [Class Wiki at erau.us]
http://www.erau.us/clswiki/doku.php/cls/dsp/cec411/lab2 4/4
Fig. 2: Waveform and spectrum of an AM signal.
cls/dsp/cec411/lab2.txt · Last modified: 2018/09/11 10:27 by Jianhua Liu [/clswiki/doku.php/user/jhl]