Made For Science Quanser Rotary Servo Base Unit CoursewareStud LabVIEW
Made For Science Quanser Rotary Servo Base Unit CoursewareStud LabVIEW
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
For more information on the solutions Quanser Inc. offers, please visit the web site at:
http://www.quanser.com
This document and the software described in it are provided subject to a license agreement. Neither the software nor this document may be
used or copied except as specified under the terms of that license agreement. All rights are reserved and no part may be reproduced, stored in
a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior
written permission of Quanser Inc.
ACKNOWLEDGEMENTS
Quanser, Inc. would like to thank Dr. Hakan Gurocak, Washington State University Vancouver, USA, for rewriting this manual to include embedded
outcomes assessment.
Preface v
1 SRV02 Modeling 1
1.1 Background 2
1.1.1 Modeling Using First-Principles 2
1.1.2 Modeling Using Experiments 5
1.2 Pre-Lab Questions 8
1.3 Lab Experiments 9
1.3.1 Frequency Response Experiment 10
1.3.2 Bump Test Experiment 12
1.3.3 Model Validation Experiment 13
1.3.4 Results 15
1.4 System Requirements 17
1.4.1 Overview of Files 17
1.4.2 Hardware Setup 17
1.4.3 Software Setup 18
1.5 Lab Report 19
1.5.1 Template for Content 19
1.5.2 Tips for Report Format 20
A SRV02 LabVIEW
Integration 67
A.1 Applying Voltage to SRV02
Motor 68
A.1.1 Configuring the Simulation Loop 68
A.1.2 Interfacing to the DC Motor 69
A.1.3 Running the VI 70
A.2 Reading Position using
Potentiometer 71
A.2.1 Interfacing to the Potentiometer 71
A.2.2 Measuring Position 72
A.3 Measuring Speed using
Tachometer 75
A.4 Measuring Position using
Encoder 78
A.5 Saving Data 80
Background section provides all the necessary theoretical background for the experiments. You should read this
section first to prepare for the Pre-Lab questions and for the actual lab experiments.
Pre-Lab Questions section provides targetted questions for preliminary calculations that need to be done prior to the
lab experiments. You should go through these questions and try to answer them using the background materials
and the references given at the end of the manual.
Lab Experiments section provides you with step-by-step instructions to conduct the lab experiments and to record
the collected data.
System Requirements section describes all the details of how to configure the hardware and software to conduct
the experiments. It is assumed that the hardware and software configuration have been completed by the instructor
or the teaching assistant prior to the lab sessions. If not, you can configure the systems by following the instructions
given in this section.
When you write your lab report, you should use the specific template for content given at the end of each laboratory
chapter. A section on Tips for Report Format is also provided at the end of each laboratory chapter.
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.
• 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 [1], [2], and [4], respectively.
• Wiring and operating procedure of the SRV02 plant with the amplifier and data-aquisition (DAQ) device, as
discussed in Reference [4].
• Transfer function fundamentals, e.g. obtaining a transfer function from a differential equation.
• Laboratory described in Appendix A to get familiar with using LabVIEW™ with the SRV02.
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.
The DC motor armature circuit schematic and gear train is illustrated in Figure 1.1. As specified in [4], recall that Rm
is the motor resistance, Lm is the inductance, and km is the back-emf constant.
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 flow. The back emf voltage is given by:
dIm (t)
Vm (t) − Rm Im (t) − Lm − km ωm (t) = 0 (1.1.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 (1.1.4)
Vm (t) − km ωm (t)
Im (t) = (1.1.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.
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
dωl (t)
Jl + Bl ωl (t) = τl (t) (1.1.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) (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:
where Kg is the gear ratio and ηg is the gearbox efficiency. The planetary gearbox that is directly mounted on the
SRV02 motor (see [4] for more details) is represented by the N1 and N2 gears in Figure 1.1 and has a gear ratio of
N2
Kgi = (1.1.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 = (1.1.11)
N3
The gear ratio of the SRV02 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) = (1.1.13)
ηg Kg
Intuitively, the motor shaft must rotate Kg times for the output shaft to rotate one revolution.
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:
Collecting the coefficients in terms of the load shaft velocity and acceleration gives
dωl (t)
(ηg Kg2 Jm + Jl ) + (ηg Kg2 Bm + Bl )ωl (t) = ηg Kg τm (t) (1.1.17)
dt
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.
where kt is the current-torque constant (N.m/A), ηm is the motor efficiency, and Im is the armature current. See [4]
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:
ηg Kg2 ηm kt km + Beq Rm
Beq,v = (1.1.27)
Rm
and the actuator gain equals
ηg Kg ηm kt
Am = (1.1.28)
Rm
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.
The Bode plot can then be used to find the steady-state gain, i.e. the DC gain, and the time constant of the system.
The cuttoff frequency, ωc , shown in Figure 1.3 is defined 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 defined as
the frequency where the gain is √12 , or about 0.707, of the maximum gain. The cutoff frequency is also known 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 SRV02 plant transfer function given in equation 1.1.1 is defined as:
Ωl (ω j)
|Gwl,v (w)| = (1.1.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 first-order system form given in Equation 1.1.1. By substituting s = j w in this equation, we can find the
frequency response of the system as:
Ωl (ω j) K
= (1.1.30)
Vm (ω j) τω j + 1
Then, the magnitude of it equals
K
|Gwl,v (ω)| = √ (1.1.31)
1 + τ 2 ω2
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)
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:
Y (s) K
= (1.1.33)
U (s) τs + 1
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
∆y
K= (1.1.34)
∆u
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:
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)
τ = 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:
KAv e(−s t0 )
Ωl (s) = (1.1.39)
(τ s + 1) s
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 ).
( t−t0
)
ωl (t) = K Av 1 − e(− τ ) + ωl (t0 ) (1.1.40)
1. In Section 1.1.1.3 we obtained an equation (1.1.26) that described the dynamic behavior of the load shaft
speed as a function of the motor input voltage. Starting from this equation, find the transfer function VΩml (s)
(s) .
2. Express the steady-state gain (K) and the time constant (τ ) of the process model (Equation (1.1.1)) in terms
of the Jeq , Beq,v , and Am parameters.
3. Calculate the Beq,v and Am model parameters using the system specifications given in [4]. The parameters
are to be calculated based on an SRV02-ET in the high-gear configuration.
4. Calculate the moment of inertia about the motor shaft. Note that Jm = Jtach + Jm,rotor where Jtach and
Jm,rotor are the moment of inertia of the tachometer and the rotor of the SRV02 DC motor, respectively. Use
the specifications given in [4].
5. 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 specifications given
in [4] find the total moment of inertia Jg from the gears . Hint: Use the definition of moment of inertia for a disc
2
Jdisc = mr 2 .
6. Assuming the disc load is attached to the load shaft, calculate the inertia of the disc load, Jext,l , and the total
load moment of inertia, Jl .
7. Evaluate the equivalent moment of inertia Jeq .
8. 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.
9. Referring to Section 1.1.2.1, find the expression representing the time constant τ of the frequency response
model given in Equation 1.1.31. Begin by evaluating the magnitude of the transfer function at the cutoff fre-
quency ωc .
10. Referring to Section 1.1.2.2, find the steady-state gain of the step response and compare it with Equation
1.1.34. Hint: The the steady-state value of the load shaft speed can be defined as ωl,ss = lim ωl (t).
t→∞
11. Evaluate the step response given in equation 1.1.40 at t = t0 + τ and compare it with Equation 1.1.34.
• Frequency response, or
• Bump test
In this laboratory, first you will conduct two experiments exploring how these methods can be applied to a real system.
Then, you will conduct a third experiment to fine tune the parameters of the transfer functions you obtained and to
validate them.
Experimental Setup
The SRV02 Modeling VI shown in Figure 1.5 will be used to conduct the experiments. The DC motor and sensors
of the SRV02 system is interfaced using LabVIEW™ . Using the developed first-order transfer function, the SRV02
is also simulated. 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 the lab files are configured
according to your SRV02 setup. If they have not been configured already, then you need to go to Section 1.4 to
configure the lab files first.
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 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. Open the LabVIEW project called Quanser SRV02 Project (Student).lvproj, shown in Figure 1.11 in Section
1.4.
2. Open the SRV02 Modeling.vi shown in Figure 1.5. Make sure the VI is configured for your data acquisition
device, as explained in Section 1.4.
3. Set the Signal Generator parameters to:
• Signal Type: sine
• Amplitude: 0 V
• Offset: 2.0 V
• Frequency: 0.4 Hz
4. Run the VI. The SRV02 unit should begin rotating in one direction and the VI should look something similar to
Figure 1.6. Note that in the Speed (rad/s) scope, the red trace is the measured speed while the blue trace is
the simulated speed (generated by the SRV02 Model).
5. Measure the speed of the load shaft and enter the measurement in Table 1.1 below under the f = 0 Hz row.
Note: The measurement can be done directly from the LabVIEW™ chart. For a more precise measurement,
stop the VI and go to the Measure tab. The graph saves the last 5 seconds of measured data. Use the cursors
to take measurements. Cursor 0 and 1 are fixed to the plot traces, whereas Cursor 2 is free and can be
positioned anywhere on the plot area.
6. 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.
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.
• Offset: 0 V
• Frequency: 1.0 Hz
3. The SRV02 unit should begin rotating smoothly back and forth and the scopes should be reading a response
similar to Figure 1.8.
4. Measure the maximum positive speed of the load shaft at f = 1.0 Hz input and enter it in Table 1.1 below.
Note: As before, this measurement can be done directly from the scope or, preferably, you can use Measure
tab and use a cursor on the Graph to find the maximum load speed on the saved data (you will have to stop
the VI).
5. Calculate the gain of the system (in both linear and dB units) and enter the results in Table 1.1.
6. Increase the frequency to f = 2.0 Hz by adjusting the Frequency (Hz) control box on the front panel. Measure
the maximum load speed and calculate the gain. Repeat this step for each of the frequency settings in Table
1.1. Re-run the VI in case it was previously stopped (for example, to take cursor measurements).
7. Using 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.
Feel free to use any program to generate the Bode, e.g., LabVIEW™ or Microsoft Excelr . If using LabVIEW™
, you can complete the block diagram in the Modeling Results (Student).vi that is supplied.
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.
9. Click the Stop button to stop the VI.
10. Turn off the power to the amplifier if no more experiments will be performed on the SRV02 in this session.
1. Open the LabVIEW project called Quanser SRV02 Project (Student).lvproj, shown in Figure 1.11 in Section
1.4.
2. Open the SRV02 Modeling.vi shown in Figure 1.5. Make sure the VI is configured for your data acquisition
device, as explained in Section 1.4.
3. Set the Signal Generator parameters to the following:
• Frequency: 0.4 Hz
4. Run the SRV02 Modeling VI. The gears on the SRV02 should be rotating in the same direction and alternating
between low and high speeds. The response in the scopes should be similar to Figure 1.9.
5. Plot the response and attach it to your report.
Note: As described in Section A.5, to export the image of the scope right-click on the LabVIEW Chart and
go to Export | Export Simplified Image. Select the Bitmap (*.bmp) and Export to clipboard options to save the
image to the clipboard and then save it using a graphics software. Alternatively, you can also export the data
into an Excelr and generate the plot in the spreasheet.
6. Find the steady-state gain using the measured step response and enter it in Table 1.2. Use the cursors in the
Servo Speed (rad/s) Graph in the Measure tab to measure points on the response.
7. Find the time constant from the obtained response and enter the result in Table 1.2.
8. Click the Stop button to stop the VI.
9. Turn off the power to the amplifier if no more experiments will be performed on the SRV02 in this session.
1. Open the LabVIEW project called Quanser SRV02 Project (Student).lvproj, shown in Figure 1.11 in Section
1.4.
2. Open the SRV02 Modeling.vi shown in Figure 1.5. Make sure the VI is configured for your data acquisition
device, as explained in Section 1.4.
5. In the Model Variables panel on the VI, set the model steady-state gain to K = 1.25 and observe how the
simulation changes.
6. Change the model time constant to tau = 0.2 and observe how the simulation changes.
7. Vary the gain and time constant model parameters. How do the gain and the time constant affect the system
response?
8. Enter the nominal values, K and τ , that were found in Section 1.2 in the Model Variables section on the VI
front panel. Examine how well the simulated response matches the measured one.
9. 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.
10. Provide two reasons why the nominal model does not represent the SRV02 with better accuracy.
11. Show 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 Model Variables, run the VI, 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 .
12. Explain how well the nominal model, the frequency response model, and the bumptest model represent the
SRV02 system.
1.3.4 Results
Fill out Table 1.2 below, with your results.
• Quanser VoltPAQ power amplifier, or equivalent (e.g. Reference [2] for VoltPAQ User Manual).
Required Software
• NI LabVIEW™
• NI LabVIEW Control Design and Simulation Module
1. Connect the Quanser SRV02 to the amplifier (e.g. VoltPAQ) and DAQ device as described in [4].
Note: If you are using the NI CompactRIO, then see the SRV02 cRIO User Manual ([3]).
2. Open the LabVIEW project called Quanser Modeling (Student).lvproj shown in Figure 1.11.
3. To run the SRV02 Modeling Experiments, open the SRV02 Modeling VI.
4. Choose data acquisition device: Before running the VI, make sure you set the correct Board type in the HIL
Initialize block (e.g., 'q1_cRIO', 'q2_usb', 'q8_usb', 'qpid', or 'qpid_e').
5. Channel Configuration: For any of these VIs, the analog input and ouput channels are set, by default, to
match the wiring in the SRV02 User Manual ([4]). If the wiring is different on your system, make sure the VI
uses the correct channels. For instance, if your tachometer is connected to Analog Input Channel #0 on your
DAQ, then set the tach channel in the VI to 0 (instead of 1).
6. Quanser CompactRIO Users: Before running the VI, make sure you can connect to your CompactRIO
through the Measurement & Automation software. See the SRV02 cRIO User Manual ([3]).
1. Briefly describe the main goal of this experiment and the procedure.
1. Briefly describe the main goal of this experiment and the experimental procedure (Section 1.3.2).
1. Briefly describe the main goal of this experiment and the experimental procedure (Section 1.3.3).
II. RESULTS
Do not interpret or analyze the data in this section. Just provide the results.
III. ANALYSIS
Provide details of your calculations (methods used) for analysis for each of the following:
• Has cover page with all necessary details (title, course, student name(s), etc.)
• Each of the required sections is completed (Procedure, Results, Analysis and Conclusions).
• Typed.
• Tables are numbered, they include labels, each table has a descriptive caption.
• Data are presented in a useful format (graphs, numerical, table, charts, diagrams).
The objective of this experiment is to develop a feedback system that controls the position of the rotary servo load
shaft. Using the proportional-integral-derivative (PID) family, a compensator is designed to meet a set of specifica-
tions.
Topics Covered
• Design a proportional-derivative (PD) compensator that controls the position of the servo load shaft according
to certain time-domain requirements.
• Simulate the PD controller using the developed model of the plant and ensure the specifications are met without
any actuator saturation.
• Implement the controller on the Quanser SRV02 device and evaluate its performance.
Prerequisites
Recall in the SRV02 modelling laboratory, 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 (ef-
fectively 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 (2.1.4)
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 properties depend on the values of ωn and ζ.
Consider a second-order system as shown in Equation 2.1.4 subjected to a step input given by
R0
R(s) = (2.1.5)
s
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 )
PO = (2.1.6)
R0
From the initial step time, t0 , the time it takes for the response to decay to 4% of its final value, t1 , is
ts = t1 − t0 (2.1.7)
In a second-order system, the amount of overshoot depends solely on the damping ratio parameter and it can be
calculated using the equation ( )
− √π ζ
1−ζ 2
P O = 100 e (2.1.8)
The settling time depends on both the damping ratio and natural frequency of the system and it can be derived as:
4
ts = (2.1.9)
ζωn
Generally speaking, the damping ratio affects the shape of the response while the natural frequency affects the
speed of the response.
Open-loop bode should satisfy the following phase margin and bandwidth specifications:
and
ωbw = 25.0 rad/s. (2.1.11)
The desired time-domain specifications for controlling the position of the SRV02 load shaft are:
ts ≤ 0.20 s (2.1.13)
Note: The specifications given above must be met while keeping the DC motor input voltage peak within ±10V.
This operating range is necessary to prevent any damage.
Thus when tracking the load shaft reference, the response should settle within 4% of its final value in 0.20 s or less
and that final value should be within 0.03 rad of the reference signal. The overshoot should be less than or equal to
2 %. So if the step is 1.0 rad, then is the peak should not exceed 1.02 rad.
The proportional-velocity (PD) compensator to control the position of the SRV02 has the following structure
( )
d d
Vm (t) = kp (θd (t) − θl (t)) + kd θd (t) − θl (t) (2.1.15)
dt dt
where kp is the proportional control gain, kd is the derivative 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
PD control is given in Figure 2.3. 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.15 gives
From the Plant block in Figure 2.3 and equation 2.1.3, we can write
Θl (s) K
= (2.1.17)
Vm (s) s (τ s + 1)
Substituting equation 2.1.16 into 2.1.17 and solving for Θl (s)/Θd (s) gives the SRV02 position closed-loop transfer
function as:
Θl (s) K(kp + kd s)
= (2.1.18)
Θd (s) τ s2 + (1 + K kd ) s + K kp
4. Based on the nominal SRV02 model parameters, K and τ , found in SRV02 Modeling Laboratory in Section 1,
calculate the control gains needed to satisfy the time-domain response requirements given in Section 2.1.1.2.
Before getting starting... Read Section 2.4 for information about the files you will be using for the lab and how to
configure your SRV02.
1. Open the LabVIEW project called SRV02 Position Control (Student).lvproj, shown in Figure 2.13 in Section
2.4.
2. Within the SRV02 Control Design and Simulation folder, open the SRV02 Position Control Design.vi shown in
Figure 2.4.
3. Go to its block diagram and enter the SRV02 DC motor model plant in the MathScript node shown in Figure
s+1
2.5, below. Here's an example of how to use the tf function to generate the transfer function G = s+2s+3 .
num = [1 2];
den = [1 2 3];
G = tf(num,den);
For additional information about the tf function, look through the LabVIEW help or online.
and more stable the system is. The higher the bandwidth, the more responsive the system is to an input. What
is the effect of increasing kp or kd ?
6. Find proportional and derivative control gains that satisfy the bandwidth and phase margin specifications given
in Section 2.1.1.2. These control gains are the Frequency-Based Design, or FBD, parameters.
7. In the Closed Loop Step Response tab, verify that the time-domain specifications given in Section 2.1.1.2 are
satisfied. Enter the time-domain specifications values in Table 2.1.
1. Open SRV02 Position Control | SRV02 Control Design and Simulation | SRV02 PD Control Simulation.vi
shown in Figure 2.7.
4. Using the Gain, Derivative, and Summation blocks from the Control Design and Simulation palette, build a PD
controller as shown in Figure 2.3. Use the existing proportional and derivative gain controls already in the VI.
kp = 5
kd = 0
The response should be as shown in Figure 2.9. Both the output response, i.e. the servo angle, and the control
input, i.e. the dc motor voltage, are being simulated.
Figure 2.9: SRV02 PD Control Simulation VI shown when running with kp = 5 and kd = 0
6. Change the proportional gain, kp , and examine its effect on the response. In particular, what happens to the
overshoot and settling time as kp is increased?
7. Change the derivative gain, kd , and examine its effect on the response. What happens to the settling time and
overshoot?
8. Enter the FBD gains, kp and kd , you found in Section 2.3.1.1. Attach the position and input voltage responses
to your report. To export a response as an image right-click on the chart, go to Export | Export Simplified
Image, and select the BMP and Clipboard options.
9. Are the settling time and overshoot specifications given in Section 2.1.1.2 satisfied using the FBD control?
Hint: You can stop the VI and use the Graph Palette to zoom up on the overshoot and make sure the specifi-
cations are met. The Graph Palette located on the top of the chart is illustrated in Figure 2.10.
10. Examine the control input in the bottom scope. In regards to the input voltage, what is this simulation assuming?
Should this controller be implemented on the actual hardware?
11. Based on your answer in 10, modify the simulation to make it more realistic. Looks through the Simulation
Module palette for the appropriate block.
1. Run the SRV02 Position Control.lvproj | SRV02 Position Control Design.vi used in Section 2.3.1.1.
6. List why the specifications based on the TDD PD control gains you calculated are not satisfied in simulation.
7. You may have to tune your gains slightly until the time-domain requirements are met. Once you have found
a set of gains that satisfy the specifications, enter them below. These are known as the Time-Domain Design
control gains, or TDD.
8. Based on the simulation, what is the expected settling time and percentage overshoot when using the TDD
controller? Enter these in Table 2.1. Do they satisfy the specifications?
9. Go to the Open-Loop Bode tab. Enter the expected bandwidth and phase margin when using the TDD control
gains. How does the bandwidth and phase margin compare with the FBD controller?
We will now simulate the closed-loop servo position control using a more realistic model (e.g. one that includes the
saturation block).
In this section the Time-Domain Design (TDD) controller is ran on the actual SRV02 system.
1. In the SRV02 Position Control.lvproj project, open the SRV02 Position Control VI. Make sure it is configured
for your data acquisition device as explained in Section 2.4.
2. As done previously in Section 2.3.1.1, enter the SRV02 plant in the MathScript node and build the PD control
using the Gain, Summation, and Saturation VIs from the Control Design and Simulation palette. Use the
existing proportional and derivative gain controls already in the VI.
3. Turn ON the power amplifier (e.g. Quanser VoltPAQ).
4. Run the VI. The top gears on the SRV02 should begin rotating back-and-forth and the VI should look similarly
as shown in Figure 2.12. The top scope shown the measured response in yellow, the simulated response in
red, and the desired or reference position in blue. The bottom scope is the input motor voltage.
5. Enter the TDD PD gains you found in Section 2.3.2.1 in the VI.
9. If your measured response did not meet the specifications listed in 2.1.1.2, then try tuning the PD gains as the
VI is ran until it does. Recall the strategy you used in Section 2.3.2.1 and document your approach. Attach
the position and voltage response below. Show a close-up view of the response as the step goes up.
10. Measure the overshoot, settling time, and steady-state error. Enter your newly tuned TDD control gains and
the measured specifications in Table 2.1.
Table 2.1: Summary of results for the SRV02 Position Control laboratory.
• Data-aquisition (DAQ) device that is compatible with LabVIEW™ , e.g., NI USB or PCI DAQ, NI CompactRIO,
or Quanser Hardware-in-the-loop (HIL).
• Quanser SRV02-ET rotary servo. See Reference [4].
• Quanser VoltPAQ power amplifier, or equivalent (e.g. Reference [2] for VoltPAQ User Manual).
Required Software
• NI LabVIEW™
• NI LabVIEW Control Design and Simulation Module
• Quanser Rapid Control Prototyping Toolkitr
• NI LabVIEW MathScript Module
• For NI CompactRIO users:
– NI LabVIEW Real-Time Module
– NI LabVIEW FPGA Module 2010
– RIO Drivers
Table 2.2: Files supplied with the SRV02 Position Control laboratory.
1. Connect the Quanser SRV02 to the amplifier (e.g. VoltPAQ) and DAQ device as described in [4].
2. Make sure the SRV02 is in the high-gear configuration.
Note: If you are using the NI CompactRIO, then see the SRV02 cRIO User Manual ([3]).
3. The SRV02 Control Design and Simulation folder contains the simulation-based VIs that do not require any
hardware.
4. Choose data acquisition device: Before running the VI, make sure you set the correct Board type in the HIL
Initialize block (e.g., 'q1_cRIO', 'q2_usb', 'q8_usb', 'qpid', or 'qpid_e').
5. Channel Configuration: For any of these VIs, the encoder input and analog ouput channels are set, by
default, to match the wiring in the SRV02 User Manual ([4]). If the wiring is different on your system, make
sure the VI uses the correct channels.
6. Quanser CompactRIO Users: Before running the VI, make sure you can connect to your CompactRIO
through the Measurement & Automation software. See the SRV02 cRIO User Manual ([3]).
When you are writing your lab report, follow the outline corresponding to the experiment you conducted to build the
content of your report. Also, in Section 2.5.3 you can find some basic tips for the format of your report.
II. RESULTS Do not interpret or analyze the data in this section. Just provide the results.
1. Step response plot from step 8 in Section 2.3.1.2, Response without actuator saturation.
2. Step response plot from step 13 in Section 2.3.1.2, Response with actuator saturation.
3. Provide applicable data collected in this laboratory (from Table 2.1).
III. ANALYSIS Provide details of your calculations (methods used) for analysis for each of the following:
1. Step 6 in Section 2.3.1.2, Effect of proportional gain on simulated step response (without actuator saturation).
2. Step 7 in Section 2.3.1.2, Effect of derivative gain on simulated step response (without actuator saturation).
IV. CONCLUSIONS Interpret your results to arrive at logical conclusions for the following:
2. Step 10 in Section 2.3.1.2, Assess whether the FBD controller can be implemented on hardware.
II. RESULTS Do not interpret or analyze the data in this section. Just provide the results.
1. Response plot from step 3 in Section 2.3.2.2, TDD controller simulation with step input.
2. Response plot from step 6 in Section 2.3.2.3, TDD controller implementation with step input.
3. Response plot from step 9 in Section 2.3.2.3, Tuned TDD controller with step input (if applicable).
4. Provide applicable data collected in this laboratory (from Table 2.1).
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 for each of the following:
• Has cover page with all necessary details (title, course, student name(s), etc.)
• Each of the required sections is completed (Procedure, Results, Analysis and Conclusions).
• Typed.
• Tables are numbered, they include labels, each table has a descriptive caption.
• Data are presented in a useful format (graphs, numerical, table, charts, diagrams).
• No hand drawn sketches/diagrams.
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.
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 [1], [2], and [4], respectively.
• Wiring and operating procedure of the SRV02 plant with the amplifier and data-aquisition (DAQ) device, as
discussed in Reference [4].
• Transfer function fundamentals, e.g. obtaining a transfer function from a differential equation.
• Laboratory described in Appendix A to get familiar with using LabVIEW™ with the SRV02.
The time-domain requirements for controlling the speed of the SRV02 load shaft are:
ess = 0 (3.1.1)
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:
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
{
2.5 rad/s t ≤ t0
ωd (t) = (3.1.6)
7.5 rad/s t > t0
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
ω(tp ) = ωd (t0 ) + (ωd (t) − ωd (t0 )) 1+ (3.1.7)
100
The closed-loop speed response should therefore not exceed the value given in Equation 3.1.8.
Consider the speed control system with unity feedback shown in Figure 3.1. Let the compensator be C(s) = 1.
We can find the steady-state error using the final value theorem:
where
R(s)
E(s) = (3.1.10)
1 + C(s) P (s)
The voltage-to-speed transfer function for the SRV02 was found in Section 1 as:
K
P (s) = (3.1.11)
τs+1
R0
Substituting R(s) = s and C(s) = 1 gives:
R0
E(s) = ( ) (3.1.12)
K
s 1+ τ s+1
The proportional-integral (PI) compensator used to control the velocity of the SRV02 has the following structure:
∫
Vm (t) = kp (bsp ωd (t) − ωl (t)) − ki (ωd (t) − ωl (t)) dt (3.1.15)
where kp is the proportional control gain, ki is the integral control gain, ωd (t) is the setpoint or reference angular
speed for the load shaft, ωl (t) is the measured load shaft angular speed, bsp is the setpoint weight, and Vm (t) is the
voltage applied to the SRV02 motor. The block diagram of the PI control is given in Figure 3.2.
In this section, we will first calculate the minimum damping ratio and natural frequency required to meet the speci-
fications 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 ( P O )2 (3.1.18)
100 ln 100 + π 2
and
π
ωn = √ (3.1.19)
tp 1 − ζ2
Substituting the percent overshoot specifications given in 3.1.3 into Equation 3.1.18 gives the required damping ratio
ζ = 0.690 (3.1.20)
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 .
To obtain zero steady-state error, an integrator is placed in series with the plant. This system is denoted by the
transfer function
P (s)
Pi (s) = (3.1.27)
s
where P (s) is the plant transfer function in Equation 3.1.11.
The phase margin and crossover frequency specifications listed in equations 3.1.4 and 3.1.5 of Section 3.1.1.1 can
then be satisfied using a proportional gain Kc and the lead transfer function
1 + aT s
Glead (s) = (3.1.28)
1+T s
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:
Kc (1 + a T s)
C(s) = (3.1.29)
(1 + T s) s
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.
In this section, we will summarize the steps required 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. Use your software to
generate a Bode plot of Pi (s). For instance, in MathScript you could enter the following commands to construct
the Pi (s) transfer function.
These parameters are used with the commands tf and series to create the Pi (s) transfer function. You can
then generate the Bode under your software requirement (e.g., Matlabr or LabVIEW™ ). The Bode of Pi (s) is
shown in Figure 3.5. It also lists the gain and phase stability margins as well as the phase and gain crossover
frequencies.
2. Find how much more gain is required such that the gain crossover frequency is 50.0 rad/s. As mentioned
before, the lead compensator adds gain to the system and will increases the phase as well. Therefore, gain
Kc is not to be designed to meet the specified 75.0 rad/s fully.
As given in Figure 3.5, the crossover frequency of the uncompensated system is about 1.53 rad/s. The Bode
plot after adding gain Kc , i.e., the loop transfer function Lp (s) from Section 3.1.3, is given in Figure 3.6.
This initial estimate of the gain can be found from the Bode plot and then adjusted according to the crossover
frequency calculated in the generated Bode plot of the Lp (s) system.
3. Gain needed for specified phase margin must be found next so that the lead compensator can achieve
the specified phase margin of 75 degrees. Also, to ensure the desired specifications are reached, we'll add
another 5 degrees to the maximum phase of the lead.
To attain the necessary phase margin, the maximum phase of the lead can be calculated using
The lead compensator, as explained in Section 3.1.3.1, has two parameters: a and T . To attain the maximum
phase ϕm shown in Figure 3.4, the Lead compensator has to add 20 log10 (a) of gain. This is determined using
the equation
1 + sin ϕm
a=− (3.1.35)
−1 + sin ϕm
4. The frequency at which the lead maximum phase occurs must be placed at the new gain crossover fre-
quency ω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).
As illustrated earlier in Figure 3.4 in Section 3.1.3.1, the maximum phase occurs at the maximum phase fre-
quency ωm . Parameter T given by:
1
T = √ (3.1.36)
ωm a
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.
5. Bode plot of the lead compensator Clead (s). By defining the Lead compensator transfer function given in
Equation 3.1.28 in software, you can generate a Bode similarly as shown in Figure 3.7.
7. Check response by simulating the system to make sure that the time-domain specifications are met. Keep
in mind that the goal of the lead design is the same as the PI control, the response should meet the desired
steady-state error, peak time, and percentage overshoot specifications given in Section 3.1.1. Thus, if the
crossover frequency and/or phase margin specifications are not quite satisfied, the response should be simu-
lated to verify if the time-domain requirements are satisfied. If so, then the design is complete. If not, then the
lead design needs to be re-visited.
You will work on this later in the laboratory as described in Section 3.3.2.1.
The peak-to-peak noise of the measured SRV02 load gear signal can be calculated using
1
eω = Kn ωl (3.1.37)
100
where Kn is the peak-to-peak ripple rating of the sensor and ωl is the speed of SRV02 load gear. The rated peak-
to-peak noise of the SRV02 tachometer is given in Appendix B of Reference [4] as:
Kn = 7 % (3.1.38)
Based on this specification, the peak-to-peak noise, when the load shaft runs at 7.5 rad/s, will be
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?
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-to-
peak ripple estimate in Equation 3.1.39, the peak speed of the load gear, including the noise, can be found as:
Using
100 (ω(tp ) − ωd (t))
PO = (3.1.42)
ωd (t) − ωd (t0 )
the new maximum percent overshoot for a 5.0 rad/s step is
P O ≤ 10.2 % (3.1.43)
2. The nominal SRV02 model parameters, K and τ , found in SRV02 Modeling Laboratory (Section 1) should
be about 1.53 (rad/s-V) and 0.0254 sec, respectively. Calculate the PI control gains needed to satisfy the
time-domain response requirements.
3. Find the frequency response magnitude, |Pi (ω)|, of the transfer function Pi (s) given in Equation 3.1.27.
4. Calculate the DC gain of Pi (s) given in Equation 3.1.27. Hint: The DC gain is the gain when the frequency is
zero, i.e. ω = 0 rad/s. However, because of its integrator, Pi (s) has a singularity at zero frequency. Therefore,
the DC gain is not technically defined for this system. Instead, approximate the DC gain by using ω = 1 rad/s.
Make sure the DC gain estimate is evaluated numerically in dB using the nominal model parameters, K = 1.53
and τ = 0.0254, (or use what you found for K and τ in Section 1).
5. The gain crossover frequency, ωg , is the frequency at which the gain of the system is 1 or 0 dB. Express
the crossover frequency symbolically in terms of the SRV02 model parameters K and τ . Then, evaluate the
expression using the nominal SRV02 model parameters K = 1.53 and τ = 0.0254, (or use what you found for
K and τ in Section 1).
In each of the experiments, you will first simulate the closed-loop response of the system. Then, you will implement
the controller using the SRV02 hardware and software to compare the real response to the simulated one.
IMPORTANT: Before you conduct these experiments, you need to make sure that the correct LabVIEW™ VI is used
and configured according to your SRV02 setup. If it has not been configured already, then you need to go to Section
3.4 to configure the VI first.
3.3.1.1 Simulation
First you will simulate the closed-loop speed response of the SRV02 with a PI controller and a 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.
Experimental Setup
The SRV02 Speed Control Simulation VI 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 is simulated using a Transfer Function model.
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: LabVIEW VI used to simulate the closed-loop SRV02 speed response.
1. Open the LabVIEW project called SRV02 Speed Control.lvproj, shown in Figure 3.12 in Section 3.4.
2. In the Simulation and Control Design folder, open the SRV02 Speed Control Simulation.vi.
3. Run the VI.
4. 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 Signal Generator parameters to:
5. Ensure the Manual Switch is set to the upward position to activate the PI control.
6. The scopes should be displaying responses similar as shown in Figure 3.9. Note that in the Servo Speed
scope, the blue trace is the setpoint speed while the red trace is the simulated speed.
7. Enter the proportional and integral control gains found in Section 3.1.2.2 as kp and ki in the VI front panel.
8. Show the simulated PI speed response and its input voltage in two separate figures. To do this, stop the VI,
right-click on the chart, and select Export | Export Simplified Image from the menu. Save it as a bitmap on the
clipboard and append it your report. See Section A.5 for more details on saving data.
9. 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? Use the cursors in the Servo Speed (rad/s)
Graph in the Measure tab to measure points off the response.
Experimental Setup
The SRV02 Speed Control VI in Figure 3.10 is used to perform the speed control exercises in this laboratory. The
VI interfaces with the DC motor and sensors of the SRV02 system. 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.
1. Open the LabVIEW project called SRV02 Speed Control.lvproj, shown in Figure 3.12 in Section 3.4.
2. Open the SRV02 Speed Control.vi and make sure it is configured for your data acquisition device, as detailed
in Section 3.4.
3. Run the VI.
4. 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 Signal Generator parameters to:
• Signal Type: Square
• Amplitude: 2.5 rad/s
• Offset: 5.0 rad/s
• Frequency: 0.4 Hz
5. Ensure the Manual Switch is set to the upward position to activate the PI control.
6. The scopes should be displaying responses similar as shown in Figure 3.10. Note that in the Servo Speed
scope, the blue trace is the setpoint speed while the red trace is the simulated speed.
7. Enter the proportional and integral control gains found in Section 3.1.2.2 as kp and ki in the VI front panel.
8. When a suitable response is obtained, click on the Stop button to stop running the VI. Generate a figure showing
the PI speed response and its input voltage (as in the simulation lab in Section 3.3.1.1).
9. Due to the noise in the measured speed signal, it is difficult to obtain an accurate measurement of the specifi-
cations. In the Signal Generator section of the VI, set the Amplitude (rad/s) to 0 rad/s and the Offset (rad/s) to
7.5 rad/s in order to generate a constant speed reference of 7.5 rad/s. Show the response of the noise in the
signal.
10. 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?
11. 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?
In this section, the lead compensator for SRV02 speed control is designed. Our goal is to confirm that the desired
frequency-based specifications in an ideal situation are satisfied. There is a step response simulation at the end to
verify, at least preliminary, that the time-domain specifications are also satisfied. The full closed-loop lead simulation
will be performed in the next section.
Experimental Setup
The SRV02 Lead Control Design LabVIEW™ VI shown in Figure 3.11 is used to design the lead controller of the
SRV02. The various systems described in Section 3.1.3 (e.g., compensated system, lead compensator) are defined
in the VI and their corresponding Bode plots are generated using the LabVIEW™ Control Design Module tools.
Figure 3.11: LabVIEW VI used to design the lead compensator for SRV02 speed control.
1. Open the LabVIEW project called SRV02 Speed Control.lvproj, shown in Figure 3.12 in Section 3.4.
2. Open the SRV02 Lead Control Design.vi.
3. Enter the model parameters K and tau of your system in the VI front panel control boxes (or use the default
nominal values).
4. Run the VI. The steps below correspond to the design steps outlined in Section 3.1.3.2 to find Kc , a, and T
lead parameters.
5. Step 1: Bode plot of open-loop uncompensated system. The Open-Loop tab in the VI displays the magni-
tude and phase Bode plots of the plant + integrator transfer function: Pi (s) = P (s)/s. Similarly as described in
Step 1 of Section 3.1.3.2, the phase margin crossover frequency is about 1.52 rad/s (i.e., the frequency where
the magnitude of the system is 0 dB). This however depends on the SRV02 model parameters, K and τ , you
entered.
7. Step 3: Gain needed for specified phase margin. Measure the phase margin (PM) on the Bode magnitude
plot of Kc Pi (s). Calculate ϕm , given in Equation 3.1.34, for a desired phase margin of 75.0 degrees. Then
compute parameter a using Equation 3.1.35.
8. Enter parameter a in the a input box on the VI. Go to the LEAD tab and examine the magnitude plot of the lead
compensator and how it adds 20 log10 (a) of gain.
9. Step 4: The frequency at which the lead maximum phase occurs. Find parameter T using Equation 3.1.36,
where ωm is the frequency where −10 log a gain should be in the Kc Pi (s) system. To do this, go back to the
Open-Loop Gain tab. Compute −10 log a, find this on the Kc Pi (s) magnitude Bode plot (using the cursor on
the graph), and record the frequency. You can then find parameter T .
10. Step 5: Bode plot of the lead compensator. Enter the parameter T you found in the T input box on the VI.
The updated lead Bode plot, in the LEAD tab, shows the breakpoint frequencies occursing at 1/(a T ) and 1/T .
11. Step 6: Bode plot of the loop transfer function. Go to the Loop TF tab. This shows the Bode plot of full loop
transfer function L(s) = Kc C(s)P (s)/s. Record the frequency-domain specifications and attach the magnitude
and phase Bode plots of L(s).
12. Step 7: Check response. Go the Closed Loop Step Response and record the time-domain specifications.
13. Are the frequency-based and time-domain specifications given in Section 3.1.1.1 satisfied?
14. Click on the Stop button to stop the VI.
3.3.2.2 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 SRV02
Speed Control Simulation LabVIEW™ VI shown in Figure 3.9 again.
1. Open the LabVIEW project called SRV02 Speed Control.lvproj, shown in Figure 3.12 in Section 3.4.
2. Open the SRV02 Speed Control Simulation.vi.
3. Enter the lead control parameters found in Section 3.1.3.2. These are denoted as Kc, a, and T in the VI front
panel.
IMPORTANT: Make sure you enter the linear value of Kc , i.e., not the value in decibels. Recall that xdB =
20 log10 x.
4. Set the Signal Generator block parameters to the following:
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. Show the Simulated Lead speed response and its input voltage.
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.
1. Open the LabVIEW project called SRV02 Speed Control.lvproj, shown in Figure 3.12 in Section 3.4.
2. Open the SRV02 Speed Control.vi and make sure it is configured for you data acquisition device. See Section
3.4 for details.
3. Enter the lead control parameters found in Section 3.1.3.2. These are denoted as Kc, a, and T in the VI front
panel.
IMPORTANT: Make sure you enter the linear value of Kc , i.e., not the value in decibels. Recall that xdB =
20 log10 x.
4. Set the Signal Generator block parameters to the following:
6. Run the VI. The scopes should be displaying responses similar to Figure 3.10.
7. When a suitable response is obtained, click on the Stop button to stop the VI. Show the lead speed response
and its input voltage.
8. Measure the steady-state error, the percent overshoot, and the peak time of the SRV02 load gear. For the
steady-state error, it may be beneficial to give a constant reference and take its average as done in Section
3.3.1.2. Does the response satisfy the specifications given in Section 3.1.1.1?
9. Using both your simulation and implementation results, comment on any differences between the PI and lead
controls.
10. Click the Stop button to stop the VI.
11. Turn off the power to the amplifier if no more experiments will be performed on the SRV02 in this session.
• Data-aquisition (DAQ) device that is compatible with LabVIEW™ , e.g., NI USB or PCI DAQ, NI CompactRIO,
or Quanser Hardware-in-the-loop (HIL).
Required Software
• NI LabVIEW™
Table 3.2: Files supplied with the SRV02 Speed Control laboratory.
3. Choose data acquisition device: Before running the VI, make sure you set the correct Board type in the HIL
Initialize block (e.g., 'q1_cRIO', 'q2_usb', 'q8_usb', 'qpid', or 'qpid_e').
4. Channel Configuration: For any of these VIs, the analog input and ouput channels are set, by default, to
match the wiring in the SRV02 User Manual ([4]). If the wiring is different on your system, make sure the VI
uses the correct channels. For instance, if your tachometer is connected to Analog Input Channel #0 on your
DAQ, then set the tach channel in the VI to 0 (instead of 1).
5. Quanser CompactRIO Users: Before running the VI, make sure you can connect to your CompactRIO
through the Measurement & Automation software. See the SRV02 cRIO User Manual ([3]).
When you are writing your report, follow the outline corresponding to the experiment you conducted to build the
content of your report. Also, in Section 3.5.3 you can find some basic tips for the format of your report.
1. Simulation
II. RESULTS
Do not interpret or analyze the data in this section. Just provide the results.
1. Response plot from step 8 in Section 3.3.1.1, Step response simulation with PI Control
2. Response plot from step 8 in Section 3.3.1.2, Step response implementation with PI Control
3. Signal noise plot from step 9 in Section 3.3.1.2, Step response implementation with PI Control
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 for the following:
1. Control Design
II. RESULTS
Do not interpret or analyze the data in this section. Just provide the results.
1. Bode plot from step 6 in Section 3.3.2.1, Bode plot of Lp (s) = Kc Pi (s) system.
2. Bode plot from step 11 in Section 3.3.2.1, Bode plot of loop transfer function, L(s).
3. Response plot from step 9 in Section 3.3.2.2, Step response simulation with Lead Control.
4. Response plot from step 7 in Section 3.3.2.3, Step response implementation with Lead Control.
III. ANALYSIS
Provide details of your calculations (methods used) for analysis for each of the following:
1. Step 6 in Section 3.3.2.1, Finding necessary gain Kc needed to reach desired crossover frequency.
2. Step 7 in Section 3.3.2.1, Finding lead gain a needed for specified phase margin.
3. Step 9 in Section 3.3.2.1, Finding frequency at which the lead maximum phase occurs and obtaining lead
parameter T .
1. Step 13 in Section 3.3.2.1, Bode and preliminary step response simulation with Lead Control.
2. Step 7 in Section 3.3.2.2, Step response simulation with Lead Control
• Has cover page with all necessary details (title, course, student name(s), etc.)
• Each of the required sections is completed (Procedure, Results, Analysis and Conclusions).
• Typed.
• Tables are numbered, they include labels, each table has a descriptive caption.
• Data are presented in a useful format (graphs, numerical, table, charts, diagrams).
• No hand drawn sketches/diagrams.
SRV02 LABVIEW
INTEGRATION
In this section, we explain how to command voltages to the Quanserr SRV02 and measure the position and speed
of its load shaft using LabVIEW™ .
Required Hardware
• Data acquisition (DAQ) device that is compatible with LabVIEW™ and the Quanser Rapid Control Prototyping
Toolkitr (RCP TK).
Required Software
Follow the instructions given in the RCP Toolkit Quick Start Guide - for either Windows or NI-CompactRIO - to install
LabVIEW™ , its necessary add-on modules, and RCP on your PC/laptop and on the NI CompactRIO (if used).
Prerequisites
The user should be familiar with the following:
• Main components of the SRV02, e.g., DC motor and sensors such as the potentiometer [4].
• Basics of LabVIEW™ .
• Add and configure Quanser Rapid Control Prototyping Toolkitr drivers to output voltage to the motor.
• Using the Sine Signal Simulation Module block.
Note: Quanser Q1-cRIO users: If you are using a Q1-cRIO with the NI CompactRIO, make sure you add your
NI cRIO to your LabVIEW project before proceeding, as shown the Quanser Rapid Control Prototyping Toolkitr
Getting Started page.
3. Go to the block diagram and create a Simulation loop, as depicted in Figure A.2. It is found in the Control
Design & Simulation | Simulation palette.
4. Double-click on the Simulation loop input node (or right-click on the border and select Configure Simulation
Parameters) to access the Simulation Parameters box shown in Figure A.3.
5. As shown in Figure A.3, in the Simulation Parameters tab set the following:
• Final time (s): Inf
This configures the simulation to run until it is stopped by the user at a sampling rate of 100 Hz. When
performing control, any of the fixed solvers can be used but Runge-Kutta 1 is typically the default.
6. As shown in Figure A.3, in the Timing Parameters tab set the following:
• Select Synchronize Loop to Timing Source
• Timing Source: 1 kHz Clock
• Select Auto Period
This synchronizes the simulation to the PC clock. Otherwise, the simulation would run as fast as possible
(which is fine when doing pure simulation, but not when interfacing to hardware).
3. Click on OK.
4. Add the following VIs:
6. Add the
7. Halt Simulation block from the Control Design & Simulation | Simulation | Utilities palette.
8. To add a Stop button, go the front panel of the VI and look through the Modern | Boolean palette.
9. In the block diagram, connect the Stop button and Halt Simulation VI as shown in Figure A.1.
1. Make sure the SRV02, DAQ, and amplifier are connected as described in SRV02 User Manual (see [4]).
3. By default, the HIL Write VI is set write to Analog Output Channel #0. If the motor is not connected to Analog
Output Channel #0, then select the appropriate channel in HIL Write.
4. Run the VI by clicking on the white arrow in the top-left corner. This should apply a sine wave voltage to the
DC motor and cause the SRV02 gears to rotate back-and-forth.
Topics Covered
• Add and configure Quanser Rapid Control Prototyping Toolkitr drivers to read potentiometer sensor.
• Use SimTime Waveform Simulation blocks to plot potentiometer reading.
1. Add the HIL Read VI from the Quanser Rapid Control Prototyping palette and connect it as shown in Figure
A.4.
2. If you followed the SRV02 Quick Start Guide or the typical connections in the User Manual, then your
potentiometer is NOT connected. Make sure you connect the potentiometer to Analog Input #0 on your data
acquisition (DAQ) device before proceeding. Follow the instructions given the SRV02 User Manual [4] for a
Two-Channel DAQ. Note: If you are using a Q1-cRIO, omit the connection to Analog Input #1.
3. The potentiometer is connected to Analog Input #0 on the DAQ board. Since the HIL Read is already configured
to read from this channel, no changes are necessary.
4. Add the SimTime WaveForm block from the Control Design & Simulation | Simulation | Graph Utilities palette.
Connect the analog voltages output from the HIL Read VI to the graph as shown in Figure A.4.
Note: The potentiometer has an electrical range of 352 degrees across ± 5 V (see [4] for further details). As
a result, the potentiometer outputs a discontinuous voltage signal as seen in Figure A.6. The disadvantage
is that you cannot surpass the ± 180 degree range when controlling the position or take the derivative of this
sensor to control velocity.
1. In the block diagram, name the SimTime Waveform block as Pot Position (deg). This scope will display the
angular measurement of the load gear in degrees.
2. Add another SimTime WaveForm block and connect it to the voltage outputted by the Signal Generator, as
depicted in Figure A.7. Label this as Motor Voltage (V).
3. To adjust the amplitude and frequency of the Signal Generator from the front panel, double-click on the Signal
Generator block and configure it as follows:
12. Set the amplitude to 1. Examine the relationship between the input voltage and load position. When the input
voltage increases in the positive direction, the potentiometer angle increases. This is an important convention
used in controls. You want to make sure a positive control effort results in a positive measurement.
13. Click on the Stop button to stop the VI.
14. Power OFF the amplifier if no more experiments will be run in this session.
Using the VI built in Section A.2, go through this procedure to add the tachometer functionality:
1. Two-Channel DAQ Users: If your DAQ has 2 or more analog input channels (e.g., Quanser Q2-USB), then
make sure you follow the connections given in the SRV02 User Manual [4] for a two-channel DAQ. This way
you can measure both the potentiometer and the tachometer.
Q1-cRIO Users: If you are using a single Q1-cRIO module in your NI CompactRIO, then connect the tachome-
ter from the SRV02 to Analog Input #0 on the Q1-cRIO, as shown in the SRV02 Quick Start Guide (and the
SRV02 User Manual [4] for a single-channel DAQ and amplifier).
2. Two-Channel DAQ Users: If you connected your tachometer to Analog Input #1 (as well as the potentiometer
Figure A.10: Configuring HIL Read to read from analog channel 0 and 1.
(c) Add an Index Array block from the Programming | Array palette and expand it to output two array elements.
(d) Add a SimTime Waveform called Tach Speed (rad/s) into the VI.
(e) Connect the Index Array and SimTime Waveform blocks as shown in Figure A.9a. This is how you access
multiple analog channels in LabVIEW™ with RCP.
3. Q1-cRIO Users: The VI is already set up to read from AI #0. To read the correct value, change the gain that
was added to read the position from the potentiometer in Section A.2 to 1 (instead of 35.2). See the VI shown
in Figure A.9b.
4. Power ON the amplifier.
5. Run the VI. As the SRV02 rotates back-and-forth, the Tach Speed (rad/s) chart should be plotting the tachome-
ter readings in rad/s.
Note: Similarly as in Section A.2, you can add a gain between the output of channel #1 in the HIL Read VI to
obtain a measurement in certain units (e.g., rpm). In this case, the calibration gain is approximately 1 rad/s/V,
so there is no calibration gain required to read in radians per second.
Finding Calibration Gain: The back-emf constant of the tachometer sensor is 1.5 mV/rpm. However, the mea-
surement is taken directly from the motor itself (see [4]). Thus, to read the velocity of the gear the tachometer
calibration gain must be divided by the gear ratio, i.e., 1000 / 1.5 / 70 to read the rate in RPM when using the
SRV02 in the high-gear configuration (or 1 / 1.5 / 14 if using the low-gear configuration). To obtain in radians
1000(2π)
per second, multiply the gain by 2π/60, which results in 1.5(70)(60) = 0.997 ≈ 1 rad/s/V.
6. Examine the relationship between the input voltage and load speed. When the input voltage increases in the
positive direction, the tachometer velocity increases. Similar to the potentiometer, the speed of the load shaft
should go positive when the input voltage is positive. Otherwise we could add a -1 gain to the tach output to
follow the conventions.
7. Click on the Stop button to stop running the VI.
8. Power OFF the amplifier if no more experiments will be run in this session.
Figure A.12: VI used to send voltage to SRV02 and read the potentiometer, tachometer, and encoder sensors.
Using the VI designed in either Section A.2 or A.3, follow this procedure to add encoder functionality:
1. Recall that, as instructed in [4], the encoder is connected to Encoder Input #0 on the data acquisition board.
2. To add the encoder read channel, double-click on the HIL Read VI.
3. Under Polymorphic instances, select Mixed.
4. Set the analog channels array to read [0,1] and the first element in the encoder channels array to [0].
5. Similarly as done in Section A.3 for the HIL Read, add an Index Array to access the Encoder Channel #0
measurement as a scalar value (instead of an array).
6. The HIL Read VI outputs counts. The SRV02 encoder has (in quadrature mode) outputs 4096 counts per
revolution. To convert this into an angle in degrees, add a DBL Conversion and a Gain block with the value
360/4096 = 0.08789 deg/count. Connect blocks as shown in Figure A.12.
7. Put in another SimTime Waveform, label it Encoder Position (deg), and connect it to the enc (deg) output
terminal on the encoder_count sub-VI. This will display the encoder measurement in degrees.
8. Power ON the power amplifier.
9. Run the VI. As the SRV02 rotates back-and-forth, the Encoder Position (deg) should display the encoder
readings. The input voltage and position scopes should appear similarly as shown in Figure A.13. Note that
no further calibration is needed since the encoder position increases when the input voltage goes positive.
10. Click on the Stop button to stop running the VI.
11. Power OFF the amplifier if no more experiments will be run in this session.
Consider the encoder position response obtained in Figure A.14. The procedure below will show you how to save
this response as a bitmap.
1. When the VI is stopped, right-click on the Chart or Graph and select Export | Export Simplified Image to load
the window shown in Figure A.15.
2. Select the Bitmap (*.bmp) and Export to clipboard options and click on Export.
Note: When the Chart or Graph includes a grid, it may be better to set the Hide Grid option to see the response
better in the image.
3. Paste the image into your favorite image program (e.g., Microsoft Paint, IrfanView) to save it to some location
(or paste the image directly into a document). The exported bitmap of Figure A.14 is shown in Figure A.16.
You can also export the data into Excelr by selecting Export | Export to Excel when right-clicking on the Chart or
Graph. You can then generate a plot in Excelr from the saved data points.
Quanser’s rotary collection allows you to create experiments of varying complexity – from basic to advanced. Your lab
starts with the Rotary Servo Base Unit and is designed to help engineering educators reach a new level of efficiency
and effectiveness in teaching controls in virtually every engineering discipline including electrical, computer, mechanical,
aerospace, civil, robotics and mechatronics. For more information please contact [email protected]
©2012 Quanser Inc. All rights reserved.