# CS计算机代考程序代写 matlab Rensselaer Mechatronics

Rensselaer Mechatronics

Prelab 3: Frequency Response of a DC motor

Prelab Objectives:

• Obtain the theoretical frequency response for input voltage to the output speed of a DC motor

• Use the bode diagram to predict what the output sine wave of the DC motor will look like at different input voltage frequencies.

This predicted output will be compared to observations and data obtained during the lab.

Note: the example code and plots provided in this pre-lab are for a different input voltage and frequency than will be performed in the experiment. You can copy and paste this code but you must modify it based on your needs.

Part A: Understanding the input

• This lab will examine the output of a DC motor in response to an input sinusoid with different frequencies: 1, 50, and 100 rad/sec. For each frequency calculate how long it will take in seconds to observe 3 cycles of the sine wave:

w = 1 rad/s Time 3 cycles = ______________________________

w = 50 rad/s Time 3 cycles = ______________________________

w = 100 rad/s Time 3 cycles = ______________________________

Now we know how long to collect the data to capture 3 periods of the output. For each frequency, plot an input signal of amplitude 3.25 V for at least 3 periods to verify your result. These graphs do not need to be included in the prelab submission.

% Example of plotting an input sine wave voltage:

V=3.0; % an example voltage

T3=1.18; w=16; % an example frequency of 16 rad/sec needs 1.18 seconds for 3 cycles

dt=.005;t=0:dt:T3; % create a time vector so we can plot sin(wt)

plot(t, V*sin(w*t)) % Verify input magnitude and period

Part B: Obtaining the Bode Diagram for the Speed of a DC motor:

As we saw in the previous lab, the speed response of a DC motor to a voltage input can be modeled as a first order transfer function, . For this prelab, use the following: , and .

• Create the transfer function in MATLAB and obtain the bode diagram:

K=60; % steady state gain (rad/sec)/volt

tau=0.04; % time constant (sec)

Gvspd=tf(K,[tau 1]); % transfer function from V to spd (volts to speed)

bode(Gvspd,1:100) % type “help bode” at the command line for units

Include a screenshot of this bode diagram:

[Insert Bode Diagram Here]

• From this bode diagram extract the magnitude and angle at frequencies 1, 50 and 100 rad/s (use units of , and degrees):

w=1 rad/s Mag = ____________________ Angle = ______________________

w=50 rad/s Mag = ____________________ Angle = ____________________ _

w=100 rad/s Mag = ____________________ Angle = ______________________

• Now obtain the exact results at these frequencies with the command:

[mag,phase]=bode(Gvspd, w) % type “help bode” at the command line for units

Obtain the magnitude and phase using this method for all the frequencies (use units of ,degrees):

w=1 rad/s Mag = ____________________ Angle = ______________________

w=50 rad/s Mag = ____________________ Angle = ______________________

w=100 rad/s Mag = ____________________ Angle = ______________________

Part C: Predict the output based off the bode diagram

The bode diagram predicts how the magnitude and angle (delay) of the output will change based on the input frequency. The input and output calculations for an example are given below. Remember to change them for your own calculation ( is used for output speed of the motor so as to not confuse it with the frequency, . Be sure to use proper units!):

Input voltage (volts):

Output speed (rad/sec):

• Compute and plot the predicted output of the system:

Include 3 graphs of the predicted output to input sine waves of frequency 1, 50, and 100 rad/s and clearly label each graph with the correct units. Only plot 3 periods of the output.

Insert graphs here.

Part D: Plotting the output and input on the same graph

Use the example code to plot both the input and output for each frequency on the same graph. Since they have different units, separate y-axis labels will be used.

%% Part D plotting both on same graph:

yyaxis left

plot(t,V*mag16*sin(w*t+phase16/180*pi))

ylim([-180 180]) % Refine these limits as needed, then

% use this same limit for all 3 graphs

ylabel(‘Rotational speed’)

yyaxis right

plot(t,V*sin(w*t))

ylim([-3.5 3.5]) % Refine these limits at needed, then

% use this same limit for all 3 graphs

ylabel(‘Voltage input’)

title([‘Voltage and rotational speed for ‘,num2str(w),’rad/s’])

xlabel(‘time sec’)

• Create 3 graphs (one for each frequency) that have the input voltage and the output speed on the same graph:

Insert graphs here.