0% found this document useful (0 votes)
53 views

MECE 4372 Mechanics Control Vibration Lab Lab Report 4

The document summarizes an experiment involving generating triangular waves using Fourier series approximations in MATLAB and comparing simulated and experimental inputs and outputs of a system with a triangular wave input. Key findings include: - As the number of Fourier terms used to approximate the triangular wave increased, the approximation became more accurate. - As the frequency of the triangular wave input increased, the amplitude of the experimental and simulated outputs decreased due to the low-pass filtering effect of the combined system. - The experimental and simulated inputs and outputs matched closely at lower frequencies but differed more at higher frequencies due to the increased filtering effect.

Uploaded by

sunshine heaven
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

MECE 4372 Mechanics Control Vibration Lab Lab Report 4

The document summarizes an experiment involving generating triangular waves using Fourier series approximations in MATLAB and comparing simulated and experimental inputs and outputs of a system with a triangular wave input. Key findings include: - As the number of Fourier terms used to approximate the triangular wave increased, the approximation became more accurate. - As the frequency of the triangular wave input increased, the amplitude of the experimental and simulated outputs decreased due to the low-pass filtering effect of the combined system. - The experimental and simulated inputs and outputs matched closely at lower frequencies but differed more at higher frequencies due to the increased filtering effect.

Uploaded by

sunshine heaven
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

MECE 4372 Mechanics Control Vibration Lab

Lab Report 4
OBJECTIVE

One objective of the lab is to generate a triangular wave on MATLAB and compare different
summations of a Fourier series to create a triangular wave. Another objective is to compare
simulation and experimental inputs and outputs of a system with a triangular wave input.

EXPERIMENTAL SETUP

Figure 1 shows the block diagram for the experiment.

Figure 1 - Block Diagram for Experiment

Figure 2 shows the circuit diagram for the experiment.

Figure 2 - Circuit Diagram for Experiment

EXPERIMENTAL PROCEDURE

1. Using MATLAB, approximate a triangular wave with an amplitude of 1 and a frequency


of 30 Hz. Generate four waveforms using N = 1, 5 10, and 20 for the number of Fourier
terms for approximation and compare each approximation.
2. Use the LabView VI Scope to measure a response of the combined system to a triangular
wave input. Four different sets of data should be recorded for four different frequencies
(0.5 Hz, 5 Hz, 15 Hz, and 30 Hz)
3. Write a MATLAB script to compare the numerically simulated input and output to the
experimental input and output. Use N = 20 for the number of Fourier terms to
approximate the triangular wave. Use the second-order system parameters found in Lab 3
to model the combined system (Use the TA gray box values).
RESULTS

Part 1:
Figure 3 shows the results of Part 1 of Lab 4 which was to approximate a triangular wave with an
amplitude of 1 and frequency of 30 Hz using different number of Fourier terms for
approximation. The code used for Part 1 can be found in Appendix A and turned in with this lab
report.

Figure 3 - Plot Showing Summation of Sine Waves to Create a Triangular Wave


Part 2:
Figure 4 shows the plot for a triangular wave input at 0.5 Hz. The code for Part 2 can be found in
Appendix B and turned in with his lab report.

Figure 4 - Plot Showing Experimental and Simulation Results for a Triangular Wave at 0.5 Hz
Figure 5 shows the plot for a triangular wave input at 5 Hz.

Figure 5 - Plot Showing Experimental and Simulation Results for a Triangular Wave at 5 Hz
Figure 6 shows the plot for a triangular wave input at 15 Hz.

Figure 6 - Plot Showing Experimental and Simulation Results for a Triangular Wave at 15 Hz
Figure 7 shows the plot for a triangular wave input at 30 Hz.

Figure 7 - Plot Showing Experimental and Simulation Results for a Triangular Wave at 30 Hz

DISCUSSION

Part 1:
Figure 3 shows the results from Part 1 of Lab 4. As the number of terms in the series summation,
N, increases from 1 to 20, the graph looks closer to a triangular wave. This happens because
more terms are added to the summation which relates to a more accurate representation of a
triangular wave.

