Go Down

### Topic: Balancing robot for dummies (Read 62240 times)previous topic - next topic

#### pseddon

#105
##### Feb 14, 2013, 05:44 pm
Found your code - that is what I was hoping for.

Thanks, Peter

#### Lauszus

#106
##### Feb 14, 2013, 05:47 pm
Good. Note that if you are looking for the PS3 version, have a look at the PS3 branch: https://github.com/TKJElectronics/BalancingRobotArduino/tree/PS3

#### john_john

#107
##### Mar 19, 2013, 07:09 pmLast Edit: Mar 19, 2013, 07:30 pm by john_john Reason: 1
Hey guys! I am building self-balancing robot too and I would be grateful if you could help me a little bit to understand the following concepts:

1. Integral term (i_term). This term always grows in the existance of the error. Many of you use the ceiling values for this term. The first question is - if my max val for the torque is 255 what are appropriate ceiling values for the i_term and how to determine them?

2. If my robot overshoots, the error sign will change. How to go about the i_term in this case, which might be quite big causing lag? Should I just zero integral term every time my error change in sign?

3. I am using self-made optical rotary encoder. You guys are adding terms to the PID and I cannot get my head around it. So it's sort of a method of providing a feedback to the controller in terms of velocity? But in this case our set-point = zero error is in terms of the angle. How you relate both?

Patricks code:
pTerm_Wheel = Kp_Wheel * count;           //  -(Kxp/100) * count;
dTerm_Wheel = Kd_Wheel * (count - last_count);

4. Somebody wrote about using a potentiometer in order to determine values for PID coefficients. Can you provide some information how it's done?

5. Also can you give some ideas how could I save a stream of data (my error) into external memory? The purpose is to analyze the responce.

#### Lauszus

#108
##### Mar 25, 2013, 03:09 am
I just released a balancing robot kit on Kickstarter: http://www.kickstarter.com/projects/tkjelectronics/balanduino-balancing-robot-kit and I thought you guys might be interested.

Here is a video of it as well:

#### susheel

#109
##### Mar 27, 2013, 11:52 pm
hello everyone.

i have been trying to build my own bot for a few months now and i have come quite far in building it, just havent got it to balance yet. but this forum is been of great help. so i finally decided to consult the experts.

I am using a 9DOF pololu IMU but as shown on previous threads i only use 2axis  accel and 1axis gyro readings which via the kalman filter give an actual angle. i use a dfrobot motor driver and dc motorrs (without encoders).

the things that i think are causing problems are

1.  The delay caused by the Kalman algorithm. this leads to a backlash since by the time the kalman output reaches zero the real bot angle already crosses vertical zero.

2.  Motor Stiction, there is no movement of the wheels at low speeds, the PWM input has to be atleast 50 (in a 0 - 255 range) for the motors to move.

3. I also started to wonder if the size of the wheels and the structural dimentions of the bot have any effect on the final balancing. most importantly does the weight distribution of the bot have to be perfect.

Please do let me know what you think. if anyone else has experienced such problems, how did you overcome them.

#### Lauszus

#110
##### Apr 02, 2013, 11:55 pm
@john_john
You should checkout my source code for my Balancing robot: https://github.com/TKJElectronics/BalancingRobotArduino

@susheel
1. Do you mean there is a problem when the angle change from 0 to 360? This can easily be fixed by making the angle 180 when the robot is upright.

2. I don't do anything to prevent that, but I have seen other people do that, but I really don't think it's necessary.

3. Try to make the robot as symmetric as possible, so one of the sides doesn't weigh more than the other - my robot can almost balance by itself. Also remember to put some weight at the top in order to raise the center of gravity. Remember that the better the mechanical structure is the better the end result will be!

#### cannon_b

#111
##### Jul 15, 2013, 08:19 pm
Did you ever get your robot to balance with stepper motors?

I haven't had the time to look at your code yet but it sounds like your having the same problems that I have..

I have no problem getting my robot to balance but it's shaking a lot and I think it's manly to the backlash.
You can see it in the video blow if you look closely you will see the shaking..

