Sunteți pe pagina 1din 14

Experiment- 1

Objective: Learning Simulink and a simple filtering exercise Description: In this experiment, you will generate a 1 MHz square-wave, and extract its first harmonic using a 7-th order Butterworth filter with cut-off frequency of 2 MHz. You will also extract its third harmonic using a bandpass Butterworth filter centered around 3 MHz.

Instructions
I. Initialization: Copy the initialization files for the experiment into your Matlab working directory. The following constants should be set by the startup file. Use who in the matlab workspace to check if the constants are all there. FREQ = 2*pi*1e6 ----------------signal frequency in rad/sec T_PERIOD = 1e-6 ---------------Time period of square wave T_SAMPLE = 1e-6/32 ------------Sampling period used in Simulink FFT_NUM_PTS = 4096 ------------Number of points used for FFT T_SIM = FFT_NUM_PTS*T_SAMPLE --Time of simulation NUM_SAMPLES = T_SIM/T_SAMPLE --Total number of samples F_CUTOFF = 4*pi*1e6 ------------Cutoff frequency of lowpass Butterworth filter F_BAND_LOW = 2.7*2pi*1e6 -------Lower cutoff of bandpass Butterworth filter F_BAND_HIGH = 3.3*2pi*1e6 ------Higher cutoff of bandpass Butterworth filter II. Testing (This part is a test to make sure things are set up properly.) From Simulink/Sources, select a Sine wave generator and copy it to your model window. Set the frequency to FREQ. From ece359lib copy a Fourier transform block and link it to the output of the Sine wave block. Click on the menu item Simulation in your model window and select Parameters. Within the Solver sub-menu, set Stop time to T_SIM and Max step size to T_SAMPLE. Attach a Scope from Simulink/Sinks to the signal and zoom in to observe the signal shape. Start the simulation. You should see a window with the Fourier

transform of the sine wave. As expected a spike is seen at FREQ=2*pi*1e06 rad/sec If you are successful, move on to the next step. Fourier transform computation may take a long time (1 min on a 200MHz Pentium cpu). If your computer is slower, or has less memory, try reducing FFT_NUM_PTS by a factor of two. III. Constructing a Butterworth filter Use help butter at the Matlab prompt to get help on Butterworth filter design. We will be designing a continuous time low-pass filter. Construct a Butterworth filter with cutoff frequency at F_CUTOFF=4*pi*10^6 rad/sec and order 7. Store the coefficients of the numerator polynomial in B and denominator in A, i.e. use [B,A] = butter(7,F_CUTOFF,'s') Use bode(B,A) to look at the transfer function of the Butterworth filter. From the Simulink/Linear library copy a Transfer Fcn block into a new model window, and set Numerator to B and Denominator to A. Note: Simulink will get the values of the vectors A and B from the Matlab workspace, assuming you have done step 2. IV. Lowpass filtering the first harmonic From the Simulink/Sources library, get a Signal Generator block. Under waveform select square. Set the amplitude to 1 and frequency to FREQ. Make sure that the frequency is in rad/sec Pass the square wave output through the filter. Attach a Fourier transform block at both the input and the output of the filter. Set the first three parameters in the block to FFT_NUM_PTS and set the Sample time to T_SAMPLE. Do not use C-click to create multiple copies of the Fourier transform block. Instead, copy the block from ece359lib each time you wish to use it. Start the simulation, two windows with the input and the output Fourier transforms should appear. Use Scopes from simulink/sinks to look at the signals at the input and the output in time domain. Zoom in sufficiently to observe the waveforms. V. Bandpass filtering the third harmonic Design a bandpass Butterworth filter with lower and higher frequency limits F_BAND_LOW and F_BAND_HIGH respectively. Use order 7. (Again do help butter.m at the Matlab prompt for help). Repeat part IV with this filter. You only need to update A and B in the Matlab workspace to do this. Other blocks in the experiment can remain unchanged.

