You are on page 1of 7

Lab Report

Objectives: Estimate the transfer function of the combined system.

Part 1:
Write a MATLAB m-file to read the measured combined system (gray box with DC
motor) frequency response results from Lab 2 Task 2

Sol.

Gray Box Script:

clear

clc

%% Load Data

load Task1.txt %loads the data file 'data.txt'

Input_Array = Task1 ; %copy data into Input_Array

f = Input_Array(:,1); %frequency vector

m = Input_Array(:,2); %magnitude vector

p = Input_Array(:,3); %phase vector in degrees

%% Define Model System Coefficients

a=45000;

K1=a*10^0.5;

%K2=1; %used for second order systems

%z = 0.22;

%wn = 75*2*pi;

%% Define Model System

num1 = [0 K1]; %high pass filter with gain

den1 = [1 a];
%num2 = [0 0 K2*wn^2]; %second order system (not

%den2 = [1 2*z*wn wn^2]; %used for this system)

%% Connect in Series

%[num,den] = series(num1,den1,num2,den2); %only used for the combined

%system

%% Compute Model Results

w = 2*pi*f; %convert Hz to rad/s

[m2,p2] = bode(num1,den1,w); %obtain magnitude and phase

m2 = 20*log10(m2); %change magnitude to dB

%% Compare Model to Experimental Results

figure(1)

subplot(211)

semilogx(w,m,'o',w,m2) %plot model and data magnitudes

xlabel('Frequency (rad/sec)')

ylabel('Magnitude (dB)')

title('Gary Box Bode plot')

grid on

subplot(212)

semilogx(w,p,'o',w,p2) %plot model and data phases


xlabel('Frequency (rad/s)')

ylabel('Phase (deg)')

grid on
Observations and Results:

Fig.1 Bode plot of Gray Box

Fig.3 Bode plot of Dc motor


Fig.4 Bode plot of combined system

Discussion

The corner frequency, using the method of intersecting lines, was found to be 45000
rad/s for the Gray Box amplifier and 125 rad/s for the DC motor. Once higher
frequencies are achieved on either system the output provided drops exponentially. If
the DC motor behavior is analyzed further, and the corner frequency is converted
back into Hz, it isdetermined that if the motor turns faster than 19.9 rev/s it will
greatly lose efficiency. Using MATALB the transfer function for the Gray Box and
DC motor systems
were found to be:

Conclusions
Using MATLAB the corner frequencies for each system were found easily. Built
in MATLAB function made finding the transfer function for each system easy as well.
The Gray Box system was seen as a first order system while the DC motor was a
second order system.
Part 2:
1.Use a general second-order transfer function of the form below to model the
combined system.

2. Use the plotted Bode plot and data from Part 1 to;

A. Calculate the overall gain .


Sol. To find the values of Gain K, we find the constant magnitude before the corner
frequency on the magnitude bode plot. Here, we find that the constant magnitude is
2.1934 db. Then using the equation,
20log K=2.1934 db
we find the value of K = 1.287.
B.Find the natural frequency
Sol. To find the value of Natural Frequency wn, we check the phase bode plot and
select the value of frequency when the phase of the system is -90 degrees. From the
system response data file, we find the value of wn=189 rad/s.
c.Find the damping ratio .
Sol. Now using the Matlab code and substituting values of K and wn, we adjust the
value of z to best fit the measured results for the overall system

DC Motor Script:

clear

clc

%% Load Data

load Task2.txt %loads the data file 'data.txt'

Input_Array = Task2; %copy data into Input_Array

f = Input_Array(:,1); %frequency vector

m = Input_Array(:,2); %magnitude vector


p = Input_Array(:,3); %phase vector in degrees

m3=m-9.5;

%% Define Model System Coefficients

K = .434;

z = 1.2;

wn = 20*2*pi;

%% Define Model System

num2 = [0 0 K*wn^2]; %second order system

den2 = [1 2*z*wn wn^2];

%% Connect in Series

%% Compute Model Results

w = 2*pi*f; %convert Hz to rad/s

[m2,p2] = bode(num2,den2,w); %obtain magnitude and phase

m2 = 20*log10(m2); %change magnitude to dB

%% Compare Model to Experimental Results

figure(1)

subplot(211)

semilogx(w,m3,'o',w,m2) %plot model and data magnitudes

xlabel('Frequency (rad/s)')
ylabel('Magnitude (dB)')

title('DC Motor Bode plot')

grid

subplot(212)

semilogx(w,p,'o',w,p2) %plot model and data phases

xlabel('Frequency (rad/s)')

ylabel('Phase (deg)')

grid

Combined Transfer Function Script:

Discussion
After adjusting the values of z to best fit the measured results, we find the value of z =
1.9 which is as expected as the value of z should be greater than 0.707. Therefore, K =
1.287,wn = 189,z = 1.9

Conclusions
From this lab, using the Matlab code given below, we were able to adjust the
coefficients of our model to best fit the measured results for the overall system and we
plot the bode plots of our system response.

You might also like