Rotatory Inverted Pendulum Using Arduino
Rotatory Inverted Pendulum Using Arduino
USING ARDUINO
Ankur Rai
Dept.of Electrical and Electronics Engineering
NMAMIT,Nitte
Udupi, India
[email protected]
Elton Monteirro
Dept.of Electrical and Electronics Engineering
NMAMIT,Nitte
Udupi, India
[email protected]
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.
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.
Wire.begin();
Serial.begin(115200);
Serial.println("initialize MPU");
mpu.initialize();
Serial.println(mpu.testConnection()?"Connected":"Connecti
on failed");
//initialize servos
myservo.attach(9);
myservo2.attach(10);
}
void loop() {
//read sensor values
mpu.getMotion6(&ax,&ay,&az,&gx,&gy,&gz);
val=map(-ay,-17000,17000,0,179);
val1=map(ax,-17000,17000,0,179);
//output of servo
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
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.