Lab 1. The Fourier Transform



Similar documents
Experiment 3: Double Sideband Modulation (DSB)

Electrical Resonance

Analog and Digital Signals, Time and Frequency Representation of Signals

Lab #9: AC Steady State Analysis

EXPERIMENT NUMBER 5 BASIC OSCILLOSCOPE OPERATIONS

The Fourier Analysis Tool in Microsoft Excel

Department of Electrical and Computer Engineering Ben-Gurion University of the Negev. LAB 1 - Introduction to USRP

SGN-1158 Introduction to Signal Processing Test. Solutions

Lab 1: The Digital Oscilloscope

B3. Short Time Fourier Transform (STFT)

ANALYZER BASICS WHAT IS AN FFT SPECTRUM ANALYZER? 2-1

Lab 3: Introduction to Data Acquisition Cards

Signal Processing First Lab 01: Introduction to MATLAB. 3. Learn a little about advanced programming techniques for MATLAB, i.e., vectorization.

Auto-Tuning Using Fourier Coefficients

RF Measurements Using a Modular Digitizer

Laboratory 4: Feedback and Compensation

Analysis/resynthesis with the short time Fourier transform

CIRCUITS LABORATORY EXPERIMENT 3. AC Circuit Analysis

The Calculation of G rms

SR2000 FREQUENCY MONITOR

DIODE CIRCUITS LABORATORY. Fig. 8.1a Fig 8.1b

High Quality Integrated Data Reconstruction for Medical Applications

Frequency Response of FIR Filters

Matlab GUI for WFB spectral analysis

SIGNAL GENERATORS and OSCILLOSCOPE CALIBRATION

How To Understand The Discrete Fourier Transform

SIGNAL PROCESSING & SIMULATION NEWSLETTER

FREQUENCY RESPONSE OF AN AUDIO AMPLIFIER

MATERIALS. Multisim screen shots sent to TA.

LAB 7 MOSFET CHARACTERISTICS AND APPLICATIONS

Spectral Analysis Using a Deep-Memory Oscilloscope Fast Fourier Transform (FFT)

MATRIX TECHNICAL NOTES

The Algorithms of Speech Recognition, Programming and Simulating in MATLAB

Lab 5 Operational Amplifiers

EXPERIMENT NUMBER 8 CAPACITOR CURRENT-VOLTAGE RELATIONSHIP

Lab Exercise 1: Acoustic Waves

Design of FIR Filters

VCO Phase noise. Characterizing Phase Noise

EE 1202 Experiment #4 Capacitors, Inductors, and Transient Circuits

AC : MEASUREMENT OF OP-AMP PARAMETERS USING VEC- TOR SIGNAL ANALYZERS IN UNDERGRADUATE LINEAR CIRCUITS LABORATORY

Applications of the DFT

Electronic Communications Committee (ECC) within the European Conference of Postal and Telecommunications Administrations (CEPT)

PCM Encoding and Decoding:

Fermi National Accelerator Laboratory. The Measurements and Analysis of Electromagnetic Interference Arising from the Booster GMPS

Experiment 2 Diode Applications: Rectifiers

Lecture 1-6: Noise and Filters

CMPT 468: Matlab Tutorial 3: Analysis with the Fast Fourier Transform (FFT)

Lab 4 - Data Acquisition

Curve Fitting, Loglog Plots, and Semilog Plots 1

Q1. The graph below shows how a sinusoidal alternating voltage varies with time when connected across a resistor, R.

Real time spectrum analyzer light

Experiment #11: LRC Circuit (Power Amplifier, Voltage Sensor)

AC CIRCUITS - CAPACITORS AND INDUCTORS

LABORATORY 10 TIME AVERAGES, RMS VALUES AND THE BRIDGE RECTIFIER. Bridge Rectifier

SIGNAL PROCESSING FOR EFFECTIVE VIBRATION ANALYSIS

Sampling and Interpolation. Yao Wang Polytechnic University, Brooklyn, NY11201

ECE 435 INTRODUCTION TO THE MICROWAVE NETWORK ANALYZER

