Lab1 Workbook
Lab1 Workbook
Fall 2024
Lab 1: Rotary Servo Base Unit Modeling
The objective of this experiment is to nd a transfer function that describes the rotary
motion of the Rotary Servo Base Unit. The dynamic model is derived analytically from
classical mechanics principles and using experimental methods.
Topics:
Deriving the dynamics equation and transfer function for the Rotary Servo Base Unit
servo plant using the rst-principles.
Obtaining the Rotary Servo Base Unit transfer function using a frequency response
experiment.
Obtaining the Rotary Servo Base Unit transfer function using a bump test.
Tuning the obtained transfer function and validating it with the actual system response.
Prerequisites:
Familiar with Transfer function fundamentals, e.g. obtaining a transfer function from
a dierential equation.
1 Background
The angular speed of the Rotary Servo Base Unit load shaft with respect to the input motor
voltage can be described by the following rst-order transfer function
Ωl (s) K
= (1)
Vm (s) τs + 1
where Ωl (s) is the Laplace transform of the load shaft speed ωl (t), Vm (s) is the Laplace
transform of motor input voltage vm (t), K is the steady-state gain, τ is the time constant,
and s is the Laplace operator.
The Rotary Servo Base Unit transfer function model is derived analytically in Section
1.1 and its K and τ parameters are evaluated. These are known as the nominal model
parameter values. The model parameters can also be found experimentally. Sections 1.2.1
and 1.2.2 describe how to use the frequency response and bump-test methods to nd K and
τ . These methods are useful when the dynamics of a system are not known, for example in
a more complex system. After the lab experiments, the experimental model parameters are
compared with the nominal values.
1
1.1 Modeling Using First-Principles
The DC motor armature circuit schematic and gear train is illustrated in Figure 1. As
specied in Rotary Servo Base Unit User Manual, recall that Rm is the motor resistance, Lm
is the inductance, and km is the back-emf constant.
Figure 1: Rotary Servo Base Unit DC motor armature circuit and gear train
The back-emf (electromotive) voltage eb (t) depends on the speed of the motor shaft, ωm ,
and the back-emf constant of the motor, km . It opposes the current ow. The back emf
voltage is given by:
dIm (t)
Vm (t) − Rm Im (t) − Lm − km ωm (t) = 0 (3)
dt
Since the motor inductance Lm is much less than its resistance, it can be ignored. Then, the
equation becomes
Vm (t) − Rm Im (t) − km ωm (t) = 0 (4)
Solving for Im (t), the motor current can be found as:
Vm (t) − km ωm (t)
Im (t) = (5)
Rm
In this section the equation of motion describing the speed of the load shaft, ωl , with respect
to the applied motor torque, τm , is developed.
2
Since the Rotary Servo Base Unit is a one degree-of-freedom rotary system, Newton's
Second Law of Motion can be written as:
J ·α=τ (6)
where J is the moment of inertia of the body (about its center of mass), α is the angular
acceleration of the system, and τ is the sum of the torques being applied to the body. As
illustrated in Figure 1, the Rotary Servo Base Unit gear train along with the viscous friction
acting on the motor shaft, Bm , and the load shaft Bl are considered. The load equation of
motion is
dωl (t)
Jl + Bl ωl (t) = τl (t) (7)
dt
where Jl is the moment of inertia of the load and τl is the total torque applied on the
load. The load inertia includes the inertia from the gear train and from any external loads
attached, e.g. disc or bar. The motor shaft equation is expressed as:
dωm (t)
Jm + Bm ωm (t) + τml (t) = τm (t) (8)
dt
where Jm is the motor shaft moment of inertia and τml is the resulting torque acting on the
motor shaft from the load torque. The torque at the load shaft from an applied motor torque
can be written as:
τl (t) = ηg Kg τml (t) (9)
where Kg is the gear ratio and ηg is the gearbox eciency. The planetary gearbox that is
directly mounted on the Rotary Servo Base Unit motor (see Rotary Servo Base Unit User
Manual for more details) is represented by the N1 and N2 gears in Figure 1 and has a gear
ratio of
N2
Kgi = (10)
N1
This is the internal gear box ratio. The motor gear N3 and the load gear N4 are directly
meshed together and are visible from the outside. These gears comprise the external gear
box which has an associated gear ratio of
N4
Kge = (11)
N3
The gear ratio of the Rotary Servo Base Unit gear train is then given by:
Thus, the torque seen at the motor shaft through the gears can be expressed as:
τl (t)
τml (t) = (13)
ηg K g
Intuitively, the motor shaft must rotate Kg times for the output shaft to rotate one
revolution.
θm (t) = Kg θl (t) (14)
3
We can nd the relationship between the angular speed of the motor shaft, ωm , and the
angular speed of the load shaft, ωl by taking the time derivative:
To nd the dierential equation that describes the motion of the load shaft with respect
to an applied motor torque substitute equations (13), (15) and (7) into equation (8) to get
the following:
In this section the electrical equation derived in Section 1.1.1 and the mechanical equation
found in Section 1.1.2 are brought together to get an expression that represents the load
shaft speed in terms of the applied motor voltage.
The motor torque is proportional to the voltage applied and is described as
where kt is the current-torque constant (N.m/A), ηm is the motor eciency, and Im is the
armature current. See Rotary Servo Base Unit User Manual for more details on the Rotary
Servo Base Unit motor specications.
We can express the motor torque with respect to the input voltage Vm (t) and load shaft
speed ωl (t) by substituting the motor armature current given by equation 5 in Section 1.1.1,
into the current-torque relationship given in equation 21:
ηm kt (Vm (t) − km ωm (t))
τm (t) = (22)
Rm
To express this in terms of Vm and ωl , insert the motor-load shaft speed equation 15, into
equation 21 to get:
ηm kt (Vm (t) − km Kg ωl (t))
τm (t) = (23)
Rm
4
If we substitute (23) into (20), we get:
d ηg Kg ηm kt (Vm (t) − km Kg ωl (t))
Jeq ωl (t) + Beq ωl (t) = (24)
dt Rm
km ηg Kg2 ηm kt
d ηg Kg ηm kt Vm (t)
ωl (t) Jeq + + Beq ωl (t) = (25)
dt Rm Rm
ηg Kg2 ηm kt km + Beq Rm
Beq,v = (27)
Rm
and the actuator gain equals
ηg Kg ηm kt
Am = (28)
Rm
In Section 1.1 you learned how the system model can be derived from the rst-principles.
A linear model of a system can also be determined purely experimentally. The main idea
is to experimentally observe how a system reacts to dierent inputs and change structure
and parameters of a model until a reasonable t is obtained. The inputs can be chosen in
many dierent ways and there are a large variety of methods. In Sections 1.2.1 and 1.2.2,
two methods of modeling the Rotary Servo Base Unit are outlined: (1) frequency response
and, (2) bump test.
In Figure 2, the response of a typical rst-order time-invariant system to a sine wave input
is shown. As it can be seen from the gure, the input signal (u) is a sine wave with a
xed amplitude and frequency. The resulting output (y ) is also a sinusoid with the same
frequency but with a dierent amplitude. By varying the frequency of the input sine wave
and observing the resulting outputs, a Bode plot of the system can be obtained as shown in
Figure 3.
The Bode plot can then be used to nd the steady-state gain, i.e. the DC gain, and the
time constant of the system. The cutto frequency, ωc , shown in Figure 3 is dened as the
frequency where the gain is 3 dB less than the maximum gain (i.e. the DC gain). When
working in the linear non-decibel range, the 3 dB frequency is dened as the frequency where
the gain is √12 , or about 0.707, of the maximum gain. The cuto frequency is also known
5
Figure 2: Typical frequency response
as the bandwidth of the system which represents how fast the system responds to a given
input.
The magnitude of the frequency response of the Rotary Servo Base Unit plant transfer
function given in equation 1 is dened as:
Ωl (ω j)
|Gwl,v (w)| = (29)
Vm (ω j)
where ω is the frequency of the motor input voltage signal Vm . We know that the transfer
function of the system has the generic rst-order system form given in Equation (1). By
substituting s = j w in this equation, we can nd the frequency response of the system as:
Ωl (ω j) K
= (30)
Vm (ω j) τω j + 1
Then, the magnitude of it equals
K
|Gwl,v (ω)| = √ (31)
1 + τ 2 ω2
Let's call the frequency response model parameters Ke,f and τe,f to dierentiate them
from the nominal model parameters, K and τ , used previously. The steady-state gain or the
DC gain (i.e. gain at zero frequency) of the model is:
The bump test is a simple test based on the step response of a stable system. A step input
is given to the system and its response is recorded. As an example, consider a system given
6
Figure 3: Magnitude Bode plot
Y (s) K
= (33)
U (s) τs + 1
The step response shown in Figure 4 is generated using this transfer function with K = 5
rad/V.s and τ = 0.05 s.
Figure 4: Input and output signal used in the bump test method
The step input begins at time t0 . The input signal has a minimum value of umin and
a maximum value of umax . The resulting output signal is initially at y0 . Once the step is
7
applied, the output tries to follow it and eventually settles at its steady-state value yss . From
the output and input signals, the steady-state gain is
∆y
K= (34)
∆u
where ∆y = yss − y0 and ∆u = umax − umin . In order to nd the model time constant, τ ,
we can rst calculate where the output is supposed to be at the time constant from:
Then, we can read the time t1 that corresponds to y(t1 ) from the response data in Figure 4.
From the gure we can see that the time t1 is equal to:
t1 = t0 + τ (36)
τ = t1 − t0 (37)
Going back to the Rotary Servo Base Unit system, a step input voltage with a time delay
t0 can be expressed as follows in the Laplace domain:
Av e(−s t0 )
Vm (s) = (38)
s
where Av is the amplitude of the step and t0 is the step time (i.e. the delay). If we substitute
this input into the system transfer function given in Equation (1), we get:
KAv e(−s t0 )
Ωl (s) = (39)
(τ s + 1) s
We can then nd the Rotary Servo Base Unit load speed step response, wl (t), by taking
inverse Laplace of this equation. Here we need to be careful with the time delay t0 and note
that the initial condition is ωl (0− ) = ωl (t0 ).
t−t0
ωl (t) = K Av 1 − e(− τ ) + ωl (t0 ) (40)
2 Pre-Lab Questions
Before you start the lab experiments given in Section 3, you should study the background
materials provided in Section 1 and work through the questions in this Section.
1. In Section 1.1.3 we obtained Equation (26) that described the dynamic behavior of the
load shaft speed as a function of the motor input voltage. Starting from this equation,
nd the transfer function VΩml (s)
(s)
.
2. Express the steady-state gain (K) and the time constant (τ ) of the process model
Equation (1) in terms of the Jeq , Beq,v , and Am parameters.
8
3. ⋆ The load attached to the motor shaft includes a 24-tooth gear, two 72-tooth gears,
and a single 120-tooth gear along with any other external load that is attached to the
load shaft. Thus, for the gear moment of inertia Jg and the external load moment
of inertia Jl,ext , the load inertia is Jl = Jg + Jl,ext . Using the specications given in
Rotary Servo Base Unit User Manual nd the total moment of inertia Jg from the
2
gears . Hint: Use the denition of moment of inertia for a disc Jdisc = mr2 .
Answer: The formula to calculate the moment of inertia of a disc is
mr2
Jdisc = (41)
2
where m is the mass and r is the radius. Assuming the gears are discs and using the
parameters given in Rotary Servo Base Unit User Manual, the moment of inertia of
the 24-tooth, 72-tooth, and 120-tooth gears are
which equals
Jg = 5.282 × 10−5 kg m2 (46)
4. ⋆ Evaluate the equivalent moment of inertia Jeq . This is the total inertia from the
motor and gears. The moment of inertia of the DC motor can be found in the Rotary
Servo Base Unit User Manual.
Answer: Using equation 18 with the gear train and motor specications listed in
Rotary Servo Base Unit User Manual, Jm = 3.9 × 10−7 kg m2 , the equivalent moment
of inertia acting on the Rotary Servo Base Unit motor shaft is
5. ⋆ Calculate the steady-state model gain K and time constant τ . These are the nominal
model parameters and will be used to compare with parameters that are later found
experimentally.
Answer: The nominal model parameters should be about K = 1.53 rad/(V s) and
τ = 0.0217 s.
6. Referring to Section 1.2.1, nd the expression representing the time constant τ of the
frequency response model given in Equation (31). Begin by evaluating the magnitude
of the transfer function at the cuto frequency ωc .
9
7. Referring to Section 1.2.2, nd the steady-state gain of the step response and compare
it with Equation (34). Hint: The the steady-state value of the load shaft speed can
be dened as ωl,ss = limt→∞ ωl (t).
8. Evaluate the step response given in Equation (40) at t = t0 + τ and compare it with
Equation (35).
3 Lab Experiments
The main goal of this laboratory is to nd a transfer function (model) that describes the
rotary motion of the SRV02 load shaft as a function of the input voltage. We can obtain
this transfer function experimentally using one of the following two methods:
Frequency response, or
Bump test
In this laboratory, rst you will conduct two experiments exploring how these methods
can be applied to a real system. Then, you will conduct a third experiment to ne tune the
parameters of the transfer functions you obtained and to validate them.
Experimental Setup
The q_servo_modeling Simulink diagram shown in Figure 5 will be used to conduct
the experiments. The Rotary Servo Interface subsystem contains QUARC blocks that
interface with the DC motor and sensors of the SRV02 system as discussed in Reference
[VoltPAQ User Manual]. The Servo Model uses a Transfer Fcn block from the Simulink
library to simulate the SRV02 system. Thus, both the measured and simulated load shaft
speed can be monitored simultaneously given an input voltage.
IMPORTANT: Before you can conduct these experiments, you need to make sure that
on the left side of your Matlab, all the codes related to Modeling are listed in the Matlab
Current Folder. If not, you need to nd the path of the folder where you extracted the les
and paste the path into the Matlab path, as shown in Figure 6.
10
Figure 6: Matlab current folder
As explained in Section 1.2.1 earlier, the frequency response of a linear system can be ob-
tained by providing a sine wave input signal to it and recording the resulting output sine
wave from it. In this experiment, the input signal is the motor voltage and the output is the
motor speed.
In this method, we keep the amplitude of the input sine wave constant but vary its
frequency. At each frequency setting, we record the amplitude of the output sine wave. The
ratio of the output and input amplitudes at a given frequency can then be used to create a
Bode magnitude plot. Then, the transfer function for the system can be extracted from this
Bode plot.
First, we need to nd the steady-state gain of the system. This requires running the system
with a constant input voltage. To create a 2V constant input voltage follow these steps:
1. Before you can conduct these experiments, you need to congure the lab les rst. In
Matlab, open setup_servo_modeling.m. In line 11, replace XXX with your Student
ID. Run this matlab script le.
2. In the Simulink diagram, double-click on the Signal Generator block and ensure the
following parameters are set:
11
Frequency: 0.0001 (Since Signal Generator block does not accept zero frequency,
a very small value is adopted here.)
Units: Hertz
3. Set the Amplitude (V) gain block to 0. (The signal from Signal Generator block will
be zero after this block. Hence, a constant input will be applied to the system.)
12
7. Measure the speed of the load shaft and enter the measurement in Table 1 below under
the f = 0 Hz row.
Hint: The measurement can be done directly from the scope using the Cursor Mea-
surements tool. Alternatively, you can use Matlab commands to nd the maximum
load speed using the saved wl variable. When the controller is stopped, the w_l (rad/s)
scope saves the last 10 seconds of response data to the Matlab workspace in the wl
parameter. It has the following structure: wl(:,1) is the time vector, wl(:,2) is the
measured speed, and wl(:,3) is the simulated speed.
8. Calculate the steady-state gain both in linear and decibel (dB) units as explained in
1.2.1. Enter the resulting numerical value in the f = 0 Hz row of Table 1. Also, enter
its non-decibel value in Table 2 in Section 3.4.
In this part of the experiment, we will send an input sine wave at a certain frequency to the
system and record the amplitude of the output signal. We will then increment the frequency
and repeat the same observation.
To create the input sine wave:
1. In the Simulink diagram, double-click on the Signal Generator block and ensure the
following parameters are set:
5. The Rotary Servo Base Unit unit should begin rotating smoothly back and forth and
the scopes should be reading a response similar to Figures 9 and 10.
6. Measure the maximum positive speed of the load shaft at f = 1.0 Hz input and enter
it in Table 1 below. As before, this measurement can be done directly from the scope
using the Cursor Measurements tool or you can use Matlab commands to nd the
maximum load speed using the saved wl variable.
7. Calculate the gain of the system (in both linear and dB units) and enter the results in
Table 1.
13
Figure 9: Input motor voltage
8. Increase the frequency to f = 2.0 Hz by adjusting the frequency parameter in the Signal
Generator block. Measure the maximum load speed and calculate the gain. Repeat
this step for each of the frequency settings in Table 1.
9. Using the Matlab plot command and the data collected in Table 1, generate a Bode
magnitude plot. Make sure the amplitude and frequency scales are in decibels. When
making the Bode plot, ignore the f = 0 Hz entry as the logarithm of 0 is not dened.
10. Calculate the time constant τe,f using the obtained Bode plot by nding the cuto
frequency. Label the Bode plot with 3 dB less that the steady-state gain and the cuto
frequency. Enter the resulting time constant in Table 2. Hint: If you cannot nd the
cuto frequency based on the tests to 8 Hz, please try to do more tests with higher
frequencies, such as 9 Hz 12 Hz.
11. Click the Stop button on the Simulink diagram toolbar (or select QUARC | Stop from
the menu) to stop the experiment.
14
f (Hz) Amplitude (V) Max Load Speed (rad/s) Gain:|G(ω )| (rad/s/V) Gain:|G(ω )| (rad/s/V, dB)
0.0 2.0
1.0 2.0
2.0 2.0
3.0 2.0
4.0 2.0
5.0 2.0
6.0 2.0
7.0 2.0
8.0 2.0
Table 1: Collected frequency response data (use 20log10(|G|) to calculate Gain in dB).
In this method, a step input is given to the Rotary Servo Base Unit and the corresponding
load shaft response is recorded. Using the saved response, the model parameters can then
be found as discussed in Section 1.2.2.
To create the step input:
1. Double-click on the Signal Generator block and ensure the following parameters are
set:
4. Open the load shaft speed scope, Speed (rad/s), and the motor input voltage cope, Vm
(V).
5. Select QUARC | Start to run the controller. The gears on the Rotary Servo Base Unit
should be rotating in the same direction and alternating between low and high speeds.
The response in the scopes should be similar to Figures 11 and 12.
6. Plot the response in Matlab. Recall that the maximum load speed is saved in the
Matlab workspace under the wl variable.
7. Find the steady-state gain using the measured step response and enter it in Table 2.
Hint: Use the Matlab ginput command to measure points o the plot.
8. Find the time constant from the obtained response and enter the result in Table 2.
9. Click the Stop button on the Simulink diagram toolbar (or select QUARC | Stop from
the menu) to stop the experiment.
15
Figure 11: Square input motor voltage.
In this experiment, you will adjust the model parameters you found in the previous exper-
iments to tune the transfer function. Our goal is to match the simulated system response
with the parameters you found as closely as possible to the response of the actual system.
To create a step input:
1. Double-click on the Signal Generator block and ensure the following parameters are
set:
16
4. Open the load shaft speed scope, w_l (rad/s), and the motor input voltage scope,
V_m (V).
5. Select QUARC | Start to run the controller. The gears on the Rotary Servo Base Unit
should be rotating in the same direction and alternating between low and high speeds
and the scopes should be as shown in Figures 13 and 14. Recall that the yellow trace
is the measured load shaft rate and the blue trace is the simulated trace. By default,
the steady-state gain and the time constant of the transfer function used in simulation
are set to: K = 1 rad/s/V and τ = 0.1s. These model parameters do not accurately
represent the system.
Figure 13: Input square voltage with default model parameters: K = 1 and τ = 0.1.
Figure 14: Speed step response with default model parameters: K = 1 and τ = 0.1.
17
9. Restart the simulation again and observe how the simulation changes.
10. Vary the gain and time constant model parameters. How do the gain and the time
constant aect the system response?
11. Enter the nominal values, K and τ , that were found in pre-lab questions, in the Matlab
Command Window. Update the parameters and examine how well the simulated
response matches the measured one.
12. If the calculations were done properly, then the model should represent the actual
system quite well. However, there are always some dierences between each servo
unit and, as a result, the model can always be tuned to match the system better. Try
varying the model parameters until the simulated trace matches the measured response
better. This can be done by manually changing the Servo Model Transfer Function
block parameters or changing the K and tau parameters in the Matlab Command
Window and restarting the Simulink model. Enter these tuned values under the Model
Validation section of Table 2.
13. Provide two reasons why the nominal model does not represent the Rotary Servo Base
Unit with better accuracy.
14. Create a Matlab gure that shows the measured and simulated response of the model
validation response using the tuned model parameters of K and τ .
15. Explain how well the nominal model, the frequency response model, and the bumptest
model represent the Rotary Servo Base Unit system.
16. Click the Stop button on the Simulink diagram toolbar (or select QUARC | Stop from
the menu) to stop the experiment.
17. Record the test number shown in Display block. Take a screen shot of the Simulink
interface with the test number that you record. Hint: Every student has a unique test
number.
3.4 Results
18
From Section Description Symbol Value Unit
Section 2 Nominal Values
Open-Loop Steady-State Gain K rad/(V.s)
Open-Loop Time Constant τ s
Section 3.1 Frequency Response Exp.
Open-Loop Steady-State Gain Ke,f rad/(V.s)
Open-Loop Time Constant τe,f s
Section 3.2 Bump Test Exp.
Open-Loop Steady-State Gain Ke,b rad/(V.s)
Open-Loop Time Constant τe,b s
Section 3.3 Model Validation
Open-Loop Steady-State Gain Ke,v rad/(V.s)
Open-Loop Time Constant τe,v s
Table 2: Summary of results for the Rotary Servo Base Unit Modeling laboratory.
4 Lab Report
When you prepare your lab report, you can follow the outline given in Section 4.1 to build
the content of your report. Also, in Section 4.2 you can nd some basic tips for the format
of your report.
I. PROCEDURE
I.1. Frequency Response Experiment
1. Briey describe the main goal of this experiment and the procedure.
1. Briey describe the main goal of this experiment and the experimental procedure
(Section 3.2).
1. Briey describe the main goal of this experiment and the experimental procedure
(Section 3.3).
II. RESULTS
Do not interpret or analyze the data in this section. Just provide the results.
19
1. Table 1 and Bode plot from step 9 in Section 3.1.2, Gain at varying frequencies.
2. Response plot from step 6 in Section 3.2, Bump Test Experiment.
3. Response plot from step 14 in Section 3.3, Model Validation Experiment.
4. Provide data collected in this laboratory (from Table 2).
5. Provide your test number and the screen shot in Step 17 in Section 3.3.
III. ANALYSIS
Provide details of your calculations (methods used) for analysis for each of the following:
IV. CONCLUSIONS
Interpret your results to arrive at logical conclusions.
PROFESSIONAL APPEARANCE
Has cover page with all necessary details (title, course, student name(s), etc.)
Each of the required sections is completed (Procedure, Results, Analysis and Conclu-
sions).
Typed.
20
Figures are numbered, axes have labels, each gure has a descriptive caption. All
curves in a gure has dierent color and line style.
Tables are numbered, they include labels, each table has a descriptive caption.
Data are presented in a useful format (graphs, numerical, table, charts, diagrams).
21