Robô Pêndulo Controle PID

You might also like

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

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/285470677

PID control for two-wheeled inverted pendulum (WIP) system

Article · January 2015

CITATIONS READS

0 679

4 authors, including:

Bogdan Gramescu Constantin Nitu


Polytechnic University of Bucharest Polytechnic University of Bucharest
37 PUBLICATIONS   39 CITATIONS    54 PUBLICATIONS   90 CITATIONS   

SEE PROFILE SEE PROFILE

Claudia Borzea
National Research and Development Institute for Gas Turbines
19 PUBLICATIONS   8 CITATIONS   

SEE PROFILE

Some of the authors of this publication are also working on these related projects:

Compressed Air Energy Storage Installation View project

Medical rehabilitation View project

All content following this page was uploaded by Claudia Borzea on 18 May 2018.

The user has requested enhancement of the downloaded file.


PID Control for Two-Wheeled Inverted Pendulum (WIP) System

PID CONTROL FOR TWO-WHEELED INVERTED PENDULUM


(WIP) SYSTEM
Bogdan Grămescu, Constantin Niţu, Nguyen Su Phuong Phuc, Claudia Irina Borzea
University “POLITEHNICA”of Bucharest
313, Splaiul Independentei, 060042 – Bucharest, Romania
bogdan.gramescu@upb.ro , constantin.nitu@upb.ro

Abstract - The complexity of the inverted pendulum system has drawn the interest of many researchers
around the world. Its instability feature is a good example for a control engineer, with the purpose of
verifying the control theory. To verify this system, equilibrium can be maintained, being possible to do
the simulation using a method with a closed loop controller, such as LQR or PID.
The article presents the achievement of a two-wheeled inverted pendulum (WIP) system, having an open-
source development Arduino platform as control centre, which is programmed with Processing open-
source environment. With the purpose of optimizing the system operation, a Kalman filter is implemented
on the Arduino platform.

Keywords: Mechatronics, Inverted Pendulum, Arduino, Kalman Filter, Control Algorithm.

1. Introduction

The stabilization issue has been increasingly approached The main goal was to design a mechatronic system
in recent years, being found in a very vast application consisting of an inverted pendulum articulated on the
range. One of the classical stabilization control issues is wheels axis of a two-wheeled system, with constructive
the inverted pendulum. The process is nonlinear and solutions to correct the design errors of existent
unstable, with a single input signal and several output products, and to simplify the realization of a control and
signals. The inverted pendulum presented in this article actuation system.
is a two-wheeled inverted pendulum system.
The stabilization of the inverted pendulum represents a 2. The structure of Two-Wheeled Inverted
basic model for the control of other similar processes, Pendulum (WIP) System
such as: rocket takeoff, equilibration of heavy loaded
cranes, etc. In recent researches, the balancing of the The design principle was the following: the mechanical
inverted pendulum has often been studied in the modern components consisted of LEGO components, the centre
control theories, such as fuzzy control, variable gain of gravity being chosen as high as possible in regard to
control, nonlinear control and neural networks. the axis of rotatio.

Figure 1: The structure of the two-wheeled inverted pendulum system

Besides these components used as support, the v3 control platform and an electronic block consisting
system also consists of motors (Lego NXT with 1:48 of L298 motor driver circuit, a DC-DC convertor with
integrated reduction gearbox and rotation transducer 3.3V DC, and a Bluetooth HC-05 communication
with 720 pulses per rotation), the Arduino Mega 2560 module for the connection with a computer system.

246 The Romanian Review Precision Mechanics, Optics & Mechatronics, 2015, Issue 48
PID Control for Two-Wheeled Inverted Pendulum (WIP) System

Figure 2: The electronic block

The control system also integrates a GY-521 3. The control program implemented on the
sensor based on MPU-6050. This one is used to provide Arduino platform
the necessary information to the control algorithm,
regarding angles, speeds and angular accelerations. Starting from the mathematical model necessary
Thus, an inertial sensor had to be installed, being for the implementation of the control algorithm, it was
necessary to read the data provided by this one, but also possible to elaborate the control program of the system,
to filter this data, in order to reduce noise and errors as which was implemented in the Arduino Mega platform.
much as possible. As programming environment, the open-source Arduino
MPU-6050 is the first integrated 6 axis motion software (IDE) was used, which uses Java programming
tracking device that combines a 3 axis gyroscope, a 3 language that is based on Processing open-source
axis accelerometer, and a digital motion processor language.
(DMP), all in a small package, of 4mmx4mmx0.9mm. The control algorithm for the inverted pendulum
The values received from MPU-6050 sensor are system is similar to the one presented in figure 3
transmitted to the Arduino development platform
through I2C interface.

Figure 3: The control algorithm used for the robot

The entire control process is a closed loop, the left motor, respectively minus the output of PID 3
steps repeating with a predetermined frequency (figure controller on right motor, or vice versa. Depending on
4). Initially, all parameters have to be declared and all the output reference of PID 1 controller, the entire
the necessary conditions have to be set for the following inverted pendulum structure can be controlled for
steps. This first step of initialization is included in moving forwards or backwards. Depending on the
setup() function of the program, and is passed through output reference of PID 3 controller, the structure can be
once. controlled so that to turn or rotate.
After passing through the first step, the program The frequency of passing through the loop is a
will run a closed loop, at the end of each set of steps very important factor, with direct effect on the stability
being obtained the command for each motor. The loop level of the system. In figure 4, the main steps are
of the program implemented on Arduino platform is presented briefly, behind whom there are various other
loop() function. The PWM signal for each motor is steps such as: calibration of the signals received from
equal to the sum of the outputs of PID 1, respectively sensors, filtering these signals, communication with
PID 2 controllers, plus the output of PID 3 controller on computer, checking the battery level, etc.