Part 2:
For all plots in Part 2, the simulated and experimental input are close together and maintain the
same trend as expected. The amplitudes of both inputs are the same. Figure 4 shows the results
for a triangular wave at 0.5 Hz. The experimental has an amplitude that is about 1 V greater than
the simulated output. The experimental output amplitude is around 4.7 V, and the simulated
output amplitude is around 3 V. Figure 5 shows the results of a triangular wave at 5 Hz. The
amplitude has dropped from the 0.5 Hz plot. The experimental output amplitude is around 2.7 V,
and the simulated amplitude output is around .7 V. Additionally, the output amplitude does not
line up with the input amplitude. Figure 6 shows the results of a triangular wave at 15 Hz. The
amplitude is lower than the amplitude in the 5 Hz plot. The experimental output amplitude is
around 1 V, and the simulated output amplitude is around 0.4 V. Also, the amplitudes of the
output do not match the input amplitudes. Figure 7 shows the results of a triangular wave at 30
Hz. The amplitudes of the output are lower than the input, and the amplitudes of the output do
not match. Also, the amplitudes of the output do not line up with the input amplitudes.

As the frequency increases from 0.5 Hz to 30 Hz, the output amplitudes begin to decrease due to
a filtering effect. At 0.5 Hz, the input signal is seen in the output, and the output receives most of
the signal. As the frequency increases, less of the signal/data is being transmitted. The combined
system is a low-pass filter which was seen in the previous lab Bode plots, so this filtering effect
matches the low-pass filter effect.

CONCLUSION

In Part 1, a plot was made to see the difference in triangular waves by using different numbers of
Fourier terms for approximation, and N = 20 showed a good approximation for a triangular
wave. In Part 2, plots were made for different frequencies of a triangular wave input. The
experimental and simulated input and output were close together at the lowest frequency, 0.5 Hz,
and the inputs and outputs were different as the frequency increased. This trend is due to the
combined system being a low-pass filter which produced the filtering effect.

APPENDIX A: Part 1 Code

clc % clears command window


clear % clears workspace
close all % clears windows

freq = 30; % frequency determined from lab 4 part 1 instructions


T = 1/freq; % period of signal
A = 1; % amplitude determined from lab 4 part 1 instructions
x = 0; % variable to store data

t = linspace(0,2*T,2000); % time series to generate a traingular wave with 2T


with 1000 points per period
xm = zeros(20,2000); % memory variable to store data points

for m = [1 5 10 20] % how many number of sine waves that is added


for n = 1:2:m % runs sum for n value with odd value of sine waves
An = 8*A/(n*pi)^2; % amplitude based on fourier series obtained
x = x + An*cos(2*pi*n*t/T); % first sine wave
end % repeat for odd value
xm(m,:) = x; % store in memory
x = 0; % zero out x value after each m value calculation
end % repeat for each number of sine wave

plot(t,xm(1,:),t,xm(5,:),t,xm(10,:),t,xm(20,:)); % plot all 4 summations


legend('N=1','N=5','N=10','N=20'); % create legend
grid on % adds grid lines
title('Summation of Sine Waves to Create a Traingular Wave'); % creates title
on plot
xlabel('Time'); % create x-axis label
ylabel('Output'); % creates y-axis label
APPENDIX B: Part 2 Code

clc % clears command window


clear % clears workspace
close all % clears windows

data1 = load('lab4_exp1.txt'); % loads data for 0.5 Hz


data2 = load('lab4_exp2.txt'); % loads data for 5 Hz
data3 = load('lab4_exp3.txt'); % loads data for 15 Hz
data4 = load('lab4_exp4.txt'); % loads data for 30 Hz

t1 = data1(:,1); % separates time data for 0.5 Hz


x1 = data1(:,2); % separates input data for 0.5 Hz
y1 = data1(:,3); % separates output data for 0.5 Hz
t2 = data2(:,1); % separates time data for 5 Hz
x2 = data2(:,2); % separates input data for 5 Hz
y2 = data2(:,3); % separates output data for 5 Hz
t3 = data3(:,1); % separates time data for 15 Hz
x3 = data3(:,2); % separates input data for 15 Hz
y3 = data3(:,3); % separates output data for 15 Hz
t4 = data4(:,1); % separates time data for 30 Hz
x4 = data4(:,2); % separates input data for 30 Hz
y4 = data4(:,3); % separates output data for 30 Hz

