0% found this document useful (0 votes)
511 views

Rotatory Inverted Pendulum Using Arduino

This document describes the implementation of a control system for stabilizing a rotary inverted pendulum using an Arduino. It first provides background on inverted pendulums and discusses how they are inherently unstable without active control. It then outlines the components of the control system, including the inverted pendulum process, servo motor actuator, Arduino controller, and MPU6050 gyroscope sensor. The document presents the algorithm for implementation, involving initializing components, reading sensor values, sending signals to the servo motor, and repeating. It provides block diagrams of the control system and component connections. Code is presented for initializing libraries and components, reading sensor values, and writing signals to control the servo motor position.

Uploaded by

Ankur Rai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
511 views

Rotatory Inverted Pendulum Using Arduino

This document describes the implementation of a control system for stabilizing a rotary inverted pendulum using an Arduino. It first provides background on inverted pendulums and discusses how they are inherently unstable without active control. It then outlines the components of the control system, including the inverted pendulum process, servo motor actuator, Arduino controller, and MPU6050 gyroscope sensor. The document presents the algorithm for implementation, involving initializing components, reading sensor values, sending signals to the servo motor, and repeating. It provides block diagrams of the control system and component connections. Code is presented for initializing libraries and components, reading sensor values, and writing signals to control the servo motor position.

Uploaded by

Ankur Rai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

ROTATORY INVERTED PENDULUM

USING ARDUINO

Ankur Rai
Dept.of Electrical and Electronics Engineering
NMAMIT,Nitte
Udupi, India
[email protected]

Abstract an inverted pendulum is a pendulum that


has its center of mass above its pivot point. It is often
implemented with the pivot point mounted on a cart that
can move horizontally and may be called a cart and pole
as shown in the photo. Most applications limit the
pendulum to 1 degree of freedom by affixing the pole to
an axis of rotation. Whereas a normal pendulum is
stable when hanging downwards, an inverted pendulum
is inherently unstable, and must be actively balanced in
order to remain upright; this can be done either by
applying a torque at the pivot point, by moving the pivot
point horizontally as part of a feedback system,
changing the rate of rotation of a mass mounted on the
pendulum on an axis parallel to the pivot axis and
thereby generating a net torque on the pendulum, or by
oscillating the pivot point vertically. The inverted
pendulum is a classic problem in dynamics and control
theory and is used as a benchmark for testing control
strategies.
I. INTRODUCTION
A pendulum is an inherently stable system since if no
external forces are applied to it will come to rest hanging
directly its pivot point. This is also called the equilibrium
state of the pendulum.

Fig 1 A Simple Pendulum

Elton Monteirro
Dept.of Electrical and Electronics Engineering
NMAMIT,Nitte
Udupi, India
[email protected]

The inverted pendulum consists of the same elements as the


pendulum but placed upside down. Where the normal
pendulum is inherently stable since it goes toward
equilibrium if no external inputs are provided, the inverted
pendulum is inherently unstable since its equilibrium
position is disrupted if no external input is provided to keep
it in place.

Fig 2 Inverted Pendulum


A common way to visualize an inverted pendulum is to think
of a person balancing a stick on the palm of their hand. If no
correction is applied by moving the hand, then the stick will
inevitably fall over. This means that any system which
resembles the hand-stick-system is in need of active
monitoring and control to keep it stable. The major
difference from this to the inverted pendulum that will be
used in this paper is that it is restricted to movement around
a single axis whereas the stick can fall in all directions from
its standing position.

Fig 3 Broom Stick Balancing


The inverted pendulum has been a classroom example in
control engineering for many years since it makes for a good
exercise in many of the skills needed in a course on the
subject.

arm and the motor keeps the inverted pendulum upright by


moving the wheels analogues to generating torque at the
pivot point (which in the simple example of keeping a stick
placed in the palm of your upright consist in moving the
hand back and forth).
In this case the rocket body is equivalent to the pendulum
arm and the torque is applied at base of the rocket via the
rocket engines.
Servo motor is a simple electrical motor, controlled with the
help of servomechanism. If the motor as controlled device,
associated with servomechanism is DC motor, then it is
commonly known DC Servo Motor. If the controlled motor
is operated by AC, it is called AC Servo Motor. There are
some special types of application of electrical motor where
rotation of the motor is required for just a certain angle not
continuously for long period of time. For these applications,
some special types of motor are required with some special
arrangement which makes the motor to rotate a certain angle
for a given electrical input (signal). For this purpose servo
motor comes into picture. This is normally a simple DC
motor which is controlled for specific angular rotation with
the help of additional servomechanism (a typical closed
loop feedback control system).

