100% found this document useful (1 vote)
117 views90 pages

Made For Science Quanser Rotary Servo Base Unit CoursewareStud LabVIEW

Uploaded by

Helmut Pinto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
117 views90 pages

Made For Science Quanser Rotary Servo Base Unit CoursewareStud LabVIEW

Uploaded by

Helmut Pinto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 90

STUDENT WORKBOOK

SRV02 Base Unit Experiment For LabVIEW Users


Standardized for ABET * Evaluation Criteria
Developed by:
Jacob Apkarian, Ph.D., Quanser
Michel Lévis, M.A.Sc., Quanser
Hakan Gurocak, Ph.D., Washington State University

SRV02 educational solutions


are powered by:

Course material
complies with:

CAPTIVATE. MOTIVATE. GRADUATE.


*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.
© 2012 Quanser Inc., All rights reserved.

Quanser Inc.
119 Spy Court
Markham, Ontario
L3R 5H6
Canada
[email protected]
Phone: 1-905-940-3575
Fax: 1-905-940-3576

Printed in Markham, Ontario.

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.

SRV02 Workbook - Student Version ii


CONTENTS

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

2 SRV02 Position Control 21


2.1 Background 22
2.1.1 Desired Position Control Response 22
2.1.2 PD Controller Design 24
2.2 Pre-Lab Questions 25
2.3 Lab Experiments 26
2.3.1 Frequency-Based Design (FBD) 26
2.3.2 Time-Domain Design (TDD) 30
2.3.3 Results 33
2.4 System Requirements 34
2.4.1 Overview of Files 34
2.4.2 Hardware Setup 34
2.4.3 Software Setup 35
2.5 Lab Report 36
2.5.1 Template for Content (FBD Experiment) 37
2.5.2 Template for Content (TDD Experiment) 38
2.5.3 Tips for Report Format 39

3 SRV02 Speed Control 41


3.1 Background 42
3.1.1 Desired Response 42
3.1.2 PI Control Design 43
3.1.3 Lead Control Design 45
3.1.4 Sensor Noise 49
3.2 Pre-Lab Questions 51
3.3 Lab Experiments 52

SRV02 Workbook - Student Version v 1.0


3.3.1 Step Response with PI Control 52
3.3.2 Step Response with LEAD Control 55
3.3.3 Results 58
3.4 System Requirements 59
3.4.1 Overview of Files 59
3.4.2 Software Setup 59
3.5 Lab Report 61
3.5.1 Template for Content (PI Control Experiments) 62
3.5.2 Template for Content (Lead Control Experiments) 63
3.5.3 Tips for Report Format 65

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

SRV02 Workbook - Student Version iv


PREFACE

Every laboratory chapter in this manual is organized into four sections.

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 Workbook - Student Version v 1.0


SRV02 Workbook - Student Version 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 [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.

SRV02 Workbook - Student Version 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.

1.1.1 Modeling Using First-Principles

1.1.1.1 Electrical Equations

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.

Figure 1.1: SRV02 DC motor armature circuit and gear train

The back-emf (electromotive) voltage eb (t) depends on the speed of the motor shaft, ωm , and the back-emf constant
of the motor, km . It opposes the current flow. The back emf voltage is given by:

eb (t) = km ωm (t) (1.1.2)

Using Kirchoff's Voltage Law, we can write the following equation:

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)

SRV02 Workbook - Student Version 2


Solving for Im (t), the motor current can be found as:

Vm (t) − km ωm (t)
Im (t) = (1.1.5)
Rm

1.1.1.2 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
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:

τ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 [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:

Kg = Kge Kgi (1.1.12)

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.

θm (t) = Kg θl (t) (1.1.14)

SRV02 Workbook - Student Version 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:

dωl (t) Jl ( dωdt


l (t)
) + Bl ωl (t)
Jm Kg + Bm Kg ωl (t) + = τm (t) (1.1.16)
dt ηg Kg

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

Defining the following terms:


Jeq = ηg Kg2 Jm + Jl (1.1.18)
Beq = ηg Kg2 Bm + Bl (1.1.19)
simplifies the equation as:
dωl (t)
Jeq + Beq ωl (t) = ηg Kg τm (t) (1.1.20)
dt

1.1.1.3 Combining the Electrical and Mechanical Equations

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

τm (t) = ηm kt Im (t) (1.1.21)

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:

ηm kt (Vm (t) − km Kg ωl (t))


τm (t) = (1.1.23)
Rm
If we substitute (1.1.23) into (1.1.20), we get:
( )
d ηg Kg ηm kt (Vm (t) − km Kg ωl (t))
Jeq wl (t) + Beq wl (t) = (1.1.24)
dt Rm

After collecting the terms, the equation becomes


( ) ( )
d km ηg Kg2 ηm kt ηg Kg ηm kt Vm (t)
wl (t) Jeq + + Beq ωl (t) = (1.1.25)
dt Rm Rm

SRV02 Workbook - Student Version 4


This equation can be re-written as:
( )
d
wl (t) Jeq + Beq,v ωl (t) = Am Vm (t) (1.1.26)
dt

where the equivalent damping term is given by:

η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

1.1.2 Modeling Using Experiments


In Section 1.1.1 you learned how the system model can be derived from the first-principles. A linear model of a
system can also be determined purely experimentally. The main idea is to experimentally observe how a system
reacts to different inputs and change structure and parameters of a model until a reasonable fit is obtained. The
inputs can be chosen in many different ways and there are a large variety of methods. In Sections 1.1.2.1 and
1.1.2.2, two methods of modeling the SRV02 are outlined: (1) frequency response and, (2) bump test.

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.

Figure 1.2: Typical frequency response

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.

SRV02 Workbook - Student Version v 1.0


Figure 1.3: Magnitude Bode plot

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)

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:

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