AN-007 APPLICATION NOTE MEASURING MAXIMUM SUBWOOFER OUTPUT ACCORDING ANSI/CEA-2010 STANDARD INTRODUCTION CEA-2010 (ANSI) TEST PROCEDURE

Computing Fourier Series and Power Spectrum with MATLAB

Appendix D Digital Modulation and GMSK

See Horenstein 4.3 and 4.4

Computer Networks and Internets, 5e Chapter 6 Information Sources and Signals. Introduction

Oscilloscope, Function Generator, and Voltage Division

Non-Data Aided Carrier Offset Compensation for SDR Implementation

Hideo Okawara s Mixed Signal Lecture Series. DSP-Based Testing Fundamentals 46 Per-pin Signal Generator

The continuous and discrete Fourier transforms

FOURIER TRANSFORM BASED SIMPLE CHORD ANALYSIS. UIUC Physics 193 POM

Introduction to Digital Audio

Lab 1: Introduction to PSpice

The Fundamentals of Signal Analysis. Application Note 243

Frequency Response of Filters

Spectrum Level and Band Level

Introduction to IQ-demodulation of RF-data

AC Measurements Using the Oscilloscope and Multimeter by Mr. David Fritz

SERIES-PARALLEL DC CIRCUITS

PropScope USB Oscilloscope

INTERFERENCE OF SOUND WAVES

Iowa State University Electrical and Computer Engineering. E E 452. Electric Machines and Power Electronic Drives. Laboratory #3 Figures of Merit

S. Boyd EE102. Lecture 1 Signals. notation and meaning. common signals. size of a signal. qualitative properties of signals.

RC & RL Transient Response

= V peak 2 = 0.707V peak

PHYSICS LAB #2 Passive Low-pass and High-pass Filter Circuits and Integrator and Differentiator Circuits

CHAPTER 3: DIGITAL IMAGING IN DIAGNOSTIC RADIOLOGY. 3.1 Basic Concepts of Digital Imaging

Advanced Signal Processing and Digital Noise Reduction

Current and Temperature Ratings

Agilent PN Extending Vector Signal Analysis to 26.5 GHz with 20 MHz Information Bandwidth

L9: Cepstral analysis

FAST Fourier Transform (FFT) and Digital Filtering Using LabVIEW

