SRV02 Workbook
SRV02 Workbook
SRV02 Workbook
Flexible Link
2 DOF Robot
Flexible Joint
Inverted Pendulum
Gyro/Stable Platform
Multi-DOF Torsion
With the SRV02 Base Unit, you can select from 10 add-on modules to create experiments of varying complexity across a
wide range of topics, disciplines and courses. All of the experiments/workstations are compatible with MATLAB/Simulink.
To request a demonstration or a quote, please email [email protected].
ABET, Inc., is the recognized accreditor for college and university programs in applied science, computing, engineering, and technology. Among the most respected accreditation
organizations in the U.S., ABET has provided leadership and quality assurance in higher education for over 75 years.
2011 Quanser Inc. All rights reserved. MATLAB and Simulink are registered trademarks of The MathWorks, Inc.
+1-905-940-3575
QUANSER.COM
STUDENT WORKBOOK
SRV02 Base Unit Experiment For Matlab/Simulink Users
Standardized for ABET Evaluation Criteria
Developed by:
Jacob Apkarian, Ph.D., Quanser
Michel Lvis, M.A.Sc., Quanser
Hakan Gurocak, Ph.D., Washington State University
Course material
complies with:
Quanser Inc.
119 Spy Court
Markham, Ontario
L3R 5H6
Canada
[email protected]
Phone: 1-905-940-3575
Fax: 1-905-940-3576
ACKNOWLEDGEMENTS
Quanser, Inc. would like to thank Dr. Hakan Gurocak, Washington State University Vancouver, USA, for rewriting this manual to include embedded
outcomes assessment.
ii
CONTENTS
Preface
SRV02 Modeling
1.1
Background
1.1.1
Modeling Using First-Principles
1.1.2
Modeling Using Experiments
1.2
Pre-Lab Questions
1.3
Lab Experiments
1.3.1
Frequency Response Experiment
1.3.2
Bump Test Experiment
1.3.3
Model Validation Experiment
1.3.4
Results
1.4
System Requirements
1.4.1
Overview of Files
1.4.2
Configuring the SRV02 and the Lab Files
1.5
Lab Report
1.5.1
Template for Content
1.5.2
Tips for Report Format
1
2
2
5
8
9
9
12
13
14
15
15
15
17
17
18
19
20
20
23
24
26
27
27
30
32
33
34
34
34
35
36
37
38
39
40
41
42
42
43
45
50
v 1.0
3.2
3.3
3.4
3.5
Pre-Lab Questions
Lab Experiments
3.3.1
Step Response with PI Control
3.3.2
Step Response with LEAD Control
3.3.3
Results
System Requirements
3.4.1
Overview of Files
3.4.2
Setup for Speed Control Simulation
3.4.3
Setup for Speed Control Implementation
Lab Report
3.5.1
Template for Content (PI Control Experiments)
3.5.2
Template for Content (Lead Control Experiments)
3.5.3
Tips for Report Format
51
52
52
55
56
58
58
58
59
60
61
62
63
65
66
66
68
69
71
71
72
75
77
79
iv
PREFACE
v 1.0
vi
LABORATORY 1
SRV02 MODELING
The objective of this experiment is to find a transfer function that describes the rotary motion of the SRV02 load shaft.
The dynamic model is derived analytically from classical mechanics principles and using experimental methods.
Topics Covered
Deriving the dynamics equation and transfer function for the SRV02 servo plant using the first-principles.
Obtaining the SRV02 transfer function using a frequency response experiment.
Obtaining the SRV02 transfer function using a bump test.
Tuning the obtained transfer function and validating it with the actual system response.
Prerequisites
In order to successfully carry out this laboratory, the user should be familiar with the following:
Data acquisition device (e.g. Q2-USB), the power amplifier (e.g. VoltPAQ-X1), and the main components of
the SRV02 (e.g. actuator, sensors), as described in References [2], [4], and [6], respectively.
Wiring and operating procedure of the SRV02 plant with the amplifier and data-aquisition (DAQ) device, as
discussed in Reference [6].
Transfer function fundamentals, e.g. obtaining a transfer function from a differential equation.
Laboratory described in Appendix A to get familiar with using QUARCr with the SRV02.
v 1.0
1.1 Background
The angular speed of the SRV02 load shaft with respect to the input motor voltage can be described by the following
first-order transfer function
l (s)
K
=
(1.1.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 SRV02 transfer function model is derived analytically in Section 1.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.1.2.1 and 1.1.2.2 describe how to use the frequency response and bump-test methods to find 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.
Electrical Equations
The DC motor armature circuit schematic and gear train is illustrated in Figure 1.1. As specified in [6], recall that Rm
is the motor resistance, Lm is the inductance, and km is the back-emf constant.
eb (t) = km m (t)
Using Kirchoff's Voltage Law, we can write the following equation:
dIm (t)
km m (t) = 0
(1.1.3)
dt
is much less than its resistance, it can be ignored. Then, the equation becomes
Vm (t) Rm Im (t) Lm
(1.1.4)
2
1.1.1.2
Vm (t) km m (t)
Rm
(1.1.5)
Mechanical Equations
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.
Since the SRV02 is a one degree-of-freedom rotary system, Newton's Second Law of Motion can be written as:
J =
(1.1.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.1, the SRV02 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
dl (t)
+ Bl l (t) = l (t)
(1.1.7)
Jl
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:
dm (t)
Jm
+ Bm m (t) + ml (t) = m (t)
(1.1.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)
(1.1.9)
where Kg is the gear ratio and g is the gearbox efficiency. The planetary gearbox that is directly mounted on the
SRV02 motor (see [6] for more details) is represented by the N1 and N2 gears in Figure 1.1 and has a gear ratio of
Kgi =
N2
N1
(1.1.10)
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
Kge =
N4
N3
(1.1.11)
The gear ratio of the SRV02 gear train is then given by:
Kg = Kge Kgi
(1.1.12)
Thus, the torque seen at the motor shaft through the gears can be expressed as:
ml (t) =
l (t)
g Kg
(1.1.13)
Intuitively, the motor shaft must rotate Kg times for the output shaft to rotate one revolution.
m (t) = Kg l (t)
(1.1.14)
v 1.0
We can find 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:
m (t) = Kg l (t)
(1.1.15)
To find the differential equation that describes the motion of the load shaft with respect to an applied motor torque
substitute (1.1.13), (1.1.15) and (1.1.7) into (1.1.8) to get the following:
l (t)
Jl ( ddt
) + Bl l (t)
dl (t)
Jm Kg
+ Bm Kg l (t) +
= m (t)
dt
g Kg
(1.1.16)
Collecting the coefficients in terms of the load shaft velocity and acceleration gives
(g Kg2 Jm + Jl )
dl (t)
+ (g Kg2 Bm + Bl )l (t) = g Kg m (t)
dt
(1.1.17)
g Kg2 Bm
(1.1.18)
(1.1.19)
+ Bl
1.1.1.3
dl (t)
+ Beq l (t) = g Kg m (t)
dt
(1.1.20)
In this section the electrical equation derived in Section 1.1.1.1 and the mechanical equation found in Section 1.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
(1.1.21)
m (t) = m kt Im (t)
where kt is the current-torque constant (N.m/A), m is the motor efficiency, and Im is the armature current. See [6]
for more details on the SRV02 motor specifications.
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 1.1.5 in Section 1.1.1.1, into the current-torque relationship given in
equation 1.1.21:
m kt (Vm (t) km m (t))
m (t) =
(1.1.22)
Rm
To express this in terms of Vm and l , insert the motor-load shaft speed equation 1.1.15, into 1.1.21 to get:
m (t) =
(1.1.23)
(1.1.24)
(1.1.25)
)
d
wl (t) Jeq + Beq,v l (t) = Am Vm (t)
dt
(1.1.26)
g Kg2 m kt km + Beq Rm
Rm
(1.1.27)
g Kg m kt
Rm
(1.1.28)
1.1.2.1
Frequency Response
In Figure 1.2, the response of a typical first-order time-invariant system to a sine wave input is shown. As it can be
seen from the figure, the input signal (u) is a sine wave with a fixed amplitude and frequency. The resulting output
(y) is also a sinusoid with the same frequency but with a different 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 1.3.
v 1.0
K
1 + 2 2
(1.1.31)
Let's call the frequency response model parameters Ke,f and e,f to differentiate 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:
Ke,f = |Gwl,v (0)|
(1.1.32)
1.1.2.2
Bump Test
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 by the following transfer function:
K
Y (s)
=
U (s)
s + 1
(1.1.33)
The step response shown in Figure 1.4 is generated using this transfer function with K = 5 rad/V.s and = 0.05 s.
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 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
K=
y
u
(1.1.34)
Figure 1.4: Input and output signal used in the bump test method
where y = yss y0 and u = umax umin . In order to find the model time constant, , we can first calculate where
the output is supposed to be at the time constant from:
y(t1 ) = 0.632yss + y0
(1.1.35)
Then, we can read the time t1 that corresponds to y(t1 ) from the response data in Figure 1.4. From the figure we
can see that the time t1 is equal to:
t1 = t0 +
(1.1.36)
From this, the model time constant can be found as:
= t1 t0
(1.1.37)
Going back to the SRV02 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) =
(1.1.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.1.1), we get:
l (s) =
KAv e(s t0 )
( s + 1) s
(1.1.39)
We can then find the SRV02 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 ).
(
)
tt0
l (t) = K Av 1 e( ) + l (t0 )
(1.1.40)
v 1.0
11. Evaluate the step response given in equation 1.1.40 at t = t0 + and compare it with Equation 1.1.34.
v 1.0
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.
1.3.1.1
Steady-state gain
First, we need to find 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. In the Simulinkr diagram, double-click on the Signal Generator block and ensure the following parameters are
set:
Wave form: sine
Amplitude: 1.0
Frequency: 0.0
Units: Hertz
2. Set the Amplitude (V) slider gain to 0.
3. Set the Offset (V) block to 2.0 V.
4. Open the load shaft speed scope, w l (rad/s), and the motor input voltage scope, V m (V).
5. Click on QUARC | Build to compile the Simulink diagram.
6. Select QUARC | Start to run the controller. The SRV02 unit should begin rotating in one direction. The scopes
should be reading something similar to Figures 1.6 and 1.7. Note that in the w l (rad/s) scope, the yellow trace
is the measured speed while the purple trace is the simulated speed (generated by the SRV02 Model block).
7. Measure the speed of the load shaft and enter the measurement in Table 1.1 below under the f = 0 Hz row.
The measurement can be done directly from the scope. Alternatively, you can use Matlabr commands to find
the maximum load speed using the saved wl variable. When the controller is stopped, the w l (rad/s) scope
saves the last 5 seconds of response data to the Matlabr 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.1.2.1. Enter the resulting
numerical value in the f = 0 Hz row of Table 1.1. Also, enter its non-decibel value in Table 1.2 in Section 1.3.4.
10
1.3.1.2
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. Set the Offset (V) block to 0 V.
2. Set the Amplitude (V) slider gain to 2.0 V.
3. The SRV02 unit should begin rotating smoothly back and forth and the scopes should be reading a response
similar to Figures 1.8 and 1.9.
4. Measure the maximum positive speed of the load shaft at f = 1.0 Hz input and enter it in Table 1.1 below.
As before, this measurement can be done directly from the scope or, preferably, you can use Matlabr commands
to find the maximum load speed using the saved wl variable.
5. Calculate the gain of the system (in both linear and dB units) and enter the results in Table 1.1.
6. Now 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.1.
7. Using the Matlabr plot command and the data collected in Table 1.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 defined.
8. Calculate the time constant e,f using the obtained Bode plot by finding the cutoff frequency. Label the Bode
plot with the -3 dB gain and the cutoff frequency. Enter the resulting time constant in Table 1.2. Hint: Use the
ginput command to obtain values from the Matlabr figure.
9. Click the Stop button on the Simulinkr diagram toolbar (or select QUARC | Stop from the menu) to stop the
experiment.
10. Turn off the power to the amplifier if no more experiments will be performed on the SRV02 in this session.
v 1.0
f (Hz)
Amplitude (V)
0.0
1.0
2.0
3.0
4.0
5.0
6.0
7.0
8.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
Maximum Load
Speed (rad/s)
Gain:|G()|
(rad/s/V)
Gain:|G()|
(rad/s/V, dB)
7. Plot the response in Matlabr . Recall that the maximum load speed is saved in the Matlabr workspace under
the wl variable.
SRV02 Workbook - Student Version
12
8. Find the steady-state gain using the measured step response and enter it in Table 1.2. Hint: Use the Matlabr ginput
command to measure points off the plot.
9. Find the time constant from the obtained response and enter the result in Table 1.2.
10. Click the Stop button on the Simulinkr diagram toolbar (or select QUARC | Stop from the menu) to stop the
experiment.
11. Turn off the power to the amplifier if no more experiments will be performed on the SRV02 in this session.
v 1.0
8. Update the parameters used by the Transfer Function block in the simulation by selecting the Edit | Update
Diagram item in the q srv02 mdl Simulinkr diagram and observe how the simulation changes.
9. Enter the command tau = 0.2 in the Matlabr Command Window.
10. Update the simulation again by selecting the Edit | Update Diagram and observe how the simulation changes.
11. Vary the gain and time constant model parameters. How do the gain and the time constant affect the system
response?
12. Enter the nominal values, K and , that were found in Section 1.2 in the Matlabr Command Window. Update
the parameters and examine how well the simulated response matches the measured one.
13. If the calculations were done properly, then the model should represent the actual system quite well. However,
there are always some differences 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. Enter these tuned values under the Model Validation section of Table 1.2.
14. Provide two reasons why the nominal model does not represent the SRV02 with better accuracy.
15. Create a Matlabr figure that shows the measured and simulated response of each method (the nominal
model, the frequency response model, and the bumptest model). Enter the nominal values, K and , in
the Matlabr Command Window, update the parameters, and examine the response. Repeat for the frequency
response parameters Ke,f and e,f along with the bump test variables Ke,b and e,b .
16. Explain how well the nominal model, the frequency response model, and the bumptest model represent the
SRV02 system.
17. Click the Stop button on the Simulinkr diagram toolbar (or select QUARC | Stop from the menu) to stop the
experiment.
18. Turn off the power to the amplifier if no more experiments will be performed on the SRV02 in this session.
1.3.4 Results
Fill out Table 1.2 below, with your results.
Section
1.2
1.3.1
1.3.2
1.3.3
Description
Nominal Values
Symbol
Ke,f
e,f
Ke,b
e,b
Ke,v
e,v
Value
Unit
14
config srv02.m
Description
This laboratory guide contains pre-lab and in-lab exercises demonstrating how to model the Quanser SRV02
rotary plant. The in-lab exercises are explained using the
QUARC software.
The main Matlabr script that sets the SRV02 motor and
sensor parameters. Run this file only to setup the laboratory.
Returns the configuration-based SRV02 model specifications Rm, kt, km, Kg, eta g, Beq, Jeq, and eta m, the
sensor calibration constants K POT, K ENC, and K TACH,
and the amplifier limits VMAX AMP and IMAX AMP.
Returns various conversions factors.
Simulinkr file that implements the open-loop controller for
the SRV02 system using QUARC.
v 1.0
6. Configure Sensor: The speed of the load shaft can be measured using various sensors. Set the Spd Src
Source block in q srv02 mdl, as shown in Figure 1.5, as follows:
1 to use tachometer
2 to use the encoder
7. It is recommended that the tachometer sensor be used to perform this laboratory. However, for users who do
not have a tachometer with their servo, e.g. SRV02 or SRV02-E options, they may choose to use the encoder
with a high-pass filter to get a velocity measurement.
8. Go to the Current Directory window and double-click on the setup srv02 exp01 mdl.m file to open the setup
script for the q srv02 mdl Simulinkr model.
9. Configure setup script: The beginning of the setup script is shown below. Ensure the script is setup to match
the configuration of your actual SRV02 device. For example, the script given below is setup for an SRV02-ET
plant in the high-gear configuration mounted with a disc load and it is actuated using the Quanser VoltPAQ
device with a motor cable gain of 1. See [6] for more information on SRV02 plant options and corresponding
accessories.
Finally, make sure MODELING TYPE is set to 'MANUAL'.
%% SRV02 Configuration
% External Gear Configuration: set to 'HIGH' or 'LOW'
EXT_GEAR_CONFIG = 'HIGH';
% Encoder Type: set to 'E' or 'EHR'
ENCODER_TYPE = 'E';
% Is SRV02 equipped with Tachometer? (i.e. option T): set to 'YES' or 'NO'
TACH_OPTION = 'YES';
% Type of Load: set to 'NONE', 'DISC', or 'BAR'
LOAD_TYPE = 'DISC';
% Amplifier Gain: set VoltPAQ amplifier gain to 1
K_AMP = 1;
% Power Amplifier Type: set to 'VoltPAQ', 'UPM_1503', 'UPM_2405', or 'Q3'
AMP_TYPE = 'VoltPAQ';
% Digital-to-Analog Maximum Voltage (V)
VMAX_DAC = 10;
%
%% Lab Configuration
% Type of Controller: set it to 'AUTO', 'MANUAL'
MODELING_TYPE = 'AUTO';
% MODELING_TYPE = 'MANUAL';
10. Run the script by selecting the Debug | Run item from the menu bar or clicking on the Run button in the tool
bar. The messages shown below should be generated in the Matlabr Command Window. These are default
model parameters and do not accurately represent the SRV02 system.
Calculated SRV02 model parameter:
K = 1 rad/s/V
tau = 0.1 s
16
v 1.0
IV. CONCLUSIONS
Interpret your results to arrive at logical conclusions.
1. Steps 11, 14, and 16 in Section 1.3.3.
18
LABORATORY 2
SRV02 POSITION CONTROL
The objective of this laboratory is to develop feedback systems that control the position of the rotary servo load shaft.
Using the proportional-integral-derivative (PID) family, controllers are designed to meet a set of specifications.
Topics Covered
Design of a proportional-velocity (PV) controller for position control of the servo load shaft to meet certain
time-domain requirements.
Actuator saturation.
Design of a proportional-velocity-integral (PIV) controller to track a ramp reference signal.
Simulation of the PV and PIV controllers using the developed model of the plant to ensure the specifications
are met without any actuator saturation.
Implementation of the controllers on the Quanser SRV02 device to evaluate their performance.
Prerequisites
In order to successfully carry out this laboratory, the user should be familiar with the following:
Data acquisition device (e.g. Q2-USB), the power amplifier (e.g. VoltPAQ-X1), and the main components of
the SRV02 (e.g. actuator, sensors), as described in References [2], [4], and [6], respectively.
Wiring and operating procedure of the SRV02 plant with the amplifier and data-aquisition (DAQ) device, as
discussed in Reference [6].
Transfer function fundamentals, e.g. obtaining a transfer function from a differential equation.
Laboratory described in Appendix A to get familiar with using QUARCr with the SRV02.
v 1.0
2.1 Background
2.1.1 Desired Position Control Response
The block diagram shown in Figure 2.1 is a general unity feedback system with compensator (controller) C(s) and a
transfer function representing the plant, P(s). The measured output, Y(s), is supposed to track the reference signal
R(s) and the tracking has to match to certain desired specifications.
(2.1.1)
(2.1.2)
Recall in Laboratory: SRV02 Modelling Section 1, the SRV02 voltage-to-speed transfer function was derived. To
find the voltage-to-position transfer function, we can put an integrator (1/s) in series with the speed transfer function
(effectively integrating the speed output to get position). Then, the resulting open-loop voltage-to-load gear position
transfer function becomes:
K
P (s) =
(2.1.3)
s ( s + 1)
As you can see from this equation, the plant is a second order system. In fact, when a second order system is placed
in series with a proportional compensator in the feedback loop as in Figure 2.1, the resulting closed-loop transfer
function can be expressed as:
Y (s)
n2
(2.1.4)
= 2
R(s)
s + 2 n s + n2
where n is the natural frequency and is the damping ratio. This is called the standard second-order transfer
function. Its response proporeties depend on the values of n and .
2.1.1.1
Consider a second-order system as shown in Equation 2.1.4 subjected to a step input given by
R(s) =
R0
s
(2.1.5)
with a step amplitude of R0 = 1.5. The system response to this input is shown in Figure 2.2, where the red trace is
the response (output), y(t), and the blue trace is the step input r(t). The maximum value of the response is denoted
by the variable ymax and it occurs at a time tmax . For a response similar to Figure 2.2, the percent overshoot is
found using
100 (ymax R0 )
(2.1.6)
PO =
R0
SRV02 Workbook - Student Version
20
(2.1.7)
1 2
(2.1.8)
The peak time depends on both the damping ratio and natural frequency of the system and it can be derived as:
tp =
n 1 2
(2.1.9)
Generally speaking, the damping ratio affects the shape of the response while the natural frequency affects the
speed of the response.
2.1.1.2
Steady-state error is illustrated in the ramp response given in Figure 2.3 and is denoted by the variable ess . It is the
difference between the reference input and output signals after the system response has settled. Thus, for a time t
when the system is in steady-state, the steady-state error equals
ess = rss (t) yss (t)
(2.1.10)
where rss (t) is the value of the steady-state input and yss (t) is the steady-state value of the output.
We can find the error transfer function E(s) in Figure 2.1 in terms of the reference R(s), the plant P (s), and the
compensator C(s). The Laplace transform of the error is
E(s) = R(s) Y (s)
(2.1.11)
Solving for Y (s) from equation 2.1.3 and substituting it in equation 2.1.11 yields
E(s) =
R(s)
1 + C(s) P (s)
(2.1.12)
v 1.0
(2.1.13)
s0
In this equation, we need to substitute the transfer function for E(s) from 2.1.12. The E(s) transfer function requires,
R(s), C(s) and P(s). For simplicity, let C(s)=1 as a compensator. The P(s) and R(s) were given by equations 2.1.3
and 2.1.5, respectively. Then, the error becomes:
(
E(s) =
R0
s 1+
K
s ( s+1)
(2.1.14)
( s + 1) s
s0 s2 + s + K
lim
(2.1.15)
ess = 0
Based on this zero steady-state error for a step input, we can conclude that the SRV02 is a Type 1 system.
2.1.1.3
The desired time-domain specifications for controlling the position of the SRV02 load shaft are:
ess = 0
(2.1.17)
tp = 0.20 s
(2.1.18)
P O = 5.0 %
(2.1.19)
and
Thus, when tracking the load shaft reference, the transient response should have a peak time less than or equal to
0.20 seconds, an overshoot less than or equal to 5 %, and the steady-state response should have no error.
22
The proportional-velocity (PV) compensator to control the position of the SRV02 has the following structure
(
)
d
Vm (t) = kp (d (t) l (t)) kv
l (t)
(2.1.20)
dt
where kp is the proportional control gain, kv is the velocity control gain, d (t) is the setpoint or reference load shaft
angle, l (t) is the measured load shaft angle, and Vm (t) is the SRV02 motor input voltage. The block diagram of the
PV control is given in Figure 2.4. We need to find the closed-loop transfer function l (s)/d (s) for the closed-loop
(2.1.21)
From the Plant block in Figure 2.4 and equation 2.1.3, we can write
K
l (s)
=
Vm (s)
s ( s + 1)
(2.1.22)
Substituting equation 2.1.21 into 2.1.22 and solving for l (s)/d (s) gives the SRV02 position closed-loop transfer
function as:
l (s)
K kp
=
(2.1.23)
d (s)
s2 + (1 + K kv ) s + K kp
2.1.2.2
In control design, a factor to be considered is saturation. This is a nonlinear element and is represented by a
saturation block as shown in Figure 2.5. In a system like the SRV02, the computer calculates a numeric control
voltage value. This value is then converted into a voltage, Vdac (t), by the digital-to-analog converter of the dataacquisition device in the computer. The voltage is then amplified by a power amplifier by a factor of Ka . If the
amplified voltage, Vamp (t), is greater than the maximum output voltage of the amplifier or the input voltage limits
of the motor (whichever is smaller), then it is saturated (limited) at Vmax . Therefore, the input voltage Vm (t) is the
effective voltage being applied to the SRV02 motor. The limitations of the actuator must be taken into account when
designing a controller. For instance, the voltage entering the SRV02 motor should never exceed
Vmax = 10.0 V
(2.1.24)
v 1.0
2.1.2.3
From our previous steady-state analysis, we found that the closed-loop SRV02 system is a Type 1 system. In this
section, we will investigate the steady-state error due to a ramp input when using PV controller.
Given the following ramp setpoint (input)
R0
(2.1.25)
s2
we can find the error transfer function by substituting the SRV02 closed-loop transfer function in equation 2.1.23 into
the formula given in 2.1.11. Using the variables of the SRV02, this formula can be rewritten as E(s) = d (s) l (s).
After rearranging the terms we find:
d (s) s ( s + 1 + K kv )
E(s) =
(2.1.26)
s2 + s + K k p + K k v s
R(s) =
Substituting the input ramp transfer function 2.1.25 into the d (s) variable gives
E(s) =
R0 ( s + 1 + K kv )
s ( s2 + s + K kp + K kv s)
(2.1.27)
d
Vm (t) = kp (d (d) l (t)) + ki (d (t) l (t)) dt kv
l (t)
(2.1.28)
dt
where ki is the integral gain. We need to find the closed-loop transfer function l (s)/d (s) for the closed-loop
position control of the SRV02. Taking the Laplace transform of equation 2.1.28 gives
)
(
ki
Vm (s) = kp +
(d (s) l (s)) kv s l (s)
(2.1.29)
s
From the Plant block in Figure 2.6 and equation 2.1.3, we can write
l (s)
K
=
Vm (s)
( s + 1) s
(2.1.30)
Substituting equation 2.1.29 into 2.1.30 and solving for l (s)/d (s) gives the SRV02 position closed-loop transfer
function as:
l (s)
K (kp s + ki )
= 3
(2.1.31)
d (s)
s + (1 + K kv ) s2 + K kp s + K ki
24
2.1.3.1
To find the steady-state error of the SRV02 for a ramp input under the control of the PIV substitute the closed-loop
transfer function from equation 2.1.31 into equation 2.1.11
E(s) =
s3
d (s) s2 ( s + 1 + K kv )
+ s2 + K kp s + K ki + K kv s2
(2.1.32)
Then, substituting the reference ramp transfer function 2.1.25 into the d (s) variable gives
E(s) =
2.1.3.2
R0 ( s + 1 + K kv )
s3 + s2 + K kp s + K ki + K kv s2
(2.1.33)
It takes a certain amount of time for the output response to track the ramp reference with zero steady-state error.
This is called the settling time and it is determined by the value used for the integral gain.
In steady-state, the ramp response error is constant. Therefore, to design an integral gain the velocity compensation
(the V signal) can be neglected. Thus, we have a PI controller left as:
Vm (t) = kp ess + ki
ti
ess dt
(2.1.35)
v 1.0
26
Simulation
First, you will simulate the closed-loop response of the SRV02 with a PV controller to step input. Our goals are to
confirm that the desired reponse specifications in an ideal situation are satisfied and to verify that the motor is not
saturated. Then, you will explore the effect of using a high-pass filter, instead of a direct derivative, to create the
velocity signal V in the controller.
Experimental Setup
The s srv02 pos Simulinkr diagram shown in Figure 2.7 will be used to simulate the closed-loop position control
response with the PV and PIV controllers. The SRV02 Model uses a Transfer Fcn block from the Simulinkr library.
The PIV Control subsystem contains the PIV controller detailed in Section 2.1.3. When the integral gain is set to
zero, it essentially becomes a PV controller.
Figure 2.7: Simulink model used to simulate the SRV02 closed-loop position response.
IMPORTANT: Before you can conduct these experiments, you need to make sure that the lab files are configured
according to your SRV02 setup. If they have not been configured already, then you need to go to Section 2.4.2 to
configure the lab files first.
Closed-loop Response with the PV Controller
v 1.0
1. Enter the proportional and velocity control gains found in Pre-Lab question 4 in Matlabr as kp and kv.
2. To generate a step reference, ensure the SRV02 Signal Generator is set to the following:
Signal type = square
Amplitude = 1
Frequency = 0.4 Hz
3. In the Simulinkr diagram, set the Amplitude (rad) gain block to /8(rad) to generate a step with an amplitude
of 45 degrees (i.e., square wave goes between /8 which results in a step amplitude of /4) .
4. Inside the PIV Control subsystem, set the Manual Switch to the upward position so the Derivative block is
used.
5. Open the load shaft position scope, theta l (rad), and the motor input voltage scope, Vm (V).
6. Start the simulation. By default, the simulation runs for 5 seconds. The scopes should be displaying responses
similar to figures 2.8 and 2.9 Note that in the theta l (rad) scope, the yellow trace is the setpoint position while
the purple trace is the simulated position (generated by the SRV02 Model block). This simulation is called the
Ideal PV response as it uses the PV compensator with the derivative block.
7. Generate a Matlabr figure showing the Ideal PV position response and the ideal input voltage. After each
simulation run, each scope automatically saves their response to a variable in the Matlabr workspace. That is,
the theta l (rad) scope saves its response to the variable called data pos and the Vm (V) scope saves its data
to the data vm variable. The data pos variable has the following structure: data pos(:,1) is the time vector,
data pos(:,2) is the setpoint, and data pos(:,3) is the simulated angle. For the data vm variable, data vm(:,1)
is the time and data vm(:,2) is the simulated input voltage.
8. Measure the steady-state error, the percent overshoot and the peak time of the simulated response. Does the
response satisfy the specifications given in Section 2.1.1.3? Hint: Use the Matlabr ginput command to take
measurements off the figure.
Using a High-pass Filter Instead of Direct Derivative
9. When implementing a controller on actual hardware, it is generally not advised to take the direct derivative of
a measured signal. Any noise or spikes in the signal becomes amplified and gets multiplied by a gain and fed
into the motor which may lead to damage. To remove any high-frequency noise components in the velocity
signal, a low-pass filter is placed in series with the derivative, i.e. taking the high-pass filter of the measured
signal. However, as with a controller, the filter must also be tuned properly. In addition, the filter has some
adverse affects. Go in the PIV Control block and set the Manual Switch block to the down position to enable
the high-pass filter.
10. Start the simulation. The response in the scopes should still be similar to figures 2.8 and 2.9. This simulation
is called the Filtered PV response as it uses the PV controller with the high-pass filter block.
28
11. Generate a Matlabr figure showing the Filtered PV position and input voltage responses.
12. Measure the steady-state error, peak time, and percent overshoot. Are the specifications still satisfied without
saturating the actuator? Recall that the peak time and percent overshoot should not exceed the values given
in Section 2.1.1.3. Discuss the changes from the ideal response. Hint: The different in the response is minor.
Make sure you use ginput to take precise measurements.
2.3.1.2
In this experiment, we will control the angular position of the SRV02 load shaft, i.e. the disc load, using the PV
controller. Measurements will then be taken to ensure that the specifications are satisfied.
Experimental Setup
The q srv02 pos Simulinkr diagram shown in Figure 2.10 is used to implement the position control experiments.
The SRV02-ET subsystem contains QUARC blocks that interface with the DC motor and sensors of the SRV02
system, as discussed in Section A. The PIV Control subsystem implements the PIV controller detailed in Section
2.1.3, except a high-pass filter is used to obtain the velocity signal (as opposed to taking the direct derivative).
Figure 2.10: Simulink model used with QUARC to run the PV and PIV position controllers on the SRV02.
IMPORTANT: Before you can conduct these experiments, you need to make sure that the lab files are configured
according to your SRV02 setup. If they have not been configured already, then you need to go to Section 2.4.3 to
configure the lab files first.
1. Run the setup srv02 exp02 pos.m script.
2. Enter the proportional and velocity control gains found in Pre-Lab question 4.
3. Set Signal Type in the SRV02 Signal Generator to square to generate a step reference.
4. Set the Amplitude (rad) gain block to /8 to generate a step with an amplitude of 45 degrees.
5. Open the load shaft position scope, theta l (rad), and the motor input voltage scope, Vm (V).
6. Click on QUARC | Build to compile the Simulinkr diagram.
7. Select QUARC | Start to begin running the controller. The scopes should display responses similar to figures
2.11 and 2.12 Note that in the theta l (rad) scope, the yellow trace is the setpoint position while the purple trace
is the measured position.
v 1.0
Figure 2.12:
voltage.
PV control input
8. When a suitable response is obtained, click on the Stop button in the Simulinkr diagram toolbar (or select
QUARC | Stop from the menu) to stop running the code. Generate a Matlabr figure showing the PV position
response and its input voltage.
As in the s srv02 pos Simulink diagram, when the controller is stopped each scope automatically saves their
response to a variable in the Matlabr workspace. Thus the theta l (rad) scope saves its response to the
data pos variable and the Vm (V) scope saves its data to the data vm variable.
9. Measure the steady-state error, the percent overshoot, and the peak time of the SRV02 load gear. Does the
response satisfy the specifications given in Section 2.1.1.3?
10. Click the Stop button on the Simulinkr diagram toolbar (or select QUARC | Stop from the menu) to stop the
experiment.
11. Turn off the power to the amplifier if no more experiments will be performed on the SRV02 in this session.
Simulation
In this simulation, the goal is to verify that the system with the PV controller can meet the zero steady-state error
specification without saturating the motor.
As in the Step Response experiment in Section 2.3.1, in this experiment you need to use the s srv02 pos Simulinkr diagram
shown in Figure 2.7 in Section 2.3.1.1 again.
1. Enter the proportional and velocity control gains found in Pre-Lab question 4.
2. Set the SRV02 Signal Generator parameters to the following to generate a triangular reference (which corresponds to a ramp input):
Signal Type = triangle
Amplitude = 1
Frequency = 0.8 Hz
3. Setting the frequency to 0.8 Hz will generate an increasing and decreasing ramp signal with the same slope
used in the Pre-Lab question 6. The slope is calculated from the Triangular Waveform amplitude, Amp, and
frequency, f, using the expression.
R0 = 4 Amp f
(2.3.36)
4. In the Simulinkr diagram, set the Amplitude (rad) gain block to /3.
30
5. Inside the PIV Control subsystem, set the Manual Switch to the down position so that the High-Pass Filter
block is used.
6. Open the load shaft position scope, theta l (rad), and the motor input voltage scope, Vm (V).
7. Start the simulation. The scopes should display responses similar to figures 2.13 and 2.14.
8. Generate a Matlabr figure showing the Ramp PV position response and its corresponding input voltage trace.
9. Measure the steady-state error. Compare the simulation measurement with the steady-state error calculated
in Pre-Lab question 6.
2.3.2.2
In this experiment, we will control the angular position of the SRV02 load shaft, i.e. the disc load, using a PV
controller. The goal is to examine how well the system can track a triangular (ramp) position input. Measurements
will then be taken to ensure that the specifications are satisfied.
As in the Step Response experiment in Section 2.3.1, in this experiment you also need to use the q srv02 pos
Simulinkr diagram shown in Figure 2.10 to implement the position control experiments.
1. Run the setup srv02 exp02 pos.m script.
2. Enter the proportional and velocity control gains found in Pre-Lab question 4.
3. Set the SRV02 Signal Generator parameters to the following to generate a triangular reference (i.e., ramp
reference):
Signal Type = triangle
Amplitude = 1
Frequency = 0.8 Hz
4. In the Simulinkr diagra, set the Amplitude (rad) gain block to /3.
5. Open the load shaft position scope, theta l (rad), and the motor input voltage scope, Vm (V).
6. Click on QUARC | Build to compile the Simulinkr diagram.
7. Select QUARC | Start to run the controller. The scopes should display responses similar to figures 2.15 and
2.16.
8. Generate a Matlabr figure showing the Ramp PV position response and its corresponding input voltage trace.
9. Measure the steady-state error and compare it with the steady-state error calculated in Pre-Lab question 6.
v 1.0
32
2.3.4 Results
Fill out Table 2.1 below with your answers to the Pre-Lab questions and your results from the lab experiments.
Section / Question
Question 4
Question 4
Question 5
Question 6
Question 7
2.3.1.1
2.3.1.1
2.3.1.2
2.3.2.1
2.3.2.2
2.3.3
2.3.3
Description
Pre-Lab: Model Parameters
Open-Loop Steady-State Gain
Open-Loop Time Constant
Pre-Lab: PV Gain Design
Proportional gain
Velocity gain
Pre-Lab: Control Gain Limits
Maximum proportional gain
Pre-Lab: Ramp Steady-State Error
Steady-state error using PV
Pre-Lab: Integral Gain Design
Integral gain
Step Response Simulation
Symbol
Value
Unit
kp
kv
kp,max
ess
ki
Peak time
Percent overshoot
Steady-state error
Filtered Step Response Using PV
tp
PO
ess
Peak time
Percent overshoot
Steady-state error
Step Response Implementation
tp
PO
ess
Peak time
Percent overshoot
Steady-state error
Ramp Response Simulation with PV
tp
PO
ess
Steady-state error
Ramp Response Implementation with
PV
Steady-state error
Ramp Response Simulation with with
no steady-state error
Steady-state error
Ramp Response Implementation with
with no steady-state error
Steady-state error
ess
ess
ess
ess
Table 2.1: Summary of results for the SRV02 Position Control laboratory.
v 1.0
Table 2.2: Files supplied with the SRV02 Position Control laboratory.
File Name
02 - SRV02 Position Control - Student Manual.pdf
config srv02.m
d model param.m
Description
This laboratory guide contains pre-lab questions and lab
experiments demonstrating how to design and implement a position controller on the Quanser SRV02 rotary
plant using QUARC.
The main Matlabr script that sets the SRV02 motor
and sensor parameters as well as its configurationdependent model parameters. Run this file only to
setup the laboratory.
Returns the configuration-based SRV02 model specifications Rm, kt, km, Kg, eta g, Beq, Jeq, and
eta m, the sensor calibration constants K POT, K ENC,
and K TACH, and the amplifier limits VMAX AMP and
IMAX AMP.
Calculates the SRV02 model parameters K and tau
based on the device specifications Rm, kt, km, Kg, eta g,
Beq, Jeq, and eta m.
Returns various conversions factors.
Simulink file that simulates a closed-loop PIV controller
for the SRV02 system.
Simulink file that implements a closed-loop PIV position
controller on the SRV02 system using QUARCr .
34
5. Configure setup script: The controllers will be run on an SRV02 in the high-gear configuration with the disc
load. In order to simulate the SRV02 properly, make sure the script is setup to match this configuration, i.e. the
EXT GEAR CONFIG should be set to 'HIGH' and the LOAD TYPE should be set to 'DISC'. Also, ensure the
ENCODER TYPE, TACH OPTION, K CABLE, AMP TYPE, and VMAX DAC parameters are set according to
the SRV02 system that is to be used in the laboratory.
6. Finally, make sure CONTROL TYPE is set to 'MANUAL'.
7. Run the script by selecting the Debug | Run item from the menu bar or clicking on the Run button in the tool bar.
The
messages
shown
below,
should
be
generated
in
the
Matlabr
Command Window. The model parameters and specifications are loaded but the PIV gains are all set to
zero - they need to be changed.
SRV02 model parameters:
K = 1.53 rad/s/V
tau = 0.0254 s
Specifications:
tp = 0.2 s
PO = 5 %
Calculated PV control gains:
kp = 0 V/rad
kv = 0 V.s/rad
Integral control gain for triangle tracking:
ki = 0 V/rad/s
Before beginning the lab experiments on the SRV02 device, the q srv02 pos Simulinkr diagram and the setup srv02 exp02 pos.m
script must be configured.
Follow these steps to get the system ready for this lab:
1. Setup the SRV02 in the high-gear configuration and with the disc load as described in Reference [6].
2. Load the Matlabr software.
3. Browse through the Current Directory window in Matlabr and find the folder that contains the SRV02 position
control files, e.g. q srv02 pos.mdl.
4. Double-click on the q srv02 pos.mdl file to open the Position Control Simulinkr diagram shown in Figure 2.7.
5. Configure DAQ: Double-click on the HIL Initialize block in the SRV02-ET subsystem (which is located inside
the SRV02-ET Position subsystem) and ensure it is configured for the DAQ device that is installed in your
system. See Section A for more information on configuring the HIL Initialize block.
6. Configure Sensor: The position of the load shaft can be measured using various sensors. Set the Pos Src
Source block in q srv02 pos, as shown in Figure 2.7, as follows:
1 to use the potentiometer
2 to use to the encoder
Note that when using the potentiometer, there will be a discontinuity.
7. Configure setup script: Set the parameters in the setup srv02 exp02 pos.m script according to your system
setup. See Section 2.4.2 for more details.
v 1.0
36
v 1.0
38
v 1.0
40
LABORATORY 3
SRV02 SPEED CONTROL
The objective of this laboratory is to develop feedback systems that control the speed of the rotary servo load shaft.
A proportional-integral (PI) controller and a lead compensator are designed to regulate the shaft speed according to
a set of specifications.
Topics Covered
Design of a proportional-integral (PI) controller that regulates the angular speed of the servo load shaft.
Design of a lead compensator.
Simulation of the PI and lead controllers using the plant model to ensure the specifications are met without any
actuator saturation.
Implemention of the controllers on the Quanser SRV02 device to evaluate their performance.
Prerequisites
In order to successfully carry out this laboratory, the user should be familiar with the following:
Data acquisition device (e.g. Q2-USB), the power amplifier (e.g. VoltPAQ-X1), and the main components of
the SRV02 (e.g. actuator, sensors), as described in References [2], [4], and [6], respectively.
Wiring and operating procedure of the SRV02 plant with the amplifier and data-aquisition (DAQ) device, as
discussed in Reference [6].
Transfer function fundamentals, e.g. obtaining a transfer function from a differential equation.
Laboratory described in Appendix A to get familiar with using QUARCr with the SRV02.
v 1.0
3.1 Background
3.1.1 Desired Response
3.1.1.1
The time-domain requirements for controlling the speed of the SRV02 load shaft are:
ess = 0
(3.1.1)
tp 0.05 s, and
(3.1.2)
PO 5 %
(3.1.3)
Thus, when tracking the load shaft reference, the transient response should have a peak time less than or equal to
0.05 seconds, an overshoot less than or equal to 5 %, and zero steady-state error.
In addition to the above time-based specifications, the following frequency-domain requirements are to be met when
designing the Lead Compensator:
P M 75.0 deg
(3.1.4)
g = 75.0 rad/s
(3.1.5)
and
The phase margin mainly affects the shape of the response. Having a higher phase margin implies that the system
is more stable and the corresponding time response will have less overshoot. The overshoot will not go beyond 5%
with a phase margin of at least 75.0 degrees.
The crossover frequency is the frequency where the gain of the Bode plot is 1 (or 0 dB). This parameter mainly
affects the speed of the response, thus having a larger g decreases the peak time. With a crossover frequency of
75.0 radians the resulting peak time will be less than or equal to 0.05 seconds.
3.1.1.2
Overshoot
(3.1.6)
where t0 is the time the step is applied. Initially, the SRV02 should be running at 2.5 rad/s and after the step time
it should jump up to 7.5 rad/s. From the standard definition of overshoot in step response, we can calculate the
maximum overshoot of the response (in radians):
)
(
PO
1+
100
(3.1.7)
42
(3.1.8)
The closed-loop speed response should therefore not exceed the value given in Equation 3.1.8.
3.1.1.3
Consider the speed control system with unity feedback shown in Figure 3.1. Let the compensator be C(s) = 1.
(3.1.9)
s0
where
E(s) =
R(s)
1 + C(s) P (s)
(3.1.10)
The voltage-to-speed transfer function for the SRV02 was found in Section 1 as:
K
s+1
P (s) =
Substituting R(s) =
R0
s
(3.1.11)
E(s) =
R0
s 1+
Applying the final-value theorem to the system gives
(
ess = R0 lim
s0
K
s+1
s+1
s+1+K
(3.1.12)
)
(3.1.13)
R0
1+K
(3.1.14)
The proportional-integral (PI) compensator used to control the velocity of the SRV02 has the following structure:
v 1.0
ki (d (s) l (s))
s
(3.1.16)
To find the closed-loop speed transfer function, l (s)/d (s), we can use the process transfer function from Equation
3.1.11 and solve for l (s)/d (s) as:
l (s)
K (kp s bsp + ki )
= 2
d (s)
s + (1 + K kp ) s + K ki
3.1.2.2
(3.1.17)
In this section, we will first calculate the minimum damping ratio and natural frequency required to meet the specifications given in Section 3.1.1.1. Then, using these values we will calculate the necessary control gains kp and ki
to achieve the desired performance with a PI controller.
The minimum damping ratio and natural frequency needed to satisfy a given percent overshoot and peak time are:
(
)
PO
1
= ln
(3.1.18)
( P O )2
100
ln 100 + 2
and
n =
tp
(3.1.19)
1 2
Substituting the percent overshoot specifications given in 3.1.3 into Equation 3.1.18 gives the required damping ratio
(3.1.20)
= 0.690
Then, by substituting this damping ratio and the desired peak time, given in 3.1.2, into Equation 3.1.19, the minimum
natural frequency is found as:
n = 86.7 rad/s
(3.1.21)
Now, let's look at how we can calculate the gains. When the setpoint weight is zero, i.e. bsp = 0, the closed-loop
SRV02 speed transfer function has the structure of a standard second-order system. We can find expressions for
the control gains kp and ki by equating the characteristic equation (denominator) of the SRV02 closed-loop transfer
function to the standard characteristic equation: s2 + 2 n s + n2 .
SRV02 Workbook - Student Version
44
The denominator of the transfer function can be re-structured into the following:
(1 + K kp ) s K ki
+
equating the coefficients of this equation to the coefficients of the standard characteristic equation gives:
s2 +
and
(3.1.22)
K ki
= n2
(3.1.23)
1 + K kp
= 2 n
(3.1.24)
1 + 2 n
K
(3.1.25)
n2
K
(3.1.26)
Glead (s) =
1 + aT s
1+T s
(3.1.28)
The a and T parameters change the location of the pole and the zero of the lead compensator which changes the
gain and phase margins of the system. The design process involves examining the stability margins of the loop
transfer function, L(s) = C(s) P (s), where the compensator is given by:
C(s) =
Kc (1 + a T s)
(1 + T s) s
(3.1.29)
v 1.0
3.1.3.1
The Lead compensator is an approximation of a proportional-derivative (PD) control. A PD controller can be used
to add damping to reduce the overshoot in the transient of a step response and effectively making the system more
stable. In other words, it increases the phase margin. In this particular case, the lead compensator is designed for
the following system:
Kc P (s)
Lp (s) =
(3.1.30)
s
The proportional gain Kc is designed to attain a certain crossover frequency. Increasing the gain crossover frequency
essentially increases the bandwidth of the system which decreases the peak time in the transient response (i.e.
makes the response faster). However, as will be shown, adding a gain Kc > 1 makes the system less stable. The
phase margin of the Lp (s) system is therefore lower than the phase margin of the Pi (s) system and this translates
to having a large overshoot in the response. The lead compensator is used to dampen the overshoot and increase
the overall stability of the system, i.e increase its phase margin.
The frequency response of the lead compensator given in 3.1.28 is
Glead ( j) =
1 + a T j
1+T j
|Glead ( j)| =
(3.1.31)
T 2 2 a2 + 1
1 + T 2 2
(3.1.32)
and
G = arctan(a T ) arctan(T )
(3.1.33)
3.1.3.2
In this section, we will use Matlabr to design a lead compensator that will satisfy the frequency-based specifications
given in Section 3.1.1.1.
1. Bode plot of the open-loop uncompensated system, Pi (s), must first be found. To generate the Bode plot
of Pi (s), enter the following commands in Matlabr . NOTE: If your system has not been set up yet, then you
SRV02 Workbook - Student Version
46
need to first run the the setup srv02 exp03 spd.m script. This script will store the model parameter K and tau
in the Matlabr workspace. These parameters are used with the commands tf and series to create the Pi (s)
transfer function. The margin command generates a Bode plot of the system and it lists the gain and phase
stability margins as well as the phase and gain crossover frequencies.
% Plant transfer function
P = tf([K],[tau 1]);
% Integrator transfer function
I = tf([1],[1 0]);
% Plant with Integrator transfer function
Pi = series(P,I);
% Bode of Pi(s)
figure(1)
margin(Pi);
set (1,'name','Pi(s)');
The entire Lead compensator design is given in the d lead.m script file. Run this script after running the
setup srv02 exp03 spd.m script when CONTROL TYPE = 'AUTO' to generate a collection of Bode diagrams
including the Bode of Pi (s) given in Figure 3.5.
(3.1.34)
Kc = 53.1 V/rad
(3.1.35)
or
in the linear range is required. The Bode plot of the loop transfer function Lp (s) (from Section 3.1.3) is given
in Figure 3.6. This initial estimate of the gain was found using the ginput command. The gain was then
adjusted according to the crossover frequency calculated in the generated Bode plot of the Lp (s) system. The
commands used to generate the Bode plot are given in the d lead.m script.
v 1.0
(3.1.36)
Given that the desired phase margin in Equation 3.1.4 and the phase margin of Lp (s) is
P Mmeas = 21.5 deg
(3.1.37)
m = 41.8 deg
(3.1.38)
m = 0.728 rad
(3.1.39)
1 + sin(m )
1 + sin(m )
(3.1.40)
The gain needed is found by inserting the max phase into this equation to get
a = 4.96
(3.1.41)
(3.1.42)
which is
4. The frequency at which the lead maximum phase occurs must be placed at the new gain crossover frequency g,new . This is the crossover frequency after the lead compensator is applied. As illustrated in Figure
3.4, m occurs halfway between 0 dB and 20 log10 (a), i.e. at 10 log10 (a). So, the new gain crossover frequency
in the Lp (s) system will be the frequency where the gain is 10 log10 (a).
From Figure 3.6, it is found that the frequency where the 10 log10 (a) gain in the Lp (s) system occurs is at
about 80.9 rad/s. Thus, the maximum phase of the lead will be set to
m = 80.9 rad/s
SRV02 Workbook - Student Version
(3.1.43)
48
As illustrated earlier in Figure 3.4 in Section 3.1.3.1, the maximum phase occurs at the maximum phase frequency m . Parameter T given by:
T =
m a
(3.1.44)
is used to attain a certain maximum phase frequency. This changes where the Lead compensator breakpoint
frequencies 1/(a T ) and 1/T shown in Figure 3.4 occur. The slope of the lead compensator gain changes
at these frequencies. We can find the parameter T by substituting m = 80.9 and the lead gain value from
Equation 3.1.41 into Equation 3.1.44:
T = 0.00556 s/rad
(3.1.45)
Therefore, the lead breakpoint frequencies are:
and
1
= 36.1 rad/s
aT
(3.1.46)
1
= 180.9 rad/s
T
(3.1.47)
5. Bode plot of the lead compensator Clead (s), defined in 3.1.28 can be generated using the d lead.m script.
v 1.0
1
Kn l
100
(3.1.48)
where Kn is the peak-to-peak ripple rating of the sensor and l is the speed of SRV02 load gear. The rated peakto-peak noise of the SRV02 tachometer is given in Appendix B of Reference [6] as:
Kn = 7 %
(3.1.49)
Based on this specification, the peak-to-peak noise, when the load shaft runs at 7.5 rad/s, will be
e = 0.525 rad/s
(3.1.50)
Thus, the signal will oscillate 0.2625 rad/s about the 7.5 rad/s setpoint, or approximately between 7.24 rad/s and
7.76 rad/s. Then, taking the noise into account, what would be the maximum peak in the speed response that is to
be expected?
Equation 3.1.7 was used to find the peak value of the load gear response for a given percent overshoot. To take
into account the noise in the signal, this formula is modified as follows:
)
(
1
PO
+ e
(3.1.51)
(tp ) = d (t0 ) + (d (t) d (t0 )) 1 +
100
2
Given a reference signal that goes between 2.5 rad/s to 7.5 rad/s, as described in Section 3.1.1.1, and the peak-topeak ripple estimate in Equation 3.1.50, the peak speed of the load gear, including the noise, can be found as:
(tp ) = 8.01 rad/s
Using
PO =
(3.1.52)
(3.1.53)
(3.1.54)
50
v 1.0
Simulation
First you will simulate the closed-loop speed response of the SRV02 with a PI controller to step input. Our goals are
to confirm that the desired reponse specifications in an ideal situation are satisfied and to verify that the motor is not
saturated. Then, you will explore the effect of the setpoint weight.
Experimental Setup
The s srv02 spd Simulinkr diagram shown in Figure 3.9 is used to simulate the closed-loop speed response of
the SRV02 when using either the PI or Lead controls. The SRV02 Model uses a Transfer Fcn block from the
Simulinkr library to simulate the system. The PI compensator subsystem contains the PI control detailed in Section
3.1.2 and the Lead Compensator block has the compensator described in Section 3.1.3.
Figure 3.9: Simulink diagram used to simulate the closed-loop SRV02 speed response.
IMPORTANT: Before you can conduct these experiments, you need to make sure that the lab files are configured
according to your SRV02 setup. If they have not been configured already, then you need to go to Section 3.4.2 to
configure the lab files first.
1. Enter the proportional and integral control gains found in Section 3.1.2.2 as kp and ki in Matlabr .
2. The speed reference signal is to be a 0.4 Hz square wave that goes between 2.5 rad/s and 7.5 rad/s (i.e.
between 23.9 rpm and 71.6 rpm). Set the SRV02 Signal Generator block parameters to the following:
Signal type = square
Amplitude = 1
SRV02 Workbook - Student Version
52
Frequency = 0.4 Hz
3. In the Speed Control Simulinkr model, set the Amplitude (rad/s) gain block to 2.5 rad/s and the Offset (rad/s)
block to 5.0 rad/s.
4. Set the Manual Switch to the upward position to activate the PI control.
5. Open the load shaft position scope, w l (rad), and the motor input voltage scope, Vm (V).
6. Start the simulation. By default, the simulation runs for 5 seconds. The scopes should be displaying responses
similar to figures 3.10 and 3.11. Note that in the w l (rad) scope, the yellow trace is the setpoint position while
the purple trace is the simulated speed (generated by the SRV02 Model block).
7. Generate a Matlabr figure showing the simulated PI speed response and its input voltage. After each simulation run, each scope automatically saves their response to a variable in the Matlab workspace. The w l (rad)
scope saves its response to the variable called data spd and the Vm (V) scope saves its data to the data vm
variable. The data spd variable has the following structure: data spd(:,1) is the time vector, data spd(:,2) is
the setpoint, and data spd(:,3) is the simulated angular speed. For the data vm variable, data vm(:,1) is the
time and data vm(:,2) is the simulated input voltage.
8. Measure the steady-state error, the percent overshoot, and the peak time of the simulated response. Does
the response satisfy the specifications given in Section 3.1.1.1?
3.3.1.2
Experimental Setup
The q srv02 spd Simulinkr diagram shown in Figure 3.12 is used to perform the speed control exercises in this
laboratory. The SRV02-ET Speed subsystem contains QUARCr blocks that interface with the DC motor and sensors
of the SRV02 system, as discussed in Section A. The PI control subsystem implements the PI control detailed in
Section 3.1.2 and the Lead Compensator block implements the lead control described in Section 3.1.3.
v 1.0
Figure 3.12: Simulink model used with QUARC to run the PI and lead speed controllers on the SRV02.
54
9. When a suitable response is obtained, click on the Stop button in the Simulinkr diagram toolbar (or select
QUARC | Stop from the menu) to stop running the code. Generate a Matlabr figure showing the PI speed
response and its input voltage. As in the s srv02 spd Simulinkr diagram, when the controller is stopped each
scope automatically saves their response to a variable in the Matlabr workspace. Thus, the theta l (rad) scope
saves its response to the data spd variable and the Vm (V) scope saves its data to the data vm variable.
10. Due to the noise in the measured speed signal, it is difficult to obtain an accurate measurement of the specifications. In the Speed Control Simulinkr mode, set the Amplitude (rad) block to 0 rad/s and the Offset (rad)
block to 7.5 rad/s in order to generate a constant speed reference of 7.5 rad/s. Generate a Matlabr figure
showing the noise in the signal.
11. Measure the peak-to-peak ripple found in the speed signal, e,meas , and compare it with the estimate in Section
3.1.4. Then, find the steady-state error by comparing the average of the measured signal with the desired
speed. Is the steady-state error specification satisfied?
12. Measure the percent overshoot and the peak time of the SRV02 load gear step response. Taking into account
the noise in the signal, does the response satisfy the specifications given in Section 3.1.1.1?
13. Click the Stop button on the Simulinkr diagram toolbar (or select QUARC | Stop from the menu) to stop the
experiment.
14. Turn off the power to the amplifier if no more experiments will be performed on the SRV02 in this session.
Simulation
You will simulate the closed-loop speed response of the SRV02 with a Lead controller to step input. Our goals are
to confirm that the desired reponse specifications in an ideal situation are satisfied and to verify that the motor is not
saturated.
As in the step response with PI control experiment in Section 3.3.1.1, in this experiment you need to use the
s srv02 spd Simulinkr diagram shown in Figure 3.12 again.
1. Enter the Lead control parameters found in Section 3.1.3.2. These are denoted as Kc, a, and T in Matlabr .
2. Set the SRV02 Signal Generator block parameters to the following:
Signal type = square
Amplitude = 1
Frequency = 0.4 Hz
3. In the Speed Control Simulinkr model, set the Amplitude (rad/s) gain block to 2.5 rad/s and the Offset (rad/s)
constant block to 5.0 rad/s.
4. To engage the lead control, set the Manual Switch to the downward position.
5. Open the load shaft position scope, w l (rad), and the motor input voltage scope, Vm (V).
6. Start the simulation. By default, the simulation runs for 5 seconds. The scopes should be displaying responses
similar to Figures 3.10 and 3.11.
7. Verify if the time-domain specifications in Section 3.1.1.1 are satisfied and that the motor is not being saturated.
To calculate the steady-state error, peak time, and percent overshoot, use the simulated response data stored
in the data spd variable.
8. If the specifications are not satisfied, go back in the lead compensator design. You may have to, for example,
add more maximum phase in order to increase the phase margin. If the specifications are met, move on to the
next step.
9. Generate a Matlabr figure showing the Simulated Lead speed response and its input voltage.
v 1.0
3.3.2.2
In this section the speed of the SRV02 is controlled using the lead compensator. Measurements will be taken to see
if the specifications are satisfied.
3.3.3 Results
Fill out Table 3.1 below with your answers to the Pre-Lab questions and your results from the lab experiments.
56
Section / Question
Question 2
Question 4
Question 5
Section 3.3.1.1
Section 3.3.1.2
Section 3.3.2.1
Section 3.3.2.2
Description
Pre-Lab: PI Gains
Proportional Gain
Integral Gain
Open-Loop Time Constant
Open-Loop Steady-state Gain
Pre-Lab: DC Gain Estimate
DC Gain Estimate of Pi (s)
Pre-Lab: Gain Crossover Frequency
Gain crossover frequency
In-Lab: PI Step Response Simulation
Peak time
Percent overshoot
Steady-state error
In-Lab: PI Speed Control Implementation
Measured peak-to-peak ripple
Steady-state error
Peak time
Percent overshoot
In-Lab: Step Response Simulation
with Lead Control
Peak time
Percent overshoot
Steady-state error
In-Lab: Lead Speed Control Implementation
Peak time
Percentage overshoot
Steady-state error
Symbol
Value
Unit
kp
ki
K
|Pi (1)|
g
tp
PO
ess
e,meas
ess
tp
PO
tp
PO
ess
tp
PO
ess
v 1.0
Table 3.2: Files supplied with the SRV02 Speed Control laboratory.
File Name
03 - SRV02 Speed Control - Student Manual.pdf
config srv02.m
d model param.m
Description
This laboratory guide contains pre-lab questions and lab
experiments demonstrating how to design and implement
a speed controller on the Quanser SRV02 rotary plant using QUARCr .
The main Matlab script that sets the SRV02 motor and
sensor parameters as well as its configuration-dependent
model parameters. Run this file only to setup the laboratory.
Returns the configuration-based SRV02 model specifications Rm, kt, km, Kg, eta g, Beq, Jeq, and eta m, the
sensor calibration constants K POT, K ENC, and K TACH,
and the amplifier limits VMAX AMP and IMAX AMP.
Calculates the SRV02 model parameters K and tau based
on the device specifications Rm, kt, km, Kg, eta g, Beq,
Jeq, and eta m.
Returns various conversions factors.
Simulink file that simulates the closed-loop SRV02 speed
control using either the PI control or the lead compensator.
Simulink file that runs the PI or Lead speed control on the
actual SRV02 system using QUARCr .
58
4. Double-click on the setup srv02 exp03 spd.m file to open the setup script for the position control Simulink
models.
5. Configure setup script: The controllers will be run on an SRV02 in the high-gear configuration with the
disc load, as in Section 1. In order to simulate the SRV02 properly, make sure the script is setup to match
this configuration, e.g. the EXT GEAR CONFIG should be set to 'HIGH' and the LOAD TYPE should be set to
'DISC'. Also, ensure the ENCODER TYPE, TACH OPTION, K AMP, AMP TYPE, and VMAX DAC parameters
are set according to the SRV02 system that is to be used in the laboratory.
Finally, make sure CONTROL TYPE is set to 'MANUAL'.
6. Run the script by selecting the Debug | Run item from the menu bar or clicking on the Run button in the tool
bar. The messages shown below, should be generated in the Matlabr Command Window. The correct model
parameters are loaded but the control gains and related parameters loaded are default values that need to be
changed. That is, the PI control gains are all set to zero, the lead compensator parameters a and T are both
set to 1, and the compensator proportional gain Kc is set to zero.
SRV02 model parameters:
K = 1.53 rad/s/V
tau = 0.0254 s
PI control gains:
kp = 0 V/rad
ki = 0 V/rad/s
Lead compensator parameters:
Kc = 0 V/rad/s
1/(a*T) = 1 rad/s
1/T = 1 rad/s
Before beginning the in-lab exercises on the SRV02 device, the q srv02 spd Simulinkr diagram and the setup srv02 exp03 spd.m
script must be configured.
Follow these steps to get the system ready for this lab:
1. Setup the SRV02 in the high-gear configuration and with the disc load as described in Reference [6].
2. Load the Matlab software.
3. Browse through the Current Directory window in Matlabr and find the folder that contains the SRV02 speed
control files, e.g. q srv02 spd.mdl.
4. Double-click on the q srv02 spd.mdl file to open the Speed Control Simulink diagram shown in Figure 3.12.
5. Configure DAQ: Double-click on the HIL Initialize block in the SRV02-ET subsystem (which is located inside
the SRV02-ET Speed subsystem) and ensure it is configured for the DAQ device that is installed in your
system. See Section A for more information on configuring the HIL Initialize block.
6. Configure Sensor: To perform the speed control experiment, the angular rate of the load shaft should be
measured using the tachometer. This has already been set in the Spd Src Source block inside the SRV02-ET
Speed subsystem.
7. Configure setup script: Set the parameters in the setup srv02 exp03 spd.m script according to your system
setup. See Section 3.4.2 for more details.
v 1.0
60
1. Response plot from step 7 in Section 3.3.1.1, Step response simulation with PI Control
2. Response plot from step 9 in Section 3.3.1.2, Step response implementation with PI Control
3. Signal noise plot from step 10 in Section 3.3.1.2, Step response implementation with PI Control
4. Provide data collected in this laboratory (from Table 3.1).
III. ANALYSIS
Provide details of your calculations (methods used) for analysis for each of the following:
III.1. Step Response with PI Control
1. Step 8 in Section 3.3.1.1, Step response simulation with PI Control
2. Step 11 in Section 3.3.1.2, Step response implementation with PI Control
3. Step 12 in Section 3.3.1.2, Step response implementation with PI Control
IV. CONCLUSIONS
Interpret your results to arrive at logical conclusions for the following:
1. Step 8 in Section 3.3.1.1, Step response simulation with PI Control
2. Step 11 in Section 3.3.1.2, Step response implementation with PI Control
3. Step 12 in Section 3.3.1.2, Step response implementation with PI Control
v 1.0
1. Response plot from step 9 in Section 3.3.2.1, Step response simulation with Lead Control
2. Response plot from step 9 in Section 3.3.2.2, Step response implementation with Lead Control
3. Provide data collected in this laboratory (from Table 3.1).
III. ANALYSIS
Provide details of your calculations (methods used) for analysis for each of the following:
III.1. Step Response with Lead Control
1. Step 7 in Section 3.3.2.1, Step response simulation with Lead Control
2. Step 10 in Section 3.3.2.2, Step response implementation with Lead Control
IV. CONCLUSIONS
Interpret your results to arrive at logical conclusions for the following:
1. Step 7 in Section 3.3.2.1, Step response simulation with Lead Control
2. Step 10 in Section 3.3.2.2, Step response implementation with Lead Control
3. Step 11 in Section 3.3.2.2, Step response implementation with Lead Control
62
v 1.0
64
Appendix A
SRV02 QUARC INTEGRATION
In this section, we explain how to send command voltages to the Quanserr SRV02 and measure the position and
speed of its load shaft in real-time using your computer.
System Requirements
Before you begin this laboratory make sure:
QUARCr is installed on your PC, as described in [1].
You have a QUARCr compatible data-acquisition (DAQ) card installed in your PC. For a listing of compliant
DAQ cards, see [5].
SRV02 and amplifier are connected to your DAQ board as described in [6].
Prerequisites
The user should be familiar with the following:
System hardware:
Data acquisition card (e.g. Q2-USB in [2])
Amplifier (e.g. VoltPAQ in [4]).
Main components of the SRV02, i.e. DC motor and sensors such as the potentiometer [6].
Basics of Simulinkr .
v 1.0
Figure A.1: Simulink model used with QUARC to apply voltage to SRV02
Follow these steps to make the Simulinkr diagram:
1. Load the Matlabr software.
2. Create a new Simulinkr diagram. To do this, go to File | New | Model item in the menu bar.
3. Open the Simulink Library Browser window by clicking on the View | Library Browser item in the Simulink menu
bar or clicking on the Simulink icon.
4. Expand the QUARC Targets item and go to the Data Acquisition | Generic | Configuration folder, as shown in
Figure A.2.
5. Click-and-drag the HIL Initialize block from the library window into the blank Simulinkr model. This block is
used to configure your data-acquisition device, e.g. the Quanser Q2-USB or Q8-USB hardware-in-the-loop
(HIL) boards.
6. In the Library Browser, go to the Data Acquisition | Generic | Immediate I/O category. This contains various
blocks used to interact with actuators and sensors.
7. Click-and-drag the HIL Write Analog block from the library into the Simulinkr diagram. This block is used to
output a voltage from an Analog Output channel, i.e. digital-to-analog (D/A) channel, on the data-acquisition
device.
SRV02 Workbook - Student Version
66
v 1.0
68
v 1.0
70
v 1.0
72
Figure A.9: Simulinkr model used with QUARC to send voltage to the SRV02 and read its load shaft angle using
potentiometer.
Modify the Simulinkr diagram built in the previous section following these steps:
1. Label the Scope block that is presently connected to the HIL Read Analog Timebase block to theta l (deg).
This will display the angular measurement of the load gear in degrees.
2. Add a Scope block from the Simulinkr | Sinks folder in the Library Browser and connect it to the output of the
Slider Gain block, as shown in Figure A.9, above. Label the Scope block Vm (V) which stands for the input
motor voltage.
3. From the Simulinkr | Math Operations category in the Library Browser, add two Gain blocks into the Simulinkr model.
4. Connect the gain blocks as illustrated in Figure A.9.
One gain block between the Amplifier Pre-Compensation and HIL Write Analog blocks and label it Motor
Calibration (V/V).
Another gain block between the HIL Read Analog Timebase and theta l Scope blocks and denote it
Potentiometer Calibration (deg/V).
5. Re-compile the Simulinkr model, i.e. click on QUARC | Build.
6. Click on QUARC | Start to run the code.
7. Open the Vm (V) and theta l (deg) scopes.
8. In the Signal Generator, set the Frequency parameter to 0.25 Hz.
9. Set the Slider Gain block to 1.
10. Currently when the voltage goes positive the load gear rotates in the clockwise direction. However, the desired
convention is for the load gear to rotate in the counter-clockwise direction when the voltage goes positive. Thus,
set the Motor Calibration (V/V) block to -1.
11. As described in [6], the potentiometer outputs between 5 V when it rotated 352 degrees. Enter the value
352/10 in the Potentiometer Calibration (deg/V)block.
12. In the theta l (deg) scope, click on the Autoscale icon so the y-axis range is increased and the full signal can
be viewed.
13. Set the Slider Gain block to 0.
14. Rotate the load gear manually and examine the corresponding response in the theta l (deg) scope. Confirm
that, indeed, the correct measurement is being taken.
15. Position the load gear such that 0 is read in the theta l (deg) scope .
v 1.0
Figure A.10:
voltage.
Sinusoidal input
18. Select the QUARC | Stop item to stop the code from running.
19. Power OFF the amplifier if no more experiments will be run in this session.
74
Figure A.12: Simulinkr model used with QUARC to send voltage to SRV02 and read the potentiometer and tachometer sensors.
Using the Simulinkr diagram built in Section A.2, go through this procedure to add the tachometer functionality:
1. Double-click on the HIL Read Analog Timebase block to open its properties.
2. As detailed in [6], the tachometer is connected to Analog Input #1 on the hardware-in-the-loop board. To add
a channel, set the Analog channels field to [0,1] and click on the OK button.
3. Add a Scope block and a Gain block from Library Browser into the Simulinkr model.
4. Connect the Scope and Gain blocks as depicted in Figure A.12, above.
Connect the Gain block to the output of Channel #1 from the HIL Read Analog Timebase block and label
it Tachometer Calibration (krpm/V).
Connect the output of this gain block to the input of the Scope block and label the scope w l (rpm). The
speed of the load gear is denoted by the l . This scope will display the measured speed of the load gear
in thousand revolutions per minute.
5. Set the Signal Generator Frequency parameter to 1.0 Hz and the Slider Gain block to 1.
6. Open the Vm (V) and the w l (krpm) scopes.
7. Power ON the amplifier.
8. Go to QUARC | Build to compile the code.
9. Click on QUARC | Start to execute the code. As the SRV02 rotates back-and-forth, the w l (rpm/V) scope should
display the tachometer readings. Since the Tachometer Calibration (krpm/V) gain has not been configured yet,
the scope is displaying the tachometer output voltage, which is proportional to the speed of the load shaft.
SRV02 Workbook - Student Version
v 1.0
10. The back-emf constant of the tachometer sensor is 1.5 mV/rpm. However, the measurement is taken directly
from the motor itself (see [6]). Thus, to read the velocity of the gear the tachometer calibration gain must be
divided by the gear ratio. Enter 1 / 1.5 / 70 in the Tachometer Calibration (krpm/V) gain block when using the
SRV02 in the high-gear configuration (or 1 / 1.5 / 14 if using the low-gear configuration).
Note: The measurement will be very small. Click on the Autoscale icon in the scope to zoom up on the signal.
Alternatively, the y-range of the scope can be set manually. To do this, right-click on the y-axis, select Axes
Properties from the drop-down menu, and set the desired y-range values.
11. Examine the relationship between the input voltage and load speed. When the input voltage increases in
the positive direction, the tachometer velocity decreases. Similar to the potentiometer, the speed of the load
shaft should go positive when the input voltage is positive. To fix this, add a negative sign to the Tachometer
Calibration (krpm/V) block so the entered value becomes -1 / 1.5 / 70 (or -1 / 1.5 / 14 for low-gear). The input
voltage and load velocity scopes should read as shown in Figure A.13 and Figure A.14.
Note: If you want the measurement to be in RPM instead of kRPM, enter -1000 / 1.5 / 70 gear (or -1000 / 1.5
/ 14 for low-gear).
Figure A.13:
voltage.
Sinusoidal input
12. Select the QUARC | Stop item to stop the code from running.
13. Power OFF the amplifier if no more experiments will be run in this session.
76
Figure A.15: Simulinkr model used with QUARC to send voltage to SRV02 and reads the potentiometer, tachometer,
and encoder sensors.
Using the Simulinkr model designed in either Section A.2 or A.3, follow this procedure to add encoder functionality:
1. From the QUARC Targets | Data Acquisition | Generic | Immediate I/O category in the Library Browser, add a
HIL Read Encoder block.
2. Recall that, as instructed in [6], the encoder is connected to Encoder Input #0 on the data acquisition board.
The HIL Read Encoder block is already configured for to read channel 0 and the default encoder configurations
in the HIL Initialize block are fine (but keep in mind that these can be changed).
3. Add a Gain block and a Scope block from the Math Operations and Sinks folders in the Library Browser,
respectively, into the Simulinkr model.
4. Connect the scope and gain blocks as depicted in Figure A.15.
Connect the HIL Read Timebase block output e0 to a Gain block and label it Encoder Calibration (deg/count).
Connect the output of this gain block to the input of the Scope block and label the scope enc: theta l
(deg). This scope will display the measured angular position of the load gear in degrees.
5. Set the Frequency parameter in the Signal Generator block to 1.0 Hz and the Slider Gain block to 1.
6. Open the Vm (V) and enc: theta l (deg) scopes.
7. Save the Simulinkr model (you may want to save the model as a different file).
8. Power ON the power amplifier.
9. Go to QUARC | Build to compile the code.
v 1.0
10. Click on QUARC | Start to execute the code. As the SRV02 rotates back-and-forth, the enc: theta l (deg)
should display the encoder readings. Since the Encoder Calibration (deg/count) gain has not been configured
yet, the scope is displaying the number of counts from the encoder output, which is proportional to the position
of the load shaft.
Note: The measurement will be very large. Click on the Autoscale icon in the scope to zoom out and view the
entire signal. Alternatively, the y-range of the scope can be set manually. To do this, right-click on the y-axis,
select Axes Properties from the drop-down menu, and set the desired y-range values.
11. As discussed in [6], the encoder outputs 4096 counts for every full revolution. To measure the load gear angle,
set the Encoder Calibration (deg/count) gain block to 360 / 4096 degrees per count.
12. The measurement will be very small. Click on the Autoscale icon in the scope to zoom up on the signal or
adjust the range of the y-axis manually. The input voltage and position scopes should appear similarly as
shown in Figure A.16 and Figure A.17. Note that no further calibration is needed since the encoder position
increases when the input voltage goes positive.
Figure A.16:
voltage.
Sinusoidal input
13. Select the QUARC | Stop item to stop the code from running.
14. Power OFF the amplifier if no more experiments will be run in this session.
78
v 1.0
80
BIBLIOGRAPHY
[1] Quanser Inc. QUARC Installation Guide, 2009.
[2] Quanser Inc. Q2-USB User's Manual, 2010.
[3] Quanser Inc. VoltPAQ User's Manual, 2010.
[4] Quanser Inc. QUARC User Manual, 2011.
[5] Quanser Inc. SRV02 User Manual, 2011.
v 1.0
Flexible Link
Inverted
Pendulum
USER MANUAL
2 DOF Robot
Flexible Joint
2 DOF Inverted
Pendulum
Gyro/Stable
Platform
Multi-DOF Torsion
Double Inverted
Pendulum
Developed by:
Jacob Apkarian, Ph.D., Quanser
Michel Lvis, M.A.Sc., Quanser
Hakan Gurocak, Ph.D., Washington State University
2 DOF Ball
Balancer
Quanser educational solutions are powered by:
With the SRV02 Base Unit, you can select from 10 add-on modules to create experiments of varying complexity across a
wide range of topics, disciplines and courses. All of the experiments/workstations are compatible with LabVIEW and
MATLAB/Simulink.
To request a demonstration or a quote, please email [email protected].
2011 Quanser Inc. All rights reserved. LabVIEW is a trademark of National Instruments. MATLAB and Simulink are registered trademarks of The MathWorks, Inc.
+1-905-940-3575
QUANSER.COM