Go Down

Topic: Self balancing robot issue (Read 22823 times) previous topic - next topic

lukagabric

Hi all,

I've been working on a self balancing robot (http://goo.gl/D4Sl61) using Arduino UNO, IMU is 6 DOF MPU6050 (GY521) Accel + Gyro, L298N Motor Driver, 2 x 12V 122rpm DC motors with 80mm wheels.

To get correct angle, I'm using Kalman filter which is providing results with little noise, here is the Processing video: http://youtu.be/JN4TPRrLeRc.

I've posted the source code (sketch + libraries) on my GitHub repo:

https://github.com/lukagabric/Franko

The robot oscillates a couple of times before it falls over (up to 3 seconds max). I have 3 potentiometers for PID tunings. I've spent quite some time trying to tune the system but with no success. Any help would be much appreciated.

Thanks,
Luka.

johnwasser

This project might provide some hints:
http://students.iitk.ac.in/eclub/assets/documentations/summer12/self-balancing-bot.pdf

Check out the PID Tuning section.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

Nishant_Sood

This is a very good source that I'm reading too! >> http://blog.tkjelectronics.dk/2012/09/a-practical-approach-to-kalman-filter-and-how-to-implement-it/
"Real Men can Accomplish  Anything"

- skype : nishants5  
ਫ਼ਤੇਹ ਕਰੁਂ!
www.winacro.com

lukagabric

#3
Mar 24, 2014, 05:22 pm Last Edit: Mar 24, 2014, 05:33 pm by lukagabric Reason: 1

This is a very good source that I'm reading too! >> http://blog.tkjelectronics.dk/2012/09/a-practical-approach-to-kalman-filter-and-how-to-implement-it/


I don't think Kalman is the issue... The values are without noticeable noise, you can check the video. I recorded the graph from Processing.

lukagabric


This project might provide some hints:
http://students.iitk.ac.in/eclub/assets/documentations/summer12/self-balancing-bot.pdf

Check out the PID Tuning section.


I've seen this method mentioned on a number of self balancing robot projects. I've already tried tuning the robot like that quite a few times but with no success. I'm not sure if the issue is in code or maybe the design itself. I tried to replicate the design from other self balancing robot projects I found online...

charliesixpack

You are correct that you do not need a Kalman filter.  You also do not need an accelerometer.  Check out the attached document for some of the myths concerning balancing robots.

johnwasser

Perhaps your tuning knobs don't cover the stable region.  Try changing the range on your various tuning knobs (one at a time) to allow for finer tuning as you approach usable settings.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

lukagabric

#7
Mar 24, 2014, 08:40 pm Last Edit: Mar 25, 2014, 12:10 am by lukagabric Reason: 1

Perhaps your tuning knobs don't cover the stable region.  Try changing the range on your various tuning knobs (one at a time) to allow for finer tuning as you approach usable settings.


For kp i tried ranges from 0 to max output, for ki i tried ranges from 0 to 4 times max output and for ki very small values... everything as advertised on other projects but no luck.

lukagabric

Just to follow up.

I was suggested to try out this implementation for MPU6050 (instead of reading and combining data using Kalman filter): http://goo.gl/A1W2uP

After I implemented that I got far better results than before, still not balancing but I haven't had the time to play with PID tuning yet. I plan to add a running average filter and place the MPU a little closer to the base of the robot. I hope that it will improve stability and the robot would finally balance. Here is a clip of current progress, even though the robot is still not balancing: http://goo.gl/2LbvGN

polyglot

Using a Kalman or any other form of filter introduces latency into your control loop, which will make it much harder to keep the loop stable.   Think of it this way: more delay means less phase margin.

lukagabric

I'm not using Kalman, just reading the MPU6050 values I get. After some PID tuning and adjusting the wheel speeds this is the result I get. Hope to improve stability a bit more:

https://www.youtube.com/watch?v=mW9SlK1hiZA

thw777

Hello,

I think you might need a feedback from your motors. DC motors have a dead zone and do not start to move until the applied voltage overcomes it's friction/robot weight. It will usually overshoot right after its first move. In other words, the voltage-speed control is non linear. You might also notice that the motor will operate at different speed when different load is used at the same voltage. When there is a load, your motor driver's input speed differs from the actual motor's output speed.

Perhaps you might want to attach a tachometer or use motors with encoders. Either of these device will be able to feedback the motor's actual speed. Then you can use PID to tune the motor's speed.

Try to tune your motor's speed response first, making sure that it's speed can be controlled linearly before tuning the balancing PID.

Hope that helps;)

-thw777

lukagabric


Try to tune your motor's speed response first, making sure that it's speed can be controlled linearly before tuning the balancing PID.


I have noticed a lag when the robot gets an offset from the vertical position. It takes a split of a second for motors to start moving. Is that a dead zone? I feel like the motors should have started to move slowly, but they lag and then they start to move fast right away. The robot is balancing, but I think the robot would balance much better if the wheels would turn a bit more responsively from the vertical position. How to compensate for that dead zone? Currently I output the speed from 0->255. Should I map the speed of 0->255 to something like 30(or so)->255 to compensate for the wheels not moving due to the friction of the wheels and the weight of the robot? Is there a way to get the linear speed control (or close to that) of the wheels with current motors without adding additional components like encoders?

wildbill

When the PID responds to a small error, the resulting output will be small. It sounds as though, as suggested, your motors don't do anything for low values of PWM.

Quote
Should I map the speed of 0->255 to something like 30(or so)->255 to compensate


Sounds like it would be worth a try.

lukagabric

Here are two more videos after I added motor dead zone compensation:

https://www.youtube.com/watch?v=i-PIlF5rdAA
https://www.youtube.com/watch?v=anxJNQCpQuA

Go Up