EE 5765 Modern Communication Fall 2014, UMD Experiment 3: Fourier Series Consider the continuous time signal given by y(t) = A0 + A1 cos (2π f0 t + θ1 ) + A2 cos (4π f0 t + θ2 ) + A3 cos (6π f0 t + θ3 ) where A0 is the DC component of the signal, Ak are the amplitude of the harmonics, k is the harmonic number, and θk are the phase angle of the harmonics. The expression for a Fourier Series representation of a function signal x(t) with N harmonics is The features of a signal given by this equation can be studied in terms of the frequency, amplitudes, and phases of the sinusoidal terms. The amplitudes A1, A2, A3, . . , An specify the relative weights of the frequency components of the particular signal. These weights are a major factor in determining the shape of the signal. The phase angle of a trigonometric component controls the position of the component along the time axis. In the first part of the experiment you will investigate the effect of the magnitude and phase angle components. You will be asked to change the amplitude and phase values and compare the resulting waveform to the original one. I. Harmonic Components of Periodic Signals Consider that signal y(t) = A0 + A1 cos (2π f0 t + θ1 ) + A2 cos (4π f0 t + θ2 ) + A3 cos (6π f0 t + θ3 ) with period of T0 = 0.1 sec and the component values given in the following Table 1 a) Show the harmonic components and waveforms synthesized by using 2 and 3 harmonic components. f0=10; % Define the frequency of the signal t = 0:0.001:1; harm1 = cos(2*pi*10*t); harm2 = 2*cos(2*pi*20*t+45/180*pi); signa2 = harm1 + harm2; harm3 = 1*cos(2*pi*30*t+60/180*pi); signa3 = signa2 + harm3 figure(1) subplot(5,1,1); plot(t,harm1) subplot(5,1,2); plot(t,harm2) subplot(5,1,3); plot(t,harm3) subplot(5,1,4); plot(t,signa2) subplot(5,1,5); plot(t,signa3) Now you will study the importance of the magnitude and the phase angle of each harmonic component by changing them and comparing the resulting waveform to the original one. Lab report: 1. Labeled plots b) Changing the magnitude of the harmonics Change the magnitude of the second harmonic from A2 = 2 to A2 = 1.6, 1.2 and 1 respectively. Modify the MATLAB script of a). Lab report: 1. The line you modified 2. Labeled plots (A2=1.6, 1.2, 1) 3. Comment on the change of waveform shape c) Changing the phase of the harmonics Change the phase angle of the second harmonic from θ2 = 45o to θ2 = 35o , 25o , and 10o respectively. Modify the MATLAB script of a). Lab report: 4. The line you modified 5. Labeled plots (θ2=35o , 25o , 10o ) 6. Comment on the change of waveform shape 2 d) Adding an harmonic to the signal y(t) Using the original waveform with the three harmonics given in Table 1, create another waveform by adding a 4th harmonic with a magnitude of 1.5 and a phase angle of – o 120 . Lab report: th 1. The line you wrote to add a 4 harmonic th 2. Labeled plots showing the signal containing the 4 harmonic 3. Comparison between the new signal and the original signal II. Magnitude Spectra and the partial Fourier Series Compute and plot the magnitude spectrum and the partial Fourier series sums of two periodic signals: a square wave, and a triangular wave. a) Magnitude Spectrum of a Square Wave The following MATLAB script defines an odd square wave (period 1 sec, no DC level, 2 Vpp) % Program to give partial Fourier sums of an % odd square wave of 2 Vpp amplitude n_max = input('Enter vector of highest harmonic values desired (odd):'); f = 1; N = n_max; t = 0:0.002:1; omega_0 = 2*pi*f; x=zeros(size(t)); n=1:1:N; b_n=zeros(size(n)); for i=1:(N+1)/2; k=2*i-1; b_n(k)=4/(pi*k); % This part is for plotting the Magnitude spectrum figure(1) subplot(2,1,1),stem(b_n); xlabel('Integer Multiple of Fundamental Frequency'); ylabel('Amplitude'),grid; % This part is for plotting the partial Fourier sum x=x+b_n(k)*sin(omega_0*k*t); subplot(2,1,2),plot(t,x),xlabel('t'),ylabel('partial sum'); axis([0 1 -1.5 1.5]),text(0.05,-0.5,['max.har.=',num2str(k)]); grid; end Type the number of harmonics (e.g. 1, 3, up to 15) you want to plot, when you see the following line as you run the program 3 Enter vector of highest harmonic values desired (odd): The Fourier series components for this signal is a summation of odd harmonics of the sine wave with a magnitude of 4/(πk) , where k is the harmonic number. Using MATLAB compute the magnitude of the harmonics coefficients, that is, b1, b2, b3, b4,…, bn. Plot the amplitude spectrum (line spectrum) of the square wave and plot the partial Fourier sums starting from 1 harmonic till 15 harmonics. Lab report: 1. Labeled plots (1, 3, 9 and 15 harmonics respectively) 2. 3. 4. 5. Find magnitude b1, b2, …, b15 in Workspace and put them down Describe how the command a = input (‘b’) works Modify the code to plot the square wave with time period 10-6 sec Modify the code to shift the square wave 0.3 sec to the right. b) Magnitude Spectrum of a triangular Wave The following MATLAB script defines a triangular wave (period 1 sec, no DC level, 2 Vpp) % Program to give partial Fourier sums of a % Triangular wave of 2 Vpp amplitude n_max = input('Enter vector of highest harmonic values desired (odd):'); f = 1; N = n_max; t = 0:0.002:1; omega_0 = 2*pi*f; x=zeros(size(t)); n=1:1:N a_n=zeros(size(n)); for i=1:(N+1)/2; k=2*i-1; a_n(k)=-8/(pi^2*k*k); % This part is for plotting the Magnitude spectrum figure(2) subplot(2,1,1); stem(a_n); xlabel('Integer Multiple of Fundamental Frequency'); ylabel('Amplitude'),grid; % This part is for plotting the partial Fourier sum x=x+a_n(k)*cos(omega_0*k*t); subplot(2,1,2),plot(t,x),xlabel('t'),ylabel('partial sum'); axis([0 1 -1.5 1.5]),text(0.05,-0.5,['max.har.=',num2str(k)]); grid; end The Fourier series components for this signal is a summation of the harmonics of the 2 2 cosine wave with a magnitude of -8/(π k ) , where k is the harmonic number. Using MATLAB compute the magnitude of the harmonics coefficients, that is, a1, a2, a3, a4,…, an. Plot the amplitude spectrum (line spectrum) of the square wave and plot the partial Fourier sums starting from 1 harmonic till 15 harmonics. Lab report: 1. Labeled plots (1, 3, 9 and 15 harmonics respectively) 2. Find magnitude a1, a2, …, a15 in Workspace and put them down. 3. Modify the code to plot the square wave with time period 0.25 sec 4. Modify the code to shift the square wave 0.4 sec to the left. Additional Exercise – Lab 03: For the following questions, you need to experiment on the TIMS modules. 1. Generate a square wave composed of sinusoids of 2 kHz frequency using the TIMS modules; you can use Quadrature Utilities module, Adder, VCO, and Master Signals to generate first four harmonics. Calculate and measure the generated time domain signal and compare. 2. Analyze the generated square wave in frequency domain and observe if you have right harmonics. 3. Analyze in time domain. Explain the differences you observed as compared to a perfect square wave and explain the reasons. 5