SRV02 Exp7 Inverted Pendulum Solution

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

SRV02-Series

Rotary Experiment # 7

Inverted Pendulum

This document details the necessary laboratory setup required for the Inverted Pendulum
experiment.
Included are descriptions of all the files accompanying the experiment.
This document includes a solutions set for the accompanying laboratory experiment
designed by Quanser.

All of Quansers systems have an inherent open architecture design. It should


be noted that the following experimental setup, accompanying files and
configuration are merely one of the many possible uses of this product.

Instructor Manual
SRV02-Series
Rotary Experiment # 7

Inverted Pendulum
Instructor Manual
1. System Requirements

To complete this Lab, the following hardware is required:

[1] Quanser UPM 2405/1503 Power Module or equivalent.


[1] Quanser MultiQ PCI / MQ3 or equivalent.
[1] Quanser SRV02 Servo plant.
[1] Quanser ROTPEN Rotary Pendulum Module.
[1] PC equipped with the required software as stated in the WinCon User Manual.

The required configuration of this experiment is the SRV02 in the High-Gear


configuration along with a ROTPEN Rotary Pendulum Module as well as a UPM
2405/1503 power module and a suggested gain cable of 1.

2. Configuring the Laboratory Set-up

Once the experimental setup is connected as documented in the SRV02 Rotary


Pendulum User Manual, you should open the MATLAB script file Setup_
SRV02_Exp7.m. This script will initialize all the required workspace variables and
system parameters. There is a user-defined section of this script file that must be set
according to the configuration of the lab:

% ############### USER-DEFINED SRV02 CONFIGURATION ################################


% External Gear Configuration: set to 'HIGH' or 'LOW'
EXT_GEAR_CONFIG = 'HIGH';
% Encoder Type: set to 'E' or 'EHR'
ENCODER_TYPE = 'E';
% Is the SRV02 equipped with a Tachometer? (i.e. option T): set to 'YES' or 'NO'
TACH_OPTION = 'YES';
% Universal Power Module (UPM) Type: set to 'UPM_2405', 'UPM_1503', or 'UPM_1503x2'
UPM_TYPE = 'UPM_2405';
% Type of Load: set to 'NO_LOAD', 'DISC_LOAD', 'BAR_LOAD', 'SLIP_RING', 'ROTFLEX', 'FLEXGAGE' or 'ROTPEN'
LOAD_TYPE = 'ROTPEN';
% Cable Gain used: set to 1, 3, or 5
K_CABLE = 1;
% ############### END OF USER-DEFINED SRV02 CONFIGURATION #########################

Note: The settings that you see above are the recommended configuration of this
experiment. It is up to you the instructor to ensure that these settings match the
configuration of your particular setup.

Page # 2 Revision: 01
Further along in the setup file, you will find a section that pertains to the actual Pendulum
Configuration:

% ############### USER-DEFINED PENDULUM CONFIGURATION ################################

% Pendulum Type attached: set to 'MEDIUM' or 'LONG'


PENDULUM_TYPE = 'MEDIUM';
% Pendulum Start Position: set to 'UP' or 'DOWN'
% To Run the Pendulum-SE Controller, the Pendulum Start Position must be set to "DOWN"
PENDULUM_START = 'UP';

% ############### END OF USER-DEFINED PENDULUM CONFIGURATION #########################

Use this section to configure the setup to match your exact experimental setup. The
default settings shown above are recommend for this experiment. We recommend
switching this setting to the 'DOWN' start position only if you also intend to run the Self-
Erecting Pendulum controller as well.

Figure 1 - PENDULUM_START = 'UP' Figure 2 - PENDULUM_START = 'DOWN'

The above 2 figures show the 2 different starting locations of the pendulum experiment.
You should also notice the location of the pendulum on the shaft. If the pendulum is in
the 'UP' configuration, make sure it starts with the pendulum lying flush to the stopper. In
the 'DOWN' position, the pendulum should be fastened at the end of the shaft.