ε: Voltage output of Signal Generator (also called the Source voltage or Applied

Step Response of RC Circuits

Lecture 1-10: Spectrograms

EE362L, Power Electronics Triac Light Dimmer

Short-time FFT, Multi-taper analysis & Filtering in SPM12

Analyses: Statistical Measures

Lock - in Amplifier and Applications

Reading assignment: All students should read the Appendix about using oscilloscopes.

u = [ 2 4 5] has one row with three components (a 3 v = [2 4 5] has three rows separated by semicolons (a 3 w = 2:5 generates the row vector w = [ 2 3

Electromagnetic Induction: Faraday's Law

Unit2: Resistor/Capacitor-Filters

Optical Fibres. Introduction. Safety precautions. For your safety. For the safety of the apparatus

Transcription:

Lab 1. The Fourier Transform Introduction In the Communication Labs you will be given the opportunity to apply the theory learned in Communication Systems. Since this is your first time to work in the Communications Lab, the intent of this experiment is to help you become familiar with the lab equipment and Communications Lab procedures. Purpose As a result of performing this lab, the student will understand How to create signals using MatLab, The relationship between the time and frequency domains as shown by performing Fourier analyses of assigned signals, The relationships between sampling rate, aliasing, signal reconstruction, pulse duty cycle, etc., and The differences between Fourier Transform, Discrete Fourier Transform, and Fast Fourier Transform. A secondary purpose of this lab is to introduce you to the tools and procedures that will be required for successful completion of the Communications Labs. The tools include MatLab, LabVIEW, PSpice (a simulation software), and the Lab test equipment. Prelab In this lab you will examine the time and frequency domain representation of a signal using Matlab. Matlab provides the FFT, FFT2, IFFT, IFFT2 and FFTSHIFT functions for converting signals between the time and frequency domains. Templates for the files are available on the Communications Lab Web Site: www.utdallas.edu/~kamran/ee4250. The Read-Only files with.tem extensions are the ones you are looking for. Rename them to <filename.m> and then, using Windows Explorer files properties, remove the Read-only attribute. To use these files, you will modify functions and variables, then observe the outputs. During the lab you will plot the signals in the time domain using MatLab. In your report, be sure to comment on your results. Make sure you provide a title for each plot, and properly label the x and y axes. An explanation of how to title and label graphs is given later in this procedure. As you plan to represent signals using MatLab, a key item to remember is that MatLab functions work on signals in discrete-time. As a result, you will use the DFT (Discrete Fourier Transform) rather than a continuous function Fourier Transform. You may want Lab 1-1

to review the pages which discuss DFT in your Communications Systems text. Matlab uses the Fast Fourier Transform, or FFT, algorithm to implement the DFT. You will find information in the Matlab manual for more specific usage of commands. To learn how to use the fft function type >> help fft at the Matlab command line. FFT Discrete Fourier transform. FFT(X) is the discrete Fourier transform of vector X. If the length of X is a power of two, a fast radix-2 fast-fourier transform algorithm is used. If the length of X is not a power of two, a slower non-power-of-two algorithm is employed. FFT(X,N) is the N-point FFT, padded with zeros if X has less than N points and truncated if it has more. If X is a matrix, the FFT operation is applied to each column. See also IFFT, FFT2, IFFT2, FFTSHIFT. Another useful command, especially after you have created many variables, is whos: Example: >> help whos MatLab will show the usage of built-in function whos : WHOS is a long form of WHO. It lists each variables in the current workspace, together with information about its size, density, complexity, etc. Finally, clear all purges all the variables you have assigned. Prelab1.1: Creating a sine wave 1) Generate a sine wave with a signal frequency, f o, of 1 Hz, and an amplitude of 1 volt peak to peak. A sinusoidal, real-valued signal, is described by three parameters: frequency, amplitude, and phase. The mathematical model of the signal in time is y( t) = A sin( 2 pi f t + φ ), 0 t < T [sec] (1.1) o where A is the amplitude, f o is the signal frequency in Hertz, t is the time, and φ is initial phase. Because MatLab creates waveforms from a series of discrete points, you must generate sufficient samples to make the waveform look like an analog signal. After the waveform is created, the plot command will display an analog-like plot from the discrete data points. Begin creating the sine wave by defining 100 data points over a period of 3 seconds: >> t = 0 : 3*1/100 : 3*(1-1/100) ; Lab 1-2

Note: A semicolon prevents the vector from being echoed to the screen after you enter the command. Now you can create the sine wave. For this first sine wave, use f o = 1 [Hz], an initial phase of 0, and amplitude of 1 volt peak-to-peak: >> yt = 4 * sin ( 2 * pi * t + 0 ); Plot will display the waveform you just created: >> plot ( t, yt ) The following two commands label the axes: >> xlabel ( 'time [sec]' ) >> ylabel ( 'amplitude [volt]' ) Finish the plot by providing a title: title ( '1 Hz Sine Wave' ) Now it's your turn. 2) Generate a sinusoidal signal with following definition: A = 10 Vpp, f o = 1000 Hz, sampling time T s = 0.001 milliseconds, φ = π/4, starting time = 0, and ending time = 2 milliseconds. You can verify the number of data points by using the MatLab built-in functions size or length: >> size(t) or >> length(t) The time sequence is made regarding for the sampling time. Now you can generate a time sequence about the requirement for the array length: >> t = [0: 1000] / fs ; or t = linspace (0, 0.002, 1000 ) ; where fs is a sampling time for the time sequence. Find the value of the last element for the time sequence. Include a plot of this sine wave in your report. Prelab 1.2: The Frequency Spectrum of Sine wave. The mathematical model of a sampled (discrete valued) sine wave is y( t) = A sin( 2 pi f n* T + φ ) for n = 0,1,2,..., N-1 o where, A defines its amplitude, f o its frequency, n is the sample number, φ defines the relative phase at n = 0, and N is the signal length 1) Generate a sine wave. Use the following values: T s = 10 µsec, A = 5 Vpp, f o = 1000 Hz, and 0 t 2 msec. You will need to determine the number of data points by dividing the time period by the sampling time. s Lab 1-3

Add AWGN(Additive White Gaussian Noise) to the time domain signal in order to make the output more like the practical output of oscilloscope: >> y = A * sin ( 2*pi*fo*t )+ 0.2*randn ( 1, length ( t ) ); After you create y(t), plot the FFT of y(t), that is, Y(f). You will compare the time domain and frequency domain output of Matlab with those you observe in the lab. You can use a 512-point FFT for better resolution: >> Y = fft ( y, 512 ) ; >> plot ( Y ) You can see that a problem exists due to the fact that the output of the FFT function is a complex valued vector. MATLAB plots complex numbers on the two-dimensional complex plane, which is not the plot you are trying to generate. What is usually significant in communications is the magnitude of the frequency domain representation. You can plot the magnitude of the FFT by using MatLab's abs function: >> plot ( abs ( Y ) ) Matlab sets axes automatically unless a user defines them. To define the x- and y-axis in order to see the plot in detail: >> axis ( [ 0 20 0 1300 ] ) Now the graph looks like a frequency domain plot. However it still does not look like the sinc pulse that we would expect to see. This is because MATLAB presents frequency components from f = 0 to f = f s (i.e. from DC to the sampling frequency). However, we are used to seeing the plots range from f = -f s /2 to f = +f s /2. This problem can be overcome by using the fftshift function. To get help on this function type: >> help fftshift Plot the magnitude using the fftshift function to move the dc component to the center of the display: >> plot ( abs ( fftshift ( Y ) ) ) Now the plot is starting to look like the expected Fourier transform. However, the x-axis is still not correct. The x-axis should be scaled to display frequencies from -fs/2 to fs/2. Since the sample period is 10 µsec, the sample frequency is 100 KHz. Create a separate vector that contains frequencies (in units of KHz) for the x-axis as follows: >> L = length ( Y ) ; >> x = 100 * ( ( 0 : L-1 ) / L -.5 ) ; Try the plot again, but this time use the x-axis that you just created: >> plot ( x, fftshift ( abs ( Y ) ) ) This produces a plot of magnitude versus frequency. If you want the output to look more like the display you see with the oscilloscope, instead of using fftshift, you must define the x-axis in the following way: >> f = 100 * ( ( 0 : L/2-1 ) / L ) ; Lab 1-4

>> Y = fft ( y, 512 ) ; >> plot ( f, abs ( Y ( 1 : L/2 ) ) To increase the resolution of FFTs, use zero padding. As you see in the usage of fft, Matlab make fft can implement zero padding. If the user defines a larger value than the length of the input signal, the function fft gives the FFT output of a zero padded input signal. This is explained in Appendix D. You can also use a logarithmic scale for the magnitude of spectra. To see the magnified data of magnitude: >> plot ( f, 20 * log10 ( abs ( Y ( 1 : L/2 ) ) ) ) 2) Generate the following signal and plot its frequency spectrum. Determine the appropriate sampling rate and find the significant signal frequency of the waveform from the FFT. y(t) = 1.5sin(2π*50*t) + 5cos(2π 100 t) + 3sin(2π*200*t), 0 t 01. sec Prelab 1.3: The Frequency Spectrum of a pulse Unit impulse signal: x = [1 0 0 0 0 0 0 0] corresponds to mathematical definition: δ [n] = 1, n = 0 = 0, n = 1, 2,..., N-1 1) Using the Matlab built-in function fft to see DFTs, plot the magnitude of a DFT. The steps below illustrate how to plot the magnitude. Start by creating a vector x with N = 8 points. You do not need to take the frequency range for the x-axis into consideration when you plot the FFT of the impulse for this procedure. >> x = [1 0 0 0 0 0 0 0] ; >> plot ( x ) >> X = fft ( x ) ; >> X = fftshift ( X ) ; Use the Matlab function stem to display discrete data. If you just use the command plot, then the impulse looks like triangular pulse. >> plot ( abs ( X ) ) >> stem ( abs ( X ) ) 2) You can use the Matlab function ifft to reconstruct the time domain signal. The usage of ifft is similar to that of fft: >> X = fft ( x ) >> xi = ifft ( X ) >> stem ( real ( xi ) ) Note: Since there are both real and imaginary components in the FFT, you must specify that you want to graph the real part of xi. 3) Repeat steps 1) and 2) for input signals which are a) all ones: x = [ 1 1 1 1 1 1 1 1 ] ; Lab 1-5