Fig 4 Rotary Inverted Pendulum


Sometimes the pendulum is attached to a cart, other times to
a rod which is itself attached to a motor, and other times still
the pendulum itself is attached to the axle of a motor. No
matter how the inverted pendulum system is built the
problem is the same: it will be inherently unstable and
therefore some form of control must be implemented in
order to make sure that the pendulum remains in the vertical
upright position instead of falling due to gravity and other
disturbances.

Fig 7 Servo Motor

Fig 8 Gyroscopic Sensor MPU 6050


Fig 5 A Segway

Fig 6 SpaceX Rocket

Two examples of real-world industrial products based on the


inverted pendulum combined with a feedback control system
is the single person transport vehicle Segway and the rocket
system Grashopper from SpaceX. The Segway is a selfbalancing, two wheeled vehicle on which the driver stands.
In this case the driver can be seen as the inverted pendulum

II Control System
An inverted pendulum will be unstable unless its position
is controlled through some form of added force at any given
time. Therefore stabilizing it requires embedding it in a
control system which generally consists of the elements seen
in the block diagram.

connection diagram of the system is shown in the following


figures

Fig 9 Block Diagram of Control System


For the purposes of this project the process is the inverted
pendulum, the actuator is servo motor, the controller ,
comparator is implemented on an Arduino Uno
microcontroller, and the sensors is the Gyroscope mpu 6050
mounted on the pendulum . The reference the desired
system output value will be the equilibrium of the inverted
pendulum.
The goal of the project is to use methods from classical
control theory to stabilize an inverted pendulum in an
upright vertical position. This will be achieved by first
modeling the inverted pendulum (process) and Servo motor
(actuator). Then control theory methods will be used to
stabilize this system. The focus is to model the elements of
an inverted pendulum system i.e. the inverted pendulum
and servo motor which is used to apply torque in order to
keep the pendulum stable.

Fig 11 Connections of Arduino to MPU 6050

Fig 10 P Controller
M=Kp, the proportional term Kp is the most basic part of
the controller. It makes it possible to change the error signal
in a linear way so that the further it is from the set point the
larger the control signal will be.

III SYSTEM IMPLEMENTATION


The most basic step in the system implementation is to
connect the components of the system to each other. The

Fig 12 Connections of Arduino to MPU 6050 and Servo


Motor

We will take the P controller and write program to


implement it on the actual pendulum system. The pendulum
consist of a Servo Motors and a gyroscopic sensor as well as
power supply etc. The software part of the implementation

will be done via the Arduino Uno microcontroller. The


programs are written in C++ in order to make use of the
different libraries, functions, and tools that are available for
the Arduino. The programs makes use of the , Servo library
and MPU library which makes it easy to interface the
Arduino with the MPU 6050 on the servo motor. Arduino
has added their own layer of abstraction to the C++
language, but the basic structure of the program is the same
as for other microcontrollers.

Wire.begin();
Serial.begin(115200);
Serial.println("initialize MPU");
mpu.initialize();
Serial.println(mpu.testConnection()?"Connected":"Connecti
on failed");
//initialize servos
myservo.attach(9);

Algorithm for the Implementation of the System

myservo2.attach(10);

Step 1: Power up the device


Step 2: Initialize the libraries
Step 3: Set the servo's at initial position

}
void loop() {
//read sensor values

Step 4: Check whether gyroscope is ready

mpu.getMotion6(&ax,&ay,&az,&gx,&gy,&gz);

Step 5: Wait for the gyroscope interrupt

val=map(-ay,-17000,17000,0,179);

Step 6: Read the position values from gyroscope

val1=map(ax,-17000,17000,0,179);

Step 7: Send signals to servo to obtain desired output

//output of servo

Step 8: Goto step 6.

myservo.write(val);

Program Structure

myservo2.write(val1);

//built in libraries
#include<Servo.h>
#include<Wire.h>
#include<I2Cdev.h>
#include<MPU6050.h>

//initializations
MPU6050 mpu;
int16_t ax,ay,az;
int16_t gx,gy,gz;
Servo myservo;
Servo myservo2;
int val,val1;

void setup() {
//implementing built in functions

}
ACTUAL IMPLEMENTATION

Fig 13 Actual Implementation of the System

References

[1] Basic Control Engineering Control of Inverted Pendulum 2014 Aalborg University Esbjerg. Allan Hjbjerg
Jensen Stefan Mikkelsen.
[2] Image and pictorial representations from non-copy righted material from google images.
[3] Data Sheet Arduino Uno.
[4] Data Sheet MPU 6050.
[5] Data Sheet Servo motor Micro Servo 9g.

You might also like