Introduction: Rollbars for Self Balancing Robot and on Stairs
Added some rollbars made from badminton rackets to my simple self balancing robot which falls over quite a bit. Now at least it can get back up most of the time.
I am sorry in that I am not creating a real build instructable because this is really a poor excuse for a balancing robot - it was more of a test platform for some ideas. I am using 60rpm continuous servos which are really too slow for self-balancing, the only reason they work is because of the unusually large wheels. You really need geared motors with a couple hundred rpm. The sensor I am using is a VTI ASCA610 inclinometer accelleromter. Probably unusual in USA but common and cheap here in china.
The only other piece of hardware is an Arduino UNO. The program is supersimple! Only two IF statements to control the servos, which are always on in one direction or the other, no PID control - this is called bang-bang control.
Here is the program: (sorry about formatting)
#include <servo.h>
Servo myservo1; // create servo object to control a servo Servo myservo2; int potpin = 0; // analog pin used to connect the potentiometer int val; // variable to read the value from the analog pin int gyroPin = 1; int gyroVal = 0; int gyroAvg = 0; void setup() { myservo1.attach(11); // attaches the servo on pin 11 to the servo object myservo2.attach(9); // other wheel myservo1.writeMicroseconds(1500); delay(15); myservo2.writeMicroseconds(1500); delay(15); Serial.begin(9600); Serial.println("Program begin..."); } void loop() { val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023) val = map(val, 0, 1023, 0, 1000); // scale it to use it with the servo (value between 0 and 100) gyroVal = analogRead(gyroPin); //gyroVal = map(gyroVal, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180) gyroAvg = analogRead(gyroPin) + analogRead(gyroPin) + analogRead(gyroPin) ; gyroVal = gyroAvg / 3; //if (gyroVal > (val - 10) and gyroVal < (val + 10)) { myservo1.writeMicroseconds(1500); myservo2.writeMicroseconds(1500); } //else if (gyroVal > (val -15) and gyroVal <= (val - 10)) { myservo1.write(110); myservo2.write(0); } if (gyroVal > (0) and gyroVal < (val )) { myservo1.write(180); myservo2.write(0); } //else if (gyroVal > ( val + 10) and gyroVal <=(val + 15)) { myservo1.write(0); myservo2.write(110); } else if (gyroVal > ( val ) and (gyroVal < 800)) { myservo1.write(0); myservo2.write(180); } Serial.print(" pot: ");Serial.print(val);Serial.print(" angle: ");Serial.println(gyroVal); //myservo.write(val); // sets the servo position according to the scaled value delay(10); // }
3 Comments
8 years ago on Introduction
Very interesting idea, it looks like it works! I just wish there were some in progress pics and more explanation of how you made it.
Reply 8 years ago on Introduction
Thought about this some more... after someone dissed my pretty little pink wobot I have decided not to do a build on it. There are many better designs out there and if you are going to invest in the hardware you might as well build a good one or get a kit. This one was basically just to test the rollbar idea and I was limited to the hardware I had on hand, basically a single sensor and the two 60rpm servos which are really too slow to build a good robot. Check out the balanbot (though not sure if it is available yet in US - I can and probably will get one off taobao.com - about a 100 bucks and all the hard work is done.
Reply 8 years ago on Introduction
Thank you for your interest. I know, I have not been creating real or useful INSTRUCTABLES. But I will work on this one and at least give enough information that you can make one. The only difficult part to get is the VTI SCA610 accellerometer. That chip, while easy to use may be difficult to get in the USA, I'm not sure. The only other piece of electronics required are two continuous servos and an Arduino UNO.
Give me a few weeks to put something up.