Questions
1. Submit a printout of the block diagram in part IV. 2. Submit the Fourier transforms plots at the input and output of the Butterworth filter for part IV and at the output only for part V. 3. Does the lowpass filter achieve the goal of extracting the first harmonic of the square wave? Explain. 4. Does the bandpass filter achieve the goal of extracting the third harmonic of the square wave? Explain. 5. Write an expression for the Fourier transform of a square wave with period T_PERIOD. (We did this in class; you don't have to rederive the expression). 6. Write an expression for the Fourier transform of a square wave with period T_PERIOD, truncated to the interval [0,T_SIM]. (Agian, we did this in class; you don't have to rederive the expression). 7. Use the above expressions, to predict the height of the spikes observed in the Fourier transform of the square wave input. Do they match what you observe? 8. Use the expression for the frequency response of a 7-th order lowpass Butterworth filter to predict the height of the spike at the output of the lowpass filter in part IV. Does this match what you observe? Calculate the attenuation produced by the lowpass filter at the frequency of the third harmonic.

Experiment 2
Objective: DSB-SC Modulation and Demodulation Description: In this experiment you will design an analog modulator and an analog demodulator. Both simple multiplier type and nonlinear element type Modulators/Demodulators will be constructed. You will compare the received signal with the transmitted signal and also study the effect of phase shift at the demodulator. The carrier frequency will be 500kHz, which is in the commercial AM radio frequency range. The signal bandwidth will be 20kHz, which is the bandwidth needed for high quality music. (Actual systems may use a smaller bandwidth.)

Instructions
I. Initialization: Copy the initialization files for the experiment into your Matlab working directory. Note: You have to do the initialization again since the initialization files are different from those used in Experiment 1. The following constants should be set by the startup file. Use who in the matlab workspace to check if the constants are all there. Some additional constants may also be set, but you can ignore them. 1. 2. 3. 4. 5. 6. 7. 8. F_CARR = 2*pi*5e05 ----------Carrier Frequency, rad/sec T_PERIOD = 2*pi/F_CARR --------Time period of carrier T_SAMPLE = T_PERIOD/4.01 ----Sampling period used in Simulink FFT_NUM_PTS = 4096 ----------Number of points used for FFT T_SIM = FFT_NUM_PTS*T_SAMPLE ------Time of simulation NUM_SAMPLES = T_SIM/T_SAMPLE ------Total number of samples BW_MESSAGE = 2*pi*2e04 ------Message Bandwidth. F_CUTOFF = BW_MESSAGE*2 -----Cutoff frequency of lowpass Butterworth filter 9. F_BAND_LOW = F_CARR-F_CUTOFF -----Lower cutoff of bandpass Butterworth filter 10. F_BAND_HIGH = F_CARR+F_CUTOFF ----Higher cutoff of bandpass Butterworth filter 11. a_NONLIN = 2 ----------Linear component of Nonlinear

Device. 12. b_NONLIN = 1 ----------Quadratic component of Nonlinear Device. To speed up your block selection, the library ece359lib also has standard blocks from the simulink menu. II. Multiplier Modulator/Demodulator: As in Figure 4.1 of the book 1. Select the Message Signal block form the ece359lib library. This block produces a signal m(t) band-limited to BW_MESSAGE. 2. Multiply this signal by a unit magnitude sinusoid at frequency F_CARR (rad/sec). It's okay to use a sine wave rather than a cosine wave (that we used in class), as long as you use the same sinusoid at the demodulator. The multiplier output is the modulated signal s(t) (the greek symbol phi(t) was used in class, but here s(t) is used instead). 3. Now construct a multiplier demodulator. Use a Butterworth lowpass filter with cutoff F_CUTOFF, and order 5 for the demodulator. 4. Adjust the demodulator oscillator amplitude (i.e. use a factor of 2) to make the demodulator output v(t) equal in amplitude to the input m(t). 5. Look at the Fourier transforms of m(t), s(t), v(t). Use the scope block to see the time characteristics of the signals. III. Nonlinear Modulator/Demodulator. (You need to design the demodulator structure using the same nonlinear device.) This might be a big simulink model, refer to this link for additional help. 1. For the same input signal m(t) as in II, implement the nonlinear device based modulator of Figure 4.3 of the text. 2. Use a Butterworth order 3 band-pass filter with the parameters F_BAND_LOW, F_BAND_HIGH for the modulator. The nonlinear device may be obtained from ece359lib/Nonlinear Block. It has parameters a_NONLIN and b_NONLIN which have been preset to 2 and 1, respectively. 3. Implement a nonlinear device based demodulator without using any multipliers. Hint: The demodulator has a structure very similar to that of

