0% found this document useful (0 votes)
16 views6 pages

Mathematical Modeling and Control of QNET Rotary Inverted Pendulum in MATLAB and Real Time Implementation in Lab View Using ELVIS

Uploaded by

ChâuTrungTín
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
0% found this document useful (0 votes)
16 views6 pages

Mathematical Modeling and Control of QNET Rotary Inverted Pendulum in MATLAB and Real Time Implementation in Lab View Using ELVIS

Uploaded by

ChâuTrungTín
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/ 6

Proceedings of the 2nd International Conference on Inventive Communication and Computational Technologies (ICICCT 2018)

IEEE Xplore Compliant - Part Number: CFP18BAC-ART; ISBN:978-1-5386-1974-2

Mathematical Modeling and control of QNET


Rotary inverted pendulum in MATLAB and real
time implementation in LabVIEW using ELVIS
R.Sritharan, IV year EEE M.Sivapalanirajan, AP/EEE M.WilljuiceIruthayarajan, Prof/EEE
National Engineering College, National Engineering College, National Engineering College,
Kovilpatti. Kovilpatti. Kovilpatti.
[email protected] [email protected] [email protected]

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

978-1-5386-1974-2/18/$31.00 ©2018 IEEE 1452


Authorized licensed use limited to: Nazarbayev University. Downloaded on November 21,2024 at 07:36:47 UTC from IEEE Xplore. Restrictions apply.
Proceedings of the 2nd International Conference on Inventive Communication and Computational Technologies (ICICCT 2018)
IEEE Xplore Compliant - Part Number: CFP18BAC-ART; ISBN:978-1-5386-1974-2

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

By Euler-Lagrange equation of motion

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)

978-1-5386-1974-2/18/$31.00 ©2018 IEEE 1453


Authorized licensed use limited to: Nazarbayev University. Downloaded on November 21,2024 at 07:36:47 UTC from IEEE Xplore. Restrictions apply.
Proceedings of the 2nd International Conference on Inventive Communication and Computational Technologies (ICICCT 2018)
IEEE Xplore Compliant - Part Number: CFP18BAC-ART; ISBN:978-1-5386-1974-2

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

After substituting the parameters in the expression,


Fig. 3. Simulation of RIP model with PP controller in MATLAB
A=0.0002304, B=0.00013158, C=0.000133128
D=0.01518, E=1.335E-8, F=0.3528 and G=0.00021 The derived RIP model is represented as a sub system in
Computed state equation of the RIP model is MATLAB SIMULINK environment. By feeding the gain
θ̇ θ values to setup as in figure 3, the response of the RIP model
α̇ α for the desired state variables can be observed in scope. The
[ ] =[ ] [ ̇ ]+ [ ]Vm (19)
θ̈ θ set point for α and θ are set to be zero in figure 3.
α̈ α̇

978-1-5386-1974-2/18/$31.00 ©2018 IEEE 1454


Authorized licensed use limited to: Nazarbayev University. Downloaded on November 21,2024 at 07:36:47 UTC from IEEE Xplore. Restrictions apply.
Proceedings of the 2nd International Conference on Inventive Communication and Computational Technologies (ICICCT 2018)
IEEE Xplore Compliant - Part Number: CFP18BAC-ART; ISBN:978-1-5386-1974-2

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)

where, Q and R are the positive semi definite and positive


definite matrix. By choosing proper values of Q and R, the
importance of error and energy expenditure is focused [8].
The diagonal elements of Q matrix, control the dynamics of
the state variables. The weightage of diagonal element of Q
matrix is calculated by Ricatti equation, which may also be
described by the importance of the state variable to be
controlled as trail and error basis [9] and R=1.
Fig. 5. Real time Pendulum arm control in LabVIEW using ELVIS

Q1 =[ ]&R= [1] (25) IV.Result and Discussion


A. Response of RIP with LQR and PP controller for step input
The time domain specification parameters of the RIP
By considering various trails for Q matrix as below, the
model with the variables theta and alpha for the step input is
performance of the system is studied to get the best Q matrix.
simulated using MATLAB is shown in figure 6 and the
performance of LQR and PP controllers are compared in table
3. For the developed model of RIP, step response is shown in
Q2=[ ] Q3=[ ]and Q4=[ ] figure 7 and figure 8.

The Q1 matrix performance was better than other matrix for


the real time hardware result as the settling time and value of
gain is comparatively less than other matrix.The obtained gain
for the system with the considered Q1and R matrix is

K=[-5.4772 30.8321 -1.5987 2.5888]

Fig. 6. Step response of theta andalpha with controller

Fig. 4. Simulation of RIP model with LQR controller in MATLAB

The computed gains of LQR controller are feed to the


simulation model in MATLAB as in figure.4, the response of
the RIP model for the desired setpoint for theta and alpha can
be observed in scope. The set point for α and θ are set to be
zero as shown in figure 4. Fig. 7. Step response of theta andalpha in PP controller

978-1-5386-1974-2/18/$31.00 ©2018 IEEE 1455


Authorized licensed use limited to: Nazarbayev University. Downloaded on November 21,2024 at 07:36:47 UTC from IEEE Xplore. Restrictions apply.
Proceedings of the 2nd International Conference on Inventive Communication and Computational Technologies (ICICCT 2018)
IEEE Xplore Compliant - Part Number: CFP18BAC-ART; ISBN:978-1-5386-1974-2

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.

Fig. 8. Step response of alpha and theta in LQR controller

Figure 8 shows the time response of pendulum angle (alpha)


and pendulum arm angle (theta) for the unit step input with the
LQR controller gain.

TABLE III. TIME RESPONSE OF THETA AND ALPHA WITH LQR AND POLE
PLACEMENT CONTROLLER

Time domain Theta Alpha


specification PP LQR PP LQR
TR in Sec 0.572 0.396 0.26 0.223
TP in Sec 0.767 0.665 0.0852 0.0393
TS in Sec 1.07 0.48 0.96 0.773
Overshoot -6.794 to -5.0554 to -0.30083 to -0.29697 to Fig. 11. Response of theta with step disturbance from 12to14 sec in real
range in deg 0.68942 0.66909 0.77565 0.74645 time testing at LabVIEW for PP controller.
Error in deg -0.145 -0.183 0 -6.23e-17
The response of pendulum angle and pendulum arm angle
B. Response of RIP with distrubance with small disturbance in real time hardware
The time response of RIP for a simulated disturbance input is implementation using NI ELVIS interfacing with
added with alpha and the response is obtained as reversed LabVIEW is shown in figure 10 and 11.
output when compared to step response. It is also implemented
in real time pendulum arrangement using LabVIEW

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.

978-1-5386-1974-2/18/$31.00 ©2018 IEEE 1456


Authorized licensed use limited to: Nazarbayev University. Downloaded on November 21,2024 at 07:36:47 UTC from IEEE Xplore. Restrictions apply.
Proceedings of the 2nd International Conference on Inventive Communication and Computational Technologies (ICICCT 2018)
IEEE Xplore Compliant - Part Number: CFP18BAC-ART; ISBN:978-1-5386-1974-2

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

978-1-5386-1974-2/18/$31.00 ©2018 IEEE 1457


Authorized licensed use limited to: Nazarbayev University. Downloaded on November 21,2024 at 07:36:47 UTC from IEEE Xplore. Restrictions apply.

You might also like