SRV02 Workbook - Student Version 6


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:

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)

SRV02 Workbook - Student Version v 1.0


1.2 Pre-Lab Questions
Before you start the lab experiments given in Section 1.3, you should study the background materials provided in
Section 1.1 and work through the questions in this Section.

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.

SRV02 Workbook - Student Version 8


1.3 Lab Experiments
The main goal of this laboratory is to find a transfer function (model) that describes the rotary motion of the SRV02
load shaft as a function of the input voltage. We can obtain this transfer function experimentally using one of the
following two methods:

• Frequency response, or
• Bump test

In this laboratory, 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.

Figure 1.5: SRV02 Modeling VI used to model 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 1.4 to
configure the lab files first.

SRV02 Workbook - Student Version v 1.0


1.3.1 Frequency Response Experiment
As explained in 1.1.2.1 earlier, the frequency response of a linear system can be obtained by providing a sine wave
input signal to it and recording the resulting output sine wave from it. In this experiment, the input signal is the motor
voltage and the output is the motor speed.

In this method, we keep the amplitude of the input sine wave constant but vary its frequency. At each frequency
setting, we record the amplitude of the output sine wave. The ratio of the output and input amplitudes at a given
frequency can then be used to create a Bode magnitude plot. Then, the transfer function for the system can be
extracted from this Bode plot.

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. 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.

1.3.1.2 Gain at varying frequencies

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. Run the VI.


2. To feed a 2V sine wave at 1 Hz set the Signal Generator parameters to:
• Signal Type: sine
• Amplitude: 2.0 V

SRV02 Workbook - Student Version 10


Figure 1.6: SRV02 Modeling VI when applying 2 V offset.

• 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.

SRV02 Workbook - Student Version v 1.0


Figure 1.7: Using the Graph to take measurements.

f (Hz) Amplitude (V) Maximum Load Gain:|G(ω)| Gain:|G(ω)|


Speed (rad/s) (rad/s/V) (rad/s/V, dB)
0.0 2.0
1.0 2.0
2.0 2.0
3.0 2.0
4.0 2.0
5.0 2.0
6.0 2.0
7.0 2.0
8.0 2.0

Table 1.1: Collected frequency response data.

1.3.2 Bump Test Experiment


In this method, a step input is given to the SRV02 and the corresponding load shaft response is recorded. Using the
saved response, the model parameters can then be found as discussed in Section 1.1.2.2.

To create the step input:

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:

• Wave form: square


• Amplitude: 1.5 V
• Offset: 2.0 V

SRV02 Workbook - Student Version 12


Figure 1.8: SRV02 Modeling VI when applying 2V sine wave at 1 Hz.

• 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.3.3 Model Validation Experiment


In this experiment, you will adjust the model parameters you found in the previous experiments to tune the transfer
function. Our goal is to match the simulated system response with the parameters you found as closely as possible
to the response of the actual system.

To create a step input:

SRV02 Workbook - Student Version v 1.0


Figure 1.9: Square input motor voltage.

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:


• Signal type: square
• Amplitude: 1.0 V
• Offset: 1.5 V
• Frequency: 0.4 Hz
4. Run the VI. The gears on the SRV02 should be rotating in the same direction and alternating between low and
high speeds and the scopes should be as shown in Figure 1.10. Recall that the red plot line is the measured
load shaft rate and the blue line is the simulated speed from the model. By default, the steady-state gain and
the time constant of the transfer function used in simulation are set to: K = 1 rad/s/V and tau = 0.1 s. These
model parameters do not accurately represent the system.

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.

SRV02 Workbook - Student Version 14


Figure 1.10: SRV02 Modeling VI used to perform model validation.

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.

13. Click the Stop button to stop the VI.


14. 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.

SRV02 Workbook - Student Version v 1.0


Section Description Symbol Value Unit
1.2 Nominal Values
Open-Loop Steady-State Gain K
Open-Loop Time Constant τ
1.3.1 Frequency Response Exp.
Open-Loop Steady-State Gain Ke,f
Open-Loop Time Constant τe,f
1.3.2 Bump Test Exp.
Open-Loop Steady-State Gain Ke,b
Open-Loop Time Constant τe,b
1.3.3 Model Validation
Open-Loop Steady-State Gain Ke,v
Open-Loop Time Constant τe,v

Table 1.2: Summary of results for the SRV02 Modeling laboratory.

SRV02 Workbook - Student Version 16


1.4 System Requirements
Required Hardware

• Data-aquisition (DAQ) device that is compatible with LabVIEW™ .


• 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


• For NI CompactRIO users:

– NI LabVIEW Real-Time Module


– NI LabVIEW FPGA Module 2010
– RIO Drivers

1.4.1 Overview of Files

File Name Description


SRV02 Manual (Student).pdf This laboratory guide contains pre-lab questions and lab
experiments demonstrating how to model the Quanser
SRV02 rotary plant using various methods.
SRV02 Modeling (Student).lvproj LabVIEW project containing the student-based VIs.
SRV02 Modeling.vi VI used to model the SRV02.
Modeling Results (Student) This VI can be used to generate a Bode plot. Some pro-
gramming is required to complete it.

Table 1.3: Files supplied with the SRV02 Modeling laboratory.

1.4.2 Hardware Setup


Follow these steps to get the system hardware ready for this lab:

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.


3. Install the disc load on the top gear.

Note: If you are using the NI CompactRIO, then see the SRV02 cRIO User Manual ([3]).

SRV02 Workbook - Student Version v 1.0


1.4.3 Software Setup
Follow these steps to get the system ready for this lab:

1. Load the LabVIEW™ software.