If at any point you are unsure about your own configuration, please refer to the SRV02
User Manual and/or the SRV02 Rotary Pendulum User Manual. You may also contact
our technical support directly through www.Quanser.com.

Page # 3 Revision: 01
2.1 Configuring the Controller

Further in the script file (Setup_SRV02_Exp7.m), there is a section that will set whether
this script calls the controller design function. The controller design function
(d_SRV02_Inverted_Pendulum.m) calculates the optimal controller gains and sends
them to the MATLAB workspace. The user-defined controller specification section is as
follows:

% ############### USER-DEFINED CONTROLLER SPECIFICATIONS #########################

% Student Configuration: Set to 'MANUAL' if you want the student to calculate gains
% or set to 'AUTO' if you would like this script to set the gains
% to meet the desired specifications
Student_Config = 'MANUAL';

% ############### END OF USER-DEFINED CONTROLLER SPECIFICATIONS ##################

In this section you can select if you would like this script to return the controller gains
(AUTO) or have the students themselves calculate and enter the gains (MANUAL). It
is suggested that the instructor run this script file in the AUTO mode as to have the
optimal controller gains that meet the requirements and have the students run this script
file in the MANUAL mode as part of the laboratory procedure is to mathematically
calculate the needed gains to achieve the system requirements.

2.2 Controller Design Function

Each controller provided by Quanser is supplied with a controller design function. For the
rotary Inverted Pendulum controller, the design file (d_SRV02_Inverted_Pendulum.m)
calculates the optimal state-feedback controller gains using the MATLAB LQR function.
Inside the controller design file, you will find the following user-defined controller
specifications:

% ############### USER-DEFINED CONTROLLER SPECIFICATIONS ###########################

if strcmp (PENDULUM_START, 'DOWN')


Q = diag ([5 20 0 0]);
R = 1;
elseif strcmp (PENDULUM_START, 'UP')
Q = diag ([5 20 0 0]);
R = 1.5;
end

% ############### END OF USER-DEFINED CONTROLLER SPECIFICATIONS ####################

The provided controller is the most optimal controller for meeting the required
specifications as mentioned in the Student Handout of this laboratory.

*Note: This design file should not be given to the students as they are intended to
determine the necessary gains required to place the closed-loop poles at the
desired locations.

Page # 4 Revision: 01
2.3 Experiment Files

The following table lists all the provided files that are supplied with this experiment:

File Name Description


SRV02_Exp7_Inverted Pendulum.pdf The Student Handout for this lab. This document outlines the
lab procedure as well as introducing the student to the
experiment with a pre-lab assignment.
SRV02_Exp7_Inverted The Instructor Manual. This is the document that you are
Pendulum_Solution.pdf currently reading. It contains all the required experimental
setup, a list of the accompanying files and the complete
solution to the Student Handout laboratory.
SRV02_Rotary Pendulum_User The User Manual of the Rotary Pendulum module.
Manual.pdf
Setup_SRV02_Exp7.m This is the MATLAB script file that sets all the required
parameters of the system required to run the lab. This file
MUST be executed before running the controller.
Set_SRV02_Configuration.m This is a MATLAB function that contains all the SRV02
system parameters (motor, gearbox, sensors). It is called by
the Setup file.
Set_Pendulum_Configuration.m This is a MATLAB function that contains all the Inverted
Pendulum module parameters (spring stiffness, lengths,
anchor point locations). This function will also return the
complete system state-space representation (A, B, C, D). It is
called by the Setup file.
eqn_SRV02_Pendulum.m This file is generated by Maple and sets the state-space
representation of the SRV02 Inverted Pendulum System.
d_SRV02_Inverted_Pendulum.m This is a MATLAB function that calculates the required
controller gains. This function will return gains that will place
the closed-loop poles at the desired locations.
* This file should not be given to the students if they are
intended to calculate the gains on their own!
s_SRV02_Inverted_Pendulum.mdl This is a Simulink model that contains a simulation of the
Inverted Pendulum system. The students are intended to first
simulate their controller on this model to ensure the system is
behaving as expected before implementing the controller on
the actual system.
s_SRV02_Non_Linear_Pendulum.mdl This is a simulation of the linear & non-linear systems.
q_SRV02_ Inverted_Pendulum .mdl This is a Simulink model that contains the interface to the
actual experimental setup. The students are only supposed to
run this model after simulating their controller. This file is to
be built using WinCon.