b) shifted impulse: x = [ 0 0 0 1 0 0 0 0 ] ; c) three point boxcar: x = [ 1 1 1 0 0 0 0 0 ] ; d) symmetric boxcar: x = [ 1 1 0 0 0 0 1 1 ] ; Then, observe the each signal output and compare the values of their FFT outputs. You can combine the plots into one graph. To create one plot for the time domain and frequency domain impulse response function use the function subplot. Subplot(m,n,p) or subplot(mnp) can be used to observe two plots in an easier way at the same time in Matlab: >> subplot ( 211 ) >> stem ( x ) >> subplot ( 212 ) >> stem (abs ( X ) ) For more information, type help subplot at Matlab command line. Note that here abs specifies the absolute value, or magnitude, of X. Prelab 1.4: The Frequency Spectrum of Rectangular Pulse 1) In this section of the prelab you will generate the FFT of rectangular wave pulses. Use the m-files that you created in Prelab 1.2 for this procedure. Find the FFTs of the rectangular waves using the same parameters as in Prelab 1.2. 2) Also plot FFTs for rectangular waves with non-symmetrical duty cycles: 20%, 35%, and 75%. Use one plane of the FFT to make the outputs look like those of oscilloscope. In your lab report, comment on the spectral harmonics created by varying the duty cycle. You may need to increase the resolution of your FFTs to be able to distinguish the differences caused by varying the duty cycle. Determine the distance between spectral harmonics. To see more spectral harmonics in the FFTs, you will need to increase the points calculated by the FFT, that is, the input value N for the function fft. 3) Reconstruct the signals using ifft: >> X = fft ( x ) ; >> xi = ifft ( X ) ; Since the output xi is complex value, you must view the real part of xi to be able to compare the re-created signal with the original time domain signal: >> plot ( t, real ( xi ) ) 4) Starting with the rectangular wave sequence, create a sequence with a sampling rate of 32 points per symbol period. a) Generate two complete cycles of the sequence so that you can see two pulses. Find the FFT of this sequence. Lab 1-6