2. Open the LabVIEW project called Quanser Modeling (Student).lvproj shown in Figure 1.11.

Figure 1.11: SRV02 Modeling Project.

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]).

SRV02 Workbook - Student Version 18


1.5 Lab Report
When you prepare your lab report, you can follow the outline given in Section 1.5.1 to build the content of your report.
Also, in Section 1.5.2 you can find some basic tips for the format of your report.

1.5.1 Template for Content


I. PROCEDURE

I.1. Frequency Response Experiment

1. Briefly describe the main goal of this experiment and the procedure.

• Briefly describe the experimental procedure (Section 1.3.1.1), Steady-state gain


• Briefly describe the experimental procedure (Section 1.3.1.2), Gain at varying frequencies

I.2. Bump Test Experiment

1. Briefly describe the main goal of this experiment and the experimental procedure (Section 1.3.2).

I.3. Model Validation Experiment

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.

1. Bode plot from step 7 in Section 1.3.1.2, Gain at varying frequencies.


2. Response plot from step 5 in Section 1.3.2, Bump Test Experiment.

3. Response plot from step 11 in Section 1.3.3, Model Validation Experiment.


4. Provide data collected in this laboratory (from Table 1.1).

III. ANALYSIS
Provide details of your calculations (methods used) for analysis for each of the following:

III.1. Frequency Response Experiment

1. Step 6 in Section 1.3.1.1, Steady-state gain.


2. Step 8 in Section 1.3.1.2, Gain at varying frequencies.

III.2. Bump Test Experiment

1. Steps 6 and 7 in Section 1.3.2.

SRV02 Workbook - Student Version v 1.0


IV. CONCLUSIONS
Interpret your results to arrive at logical conclusions.

1. Steps 7, 10, and 12 in Section 1.3.3.

1.5.2 Tips for Report Format


PROFESSIONAL APPEARANCE

• Has cover page with all necessary details (title, course, student name(s), etc.)

• Each of the required sections is completed (Procedure, Results, Analysis and Conclusions).
• Typed.

• All grammar/spelling correct.


• Report layout is neat.

• Does not exceed specified maximum page limit, if any.


• Pages are numbered.

• Equations are consecutively numbered.


• Figures are numbered, axes have labels, each figure has a descriptive caption.

• 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.


• References are cited using correct format.

SRV02 Workbook - Student Version 20


LABORATORY 2

SRV02 POSITION CONTROL

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

• Know the basics of LabVIEW™ .

• Understand transfer function fundamentals.


• The SRV02 model steady-state gain, K, and time constant, τ , are needed to compute the control gains.
These parameters can either be given by the instructor or derived by doing the SRV02 Modeling (see Section
1) laboratory.

SRV02 Workbook - Student Version 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.

Figure 2.1: Unity feedback system.

The output of this system can be written as:

Y (s) = C(s) P (s) (R(s) − Y (s)) (2.1.1)

By solving for Y (s), we can find the closed-loop transfer function:

Y (s) C(s) P (s)


= (2.1.2)
R(s) 1 + C(s) P (s)

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 ζ.

2.1.1.1 Settling Time and Overshoot

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

SRV02 Workbook - Student Version 22


Figure 2.2: Standard second-order step response.

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)

This is called the settling time of the system.

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.

2.1.1.2 SRV02 Position Control Specifications

Frequency-Based Design (FBD)

Open-loop bode should satisfy the following phase margin and bandwidth specifications:

P M = 75.0 deg (2.1.10)

and
ωbw = 25.0 rad/s. (2.1.11)

Time-Domain Design (TDD)

The desired time-domain specifications for controlling the position of the SRV02 load shaft are:

ess ≤ 0.03 rad (2.1.12)

ts ≤ 0.20 s (2.1.13)

SRV02 Workbook - Student Version v 1.0


and
P O ≤ 2.0 % (2.1.14)

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.

2.1.2 PD Controller Design

2.1.2.1 Closed Loop Transfer Function

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

Figure 2.3: Block diagram of SRV02 PD position control.

position control of the SRV02. Taking the Laplace transform of equation 2.1.15 gives

Vm (s) = (kp + kd s) (Θd (s) − Θl (s)) (2.1.16)

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

SRV02 Workbook - Student Version 24


2.2 Pre-Lab Questions
1. The SRV02 closed-loop transfer function was derived in equation 2.1.18 in Section 2.1.2.1. Find the control
gains kp and kd in terms of ωn and ζ. Hint: Recall the denominator of the standard second-order system in
equation 2.1.4 .
2. Explain what approximation was made in order to find the PD gains above (assume kd > 0). Hint: Look at the
structure of the equations used.
3. Calculate the minimum damping ratio and natural frequency required to meet the specifications given in Section
2.1.1.2.

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.

SRV02 Workbook - Student Version v 1.0


2.3 Lab Experiments
The main goal of this laboratory is to explore position control of the SRV02 load shaft using the PD controller.
You are asked to verify their control design and simulate the closed-loop PD response. Then, the PD controller is
implemented on the actual SRV02.

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.

2.3.1 Frequency-Based Design (FBD)

2.3.1.1 Control Design

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.

Figure 2.4: SRV02 Position Control.

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.

4. Run the VI. It should look similarly as shown in Figure 2.6.


5. In the Open-Loop Bode tab, vary the proportional, kp , and derivative gains, kd , and examine its effect on the
phase margin (PM) and bandwidth. The bandwidth is equivalent to the PM Crossover frequency on the plot,
which is where the magnitude of the Bode plot hits 0 db (or 1). The larger the phase margin, the less overshoot

SRV02 Workbook - Student Version 26


Figure 2.5: Enter dc motor transfer function