The Romanian Review Precision Mechanics, Optics & Mechatronics, 2015, Issue 48 247
PID Control for Two-Wheeled Inverted Pendulum (WIP) System

Figure 4: Main processing steps of the program implemented in the Arduino platform

Figure 5 presents the interface generated by the adjusted directly from here. By means of this program,
program. The upper part contains the graphics which the time necessary for the control process of the robot is
present interest, and the bottom part contains the significantly reduced.
parameters of the three PID controllers, that can be

Figure 5: The communication interface between Arduino platform and computer

248 The Romanian Review Precision Mechanics, Optics & Mechatronics, 2015, Issue 48
PID Control for Two-Wheeled Inverted Pendulum (WIP) System

4. Implementation of Kalman filter on the Arduino platform

For the statistically optimum estimation of the state of measurement. For the implementation of the filter on
the basic system, the implementation of a Kalman filter the Arduino platform, the functional model has been
is very useful. This algorithm uses a series of used, which was modified according to proper
measurements observed in time, which contain noise necessities. The original source code [4] belongs to
(random variations) and other inaccuracies, and realizes Kristian Lauszus, cofounder of TKJ Electronics, an
estimations of the unknown variables that tend to be enterprise in Denmark specialized in electronic
more accurate than the ones based on a single components and their applications.

The implementation steps of Kalman filter are:

Step 1: Predict a priori state.

(1)

In this case, the equation becomes:

(2)

Based on this equation, the code implemented in the Arduino platform is:

Step 2: Predict a priori error covariance.

(3)

In this case, the equation becomes:

(4)

Based on this equation, the code implemented on the Arduino platform is:

Step 3: Compute residual.

(5)

Based on this equation, the code implemented on the Arduino platform is:

Step 4: Compute [Sk] matrix.

(6)

The Romanian Review Precision Mechanics, Optics & Mechatronics, 2015, Issue 48 249
PID Control for Two-Wheeled Inverted Pendulum (WIP) System

Based on this equation, the code implemented on the Arduino platform is:

Step 5: Compute Kalman gain [ ].

(7)

In this case, the equation becomes:

(8)

Based on this equation, the code implemented on the Arduino platform is:
In case S is a matrix, P cannot be divided by S, and therefore the inverse matrix has to be computed.

Step 6: Obtain a posteriori state estimate at k moment.

(9)
In this case, the equation becomes:
(10)

Based on this equation, the code implemented on the Arduino platform is:

Step 7: Obtain a posteriori error covariance estimate (final step).

(11)

In this case, the equation becomes:

(12)

A posteriori error covariance is reduced because the state estimation error has been diminished.

Based on this equation, the code implemented on the Arduino platform (the following variations being chosen for most
IMU) is:
Instead of Kalman filter, a complementary filter can be implemented:

250 The Romanian Review Precision Mechanics, Optics & Mechatronics, 2015, Issue 48
PID Control for Two-Wheeled Inverted Pendulum (WIP) System

(13)

where the sum of the coefficients is 1. This filter is simpler, but less accurate, providing however good results when
used for simpler systems.

Figure 6: Graphics obtained in the following cases: unfiltered, filtered with Kalman Filter and filtered with
Complementary Filter

The information provided by gyroscope is 6. References


integrated by time and used to update the angular
position, the step by step increment being useful to [1] Balancing a two-wheeled Autonomous Robot, Rich
prevent that the drift occurs in time, characteristic for Chi Ooi, School of Mechanical Engineering, The
the gyroscope. To assure enhanced disturbance University of Western Australia
sensitivity, the information from accelerometer is also [2] Advance Control of Wheeled Inverted Pendulum
used in a small amount. System, Zhijun Li, College of Automation Science and
Engineering, South China University of Technology,
5. Conclusions Chenguang Yang, School of Computing and
Mathematics, University of Plymouth, Plymouth, Devon,
The equilibrium of an inverted pendulum, UK, Liping Fan, Departament of Automation, Shanghai
articulated on the wheels axis of a two wheeled system, Jiao Tong University Shanghai, People’s Republic of
has been successfully maintained. Between two China
controllers, PID and LQR, PID controller has been [3] https://github.com/TKJElectronics/Example-
chosen to realize the program implemented on the Sketch-for-IMU-including-Kalman-filter
Arduino platform. [4] http://blog.tkjelectronics.dk/2012/09/a-practical-
Kalman filter has been successfully implemented. approach-to-kalman-filter-and-how-to-implement-
The drift of the gyroscope was efficiently removed, so it/comment-page-1/
that to allow an exact estimation of the inclination angle [5] http://www.plethora-
and its drift, for the system. The program for the project.com/education/2011/09/12/processing-tutorials/
registration of data provided by the inertial sensor and [6] NXTway-GS Model-Based Design-Control of self-
for applying Kalman filter works properly. A greater balancing two-wheeled robot built with LEGO
importance is given to the fact that data from the serial Mindstorms NXT, Yorihisa Yamamoto, Aplication
port has been successfully received, and a control Engineering, Applied Systems First Division,
algorithm has been elaborated on the basis of a CYBERNET SYSTEMS CO.,LTD.
mathematical model, for which the program outputs have [7] Progetto e implementazione del Sistema di
been observed depending on various inclinations and controllo per un pendolo inverso, Marco Triverio,
accelerations tested on the system structure, without Departamento di Elettronica e Informazione, Corso di
recording abnormal values or errors. Laurea in Ingegneria Informatica, Politehnico di Milano.

The Romanian Review Precision Mechanics, Optics & Mechatronics, 2015, Issue 48 251

View publication stats

You might also like