k = .7913; % gain value of TA's gray box system


wn = 73; % corner frequency value for TA's gray box system
z = 1.8; % damping ratio value for the TA's gray box system
num = [0 0 k*wn^2]; % numerator of the transfer function
den = [1 2*z*wn wn^2]; % denominator of the transfer function

f = [0.5 5 15 30]; % values for the frequency


A = [4.214 4.212 4.253 4.259]; % amplitudes from each frequency
r = 1; % counter for while loop
x = 0; % buffer value for later calculations
y = 0; % buffer value for later calculations

while r < 5 % while loop to create plots for each frequency


f1 = f(r); % selects frequency
T1 = 1/f1; % period calculation
A1 = A(r); % selects amplitude
t = linspace(0,2*T1,2000); % time series to generate a triangular wave
with 2T with 1000 points per period
for n = 1:2:20 % Fourier series with N = 20 for good approximation
skipping even numbers
An = 8*A1/(n*pi)^2; % Amplitude
x = x + An*cos(2*pi*n*(t-T1/4)/T1); % creates in put and time shift to
delay triangular by a quarter of a period
[mag,pha] = bode(num,den,2*pi*2/T1); % helps find the value from the
bode plot of combined system from omega 1 and picks magnitude and phase
y = y + An*mag*cos(2*pi*n*(t-T1/4)/T1+pha*pi/180); % creates output
and convert phase from degree to radians
end % end Fourier series loop
if r == 1 % create plot for 0.5 Hz
figure(1) % creates figure
plot(t,x,'--',t,y,'--',t1,x1,t1,y1); % plots simulated input and
output and experimental input and output for 0.5 Hz
title('Experimental and Simulation Results for Triangular Wave at
0.5Hz') % creates title
legend('Simulated Input','Simulated Output','Experimental
Input','Experimental Output'); % creates legend
grid on % adds grid lines
xlabel('Time [s]'); % create x-axis label
ylabel('Voltage [V]'); % creates y-axis label
end % ends loop for 0.5 Hz
if r == 2 % create plot for 5 Hz
figure(2) % creates figure
plot(t,x,'--',t,y,'--',t2,x2,t2,y2); % plots simulated input and
output and experimental input and output for 0.5 Hz
title('Experimental and Simulation Results for Triangular Wave at
5Hz') % creates title
legend('Simulated Input','Simulated Output','Experimental
Input','Experimental Output'); % creates legend
grid on % adds grid lines
xlabel('Time [s]'); % create x-axis label
ylabel('Voltage [V]'); % creates y-axis label
end % ends loop for 5 Hz
if r == 3 % create plot for 15 Hz
figure(3) % creates figure
plot(t,x,'--',t,y,'--',t3,x3,t3,y3); % plots simulated input and
output and experimental input and output for 0.5 Hz
title('Experimental and Simulation Results for Triangular Wave at
15Hz') % creates title
legend('Simulated Input','Simulated Output','Experimental
Input','Experimental Output'); % creates legend
grid on % adds grid lines
xlabel('Time [s]'); % create x-axis label
ylabel('Voltage [V]'); % creates y-axis label
end % ends loop for 30 Hz
if r == 4 % create plot for 15 Hz
figure(4) % creates figure
plot(t,x,'--',t,y,'--',t4,x4,t4,y4); % plots simulated input and
output and experimental input and output for 0.5 Hz
title('Experimental and Simulation Results for Triangular Wave at
30Hz') % creates title
legend('Simulated Input','Simulated Output','Experimental
Input','Experimental Output'); % creates legend
grid on % adds grid lines
xlabel('Time [s]'); % create x-axis label
ylabel('Voltage [V]'); % creates y-axis label
end % ends loop for 30 Hz
r = r + 1; % adds 1 to select next frequency and amplitude value
n = 1; % reset n value
An = 0; % reset An value
x = 0; % reset x value
y = 0; % reset y value
mag = 0; % reset magnitude value
pha = 0; % reset phase angle value
end % ends loop for the 4 frequencies

You might also like