Figure 2.6: SRV02 Position Control Design - Controller Analysis

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.

8. Stop the VI.

2.3.1.2 FBD Control Simulation

1. Open SRV02 Position Control | SRV02 Control Design and Simulation | SRV02 PD Control Simulation.vi
shown in Figure 2.7.

2. As shown in Figure 2.8, the block diagram is incomplete.


3. We want to simulate the position control of the SRV02 using a PD controller using the FBD gains you found in
Section 2.3.1.1. First, enter the SRV02 plant in the MathScript node, as done in the previous procedure.

SRV02 Workbook - Student Version v 1.0


Figure 2.7: SRV02 PD Control Simulation VI

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.

5. Run the VI with the following parameters:

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.

SRV02 Workbook - Student Version 28


Figure 2.8: Incomplete block diagram in SRV02 PD Control VI

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.

SRV02 Workbook - Student Version v 1.0


Figure 2.10: Using the Graph Palette to zoom up on a response

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.

12. Run the VI.


13. Examine how the response changes with the saturation block. Attach the responses to your report (using the
Export | Export Simplified Image command as descrbied previously).
14. Click on the Stop button to stop the VI.

2.3.2 Time-Domain Design (TDD)

2.3.2.1 Control Design

1. Run the SRV02 Position Control.lvproj | SRV02 Position Control Design.vi used in Section 2.3.1.1.

2. Run the VI.


3. Enter the PD gains you found in Section 2.2 in the VI.

4. Go to the Closed Loop Step Response tab.


5. Are the specifications in Section 2.1.1.2 satisfied?

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?

10. Stop the VI.

2.3.2.2 TDD Control Simulation

We will now simulate the closed-loop servo position control using a more realistic model (e.g. one that includes the
saturation block).

SRV02 Workbook - Student Version 30


1. Open SRV02 Position Control | SRV02 Control Design and Simulation | SRV02 Manual Control PD.vi.
2. Run the VI.
3. Enter the TDD control gains found in Section 2.3.2.1 in the VI. Show the position response and the resulting
motor voltage, i.e., control effort.
4. Measure the overshoot, settling time, and steady-state error. Do they satisfy the TDD specifications listed
in Section 2.1.1.2? Show your calculations and make sure the PD gains used and the resulting overshoot,
settling time, and steady-state error values are given in your answer.
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.
5. Stop the VI.

2.3.2.3 TDD Control Implementation

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.

Figure 2.11: VI used to implement PD control on SRV02

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.

SRV02 Workbook - Student Version v 1.0


Figure 2.12: Running a sample PD control on the SRV02

6. Attach images of the position and voltage responses.


7. Do the simulated and measured responses match? Attach a closeup of the transient position response when
the reference step goes up and give one reason why there is a discrepancy between the two.
8. Measure the overshoot, settling time, and steady-state of the measured response and enter them below. Are
the specifications when controlling the actual servo satisfied? If the specifications have been met, enter the
measured PO, ts , and ess values in Table 2.1. If not, go to the next step.

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.

11. Stop the VI.


12. Turn off the power amplifier.

SRV02 Workbook - Student Version 32


2.3.3 Results
Fill out Table 2.1 with your answers from your TDD control lab results - both simulation and implementation.

From Section Description Symbol Value Unit


2.3.1 Frequency-Based Design (FBD)
Proportional gain kp V/rad
Derivative gain kd V-s/rad
Phase margin PM deg
Bandwidth frequency ωbw rad/s
Settling time ts s
Percentage overshoot PO %
2.3.2.2 Time-Domain Design (TDD) Simulation
Proportional gain kp V/rad
Derivative gain kd V-s/rad
Phase margin PM deg
Bandwidth frequency ωbw rad/s
Settling time ts s
Percentage overshoot PO %
Steady-state error ess %
2.3.2.3 Time-Domain Design (TDD) Implemen-
tation
Proportional gain kp V/rad
Derivative gain kd V-s/rad
Settling time ts s
Percentage overshoot PO %
Steady-state error ess %
2.3.2.3 Time-Domain Design (TDD) Implemen-
tation - Tuned
Proportional gain kp V/rad
Derivative gain kd V-s/rad
Settling time ts s
Percentage overshoot PO %
Steady-state error ess %

Table 2.1: Summary of results for the SRV02 Position Control laboratory.

SRV02 Workbook - Student Version v 1.0


2.4 System Requirements
Required Hardware

• 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

2.4.1 Overview of Files

File Name Description


SRV02 Manual (Student).pdf This laboratory guide contains pre-lab questions and lab ex-
periments demonstrating how to design and implement a po-
sition controller on the Quanser SRV02 rotary plant using Lab-
VIEW™ .
SRV02 Position Control (Student).lvproj LabVIEW project containing the student-based VIs.
SRV02 Position Control Design (Stu- VI used to design the PD controller. The SRV02 model has
dent).vi not been enterred (e.g., to be completed by the student).
SRV02 PD Control Simulation (Stu- Simulates the PD closed-loop response of the SRV02. The
dent).vi model has not been enterred and the feedback loop is not com-
pleted.
SRV02 PD Control (Student).vi Implement PD controller on the SRV02. Control loop not com-
pleted.

Table 2.2: Files supplied with the SRV02 Position Control laboratory.

2.4.2 Hardware Setup


Follow these steps to get the system hardware ready for this lab:

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.

SRV02 Workbook - Student Version 34


3. Install the disc load on the top gear.

Note: If you are using the NI CompactRIO, then see the SRV02 cRIO User Manual ([3]).

2.4.3 Software Setup


Follow these steps to get the system ready for this lab:

1. Load the LabVIEW™ software.


2. Open the LabVIEW project called SRV02 Position Control (Student).lvproj shown in Figure 2.13.

Figure 2.13: SRV02 Position Control.

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]).

SRV02 Workbook - Student Version v 1.0


2.5 Lab Report
This laboratory contains two experiments, namely,

1. Frequency-Based Design (FBD), and

2. Time-Domain Design (TDD).

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.

SRV02 Workbook - Student Version 36


2.5.1 Template for Content (FBD Experiment)
I. PROCEDURE

I.1. FBD Control Design

• Briefly describe the main goal of the control design.

• Briefly describe the control design procedure (Section 2.3.1.1).

I.2. FBD Simulation

• Briefly describe the main goal of the simulation.

• Briefly describe the simulation procedure (Section 2.3.1.2).

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:

III.1. FBD Control Design

1. Step 5 in Section 2.3.1.1, Frequency-based control design.

III.2. FBD Simulation

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:

1. Step 9 in Section 2.3.1.2, Step response simulation without actuator saturation.

2. Step 10 in Section 2.3.1.2, Assess whether the FBD controller can be implemented on hardware.

SRV02 Workbook - Student Version v 1.0


2.5.2 Template for Content (TDD Experiment)
I. PROCEDURE

I.1 TDD Control Design

• Briefly describe the main goal of the control design.


• Briefly describe the control design procedure (Section 2.3.2.1).

I.2. TDD Simulation

• Briefly describe the main goal of the simulation.


• Briefly describe the simulation procedure (Section 2.3.2.2).

I.3. TDD Implementation

• Briefly describe the main goal of this experiment.


• Briefly describe the experimental procedure (Section 2.3.2.3).

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:

III.1 TDD Control Design

1. Step 8 in Section 2.3.2.1, Time-Domain Controller Design.

III.2. TDD Simulation

1. Step 4 in Section 2.3.2.2, TDD controller simulation with step input.

III.3. TDD Implementation

1. Step 7 in Section 2.3.2.3, Comparing simulated and implemented TDD controller.


2. Step 8 in Section 2.3.2.3, TDD controller implementation with step input.

IV. CONCLUSIONS Interpret your results to arrive at logical conclusions for each of the following:

1. Step 8 in Section 2.3.2.1, Time-domain controller design initial simulation.


2. Step 4 in Section 2.3.2.2, TDD controller simulation with step input.
3. Step 8 in Section 2.3.2.3, TDD controller implementation with step input.
4. Step 10 in Section 2.3.2.3, Tuned TDD controller implementation with step input.

SRV02 Workbook - Student Version 38


2.5.3 Tips for Report Format
PROFESSIONAL APPEARANCE

• Has cover page with all necessary details (title, course, student name(s), etc.)

• Each of the required sections is completed (Procedure, Results, Analysis and Conclusions).
• Typed.

• All grammar/spelling correct.


• Report layout is neat.

• Does not exceed specified maximum page limit, if any.


• Pages are numbered.

• Equations are consecutively numbered.


• Figures are numbered, axes have labels, each figure has a descriptive caption.

• 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.

• References are cited using correct format.

SRV02 Workbook - Student Version v 1.0


SRV02 Workbook - Student Version 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 [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.

SRV02 Workbook - Student Version v 1.0


3.1 Background
3.1.1 Desired Response

3.1.1.1 SRV02 Speed Control Specifications

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)


and
ωg = 75.0 rad/s (3.1.5)

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

In this laboratory we will use the following step setpoint (input):

{
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

SRV02 Workbook - Student Version 42


with the given values the maximum overshoot of the response is

ω(tp ) = 7.75 rad/s (3.1.8)

The closed-loop speed response should therefore not exceed the value given in Equation 3.1.8.

3.1.1.3 Steady State Error

Consider the speed control system with unity feedback shown in Figure 3.1. Let the compensator be C(s) = 1.

Figure 3.1: Unity feedback loop.

We can find the steady-state error using the final value theorem:

ess = lim s E(s) (3.1.9)


s→0

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

Applying the final-value theorem to the system gives


( )
τs+1
ess = R0 lim (3.1.13)
s→0 τs+1+K

When evaluated, the resulting steady-state error due to a step response is


R0
ess = (3.1.14)
1+K

3.1.2 PI Control Design

3.1.2.1 Closed Loop Transfer Function

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)

SRV02 Workbook - Student Version v 1.0


Figure 3.2: Block diagram of SRV02 PI speed control.

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.

We can take Laplace transform of the controller given in Equation 3.1.15:

ki (Ωd (s) − Ωl (s))


Vm (s) = kp (bsp Ωd (s) − Ωl (s)) + (3.1.16)
s
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 (3.1.17)
Ωd (s) s τ + (1 + K kp ) s + K ki

3.1.2.2 Finding PI Gains to Satisfy Specifications

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 .

SRV02 Workbook - Student Version 44


The denominator of the transfer function can be re-structured into the following:
(1 + K kp ) s K ki
s2 + + (3.1.22)
τ τ
equating the coefficients of this equation to the coefficients of the standard characteristic equation gives:
K ki
= ωn2 (3.1.23)
τ
and
1 + K kp
= 2 ζ ωn (3.1.24)
τ
Then, the proportional gain kp can be found as:
−1 + 2 ζ ωn τ
kp = (3.1.25)
K
and the integral gain ki is
ωn2 τ
ki = (3.1.26)
K

3.1.3 Lead Control Design


Alternatively, a lead or lag compensator can be designed to control the speed of the servo. The lag compensator is
actually an approximation of a PI control and this, at first, may seem like the more viable option. However, due to the
saturation limits of the actuator the lag compensator cannot achieve the desired zero steady-state error specification.
Instead, a lead compensator with an integrator, as shown in Figure 3.3, will be designed.

Figure 3.3: Closed-loop SRV02 speed control with lead compensator.

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

SRV02 Workbook - Student Version v 1.0


3.1.3.1 Finding Lead Compensator Parameters

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


1 + a T ωj
Glead (ω j) = (3.1.31)
1+T ωj
and its corresponding magnitude and phase equations are

T 2 ω 2 a2 + 1
|Glead (ω j)| = (3.1.32)
1 + T 2 ω2
and
ϕG = arctan(a T ω) − arctan(T ω) (3.1.33)
The Bode plot of the lead compensator is shown in Figure 3.4.

Figure 3.4: Bode of lead compensator.

3.1.3.2 Lead Compensator Design Steps

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.

SRV02 Workbook - Student Version 46


% 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);

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.

Figure 3.5: Bode of Pi (s) system.

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

ϕm = P Mdes − P Mmeas + 5 (3.1.34)

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

SRV02 Workbook - Student Version v 1.0


Figure 3.6: Bode of Lp (s) = Kc Pi (s) system.

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.

Figure 3.7: Bode of lead compensator Clead (s).

SRV02 Workbook - Student Version 48


6. Bode plot of the loop transfer function L(s), as described in 3.1.30, is shown in Figure 3.8. Measure the
phase margin and crossover frequency on the Bode of L(s) and determine whether or not the frequency-
domain specifications given in Section 3.1.1 have been met.

Figure 3.8: Bode of loop transfer function L(s).

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.

3.1.4 Sensor Noise


When using analog sensors, such as a tachometer, there is often some inherent noise in the measured signal.

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

eω = 0.525 rad/s (3.1.39)

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?

SRV02 Workbook - Student Version v 1.0


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:
( )
PO 1
ω(tp ) = ωd (t0 ) + (ωd (t) − ωd (t0 )) 1 + + eω (3.1.40)
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-to-
peak ripple estimate in Equation 3.1.39, the peak speed of the load gear, including the noise, can be found as:

ω(tp ) = 8.01 rad/s (3.1.41)

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)

SRV02 Workbook - Student Version 50


3.2 Pre-Lab Questions
1. Based on the steady-state error result of a step response from Equation ,what type of system is the SRV02
when performing speed control (Type 0, 1, or 2) and why?

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).

SRV02 Workbook - Student Version v 1.0


3.3 Lab Experiments
The main goal of this laboratory is to explore closed-loop speed control of the SRV02 load shaft.

In this laboratory you will conduct two experiments:

1. Step response with PI control, and


2. Step response with Lead control

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 Step Response with PI Control

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.

SRV02 Workbook - Student Version 52


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. 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:

• Signal Type: Square


• Amplitude: 2.5
• Offset: 5.0
• Frequency: 0.4

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.

3.3.1.2 Implementing PI Speed Control

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.

SRV02 Workbook - Student Version v 1.0


Figure 3.10: LabVIEW VI used to run the PI and Lead speed controllers on the SRV02.

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?

SRV02 Workbook - Student Version 54


12. Click the Stop button to stop the VI.
13. Turn off the power to the amplifier if no more experiments will be performed on the SRV02 in this session.

3.3.2 Step Response with LEAD Control

3.3.2.1 Control Design

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.

SRV02 Workbook - Student Version v 1.0


6. Step 2: Find how much more gain is required. Find gain Kc that is needed to bring the Pi (s) PM crossover
frequency to 50.0 rad/s. For your initial estimate, use the cursor on the Magnitude Plot: Pi (s) to find the
appropriate gain. Enter the gain in the Kc (dB) input on the VI (in decibels). To confirm that the phase margin
frequency is at around 50 rad/s, go to the Open-Loop+Gain tab. This shows the Bode of Pi (s) with the gain
you just added, i.e., system Lp (s) = Kc Pi (s), and displays the crossover frequency in the P.M. Frequency
indicator. Tune your Kc gain if necessary. Show the magnitude Bode of Kc Pi (s) (when exporting, make sure
to select the Hide Grid option).

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:

• Signal Type: Square


• Amplitude: 2.5 rad/s
• Offset: 5.0 rad/s
• Frequency: 0.4 Hz

SRV02 Workbook - Student Version 56


5. To engage the lead control, set the Manual Switch to the downward position.

6. Run the VI.


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 cursor in the Servo Speed (rad/s)
Graph found in the Measure tab (after the VI is stopped).

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.

3.3.2.3 Implementing LEAD Speed Control

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:

• Signal Type: Square


• Amplitude: 2.5 rad/s
• Offset: 5.0 rad/s
• Frequency: 0.4 Hz
5. To engage the lead control, set the Manual Switch to the downward position.

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.

SRV02 Workbook - Student Version v 1.0


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.

Section / Ques- Description Symbol Value Unit


tion
Question 2 Pre-Lab: PI Gains
Proportional Gain kp
Integral Gain ki
Open-Loop Time Constant τ
Open-Loop Steady-state Gain K
Question 4 Pre-Lab: DC Gain Estimate
DC Gain Estimate of Pi (s) |Pi (1)|
Question 5 Pre-Lab: Gain Crossover Frequency
Gain crossover frequency ωg
Section 3.3.1.1 In-Lab: PI Step Response Simulation
Peak time tp
Percent overshoot PO
Steady-state error ess
Section 3.3.1.2 In-Lab: PI Speed Control Implementa-
tion
Measured peak-to-peak ripple eω,meas
Steady-state error ess
Peak time tp
Percent overshoot PO
Section 3.3.2.2 In-Lab: Step Response Simulation
with Lead Control
Peak time tp
Percent overshoot PO
Steady-state error ess
Section 3.3.2.3 In-Lab: Lead Speed Control Imple-
mentation
Peak time tp
Percentage overshoot PO
Steady-state error ess

Table 3.1: Summary of results for the Speed Control laboratory.

SRV02 Workbook - Student Version 58


3.4 System Requirements
Required Hardware

• 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

3.4.1 Overview of Files

File Name Description


SRV02 Manual (Student).pdf This laboratory guide which contains pre-lab questions and
lab experiments demonstrating how to design and implement
a speed controller on the Quanser SRV02 rotary plant using
LabVIEW™ .
Quanser SRV02 Speed Control.lvproj LabVIEW project containing the SRV02 speed control VIs.
SRV02 Lead Control Design.vi VI used to design the Lead compensator.
SRV02 Speed Control Simulation.vi Simulates both the PI and LEAD closed-loop response of the
SRV02.
SRV02 Speed Control.vi Implements PI and LEAD controllers on the SRV02.

Table 3.2: Files supplied with the SRV02 Speed Control laboratory.

3.4.2 Software Setup


Follow these steps to get the system ready for this lab:

1. Load the LabVIEW™ software.


2. Open the LabVIEW project called Quanser Speed Control.lvproj shown in Figure 3.12.

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').

SRV02 Workbook - Student Version v 1.0


Figure 3.12: SRV02 Speed Project.

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]).

SRV02 Workbook - Student Version 60


3.5 Lab Report
This laboratory contains two experiments, namely,

1. Step response with PI control, and

2. Step response with lead control.

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.

SRV02 Workbook - Student Version v 1.0


3.5.1 Template for Content (PI Control Experiments)
I. PROCEDURE

I.1. Step Response with PI Control

1. Simulation

• Briefly describe the main goal of this simulation.


• Briefly describe the procedure (Section 3.3.1.1)
2. Implementation

• Briefly describe the main goal of this experiment.


• Briefly describe the experimental procedure (Section 3.3.1.2)

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

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 9 in Section 3.3.1.1, Step response simulation with PI Control

2. Step 10 in Section 3.3.1.2, Step response implementation with PI Control


3. Step 11 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 9 in Section 3.3.1.1, Step response simulation with PI Control

2. Step 10 in Section 3.3.1.2, Step response implementation with PI Control


3. Step 11 in Section 3.3.1.2, Step response implementation with PI Control

SRV02 Workbook - Student Version 62


3.5.2 Template for Content (Lead Control Experi-
ments)
I. PROCEDURE

I.1. Step Reponse with Lead Control

1. Control Design

• Briefly describe the main goal of the control design.


• Briefly describe the procedure (Section 3.3.2.1).
2. Simulation

• Briefly describe the main goal of this simulation.


• Briefly describe the procedure (Section 3.3.2.2)
3. Implementation

• Briefly describe the main goal of this experiment.


• Briefly describe the experimental procedure (Section 3.3.2.3)

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.

5. 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. Lead Control Design

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 .

III.2. Step Response with Lead Control

1. Step 7 in Section 3.3.2.2, Step response simulation with Lead Control.

2. Step 8 in Section 3.3.2.3, Step response implementation with Lead Control.

SRV02 Workbook - Student Version v 1.0


IV. CONCLUSIONS
Interpret your results to arrive at logical conclusions for the following:

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

3. Step 8 in Section 3.3.2.3, Step response implementation with Lead Control


4. Step 9 in Section 3.3.2.3, Step response implementation with Lead Control

SRV02 Workbook - Student Version 64


3.5.3 Tips for Report Format
PROFESSIONAL APPEARANCE

• Has cover page with all necessary details (title, course, student name(s), etc.)

• Each of the required sections is completed (Procedure, Results, Analysis and Conclusions).
• Typed.

• All grammar/spelling correct.


• Report layout is neat.

• Does not exceed specified maximum page limit, if any.


• Pages are numbered.

• Equations are consecutively numbered.


• Figures are numbered, axes have labels, each figure has a descriptive caption.

• 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.

• References are cited using correct format.

SRV02 Workbook - Student Version v 1.0


SRV02 Workbook - Student Version 66
Appendix A

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).

• Quanser SRV02-ET rotary servo. See Reference [4].


• Quanser VoltPAQ power amplifier, or equivalent (e.g. Reference [2] for VoltPAQ User Manual).

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™ .

SRV02 Workbook - Student Version v 1.0


A.1 Applying Voltage to SRV02
Motor
Topics Covered

• Adding Simulation Loop and configuring the simulation parameters.

• 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.

A.1.1 Configuring the Simulation Loop


In this section, we will design a new LabVIEW™ Virtual Instrument (VI) to apply a sinusoidal voltage to the SRV02
DC motor. The completed block diagram of the VI is shown in , as shown in Figure A.1. The Quanser Rapid Control
Prototyping Toolkitr drivers are used to interact with a data-acquisition board, e.g., NI PCIe-6251 device.

Figure A.1: Block diagram used to apply voltage to SRV02

Follow these steps to make the LabVIEW block diagram:

1. Load the LabVIEW™ software.


2. Create a new, blank Virtual Instrument (VI).

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

SRV02 Workbook - Student Version 68


Figure A.2: Create a Simulation Loop in the block diagram

• ODE Solver: Runge-Kutta 1 (Euler)


• Step Size (s): 0.01

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).

7. Click on the OK button to apply the changes.

A.1.2 Interfacing to the DC Motor


1. Add the HIL Initialize VI from the Quanser Rapid Control Prototyping Toolkit palette.
2. When added a prompt will appear. Under Board type, select the data acquisition device that you will be using.

3. Click on OK.
4. Add the following VIs:

• HIL Write VI from Quanser Rapid Control Prototyping Toolkit.


• Sine Signal block from the Control Design & Simulation | Simulation | Signal Generation palette.
5. As shown in Figure A.1, connect Sine Signal block to the analog voltages terminal of HIL Write VI.

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.

SRV02 Workbook - Student Version v 1.0


(a) Simulation Parameters (b) Timing Parameters

Figure A.3: Simulation Loop Parameters Dialog

A.1.3 Running the VI


Here are the steps to run the VI designed in the previous section:

1. Make sure the SRV02, DAQ, and amplifier are connected as described in SRV02 User Manual (see [4]).

2. Power ON your power amplifier (e.g., Quanser VoltPAQ-X1).

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.

5. Click on the Stop button to stop the VI.


6. Power OFF the amplifier if no more experiments will be run in this session.

SRV02 Workbook - Student Version 70


A.2 Reading Position using
Potentiometer
In this section, the LabVIEW VI previously designed in Section A.1 is modified to obtain readings from the poten-
tiometer sensor.

Topics Covered

• Add and configure Quanser Rapid Control Prototyping Toolkitr drivers to read potentiometer sensor.
• Use SimTime Waveform Simulation blocks to plot potentiometer reading.

• Calibrate sensor to read degrees using Gain block.

A.2.1 Interfacing to the Potentiometer


In this section, the VI shown in Figure A.4 is built to read the potentiometer voltage.

Figure A.4: VI used to read potentiometer

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.

5. Power ON the power amplifier.

SRV02 Workbook - Student Version v 1.0


6. Run the VI. As the SRV02 rotates back-and-forth, the chart should display the potentiometer readings similar
as shown in Figure A.5. Notice that the readings are the voltage output of the potentiometer and not an angular
measurement in degrees or radians.

Figure A.5: Reading raw voltage from the SRV02 potentiometer

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.

Figure A.6: Potentiometer reading when encountering its discontinuity

7. Click on the Stop button to stop the VI.

A.2.2 Measuring Position


The VI will now be modified to measure the servo load angle from the potentiometer as shown in Figure A.7.

Modify the VI built in the previous section following these steps:

SRV02 Workbook - Student Version 72


Figure A.7: VI used to send voltage to the SRV02 and read its load shaft angle using potentiometer.

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:

• amplitude Parameter Source: terminal


• frequency Parameter Source: terminal
4. Add the amplitude and frequency control, as illustrated in Figure A.7. Do this by right-clicking on the amplitude
terminal and selecting Create | Control. Similarly create a control for frequency.
5. From Control Design & Simulation | Simulation | Signal Arithmetic palette, add a Gain block to the VI and
connect it between the Index Array and scope blocks as shown in Figure A.7.
6. As described in [4], the potentiometer outputs between ± 5 V when it rotated 352 degrees. Enter the value
352/10=35.2 in the Gain block.
7. Make sure your amplifier is powered ON.

8. On the front panel, set the amplitude to 0.

9. Run the VI.


10. Manually rotate the load gear and examine the corresponding response in the Pot Position (deg) chart. Confirm
that, indeed, the correct measurement is being taken.
11. Position the load gear such that 0 is read in the scope.

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.

SRV02 Workbook - Student Version v 1.0


Figure A.8: Reading the SRV02 load angle using the potentiometer.

SRV02 Workbook - Student Version 74


A.3 Measuring Speed using
Tachometer
In this section, we will modify the VI designed in Section A.2 to include the reading from the tachometer. The
completed block diagram of the VI is depicted in Figure A.9.

(a) Reading both the potentiometer and tachometer

(b) Reading the tachometer

Figure A.9: Measuring speed with the tachometer.

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

SRV02 Workbook - Student Version v 1.0


on #0), then do the following:
(a) Double-click on the HIL Read VI.
(b) Under Polymorphic instances, select Analog (vector) and set the second array element to 1 as shown in
Figure A.10. This will allow you to read from channel #0 and #1.

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.

SRV02 Workbook - Student Version 76


Figure A.11: Velocity reading using tachometer.

SRV02 Workbook - Student Version v 1.0


A.4 Measuring Position using
Encoder
The VI designed previously is modified to include an encoder measurement, as illustrated in Figure A.12 below.

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.

SRV02 Workbook - Student Version 78


Figure A.13: SRV02 load gear measurement using encoder.

SRV02 Workbook - Student Version v 1.0


A.5 Saving Data
Data plotted in the Charts and Graphs in LabVIEW can be exported to various formats for offline analysis or to add
to reports.

Consider the encoder position response obtained in Figure A.14. The procedure below will show you how to save
this response as a bitmap.

Figure A.14: Sample encoder data

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.

Figure A.15: Export Simplified Image Dialog

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.

SRV02 Workbook - Student Version 80


Figure A.16: Plotting saved data

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.

SRV02 Workbook - Student Version v 1.0


SRV02 Workbook - Student Version 82
BIBLIOGRAPHY

[1] Quanser Inc. Q2-USB User's Manual, 2010.

[2] Quanser Inc. VoltPAQ User's Manual, 2010.


[3] Quanser Inc. SRV02 cRIO User Manual, 2011.

[4] Quanser Inc. SRV02 User Manual, 2011.

SRV02 Workbook - Student Version v 1.0


Over ten rotary experiments for teaching fundamental and advanced controls concepts

Rotary Servo Base Unit Inverted Flexible Link Flexible Joint


Pendulum

Ball and Beam Double Inverted Gyro/Stable 2 DOF Robot


Pendulum Platform

2 DOF Inverted 2 DOF Gantry Multi-DOF Torsion


Pendulum

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.

[email protected] +1-905-940-3575 QUANSER.COM


Solutions for teaching and research. Made in Canada.

You might also like