Assignment title: Information
EEE304 Lab 2 Answer Sheet
Name: Date:
Lab Description
Write a paragraph explaining what you have learned from this lab exercise.
Task 1
Implement sampling and reconstruction in Simulink with the following specifications.
• x(t) is a sinusoid with 70Hz with amplitude 1 with sample period 1/20000s for 1s time interval
• Zero-Order-Hold (ZOH) sampling
• Sampling frequencies: 80Hz, 400Hz, and 1000Hz. Changed by applying the corresponding sampling times in second in the zero-order hold sampling time block.
a) Build a SIMULINK model to sample x(t) with ZOH sampling method with different sampling frequencies listed in the specifications. Output the data generated to the MATLAB workspace. Include screenshot of your SIMULINK block diagram.
Note: You will need the following SIMULINK blocks: "Zero-Order Hold" block is under Simulink->Discrete and "To Workspace" block is under Simulink->Sinks.
You may notice the "To Workspace" symbol above has one input and no output. What it does is to write its input to the MATLAB workspace. The block writes its input to an array or structure (based on how you set its "Save Format" parameter). For this assignment, set "Save Format" to "Structure with time". The name of the array or structure is specified by the block's "Variable name" parameter with "simout" as the default name. Array or structure contains not only the input, but also some information about the input. To access the input data with name "simout", you can use the commands below:
>> Data=simout.signals.values;
>> Time = simout.time;
The above commands generate a time series that can be plotted with plot(Time, Data).
a) Run the above SIMULINK model with different sampling frequencies listed in the specifications. After each run, type the commands in Part a) at command line to save the results in the workspace. Make sure to use different variable names such as data80, time80, data400, time400, etc. Write a MATLAB program to plot the sampled signals and the frequency magnitude character of the sampled signals with FFT. Include your MATLAB code and figures. Compare results and discuss your observations. (Hint: an example of how to plot FFT is in Lab 1 Manual Section 2.4.)
b) Design a discrete low-pass Butterworth filter of order 6, sampling rate of 20,000Hz. Use "lsim" to simulate signal reconstruction. Your data from (a) needs to be upsampled first (see note below) before passing through the filter you designed. Specify the proper cut-off frequency of the filter. Provide the transfer function. Plot the upsampled signals and the frequency magnitude plot of the reconstructed signals (80, 400, 1000 Hz sampling rates as in (a)) with FFT. Include your MATLAB code and figures. Compare results and discuss your observations.
Note: the data from (a) needs to be upsampled for task (b). For example, if you have saved the 80 Hz sampled data in (a) as data80. Sample code below shows how to perform task (c):
data80up = upsample(data80, 20000/80) % here we upsample 80hz data to 20khz
reconstructed80 = lsim(Fil,data80up,(1:1:length(data80up))/20000); % Fil is the low-pass filter you designed
Now data80up contains the upsampled data from 80Hz to 20,000Hz, inserting 20000/80-1 = 249 zeros between data points. You need to repeat these steps for 400Hz and 1000Hz data. Upsampling will not alleviate aliasing problems, but will improve the signal reconstruction by reducing the undesirable properties of the low rate ZOH.
Task 2
In the MATLAB code provided in Section 5 of the lab manual, we created a sinusoid with frequency 1 kHz. We used a high sampling frequency of fs = 44.1 kHz that represents a fairly good approximation of the continuous time signal. Copy the MATLAB code and run it in a script.
a) Include the plots generated.
b) Compare the analytical continuous-time Fourier transform with its FFT computation. Discuss your observations.
Task 3
In the MATLAB code provided in Section 6 of the lab manual, we sampled the same sinusoid (1 kHz) in Task 2 at a lower sampling rate (fs/4) to observe the aliasing effects. Copy the MATLAB code and run it in a script. You must have all the variables from Task 2 in the MATLAB workspace for this to work.
a) Include the plots generated.
b) By looking at the plots, explain whether aliasing effects have increased or decreased.
Task 4
In the MATLAB code provided in Section 7 of the lab manual, we used upsampling to "interpolate" the values of the low rate signal and converted it to a high rate signal and then passed the signal through a low pass filter to recover the original signal. Copy the MATLAB code and run it in a script. You must have all the variables from Task 2 and 3 in the MATLAB workspace for this to work.
a) Include the plots generated.
b) Discuss the effects of aliasing of the reconstructed signal and any effect it may have had on how it sounds based on the results you see from running the code.
Task 5
In the MATLAB code provided in Section 8 of the lab manual, a frequency equalizer is implemented. Copy the MATLAB code and run it in a script.
a) Try three different sets of values for the equalization coefficients and include the frequency response plots generated.
b) Does the frequency response correspond to what you entered as coefficients in all three cases? Explain by using the plots from part a).
LAB 2: LAB REPORT GRADE SHEET
Name:
Instructor Assessment
Grading Criteria Max Points Points Lost
Template
Neatness, Clarity, and Concision 2
Lab Description 8
Description of Assigned Tasks, Work Performed & Outcomes Met
Task 1 8
Task 2 8
Task 3 8
Task 4 8
Task 5 8
Points Lost
Lab Score (out of 50) Late Lab
Lab Score