Performance Study of PID Controller and LQR Technique for Inverted Pendulum

The inverted pendulum is a classic problem in dynamics and control theory and is widely used as a benchmark for testing control algorithms. It is unstable without control. The process is non linear and unstable with one input signal and several output signals. It is hence obvious that feedback of the state of the pendulum is needed to stabilize the pendulum. The aim of the study is to stabilize the pendulum such that the position of the carriage on the track is controlled quickly and accurately. The problem involves an arm, able to move horizontally in angular motion, and a pendulum, hinged to the arm at the bottom of its length such that the pendulum can move in the same plane as the arm. The conventional PID controller can be used for virtually any process condition. This makes elimination the offset of the proportional mode possible and still provides fast response. In this paper, we have modelled the system and studied conventional controller and LQR controller. It is observed that the LQR method works better compared to conventional controller.


Introduction
Inverted pendulum is one of the most difficult systems to control in the field of control engineering, because it is a non-linear as well as an unstable system. It provides a platform to test various control techniques and is used to simulate experiments such as walking robots, missile guidance and flying objects in space. To design a control system that keeps the pendulum balanced and tracks the cart to a commanded position, the conventional PID controller is still used in industries, because of its simple in control structure, not too expensive and elective for a linear system. The conventional PID controller can be used for virtually any process condition. This makes elimination the offset of the proportional mode possible and still provides fast response.
Generally, all systems are initially checked with conventional controllers including P, PI, and PID [1] since it is easy to develop and implement. Various methods are available for tuning these controllers. If the response is not satisfactory advanced, controllers are considered. When the system is non-linear and with significant delay, conventional controllers cannot give a satisfactory result [2]. LQR controller is a suitable alternative in such case. It can deal with non-linear systems efficiently. Pole placement methods like Ackerman's formula are very popular in designing the state feedback gain K and hence to place the poles in desired locations [3]- [5]. But in these methods, we need to specify the desired poles to seek the SVFB gain. Also these methods are only applicable for single input systems. However, it is very inconvenient to specify all the closed loop poles and we would like to have a technique that works for many numbers of inputs. Due to these constrains, we make use of the theory of optimal control for the design of a better controller. Optimal controllers are designed in sense of using the least required control effort to maintain equilibrium [6]. Optimal control principle is inspired from naturally occurring systems which are optimal.
In Section 2, the problem is identified and defined. In Section 3, a detailed description about the experimental setup and system modelling is given. Section 4 describes about the designing of PID controller and LQR controller for the system. In Section 5, the simulation results are compared and Section 6 contains conclusion.

Problem Definition
The problem of controlling an inverted pendulum is to balance the pendulum in its upright position by moving the arm in opposite direction. The control output is limited by several constraints like the speed of motor controlling the arm. In this study, simulation of control in inverted pendulum system has been carried out using MATLAB and Simulink software.

Experimental Setup and Description
A Quanser rotary inverted pendulum which we used for modelling is shown in Figure 1. The inverted pendulum is hinged to its arm.
The horizontal movement of the arm and the pendulum vertical position angle are measured by optical encoder. The encoders produce 4096 pulses for revolution, which gives a very reasonable precision in measurement. The arm motion is actuated by a DC motor. The DC motor is controlling the rotary motion of the arm. Encoder is used to feedback the angular position of the pendulum to servo electronics to generate actuating signal. The controller circuits provide the controlling signal which then drives the arm through the servomotor. Rotary motion of the arm applies moments on the inverted pendulum and keeps the pendulum upright.
To model the inverted model we consider a much more simplified model as shown in Figure 2. The system dynamics can be studied from its energy relations [7]  The kinetic and potential energies are given by the following equations: where J p and M p are arm inertia and pendulum mass respectively. Applying Lagrangian formula for the equations the state space model is obtained The transfer function model of the system obtained is given as:

Controller Design
In this section, the LQR controller and PID controller design is discussed, also the controller design using A. Jose et al.

PID controller Design
PID controller is the most widely used controllers for industrial applications [8]. PID controller design schemes are easy and robust in nature [9]. Defining "u" as the controller output, the final PID algorithm is of the form: proportional, integral and derivative gains respectively which are the tuning parameters used to design a PID controller. We used the transfer function model of the system to design a PID controller in Simulink. The Simulink model of the PID controller is given in Figure 3.

LQR Controller Design
In this section, an LQR controller is developed for the inverted pendulum system. The LQR method uses the state feedback approach for controller design. As discussed, the system is expressed in state variable form as . We assume that all the states are measurable. The state variable feedback control can be found from the expression u Kx v = − + . Using this control closed loop system becomes with A c the closed loop plant matrix and v(t) the new command input. C and D matrices are not used in the SVFB design.
To design an optimal SVFB we may define a performance index.
We assume v(t) as zero as our only concern is internal stability of the system. The objective is to select the K that minimizes the performance index J. Q and R must be selected to be positive semi-definite and positive definite in order to minimize J. The feedback gain matrix K in LOR is solved using the equation To seek P we make use of a very important formula in modern control theory known as Algebraic Riccati Equation (ARE).  Figure 4.
The SVFB gain K is found using lqr command in Matlab and this gain is given in the Simulink model to obtain the outout.

Results and Discussion
The PID and LQR controller performance for the system is simulated MATLAB Simulink. Q and R values are selected based on fine tuning by trial and error method. Responses of both the systems are studied with a square wave as input. The results of both the controllers are discussed in this section.

PID Controller Response
The response of the system with PID controller is shown in Figure 5. PID controller tuning for the proposed system model is showing only a very narrow region of stability. When the gains are increased, the system is settled fast but the overshoot is very high. When we reduce the overshoot by reducing the gain, the settling time has to pay the price. Figure 5 shows a reasonably good response obtained by tuning the PID controller.

LQR Response
The LQR controller gives a much stable and robust response for the system. The response of the system with LQR controller is given in Figure 6.   There is a considerable reduction in overshoot and settling time with the LQR controller. The response is more stable and robust.