b) Reduce the sampling rate to 16 points per period. Find the FFT of this sequence. c) Reduce the sampling rate 8 and 4 points per period and plot the FFTs of these signals. d) Reconstruct each of the above FFTs using IFFT. Use stem to plot each of the reconstructed signals. e) Compare the plots of the reconstructed signals and explain the differences you observe between them. 5) Repeat step 4) for the sine wave that you generated for prelab 2.1, changing the sampling time as explained below. Complete this procedure after you generate a sine wave of the 64 data points for one cycle. >> newy1 = y ( 1:2:128 ) ; % 32-points for the first sequence >> newy2 = y ( 1:4:128 ) ; % 16-points for the second sequence >> newy3 = y ( 1:8:128 ) ; % 8-points for the third sequence >> newy4 = y( 1:16:128 ) ; % 4-points for the fourth sequence Lab 1-7

Lab Parts required for this lab: No components required for Lab q 1.1. The spectrum of a sine wave, and the effect of aliasing (From the HP Product Note 54600-3: FFT Lab Experiments Notebook - reproduced by permission from Hewlett Packard.) 1. Connect the function generator to channel 1 of the oscilloscope. Select a 2 V pp (i.e., 1 V pp displayed on the function generator) sinusoidal signal with a frequency of 1 KHz. Use "Autoscale" to display the waveform. 2. Depress the "+/-" key on the oscilloscope and then select the "On" entry under the "Function 2" menu. This will display the FFT of the time-domain waveform. Next, eliminate the trace of the waveform from the screen by depressing the "1" key and then selecting "Off" under the "1" menu entry. Use the "Time/Div" control to select an effective sampling rate of 10 KSa/s (thousand samples per second). 3. Adjust the settings of the FFT. Select the "Menu" entry under the "Function 2" menu. Select the "FFT Menu" entry and then "Autoscale FFT". Record the frequency span under "Freq Span" of the displayed spectra. Explain the relationship between this value and the effective sampling rate. 4. Using the signal's generator frequency control, progressively increase the frequency of the signal to roughly 4 KHz, allowing the FFT display to stabilize at several points along the way. You should see the peak lobe of the FFT display move to the right as the signal frequency is increased. Using "Cursors" "Find Peaks", complete the following table: Frequency Generator frequency (KHz) Cursor f1 frequency (KHz) 1.0 2.5 4.0 5. Continue to slowly increase the sinusoid's frequency. Aliasing occurs as the frequency of the sinusoid exceeds 5 KHz. As the frequency is swept from 5 KHz to 10 KHz, the main-lobe moves to left on the display. As the sinusoid's frequency is swept from 10 KHz to 15 KHz, the main lobe moves to the right on the FFT display. Complete the following table: Frequency Generator frequency (KHz) Cursor f1 frequency (KHz) 6.0 7.5 9.0 11.0 12.5 14.0 Lab 1-8

