Mathematical Modeling and Control of QNET Rotary Inverted Pendulum in MATLAB and Real Time Implementation in Lab View Using ELVIS
Mathematical Modeling and Control of QNET Rotary Inverted Pendulum in MATLAB and Real Time Implementation in Lab View Using ELVIS
Abstract—The objective of this project is the design and position to itsvertical upright position and balance control
comparison of the various controllers for QNET (Quanser stabilizes thependulum at its upright position.
NI ELVIS Trainer) Rotary Inverted Pendulum (RIP) The system model was derived using Euler-Lagrange method
Board 2.0 for NI ELVIS. The RIP system is a as it is a multivariable system[2][3]. Since the dynamics of
multivariable mode with highly nonlinear behavior. It is inverted pendulum systems are inherently nonlinear, the
used in the design of highly complex applications like equations ofmotion are linearized about the operating point
automatic aircraft landing system, and humanoid robot and is defined within which the constant gaincontroller results
stabilization. In this work, the RIP model is in local asymptotic stability.
mathematically derived using motion equation of Euler-
Lagrange. For controlling the system, PP (pole placement)
and LQR(Linear Quadratic Regulator) controllers are
designed and implemented in MATLAB for the balancing
of the pendulum arm in up-right position. A comparative
study was made for analyzing the performance of the
controllers in terms of settling time and overshoot range,
etc. Based on designed parameters using MATLAB
simulation, the control ofreal time Rotary inverted
pendulum arm is implemented in LabVIEW platform
interfaced with NI ELVIS. From the experimental results
of MATLAB simulation and LabVIEWinterfacing, the
LQR controller was better than the PP controller in
controlling the pendulum arm in upright position. Fig. 1. QNET 2.0 Rotary Pendulum Board for NI ELVIS
Keywords-Rotary Inverted Pendulum, QNET 2.0 Rotary
Pendulum Board for NI ELVIS, PP, LQR, MATLAB, QNET 2.0 is a rotary inverted pendulum interfaced in
LabVIEW. LABVIEW interfaced using NI-ELVIS data acquisition card.
I.INTRODUCTION The motor driven arm is the base of the system which rotates
in the horizontal plane and a pendulum attached with that arm
Inverted Pendulum is abench mark model and classically which is free to rotate in the vertical plane[4]. The pendulum
problem to control the nonlinear system dynamics in control angles are measured using two encoderswith a resolution of
engineering application. There are two types of inverted 0.176deg/count.
pendulum model available as the models to define the In this paper, pole placement and LQRcontrollers are designed
nonlinear dynamics in translational and rotational system. In for the RIP model. The pole placement controller places the
this paper Rotary inverted pendulum is used to define the system poles in desired position for obtain a desired response.
system with highly nonlinear and open loop multi variable The LQR method is another powerful technique to obtain a
unstable system. The application of RIP model in controlling feedback gain for balancing the pendulum in minimum cost of
the altitude of space booster rocket, automatic aircraft landing function.The LQR technique generates controllers with
system, and satellite[1][2]. guaranteed closed-loop stability and robustness
RIP invented by Furuta, is also known as Furuta's pendulum. It property[1].The paper is organized as follows. The
has two moving components with amotor driven arm and a mathematical modelof the rotary inverted pendulum is
free moving pendulum arm. The problem of balancing the presented in the Section II.The controllerdesigns for LQR and
pendulum at uprightpositionhas been divided into two major Pole placement is discussed in section III. Simulationresults of
controls i.e., swing upcontrol and balance control. The swing RIP model with controller design in MATLAB simulation and
up control is used tobring the pendulum from its stable
LABVIEW real time implementation are presented in Section The pendulum experiences the velocity due to the center mass
IV with conclusion inSection V. of the pendulum in two directions(Vpen)
II. STANDARD MODEL Vpen= -L1cosα*(α̇ )*x-L1sin α*(α̇ )*y (1)
The pendulum rotary arm also experiences the velocity only in
The modeling of rotary inverted pendulum is a challenging horizontal direction(Varm) as in [1]
one because it is a multivariable system. Normally it is a
Varm=Lrθ̇ *x (2)
nonlinear system. So the modeling is done by using the motion
equation of Euler-Lagrange. From the equation (1) and (2) the velocity (V) experienced by
the pendulum is based on the resultant of two axis.
Vx= Lrθ̇ - L1cosα * (α̇ ) (3)
Vy= -L1sin α * (α̇ ) (4)
The dynamic equation of the system is obtained by the
variation of velocity in the pendulum which can be derived
using Euler-Lagrange motion equation[3].
Qi ( ̇) ̇
(5)
Where,
q = The angular position.
Fig. 2. Pendulum motion with motor torque ̇ =The angular velocity.
Qi= External force.
The following assumptions are taken in modeling of the
L = Lagrangian.
system:
1. The system starts in the state of equilibrium that means the W= loss of energy.
initial conditions are assumed to be zero. Lagrangian is a function of angular position and angular
velocity, which is represented as
2. The pendulum deflection is restricted within few degrees in
L=Ttotal- Ptotal (5a)
up-right position to satisfy the linearity property.
Ttotal =Total kinetic energy of the RIP
3. Pendulum can be subjected to small disturbance input.
Ptotal = Total potential energy of the RIP.
4. The pendulum is displaced at an angle of α in y-axis while
Total potential energy in the system is only due to the gravity
the arm angle of θ considered in x-axis. in pendulum, so potential Energy is given as
Ptotal=Parm+Ppend (5b)
TABLE I. PARAMETERS OF RIP MODEL DESCRIPTION
As the arm of the pendulum is already balanced, P arm=0
Symbol Description Ptotal=MpgL1cosα (6)
L1 =Lp/2 Length of the Pendulum (Lp) from its Center of Total kinetic energy (KE)ofthe system can be obtained by the
Mass(m). sum of kinetic energies due to the pendulum arm, velocities of
Mr Mass of pendulum rotary Arm (kg). pendulumdue to center of mass, and rotational motion of
Mp Mass of Pendulum (kg). pendulum,
Lr Pendulum rotary Arm Length(m). Ttotal =KEpend.arm+KEVx+ KEVy + KEpend (7)
Pendulum Arm Deflection (radian). Ttotal=(1/2)*Jr ̇ 2+(1/2)*Mp[Lr ̇ -L1cosα*( ̇ )]2
α Pendulum Deflection (radian). +(1/2)*Mp[-L1sinα*( ̇ )]2+(1/2)*Jp ̇ 2
Jp Inertia of Pendulum about its center of
After getting the kinetic energy and potential energy, the
mass(kgm2).
lagrangian is given as
Jr Inertia of Pendulum rotary Arm about its center of
mass(kgm2). L=(1/2)*Jr ̇ 2 + (1/2)*MpLr2 ̇ 2- MpLr ̇ L1cosα*( ̇ )
τ Servo motor torque(Nm). + (1/2)*Mp L12cos2α*( ̇ )2+ (1/2) MpL12sin2α*( ̇ )2
Kt Motor torque constant (Nm/A). + (1/2)Jp ̇ 2 - Mpg L1cosα (8)
2
Km Back emf constant (V/rad/sec). Normally,Jp=(1/12)*MpLp andLp=2*L1
Rm Armature resistance(ohm). Hence, Jp=(1/3)MpL12 (9)
Vm Motor input voltage(Volt). Substituting equation (9) in (8)
Vx Velocity of Pendulum about its Center of mass in L=(1/2)*Jr ̇ 2 + (1/2)*MpLr2 ̇ 2- MpLr ̇ L1cosα*( ̇ )
the x-direction.
+ (1/2)*Mp L12cos2α*( ̇ )2+ (1/2) MpL12sin2α*( ̇ )2
Vy Velocity of Pendulum about its Center of mass in
the y-direction. + (1/6)*MpL12 ̇ 2 - Mpg L1cosα (10)
The Lagrange motion equation for θ̇ andα̇ are The output matrix of the RIP model is
θ
( ̇) (12) α
θ θ
[ ] =[ ] [ ̇] (20)
( ) (13) θ
α̇ α
α̇
Here we are consider loss of energy (W) = 0, as [3]
III. CONTROLLER DESIGN AND IMPLEMENTATION
After Lagrange Motion Equation for linearization considered A. Design of Pole placement controller
at equilibrium point [5], take (α=0 θ=0, θ̇ =0, α̇ =0)
(Jr + Mp Lr2) ̈ - MpLrL1 ̈ = τ (14) The pole placement method is also calledFSF (full state
2 ̈ feedback controller) which is designed based on Ackermen’s
(4/3)*Mp L1 ̈ - MpLrL1 - Mpg L1α = 0 (15)
formula or place command in MATLAB [7], for placing the
The developed torque of the motor [2]
system poles in desired position to meet out the required
τ =Kt*(Vm-Km ̇ )/Rm (16) response.
For taking matrix inverse consider the constants The control voltage is calculated using state feedback[10]
A= Jr + Mp*Lr2, B= Mp LrL1, C=(4/3) Mp L12 u =K*(xref–x) (21)
D= Mp*g *L1, E=A*C-B2, F=Kt /Rm, G=(Kt*Km)/Rm where, K is control gain matrix, xrefis the desired set value of
After combining the equation (14),(15)and(16) state variable and x is the actual state variable. Considering
the state equation of the system is the objective as getting minimum settling time, response in
FSF controller is restricted to 1 second by the hardware setup
̇ of RIP interfaced with ELVIS. So the settling time(Ts) is taken
[ ̇ ]= [ ̇ ]+ Vm (17) as 1sec and ξ = 0.7
̈ The expression for settling time is given by
̈ [ ] ̇ [ ] Ts= 4/ ξωn (22)
Therefore ωn=5.7143rad/sec for the design proposed.
And the output equation of the system is
where, ξ=damping ratio and ωn=Natural frequency
θ From ξand ωn the second order characteristic equation was
α obtained as
[ ] =[ ] [ ̇] (18)
θ S2+8S+32.6532=0 (23)
α̇ Solving the above equation will give the desired pole locations
For getting the parameters of the constants, the actual value for meeting the set point tracking. As the system was fourth
of the pendulum mass, length and inertia are available in the order equation, the remaining two poles are chosen as 10 times
student work book [6] and is shown in table II away from the desired poles location to have very less effect
on system performance. The desired poles are
TABLE II. PARAMETERS OF QNET 2.0 RIP MODEL [-4+4.0808i, -4-4.0808i,-30,-40]
Using the either place command or acker command in
Parameters Values
MATLAB, the gain values are obtained as
Mr 0.095 kg
Mp 0.024 kg
K=[-6.8903 48.6591 -2.1316 3.6966]
Lr 0.085 m
Lp 0.129 m
L1= Lp/2 0.0645 m
Kt 0.042 Nm/A
Km 0.042V/(rad/sec)
Rm 8.4 ohm
Jp 0.0001 Kgm2
Jr 5.7*10-5 Kgm2
B. Design of Linear Quadratic Regulator(LQR) controller Figure 5 shows the real time hardware implementation of
The Linear quadratic regulator control method is widely RIP model with controller design in LabVIEW platform
focused in applications requiring more control effort with interfaced with NI ELVIS data acquisition system.
minimum energy. LQR control is same as pole placement
technique but the only difference is the way of computing the
control gain matrix computed by minimizing the cost function
of the equation [7]
∫ ( ) (24)
Figure 7 shown the response of pendulum angle (alpha) and variables with the small disturbance of 1degree for a duration
pendulum arm angle (theta) for the unit step input with the of 2 seconds in PP controller method.
FSF controller gain.
Fig. 10. Response of alpha with step disturbance from 12to14 sec in real
time testing at LabVIEW for PP controller.
TABLE III. TIME RESPONSE OF THETA AND ALPHA WITH LQR AND POLE
PLACEMENT CONTROLLER
Fig. 12. Response of theta and alpha when step disturbance from 1 to 3
sec. For theta reference is 0(deg) in LQR controller.
Fig. 9. Response of theta and alpha whenstep disturbance from 1to 3 sec.
For theta reference is 0(deg) in PP controller. Figure 12 shows the response of pendulum angle (alpha) and
pendulum arm angle (theta) for the desire set point of state
Figure 9 shows the response of pendulum angle (alpha) and variables with the small disturbance of 1degree for the
pendulum arm angle (theta) for the desire set point of state duration of 2 second in LQR controller method in MATLAB
platform.
the performance based LQR gives the better result than the
Pole placement in both simulation and real time
implementation.
REFERENCES
[1] M.d.Akhtaruzzaman A.A. Shafie “Modeling and control of a
rotary inverted pendulum using various methods,
comparativeassessment and result analysis” Proceedings of the
2010 IEEE International Conference on Mechatronics and
Automation August 4-7, 2010, Xi'an, China
[2] AbhishekKathpal Ashish Singla “SimMechanics Based
Fig. 13. Response of alpha when step disturbance from 12to14 sec. In Modeling, Simulation and Real-Time Control of Rotary Inverted
real time testing inLabVIEW for LQR controller. Pendulum” 2017 11th International Conference on Intelligent
Systems and Control (ISCO)
[3] VirochSukontanakarnManukidParnichkun“Real-Time Optimal
Control for Rotary Inverted Pendulum” American Journal of
Applied Sciences 6 (6): 1106-1115, 2009
[4] Akhil Jose, Clint Augustine, ShinuMohananMalola,
KeerthiChacko“Performance Study of PID Controller and LQR
Technique for Inverted Pendulum”World Journal of Engineering
and Technology, 2015, 3, 76-81
[5] Binita Prakash, Binoy Krishna Roy and Raj Kumar
Biswas“Design, Implementation and Comparison of Different
Controllers for a Rotary Inverted Pendulum” 1st IEEE
International Conference on Power Electronics, Intelligent
Control and Energy Systems (ICPEICES-2016)
Fig. 14. Response of theta when step disturbance from 12to14 sec. In real [6] STUDENT WORKBOOK QNET 2.0 Rotary Pendulum Board
time testing inLabVIEW for LQR controller. for NI ELVIS Developed by QuanserCurriculum designed by:
Peter Martin, M.A.Sc., Quanser, Matthias Krug, Ph.D.,
Figure.13 and 14 shows the response of pendulum angle and
QuanserJacobApkarian, Ph.D., Quanser.
pendulum arm angle with the small disturbance.
[7] MODERN CONTROL ENGIEERING by KATSUHIKO
OGATA 5TH edition.
V. CONCLUSION [8] Navin John Mathew, K. Koteswara Rao, N. Sivakumaran
It is concluded that Rotary inverted pendulum was “Swing Up and Stabilization Control of a Rotary Inverted
mathematically modeled using motion equation of Lagrange Pendulum”, The International Federation of Automatic Control,
with the specifications of QNET 2.0 RIP. Pole placement and December 18-20, 2013. Mumbai, India.
LQR controllers are designed for controlling the system in [9] Prakash Dwivedia, Sandeep Pandey B , AnjaliS. Junghare b
swing up and balancing of pendulum arm using MATLAB. “Stabilization of unstable equilibrium point of rotary inverted
The effectiveness of the controllers is observed based on their pendulum using fractional controller” Journal of the Franklin
settling time and overshoot range. The simulation design is Institute 354 (2017) 7732–7766.
implemented in real time hardware model QNET 2.0
[10] M.Gopal “Digital Control and State Variable methods (2nd
interfaced to LabVIEW using ELVIS data acquisition card.
Edition)
From the real time test, the pole placement controller has more
oscillation in steady state than the LQR controlled system. So