Professional Documents
Culture Documents
ger
ger
Batch: BSEE 21
● Modify the stabilizing controller to balance at different rotary positions of the inverted
pendulum.
12.1 Quanser Rotary Inverted Pendulum Board
The Quanser QNET 2.0 Rotary Inverted Pendulum Board for NI ELVIS II, pictured in Figure
1.1, is a versatile servo system designed to teach and demonstrate a variety of inverted
pendulum based experiments. The system is driven using a direct-drive 18 V brushed DC
motor housed in a solid aluminum frame (labeled 1). Single-ended rotary encoders are used
to measure the angular positon of the DC motor and the pendulum. The following diagram
illustrates various components in the board. The encoder for the pendulum is labeled 12 in the
figure and the pendulum rod is labeled 2. There are status LEDs for power at different
voltages and communication with the host computer, labeled 3 and 4 respectively. The 24 V
supply for the motor drive is provided at an external connector labeled 5 and an LED labeled
7 shows its status.
2
No. Description No. Description
1 Motor chamber 9 Motor power connector
2 Pendulum link 10 Encoder connector
3 +5 ,−5 ,+ 15V indicators 11 Encoder connector
4 User and status indicators 12 High resolution encoder
5 24 V power jack 13 Pendulum pivot
6 Fuse 14 DC motor
7 External power indicator 15 Encoder
Table 12-1: Components in the QNET Rotary Inverted Pendulum Board
3
θ
4
Motor and Pendulum Encoders
Encoder line count 512 lines/rev
Encoder line count in quadrature 2048 lines/rev
Encoder resolution in quadrature 0.176 deg/count
Amplifier
Amplifier type PWM
Peak current 2.5 A
Continuous current 0.5 A
Output voltage ±10 V
Table 12-2: Physical parameters of the pendulum system
12.2 Using the Quanser Rotary Inverted Pendulum Board with LabVIEW
12.2.1 Initialization
The initialization blocks provide the necessary functionality to start up and initialize the
motor driver and the rotary encoders. These are placed in the accompanying VI and the user
does not need to change them in any way.
5
12.2.3 Calculating the Angular Velocities of Pendulum and Arm
The angular velocities of the arm and the pendulum can be found by differentiating the
corresponding angular positions available from the blocks shown in Figure 12-4. The
differentiator block is available in the menu Control and Simulation -> Continuous Linear
Systems.
12.2.4 Applying Voltage to the Motor
The blocks shown in Figure 12-5 are used to apply voltage to the motor. Note that it is
important to limit the voltage being sent to the analog write block to within ± 10V to avoid an
error from DAQmx Write block.
6
However, the state space model and the controller need the pendulum angle to be zero at the
upright position. Thus we need the calculation shown in Figure 12-7 for the angle correction.
7
Figure 12-9 shows the signal flow diagram of the state-space model.
In a typical feedback control system, the output, y , is fed back to the summing junction. It is
now that the topology of the design changes. Instead of feeding back y , what if we feed back
all of the state variables? If each state variable is fed back to the control, u, through a gain,
there would be n such gains k i. These gains can be adjusted to yield the required closed-loop
pole values. The negative feedback through the gains, k i, is represented in Figure 12-10 by
the feedback vector −K .
This closed-loop system can itself be represented as a state space model as follows.
ẋ=( A−BK ) x +Br
Y =Cx
Recall that the eigenvalues of the system matrix are the poles of the transfer function. Now
the poles of this system are represented by the eigenvalues of the new system matrix, A−BK .
Therefore, we can use the elements k i of the gain vector K to design the poles of the closed-
loop system with full-state feedback. There are several ways to do this, and the most
straightforward one is using the Ackerman’s formula.
12.3.1 Using the Ackerman’s Formula in MATLAB
The Ackerman’s formula calculates the gain vector K to place the closed loop poles of a
system represented as a state space model, at the locations specified in the row vector P. It is
available in MATLAB with the function acker() in the following format. A and B are the
state and input matrices respectively.
8
K = acker(A, B, P);
2. The controller must be active for a small limited range of pendulum angle to make sure it
does not make the pendulum move violently when the angle is out of this range.
Implement the logic shown in Figure 12-12 to set the motor voltage to zero if the
pendulum angle is outside the range± 0.3 rad . Place a Boolean indicator on the front panel
to indicate when the pendulum is within this range. If you implement this correctly, the
Boolean indicator would light up only when the pendulum is within ± 0.3 rad of the
upright position. Show the implemented logic to the lab instructor and get it graded.
[3 points]
9
Figure 12-12: Placing a limit on the pendulum working angle
12.5 Task 2: Inverted Pendulum Stabilization with Full State Feedback Control
Objective: Design and implement a controller to stabilize the position of arm and angle of
the pendulum.
The inverted pendulum on the rotary platform can be modeled by the state space
representation mentioned earlier in section 12.1.1.
You are required to design and implement a feedback controller that stabilizes the closed loop
system with the following transient response parameters.
T s=1.4 ,T P =1.2
1. Pre Lab Find the σ and ω d for a second order system with the above transient response
characteristics. [2 points]
σ =2.85
Wd=2.618
Wn=3.889
2. Pre Lab The closed-loop inverted pendulum is a 4th order system. So in order to achieve a
response like a 2nd order system, the remaining two poles must be at a position such that
they have no significant effect on the response of this system. Find the transfer function of
a 4th order system with two poles defined by the σ and ω d, as calculated in the previous
part, and the remaining two poles at suitable insignificant location. Write the characteristic
equation with these poles. [4 points]
10
3. Build the inverted pendulum’s state space model in MATLAB and define a row vector P
comprising of the poles of the 4th order system found in part 2. Use the Ackerman’s
formula to find the gain vector K. Write the value of K in the following space. [5
points]
K = [ -2.2853 -31.7708 1.0271 2.3173
4. Find the system matrix of the state space model of the closed loop system ( A−BK ) with
the value of K calculated in the previous part. Use eig() function in MATLAB to find
the eigenvalues of the closed loop system matrix. Write the eigenvalues here. [3 points]
Poles = eig (A – BK) are verified. Poles:
• 30.00 +0.0i
• 28.57 +0.0i
• 2.8570 + 2.6180i
• 2.8570 – 2.6180i
5. Implement your controller in LabVIEW on QNET Rotary Inverted Pendulum. Recall that
v is the voltage applied to the arm motor, θ and α are the angles of arm and pendulum and
K is the gain vector calculated above. If the pendulum is stable in the upright position and
successfully corrects small disturbances, show the implementation to the lab instructor.
Remember to manually hold the pendulum in the position where θ and α are both zero,
every time before starting the VI. [10 points]
v=−Kx , x=[ θ α θ̇ α̇ ]
6. Analysis Disturb the pendulum gently and observe its behavior. Disturb it a bit harder but
not too hard to drop it down from the inverted upright position. Describe how the
pendulum behaves in terms of angles θ and α . [2
points]
If the pendulum is moved in counter clock-wise direction then 𝜶 and 𝜽 goes high and
if the pendulum is moved clock wise direction then 𝜶 will be below zero and for 𝜽 is
above zero for counter clockwise movement.
7. Analysis Touch the arm rod (silver-colored) softly and observe how it behaves. Describe
and explain the difference in the reactions of the pendulum when perturbed on the
11
pendulum rod (red-colored) vs when perturbed on the arm rod (silver-colored). [3
points]
If the red touched with the little force, if forcefully come back to its horizontal angle
which is set to the zero and it re adjusts the rod.
It is worth noting that in steady state, the pendulum angle α and its derivative cannot have
any value other than zero. Thus, only θr and θ̇r can have non zero values in x r.
1. Implement the controller given above in LabVIEW with the Quanser Rotary Pendulum
Board. Use α r= α̇ r =θ̇r =0 and connect a square wave signal generator with the following
parameters in the place of θr . If the controller is implemented correctly, the pendulum
would stay upright and the arm would swing left to right at a frequency of 0.1 Hz . Show
the implementation to the lab instructor. [5 points]
Parameter Value
Amplitude 1 rad
Frequency 0.1 Hz
Offset 0 rad
2. Change the settings of the signal generator so that it generates a sine wave signal with the
same amplitude and frequency. Plot θ and θr on a new chart and find the phase difference
between them. [3 points]
12
13
Assessment Rubrics
Method:
Lab report evaluation and instructor observation during lab sessions.
CLO Able to complete the tasks Able to complete the Tasks completion below Marks
Performance
over 80% (4-5) tasks 50 – 80% (2-3) 50% (0-1)
1. Teamwork 1 Actively engages and Cooperates with other Distracts or
cooperates with other group members in a discourages other
group members in an reasonable manner. group members from
effective manner. conducting the
experiment.
2. Laboratory 1 Respectfully and Observes safety rules Disregards safety
safety and carefully observes safety and procedures with rules and procedures.
disciplinary rules and procedures minor deviation.
rules
3. Realization of 3 Selects relevant Needs guidance to Incapable of selecting
experiment equipment to the select relevant relevant equipment to
experiment, develops equipment to the conduct the
setup diagrams of experiment and to experiment.
equipment connections develop equipment
or wiring. connection or wiring
diagrams.
4. Conducting 3 Uses each equipment and Uses the equipment Unable to use
experiment components as intended, and components with appropriate
conducting the minor error. Needs equipment, and
experiment perfectly. help in conducting experiment is
experiment. substantially wrong.
5. Data 3 Plans data collection to Plans data collection Does not know how
collection achieve experimental to achieve to plan data collection
objectives, and conducts experimental to achieve
an orderly and a objectives, and experimental goals;
complete data collection. collects complete data data collected is
with minor error. incomplete and
contain errors.
6. Data analysis 3 Accurately conducts Conducts Unable to conduct
simple computations and computations and simple analysis on
statistical analysis using analysis on collected collected data; no
collected data; correlates data with minor error; attempt to correlate
experimental results to reasonably correlates experimental results
known theoretical values. experimental results with known
to known theoretical theoretical values.
values.
7. Computer use 3 Uses computer to collect Uses computer to Does not know how
and analyze data collect and analyze to use computer to
effectively. data with minor error. collect and analyze
data.
14