the modulator, except that it has a lowpass filter at the end. Use the lowpass filter of II.
4. Obtain the Fourier transforms of m(t), s(t), v(t). Use the scope block to see the time characteristics of the signals. IV. Phase Offset: Study the effect of phase offset between the carrier and the receiver. 1. Use the setup of part II, but for m(t), use a sinusoid with frequency

BW_MESSAGE/5 instead of the random Message Signal. You do not need the Fourier transform blocks for this part. 2. Give the receiver oscillator phase offsets with respect to the transmit oscillator in the range from 0 to pi in steps of pi/4. Reminder Matlab

accepts the pi symbol, no need to give the decimal approximation 3.14.


3. Observe time domain characteristics of the received signal. Note the level of attenuation (with sign) of the received signal for different phase shifts. You must measure the attenuation using the scope. The Fourier transformer does not preserve the sign. (A rough estimate of the attenuation, obtained by looking at the scope will suffice). 4. Plot the attenuation vs. phase shift. (Note the attenuation in a table and feed the data into Matlab to make a plot.) Take more phase offset values if needed.

Questions
1. Write the equations relating m(t), s(t), v(t). in II. (that is write the other two in terms of m(t) ) Verify your simulation results. You do not need to submit any plots for this part. 2. Submit a block diagram of II. 3. Submit a block diagram of III. Label any ambiguous components. 4. Write the equations relating m(t), s(t), v(t) in III. Your equations should explain the working of the demodulator. 5. Give plots of both m(t) and v(t) for III. Also give plots of the Fourier transforms of m(t), s(t) and v(t). 6. Explain with equations the phase-attenuation plot obtained in IV. Submit this plot. 7. Print the Fourier transform of the demodulated signal of part IV when phase shift is pi/2. Do you see anything unusual? Explain what you see. 8. Using the setup of part IV, and phase offset zero, show the transmitted signal with a solid line and the received one with a dashed line on the same plot. See scope for details. Comment on the delay between the two signals. Extra credit - Can you justify the value of this delay?

Experiment 3
Objective: FM modulation and demodulation Description: In this experiment you will design a FM modulator and a derivative based FM demodulator. You will also study the influence of the frequency deviation constant on the signal bandwidth. Instructions I. Initialization: Copy the initialization files for the experiment into your Matlab working directory. Note that the initialization files have changed The following constants should be set by the startup file. Use who in the matlab workspace to check if the constants are all there. Some additional constants may also be set, but you may ignore them F_CARR = 2*pi*5e05 ----------Carrier Frequency, rad/sec T_PERIOD = 2*pi/F_CARR ------Time period of carrier T_SAMPLE = T_PERIOD/4.01 ----Sampling period used in Simulink Kf = 5000 ------------- Frequency modulation index T_SIM = 0.004 s ---------- --Total simulation time BW_MESSAGE = 2*pi*2e04 ------Message Bandwidth. F_CUTOFF = BW_MESSAGE*2 -------Cutoff frequency of lowpass Butterworth filter F_DC_STOP = BW_MESSAGE/15 ---------Frequency cutoff for DC stop filter. II. FM Modulation (Narrowband and Wideband) Use the Message Signal (m(t)) from ece359lib . Pass this through an Integrator from ece359lib . Pass this signal through a gain block (ece359lib) of gain Kf. Use the ramp block (ece359lib) to generate a ramp with slope F_CARR. Add the ramp output to the output in part (i). Take the cosine of the resulting signal using the cos block from ece359lib. This is the FM signal s(t). (Make sure you know why this is a FM signal.) Use the Fourier Transformer from ece359lib to observe the spectra of s(t) and m(t). (You need to submit s(t) only.) The value of Kf set by the constants file is for wideband FM. Now change Kf to 200 (in the workspace enter Kf=200) and plot the Fourier