Page # 5 Revision: 01
3. Solution Set to the Student Handout

3.1 Post Lab Report

i. In the pre-lab assignment, the students were asked to make some calculations
on the non-linear system model as to the range of alpha that the linear model will
be adequate. This problem can be solved in many ways. The answers the
students provide should be between 20 & 30.

ii. The first task of the laboratory was to vary 2 parameters of the Q matrix and
generate an Iteration Table. This table will have a wide range of entries as it
was left to the student's discretion to pick their own design values. The table
should follow the sample entries shown below:

q1 q2 Theta () Alpha () Alpha Range Control Signal (u)


Settling time (s) Settling time (s) Range
1 1 2.55 2.65 - 3.2 < < 3.2 -1V< u <1V
10 1 1.1 1.51 - 7.2 < < 7.2 - 3.2 V < u < 3.2 V
1 10 2.55 2.67 - 2.9 < < 2.9 -1V< u <1V
Table 1 - Iteration Table : Sample Entries
iii. After filling out the Iteration Table, the students were to come up with the 2 Q
parameter values that would best meet the controller specifications. The optimal
settings were achieved when:

The design values the students should have obtained will probably not be these
exact values but should be relatively similar. The students were also asked to
show that their final controller did meet all required specifications. This should be
done in a table similar to the Iteration Table.

iv. Once the students were satisfied with the simulated results, they were asked to
implement the controller on the experiment. They were also asked to provide a
Measurement Table similar to:

Sample # Alpha Range Control Signal (u) Range


1 -4.5 < < 5.5 -2V< u <2V
.. .. ..
5 -4.7 < < 5.3 - 2.2 V < u < 2.2 V
Average -4.63 < < 5.4 - 2.05 V < u < 2.1 V
Table 2 - Measurement Table - Sample Entries

Page # 6 Revision: 01
The Measurement Table should be used to validate the controller and the
students are asked to show that the controller has met the required
specifications.

v. The students are asked to comment on the performance of their controller on the
actual system as opposed to the simulated results. It is in this analysis that the
student will examine the effects of the controller on physical systems. The
answers for this section are qualitative and it will be left to the instructor's
discretion with regards to the expected answers from the students.

vi. The students are asked to include their final implemented controller gains (this
should be displayed in the MATLAB command window). They should also
include all iterative controllers as was needed to meet the required specifications.

3.2 Post Lab Questions

1) The students are asked for other control techniques they might have used in order to
control the inverted pendulum. Some methods are:

Pole-Placement
Frequency Method Control (Lead/Lag Compensation)
Non-Linear Control
PID Controllers

2) This question requires the students to submit a plot of Theta and show how the
system first will move in the opposite direction before correcting direction and moving
to its desired location. Some mention of Non-Minimum Phase systems should be
discussed in the classroom prior to this laboratory. The inverted pendulum example is
an easy to understand and intuitive example of Non-Minimum Phase systems as the
students can relate to allowing the pendulum to fall in a certain direction before moving
under it to 'Catch' it. A plot of theta like Figure 3 below should be included in the
report. The students should clearly label the Non-Minimum phase response to a step-
input.

Page # 7 Revision: 01
Figure 3 - Theta Plots: Notice the Non-Minimum Phase

3) This question asks the students again to elaborate on the response of the actual
system as compared to the response of the simulated system. The students should
give some quantitative answers and some factors leading to these errors would be:

Errors in the model


Limit Cycle
Non-Linearities in the system
The signals might be saturating

4) The final question asks the student for ways of modifying the model in order to
incorporate the Limit Cycle phenomenon. The only way of simulating this non-linearity
is to model the static and viscous friction which will be non-linear and vary from plant
to plant. This might be project in non-linear modeling and system identification.

Page # 8 Revision: 01

You might also like