6. Assuming ideal sampling and using the theoretical spectra of a sine wave, plot the spectra of the sampled waveform when its frequency is 2.5, 6, and 11 KHz and the sampling frequency is 10 KHz. What values would show the reading for cursor f1 when the frequency of the waveform is 53 KHz? 78 KHz? Create spectral plots to display your conclusions. 1.2 Analyzing square and rectangular waves. In this section you will create a square wave, and then observe changes in the output spectrum as the duty cycle of the square wave is changed. 1. Connect a 2 V pp (actual value) square wave with a frequency of 10 KHz to channel 1 of the oscilloscope. Use "Autoscale" to display the waveform. 2. Activate the FFT function and turn off channel 1 as in step 2 of the previous section. Use the "Time/Div" knob to select a sampling rate of 500 KSa/s. Autoscale the FFT as described in step 3 of section 2.1. Notice that the amplitude of the spectral lines decreases monotonically. 3. Decrease the sampling rate to 200 KSa/s. At this point you should see 5 spectral lines. Using "Cursors" and "Find Peaks" determine: f1 frequency (KHz) f2 frequency (KHz) frequency (KHz) 4. When the duty cycle is changed from 50% (square wave), the signal becomes a periodic pulse instead of a square wave form, causing the envelope of the spectra to take on the shape of the sinc function. On the function generator, change the duty cycle of the signal to 20% by depressing the keys "Shift" "Offset" and then either by rotating the knob or by entering the number using "Enter Number". 5. Notice that the amplitude of the spectral components is no longer decreasing monotonically, and that there is a gap between the fourth and fifth spectral lines. Using "Cursors" and "Find Peaks", complete the table: f1 frequency (KHz) f2 frequency (KHz) frequency (KHz) Also, determine the frequency which corresponds to the missing pulse, i.e., which would occur in the separation between the fourth and fifth spectral lines. Select both f1 f2 as active cursors (both will highlighted), then adjust f1 to coincide with the fourth spectral line. f2 will be at the frequency of the missing component. Lab 1-9

6. Repeat step 5, with the duty cycle set to 25%. Notice that the number of spectral lines between gaps has changed. What is the relationship between the frequency of the missing spectral line, the period of the square wave, and the duty cycle of the square wave? 7. Repeat step 5 with the duty cycle set to 75%. Compare these results with those obtained in steps 5 and 6. Explain the results you observed. 8. Calculate the frequencies of the mission spectral lines for a duty cycle of 40%? Verify your answer by displaying the FFT on the oscilloscope. Hint: Recall that the envelope of the spectrum must be sinc shaped, and observe the display carefully. Report In this lab you analyzed sine and square/rectangular waves in the time domain and in the frequency domain. You also observed aliasing. 1. Answer the questions from the Lab and the Prelab. 2. Define a rule for preventing/detecting aliasing Don't forget to turn in a diskette containing your Matlab equations with your lab report. Lab 1-10