transforms of s(t) and m(t). (You need to submit s(t) only.) Before going on to the next part make sure you run the script constants again. We want the value of Kf restored to 5000 for the next part. III. Demodulation (Wideband FM) Kf=5000 You need not use the Fourier transform blocks for this part (to save on simulation time) 1. Pass the signal through a differentiator from ece359lib . The resulting signal (call it q(t)) passed through a conventional AM demodulator. 2. Implement the AM demodulator shown in the figure below. Recall from class that a differentiator followed by an AM demodulator can demodulate FM. Use the Rectifier(half cycle) from ece359lib. Use an order 5 Butterworth lowpass filter with cutoff F_CUTOFF. For the DC stop use a Butterworth highpass filter (help butter for help on high pass filters) of order 3 and lower cutoff F_DC_STOP. Let the output be v(t). 3. Observe m(t), v(t) using scopes. If possible, get these plots on the same matlab figure using the subplot command. The signals will not look identical for the first 1-2 ms, so be sure to plot till at least 4ms. Use the scope from ece359lib. This scope has its parameters set properly for viewing signals in this experiment. If you want to see the modulated high frequency signal(not required), use the HF scope, also in ece359lib. Scope help

Questions
1. Submit a block diagram for the entire Modulator/Demodulator system. 2. Give equations to show that the signal s(t) is indeed a FM signal. 3. Using appropriate equations, compute the bandwidth of the modulated signal s(t) for the wideband case. Assume that the peak amplitude of m(t) is 150. Does the computed bandwidth match what you observe? Submit a plot of the spectrum of s(t) in II.3. 4. Using appropriate equations, compute the bandwidth of the modulated signal s(t) for the narrowband case. Does it match what you observe? Submit a plot of the spectrum of s(t) in II.4. 5. Give the equation for the differentiator output q(t). Also give the equation for the demodulator output, v(t) in terms of the input signal m(t). 6. Submit the plots of the signals seen in III.3. Use values of Kf for the wideband case to predict the amplitude gain for the demodulated signal. Compare the peak amplitudes of m(t) and v(t) and verify the amplitude gain predicted by theory. 7. Notice that there is distortion in the initial portion of m(t), but after a few ms, v(t) begins to track m(t) closely. Explain this phenomenon (hint: it is linked to one of the filters in the demodulator). 8. This demodulation scheme filters out any DC present in the original signal. Do you think this would be a problem for a real voice broadcast system?

Experiment 4
Objective: Generating bandpass WGN and studying the effect of AWGN on DSB-SC AM. Description: In this experiment you will generate bandpass white Gaussian noise using two different methods. Then, you will see the effect of this noise on a DSB-SC system. Instructions I. Initialization: Copy the initialization files for the experiment into your Matlab working directory. Note that the initialization files have changed The following constants should be set by the startup file. Use who in the matlab workspace to check if the constants are all there. Some additional constants may also be set, but you may ignore them. Set the simulation time to T_SIM and the sample time to T_SAMPLE in the simulink models you construct. F_CARR = 2*pi*5e05 ----------Carrier Frequency, rad/sec T_PERIOD = 2*pi/F_CARR ------Time period of carrier T_SAMPLE = T_PERIOD/4.01 ----Sampling period used in Simulink T_SIM = 0.002 s ---------- --Total simulation time BW_MESSAGE = 2*pi*2e04 ------Message Bandwidth. F_CUTOFF = BW_MESSAGE -------Cutoff frequency of lowpass Butterworth filter N_0 = 0.01 ---------------------Power of noise II. Generating bandpass white noise Use the ece359lib/White Noise block to generate zero mean white gaussian noise. The noise power spectral density is already set to N_0/2. Pass this noise through the ece359lib/Band Pass filter block (bandwidth=2F_CUTOFF, and center frequency F_CARR). The resulting signal is the bandpass noise n1 (t). Use the HF scope and 359 PSD blocks from ece359lib to observe the time and frequency domain characteristics of n1 (t). The HF scope works in the same way as in the previous experiments (help available here). Print the PSD of n1 (t). III. Componentwise generation of bandpass noise (This part will use many blocks, so try and space blocks close together)

