|
EasyEDAEasyEDA
|
|
|
arduino IDEArduino
|
IStable - An agile self balancing robot, that can carry payload
IStable
Inspiration
When we ride a cycle we to steer the cycle towards the direction we fall, and that's how we balance. But the amazing part is we(or our brain) compute a complex set of calculations to balance ourselves. And that we do it naturally. With some practice it gets better. The calculation in our mind that goes on highly inspired us. At first we thought of creating the cycle, but later after watching "Handle" from Boston Dynamics, we thought of creating the self balancing robot, "Istable". Again one more inspiration was watching modelling of systems mathematically in our control systems labs along with how to tune a PID controlled system.
What it does
Istable is a self balancing robot, running on two wheels, balances itself and tries to stay vertical all the time. Istable can move in all directions, rotate and can be a good companion for you. It gives you a really good idea of robot dynamics and kinematics. Mathematically model a system. It can aslo be used to teach college students the tuning of PIDs of a closed loop system. It is a widely used control scheme algorithm and also very robust to use algorithm. Along with that From Zeigler Nichols, Cohen Coon to Kappa Tau methods can also be implemented to teach how to obtain the coefficients in real time. Theoretical modelling to real time implementation. Along with that we can use in hospitals as well where medicines are kept at very low temperature and needs absolute sterilization to enter, we can use these robots there to carry out these operations. And upcoming days we can see our future hospitals in a new form.
How we built it
The mechanical body was built using scrap woods laying around, we first made a plan how the body will look like, we gave it a shape of "I" that's and that's where it gets its name. Made the frame, placed the batteries(2x 3.7v li-ion), the heaviest component, along with that attached two micro metal motors of 600 RPM at 12v, cut two hollow circles from old sandal to make tires(rubber gives a good grip and trust me it is really necessary), used a boost converter to stabilize and step up the voltage from 7.4v to 12v, a motor driver to drive the motors, MPU6050 to measure the inclination angle, and a Bluetooth module to read the PID parameters from a mobile app to fine tune the PID loop. And the brain a microcontroller(lgt8f328p). Next we made a free body diagram, located the center of gravity, it needs to be above the centre of mass, adjusted the weight distribution like that. Next we made a simple mathematical model to represnt the robot, it is used to find the transfer function and represents the system. Later we used that to calculate the impulse and step response of the robot, which is very crucial for tuning the PID parameters, if you are taking a mathematical approach, and we did that here, no hit and trial, only application of engineering. The microcontroller runs a discrete(z domain) PID controller to balance the Istable.
Challenges we ran into
We were having trouble balancing Istable at first(which is obvious ;) ), and we realized that was due to the placing the gyro, we placed it at the top at first, we corrected that by placing at the bottom, and by that way it naturally eliminated the tangential component of the angle thus improving stabilization greatly. Next fine tuning the PID loop, we do got the initial values of the PID coefficients mathematically, but the fine tuning took a hell lot of effort and that was really challenging.
Accomplishments we are proud of
Firstly just a simple change of the position of the gyro improved the stabilization and that gave us a high hope, we were loosing confidence before. The mathematical model or the transfer function we found was going correct with real time outputs. We were happy about that. Last but not least, the yay moment was when we tuned the robot way correctly and it balanced for more than 30seconds.
What we learned
We learned a lot, a lot. From kinematics, mathematical modelling, control algorithms apart from PID - we learned about adaptive control to numerical integration. W learned how to tune PID coefficients in a proper way mathematically, no trial and error method. We learned about digital filtering to filter out noisy data, along with that learned about complementary filters to fuse the data from accelerometer and gyroscope to find accurate angles.
Whats next for Istable
We will try to add an onboard display to change the coefficients directly over there. Upgrade the algorithm so that it can auto tune the coefficients itself. Add odometry for localized navigation. Also use it as a thing for IoT to serve real time operation with real time updates.
Credits
To Deblina Chattopadhyay(deblinachattopadhyay280500@gmail.com) for making this project together.
#include "Wire.h"
#include <MPU6050_light.h>
#define alpha 0.5
float xang = 0.0;
MPU6050 mpu(Wire);
long ps = 0;
int bs=17, th=220, errorth=1;
static volatile float error = 0.0, pid = 0.0, lerror = 0.0, terror = 0.0, sp = 91.50, kp = 4, kd = 0.55, ki = 0.97;
void IMUsetup()
{
Wire.begin();
byte status = mpu.begin();
Serial.print("MPU6050 status: ");
Serial.println(status);
while (status != 0) { }
Serial.println("Calculating offsets, do not move MPU6050");
delay(1000);
mpu.calcOffsets();
Serial.println("Done!\n");
}
void setup() {
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(12, OUTPUT);
pinMode(7, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
Serial.begin(115200);
IMUsetup();
}
void loop()
{
long ps = millis();
mpu.update();
float xraw = mpu.getAngleX();
double dang = mpu.getGyroX();
xang = alpha * xraw + (1 - alpha) * xang;
error = sp - xang;
pid = kp * error - kd * dang + ki * terror;
terror += error;
if (terror > 255)
terror = 255;
else if (terror < -255)
terror = -255;
if (xang < 60.0 || xang > 120.0)
{
rightMot(0);
leftMot(0);
}
else
{
if (abs(error)<errorth)
leftMot(pid);
else
{
rightMot(pid);
leftMot(pid);
}
}
while (Serial.available() > 0)
{
char x = Serial.read();
String dat = "";
if (x == 's')
{
while (Serial.available() > 0)
dat += (char)Serial.read();
sp = dat.toDouble();
printstats();
break;
}
else if (x == 'p')
{
while (Serial.available() > 0)
dat += (char)Serial.read();
kp = dat.toDouble();
printstats();
break;
}
else if (x == 'i')
{
while (Serial.available() > 0)
dat += (char)Serial.read();
ki = dat.toDouble();
printstats();
break;
}
else if (x == 'd')
{
while (Serial.available() > 0)
dat += (char)Serial.read();
kd = dat.toDouble();
printstats();
break;
}
else if (x == 'b')
{
while (Serial.available() > 0)
dat += (char)Serial.read();
bs = dat.toInt();
th=250-bs;
printstats();
break;
}
else if (x == 'e')
{
while (Serial.available() > 0)
dat += (char)Serial.read();
errorth = dat.toInt();
printstats();
break;
}
}
}
void printstats()
{
Serial.print(sp);
Serial.print(" ");
Serial.print(kp);
Serial.print(" ");
Serial.print(ki);
Serial.print(" ");
Serial.print(kd);
Serial.print(" ");
Serial.print(errorth);
Serial.print(" ");
Serial.println(bs);
}
void rightMot(int speed)
{
if (speed < -th)
speed = -th;
if (speed > th)
speed = th;
if (speed > 0)
{
digitalWrite(A1, HIGH);
digitalWrite(A0, LOW);
analogWrite(9, bs + speed);
}
else if (speed < 0)
{
digitalWrite(A1, LOW);
digitalWrite(A0, HIGH);
analogWrite(9, bs + speed * -1);
}
else
{
digitalWrite(9, LOW);
digitalWrite(A1, LOW);
digitalWrite(A0, LOW);
}
}
void leftMot(int speed)
{
if (speed < -th)
speed = -th;
if (speed > th)
speed = th;
if (speed > 0)
{
digitalWrite(12, HIGH);
digitalWrite(7, LOW);
analogWrite(10, bs + speed);
}
else if (speed < 0)
{
digitalWrite(12, LOW);
digitalWrite(7, HIGH);
analogWrite(10, bs + speed * -1);
}
else
{
digitalWrite(10, LOW);
digitalWrite(12, LOW);
digitalWrite(7, LOW);
}
}
IStable - An agile self balancing robot, that can carry payload
- Comments(0)
- Likes(3)
- Deblina Chattopadhyay Dec 19,2021
- Guang Ning Dec 15,2021
- (DIY) C64iSTANBUL Dec 03,2021
- 1 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
-
10design
-
9usability
-
10creativity
-
10content
More by Avijit Das
- Saviour - Well a Saviour in Juncture SaviourInspirationThe countless stories and movies like the Lord of the Flies, Robinson Crusoe, Tita...
- IStable - An agile self balancing robot, that can carry payload IStableInspirationWhen we ride a cycle we to steer the cycle towards the direction we fall, and that...
- A robust Clock The project is about a digital clock that shows you accurate time and date and it can be used as sto...
-
-
-
kmMiniSchield MIDI I/O - IN/OUT/THROUGH MIDI extension for kmMidiMini
128 0 0 -
DIY Laser Power Meter with Arduino
190 0 2 -
-
-
Box & Bolt, 3D Printed Cardboard Crafting Tools
171 0 2 -