I have recently seen that I may have a problem with my IMU which the zero point is moving after a will and that I also think is do to the shaking and mess up the kalman filter..

My next step is to change the motors to the stepper motors below:
#1200 Stepper Motor: Unipolar/Bipolar, 200 Steps/Rev, 42x48mm, 4V, 1200mA
#1182 A4988 Stepper Motor Driver Carrier

#### cagiva

#112
##### Nov 06, 2014, 08:38 am
We used stepper motors and they work great. Here you can see the result:

http://youtu.be/xtMCmuR8uNU

#### kas

#113
##### Nov 07, 2014, 07:58 amLast Edit: Nov 07, 2014, 08:00 am by kas
Very nice and stable bot
No more backlash

I suspect that moving the smartphone near the the axis of rotation will make it 100% stable
Yes, I know... the eyes won't be at the right position

#### Patrik

#114
##### Dec 05, 2014, 08:43 am
Nice robot kit @Lauszus I will most likely buy one from you, liked your code as well. I'm back building some robots with my children, we bought a SainSmart InstaBots that we are tinkering with.

I will start building a new frame for my own bot in the coming holidays.
The balancing robot for dummies guide
http://www.x-firm.com/?page_id=145

#### kas

#115
##### Dec 07, 2014, 06:58 pm
Hi Patrick,

Later...
Nice to hear from you again
My balancing bot is now full digital (MPU 6050), using Lauszus modified code
Still looking for motors with no backlash...

I am now busy on another exciting  project

#### Patrik

#116
##### Dec 07, 2014, 09:04 pm
@Kas

I got the Instabot working ok I like the MPU 6050, I thing I will change the code for the Instabot to my own. I think It's a lot that can get better. i will also try Lauszus code for the IMU. When you thinker with that bot you can really see way you need motors with encoders.

In the video below you can see it balancing after tuning for 3 hours, it can get better! :
http://youtu.be/M4o_H0nWfU0

In the video below you can see it controlled from the controller, same values as the video before:
http://youtu.be/1OvLcA1cLro

The balancing robot for dummies guide
http://www.x-firm.com/?page_id=145

#### kas

#117
##### Dec 08, 2014, 08:32 amLast Edit: Dec 08, 2014, 04:00 pm by kas
Quote
When you thinker with that bot you can really see way you need motors with encoders
Yeah, without encoders, getting the bot to stay still is hopeless
Encoders are also usefull to compensate for the speed difference between left/right motors, and have straight moves.

I am now controlling the Bot with Joystick BT Commander, from my Android phone

#### Giancarlo_De_Viti

#118
##### Feb 23, 2015, 11:23 am
Hello to everybody !!

I have just discovered this forum and I'd like to show you my application of a self balancing robot.
The hardware is composed by two DC brushed motors with 65 mm diameter wheels, a 2 Amps H bridge motor driver, a 6 DOF digital IMU (3 axis accelerometer plus 3 axis gyroscope) and an Arduino UNO microcontroller.

Angular data measured by IMU components are fused via a simplified Kalman filter and used to feed a PID controller that drives the motors.

In the first prototype (www.youtube.com/watch?v=fDqIm2CmBtA) I used 122 RPM motors but the robot is a bit unstable. So I substituted the motors with 399 RPM model and now the robot is a bit more stable (www.youtube.com/watch?v=sOcq6TKG3O4).

The next step is to control the platform remotely via Xbee or  Bluetooth protocol.

Bye, Giancarlo

#### Totoxa

#119
##### Mar 09, 2015, 03:52 pm
Yeah, without encoders, getting the bot to stay still is hopeless
Encoders are also usefull to compensate for the speed difference between left/right motors, and have straight moves.

I am now controlling the Bot with Joystick BT Commander, from my Android phone

Encoders are not absolutely necessary, they are useful if you want better speed control or if you want the robot to balance and stay quiet at an angle != 0 (when you add some asymmetric load at the top).

Here is my balancing robot with motors without encoders
in the video I'm closing the speed loop.

Go Up

Please enter a valid email to subscribe

To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy