Rotary Motion Servo Plant: SRV02
Rotary Experiment #08:
Inverted Pendulum Control
Inverted Pendulum Control using QUARC
Quick-Start Guide
SRV02 SESIP Quick-Start Guide
Table of Contents
1. INTRODUCTION..........................................................................................................................................1
2. PREREQUISITES.........................................................................................................................................1
3. OVERVIEW OF FILES..................................................................................................................................2
4. IN-LAB PROCEDURES.................................................................................................................................3
4.1. Control Implementation....................................................................................................................3
4.1.1. Setup for Control Implementation..........................................................................................................4
4.1.2. Implement Balance Controller...............................................................................................................4
4.1.3. Implement Swing-Up Controller............................................................................................................4
5. REFERENCES.............................................................................................................................................5
Document Number 802 ♦ Revision 1.0 ♦ Page i
SRV02 SESIP Quick-Start Guide
1. Introduction
In industry, the crane is often used to transport items from one place to another. The gantry experiment
involves developing a control system for a crane traveling on a moving platform. In this case, the crane
is represented by the suspended pendulum and the rotary arm behaves as the moving platform that
transports the crane at different locations. The objective of the Gantry experiment is for the servo to
track a desired angle while minimizing the swinging motion of the pendulum. Practically speaking, the
algorithm developed regulates the movements of the gantry and keeps the crane steady in the vertical
down position such that items can be transported safely. Productivity is also an issue, therefore the
state-feedback system developed must satisfy a set of requirements that include the speed at which it
can transport items.
The following topics are covered in this laboratory:
● Design a Linear-Quadratic Regulator (LQR) to control the position of the servo load shaft while
balancing the pendulum according to certain time-domain requirements.
● Simulate the control using the model of the plant and ensure the specifications are met without
any actuator saturation.
● Implement the controllers on the Quanser SRV02 Inverted Pendulum device and evaluate its
performance.
Regarding Gray Boxes:
Gray boxes present in the instructor manual are not intended for the students as they provide
solutions to the pre-lab assignments and contain typical experimental results from the laboratory
procedure.
2. Prerequisites
In order to successfully carry out this laboratory, the user should be familiar with the following:
● Data acquisition card (e.g. Q8), the power amplifier (e.g. UPM), and the main components of
the SRV02 (e.g. actuator, sensors), as described in References [1], [4], and [5], respectively.
● Wiring and operating procedure of the SRV02 plant with the UPM and DAC device, as
discussed in Reference .
● Laboratory described in Reference [6] in order to be familiar using Quarc with the SRV02.
● Designing a PV position control for the SRV02 as dictated in Reference [8].
Document Number 802 ♦ Revision 1.0 ♦ Page 1
SRV02 SESIP Quick-Start Guide
3. Overview of Files
Table 1 below lists and describes the various files supplied with the SRV02 Gantry Control laboratory.
File Name Description
18 – Rotary Pendulum User This manual describes the hardware of the Rotary Pendulum and
Manual.pdf explains how to setup and wire the system for the experiments.
20 – Gantry Control – Instructor This laboratory guide contains pre-lab and in-lab exercises
Manual.pdf demonstrating how to design and implement a inverted pendulum
controller on the Quanser SRV02 Single-Inverted Pendulum (SIP)
plant using Quarc. Not competed yet.
setup_srv02_exp08_sip.m The main Matlab script that sets the SRV02 motor and sensor
parameters, the SRV02 configuration-dependent model parameters,
and the SIP sensor parameters. Run this file only to setup the
laboratory.
config_srv02.m Returns the configuration-based SRV02 model specifications Rm,
kt, km, Kg, eta_g, Beq, Jeq, and eta_m, the sensor calibration
constants K_POT, K_ENC, and K_TACH, and the UPM limits
VMAX_UPM and IMAX_UPM.
setup_sp_configuration.m Returns the pendulum model parameters g, Mp, Lp, lp, Jp, and Bp,
as well as the rotpen identifier variable RtpnOp and the angle offset
RtpnOff.
d_model_param.m Calculates the SRV02 model parameters K and tau based on the
device specifications Rm, kt, km, Kg, eta_g, Beq, Jeq, and eta_m.
calc_conversion_constants.m Returns various conversions factors.
q_sip.mdl Simulink file that implements the designed state-feedback balance
controller on the actual SRV02 SIP system using Quarc.
q_sesip.mdl Simulink file that implements the swing-up and balance controller
on the actual SRV02 SIP system using Quarc when using the
Quanser UPM with some type of DAQ board.
q_sesip_q3.mdl Simulink file that implements the swing-up and balance controller
on the actual SRV02 SIP system using Quarc when using the
Quanser Q3 board only.
Furutapaper.pdf Research paper from which the algorithm was based on
SRV02 Energy-Based Swing-Up Shows the derivation of the swing-up controller specifically for the
(.mws or .html) SRV02.
SRV02+SIP Equations - Classic Derives the kinematics, nonlinear model, as well as the linear state-
(.mws or .html) space model (which is used to design the balance controller).
Document Number 802 ♦ Revision 1.0 ♦ Page 2
SRV02 SESIP Quick-Start Guide
File Name Description
Table 1: Files supplied with the SRV02 SESIP Control experiment.
4. In-Lab Procedures
The closed-loop response of the Gantry is simulated in Section and then implement on the actual
SRV02 Single-Pendulum Gantry device in Section 4.1.
4.1. Control Implementation
The q_sesip_q3 Simulink diagram shown in Figure 1 is used to control the SRV02 Rotary Pendulum
device using the Quarc software. The SRV02-ET+ROTPEN (-E) subsystem contains Quarc blocks that
interface with the DC motor and sensors of the Rotary Pendulum system.
Figure 1: Simulink model used with Quarc to swing-up and balance the SRV02+SESIP system.
Document Number 802 ♦ Revision 1.0 ♦ Page 3
SRV02 SESIP Quick-Start Guide
Go through the steps in Section 4.1.1 to setup the lab files in order to run the controller on the inverted
pendulum system.
4.1.1. Setup for Control Implementation
Before beginning the in-lab exercises on the Gantry device, the q_sesip or q_sesip_q3 Simulink
diagrams and the setup_srv02_exp08_sip.m script must be configured.
Follow these steps to get the system ready for this lab:
1. Setup the SRV02 with the SIP module as detailed in Reference [9].
2. Load the Matlab software.
3. Browse through the Current Directory window in Matlab and find the folder that contains the
Quarc SIP control file, either q_sesip.mdl when using the UPM or q_sesip_q3.mdl when using
the Q3 board.
4. Double-click on the file to open the Rotary Gantry Control Simulink diagram shown in Figure
1.
5. Configure DAQ: Ensure the HIL Initialize block in the SRV02-ET+ROTPEN (-E) subsystem is
configured for the DAQ device that is installed in your system. By default, the block is setup for
the Quanser Q8 hardware-in-the-loop board. See Reference [6] for more information on
configuring the HIL Initialize block.
6. Configure setup script: Set the parameters in the setup_srv02_exp08_sip.m script according to
your system setup.
4.1.2. Implement Balance Controller
Follow this procedure to manually bring up the pendulum and balance the pendulum (i.e. no automatic
swing-up):
1. Setup the lab files as described in Section 4.1.1 (ensure UPM_TYPE is properly set) and run the
setup_srv02_exp08_sip.m script. The Command Window in Matlab should show a generated
gain.
2. Turn on the amplifier.
3. Set the Swing Up switch in the Simulink diagram to the downward position to turn off the
swing-up.
4. Click on Quarc | Build to compile the Simulink diagram.
5. Ensure the pendulum is motionless and in the downward vertical position.
6. Click on QuaRC | Start to begin running the controller.
7. Rotate the pendulum and bring into the upright position. Release the pendulum immediately
when the controller is engaged.
8. To run off the controller, click on the Stop button in the Simulink model tool bar and catch the
pendulum manually.
9. Make sure to run off the amplifier if the laboratory if complete.
4.1.3. Implement Swing-Up Controller
Document Number 802 ♦ Revision 1.0 ♦ Page 4
SRV02 SESIP Quick-Start Guide
Follow this procedure to perform the swing-up controller:
1. Setup the lab files as described in Section 4.1.1 (ensure UPM_TYPE is properly set) and run the
setup_srv02_exp08_sip.m script. The Command Window in Matlab should show a generated
gain.
2. Turn on the amplifier.
3. Set the Swing Up switch in the Simulink diagram to the upward position to turn on the swing-
up.
4. Ensure the mu gain block is set to 0.8.
5. Ensure the pendulum is motionless and in the downward vertical position.
6. Click on Quarc | Build to compile the Simulink diagram.
7. Click on QuaRC | Start to begin running the controller. The pendulum should begin swinging
back-and-forth. If it does not, ensure the amplifier is on or give the pendulum a slight
disturbance.
8. Try running controller the Slider Gain called mu at 0.8 (default). If it does not work, then set it
to 0.5 and increase it by 0.05 increments until the swing-up can be performed well. If the swing-
up attempts take too much rotation, increase mu so it's quicker. If it goes to fast for the swing-
up, then lower the mu factor.
9. To run off the controller, click on the Stop button in the Simulink model tool bar and catch the
pendulum manually.
10. Make sure to run off the amplifier if the laboratory if complete.
Remark: Make sure the high-gears on the servo are not loose. Tighten the screws! Otherwise when in
the balance mode the servo will go back and forth at a very high-frequency.
5. References
[1] Quanser. Q4/Q8 User Manual.
[2] Quanser. Quarc HTML Help Files.
[3] Quanser. Quarc Installation Manual.
[4] Quanser. UPM User Manual.
[5] Quanser. SRV02 User Manual.
[6] Quanser. SRV02 Quarc Integration.
[7] Quanser. Rotary Experiment #1: SRV02 Modeling.
[8] Quanser. Rotary Experiment #2: SRV02 Position Control.
[9] Quanser. Rotary Pendulum User Manual.
Document Number 802 ♦ Revision 1.0 ♦ Page 5