Generate two lowpass noise processes n_s, n_c(t) using the ece359lib/White Noise and ece359lib/low pass filter blocks. To make the two processes independent, change the random number generator seed in one of the blocks. Produce the signal n2(t) = n_s(t) sin(w0 t) + n_c(t) cos(w0 t). Here w0 refers to the carrier frequency F_CARR. (You are free to use multipliers and sine and cosine generators ) Use the HF scope to see the lowpass signals n_c(t), n_s(t) and also the bandpass signals n2(t), n_c(t) cos(w0 t), n_s(t) sin(w0 t). Save all these signals in the workspace using the save to workspace option of scope. Use the subplot function of matlab to plot the three bandpass signals above on the same figure (use subplot(3,1,row_number)). On this scale, it is difficult to observe the difference between the sine and cosine components. On a separate figure with an enlarged time scale, plot on the same axis (overlap the plots using hold on, and make one of the plots to be a dotted line) the two signals n_c(t) cos(w0 t), n_s(t) sin(w0 t). Your entire time scale should be no more than 0.05 ms. This plot shows how the two components of noise differ. Use the ece359lib/359 PSD block to plot the PSD of n2(t). IV. DSB-SC performance in bandpass noise (We will use DSB-SC system as in simulink #2.) Construct a DSB-SC transmitter/receiver. Let the message signal m(t) be a sinusoid of frequency BW_MESSAGE/2 and amplitude 100. The modulating waveform is a cosine wave with zero phase shift, frequency F_CARR and amplitude 1. For the low pass filter at the receiver, use ece359lib/DSB-Low Pass block. We will add noise to the modulated signal s(t) of DSB-SC and observe the result at the demodulator. Suppose you used variable name n2 to save the bandpass noise in part III. Now use the ece359lib/From Workspace block to input this signal into simulink. To measure the noise level of the demodulated signal, we will need to resort to some indirect methods. Pass the source signal m(t) through the same lowpass filter that you used in the demodulator. This gives us a version of the source signal delayed by the same amount as the demodulated signal. Call this signal m1(t). Multiply the demodulated signal by 2 and call the resulting signal v(t).

Subtract the signal m1(t) from it. Call the resulting signal n_r(t). n_r(t) = v(t) - m1(t) Save n_r(t) to the workspace using the scope. Use subplot to plot both n_c(t) and n_r(t) on the same figure. Compare the shape of the two signals.

Questions
1. Submit a block diagram for part II 2. Submit a block diagram for part III. 3. Submit both the required plots from III.4. Explain the difference between the two (sine and cosine) noise components as seen in the plots. 4. Submit the PSD plots from II.3 and III.5. Compare the magnitude of the PSD peak in both. The filters are known to be near perfect. Give equations or stepby-step PSD drawings to support your observation. 5. Submit a block diagram for part IV. 6. Comment on the similarity between the waveforms in IV.5.

Experiment 5
Objective: To design and simulate binary baseband and passband communication systems in the presence of noise. Description: Binary data is transmitted using antipodal rectangular pulses of duration T over an AWGN channel. The receiver is a correlation device followed by an threshold device. We also consider On-Off, Orthogonal and PSK modulation schemes.

Instructions I. Initialization: Copy the initialization files for the experiment into your Matlab working directory. Note that the initialization files have changed The following constants should be set by the startup file. Use who in the matlab workspace to check if the constants are all there. Some additional constants may also be set, but you may ignore them T = 0.1s ------------Bit symbol duration F_CARR = 2*pi*100 ------Carrier frequency (rad/sec) A = 5----------------Pulse Height T_SAMPLE = T/100 ----Sampling period used in Simulink T_SIM = 100s ---------Total simulation time N0 = 10 -------------AWGN spectral density.

II. Generating Digital modulation The first step is to make a binary data source. Use the ece359lib/Rd Wksp block to get a random sequence of 0's and 1's. This block uses the randint function of matlab to generate random data at the rate of one bit every T seconds. The two bit values 0 and 1 are equiprobable. Depending on the value of the bit, we would like to choose from the two waveforms s0 and s1. First generate the waveform s0 using the following commands, taxis=linspace(0,T,100); % same as [0:T/100:T] s0 = A*ones(size(taxis)); % s0 has value A for t between 0 and T. s0 is the desired pulse of width T. Then, generate a signal which repeats the waveform s0 every T seconds. The Repeating Table block in ece359lib generates repeated copies of a signal of our choice(see the parameters of this block).

Similarly (for antipodal signalling) generate a pulse which is the negative of s0, and call it s1. Use another Repeating Table block to generate a repeating signal corresponding to s1. To check the shape of the pulses, use the command check_s0s1 Use the ece359lib/pulse modulator to select one of the two waveforms depending on the bit value. When the control port has input 0, stream 0 is passed to output. When the control port has input 1, stream 1 is passed to the output. Make connections to achieve the desired modulation. Using a scope, check if your modulator output is what you expect (you should see alternating signal levels of +A and -A). III. Channel and receiver Generate white Gaussian noise using the ece359lib/White Noise block. Set the sample time to T_SAMPLE. To get a noise spectral density of N0/2 you need to set the power of noise to N0/2 in the ece359lib/White Noise block. Add this noise to the signal using an adder block. Check that the noise PSD is indeed N0/2 using the ece359lib/PSD block. Demodulation involves multiplying the signal by s1-s0. Generate this difference (repeating table blocks produce s0 and s1) and use a multiplier to generate the product. This product needs to be integrated over the bit period T. Use the ece359lib/correlator block to integrate. Note that the integrator needs to be reset at the end of each bit period. The reset signal is given at the second port of the integrator. Use the ece359lib/Correlator Reset block to generate this reset signal (the parameters of this block are preset). The integrator output is to be compared with a threshold value. (What is the appropriate threshold value for the modulation scheme in use?) Subtract the threshold from the integrator output using a constant block and a subtractor. A decision device is given in ece359lib. You should be able to see how this device works. To measure the bit error rate use ece359lib/Error Meter. This device needs two inputs, the transmitted data stream and the received data stream (at the decision device output). Note: You need to run the simulation for a time period corresponding to at least 1000 bits to get the accuracy needed for the error probability estimate. IV. Other forms of binary signaling Remember to use the check_s0s1 function to see the actual signal shapes you are using.

Maintain the same average signal energy as in the antipodal signal case, and implement an On-Off keying scheme. You need to set the signals s0 and s1 appropriately. Does the threshold for optimal detection change? Evaluate the error probability. Repeat for orthogonal signaling. Let s0 have constant amplitude and let s1 be positive for half the bit period and negative for the other half. Maintain the same signal energy as in the antipodal case. Repeat for passband signalling. Multiply the signals for antipodal signalling by a cosine wave with frequency F_CARR and amplitude sqrt(2). This gives a PSK signal with carrier frequency F_CARR. To generate the signals s0 and s1, use the commands, s1 = sqrt(2)*A.*cos(taxis*F_CARR); s0 = -s1;

Questions
1. Submit a block diagram of your Simulink model. 2. Calculate the threshold values for the four cases. 3. Evaluate using equations, the probabilities of error for the four cases. Match these with the observed values. Use the command Qfunction to evaluate the Q function values in matlab 4. Explain why the correlator needs to be reset. How often does it need to be reset? 5. Extra credit: You saw that there was a small difference between the measured and theoretically predicted values of the probabilities of error. Use the matlab function binopdf to comment on this difference. Hint: The reliability of measured probabilities of error depends on the number of bits transmitted in the simulation.

S-ar putea să vă placă și