Self Balancing Robot and the MPU 6050 Accelerometer/gyroscope
For now I’m just going to put up some links to the project I was trying to duplicate.
Duplicating failed, but I know why - The guy didn’t make it very clear how things are/were hooked up, but he did explain how a self balancing robot worked pretty good, so links are needed.
His code is/was written for the old IDE which of course caused some problems, they were pretty easy to fix. But in the long run it wasn’t worth fixing since it didn’t work with the hardware I got. From what I have read there are dozens of variations on the MPU 6050 Accelerometer/gyroscope, and getting the raw data off them is easy, getting usable data each one deals with that differently.
So while he was using a MPU6050 - it wasn’t the same as the one I got my hands on, and works a lot different.
He code was documented so poorly thou I couldn’t make heads or tails out of what he was doing.
So - as it stands right now, my self balancing robot project is on hold.
(It looks like he went thur 2 or 3 different versions of this robot, which maybe where some of the confusion comes from as well)
Same guy - these are the 3D files used to print it out….and his idea of using a dowel rod worked pretty well. I didn’t make my own “shield” opting for the motor/sensor shield I already had, the UNO board 3D print turned out really nice, and could be used just as mount for a UNO board.
Here is his code:
The Good Information he points to - really was good information it lead me to the point of how many different models of the MPU6050 there are.
The code in the GOOD information didn’t work either thou, and was written for a different gyroscope
Kerry Wong - has a lot of information about the science behind a self balancing thing, which is probably good to know. (There is no code that I saw on the site, but a lot of math, and theory)
mrfid72 (Youtube name) - came up with a different self balancing robot, which is a lot closer to the one I built, so I figured I’d give his code a try, and I got spinning servos, I think he is using yet another MPU6050 that looks like mine, but works differently.
(Or it could be that his code gave some errors in the math as it was compiling, that I think I fixed, but I may have fixed it the wrong direction)
Finally I came across this guys code: He is using a MPU6050 and servo motor, it looks like he also has some potentiometers hooked up. It looks to like he is only using one motor (?)
I just found the code, I didn’t find any pictures of his robot, video, or wiring diagrams.
But his code was giving out results from the gryoscope in the serial monitor. Also, when I did hook one motor up to his output pin, and I tilted the robot from side to side, the wheel would speed up or slow down. So I think his is the closest yet in terms of working with the MPU6050 I have.
The next step I think is to print out, or go line by line at the two peice of codes that almost work, and see if I can’t jam them together and get the results needed to make this thing work.
The MPU6050 -
There is actually quite a bit of information out there about this, but this tutorial was one I found to be a bit better then others. He does kind of hit on there being a lot of variations, but doesn’t go into that in a whole lot of detail.
The MPU6050 is an I2C device, that needs some special codes to make it work and do what it should do, and getting the raw (more or less unusable) data out of it is easy. Getting usable data out of it not so much due to the different variations and firmwares. And even different breakout boards label pins differently.
The MPU-6050 can be found on eBay for about $2 dollars - it is a 6DOF 3 Axis Gyroscope and Accelerometer - and from what I have read it is very accurate, but not so easy to use.
mrfid72 (Youtube name) - I was able to get his code to work, at least to the point that I can say my Robot is balancing itself.
His robot is the closest robot I have found to the one I built, but quite a bit of the math had to be changed in the original code. And I’m not sure if the changes I made are 100% right or not, they have to be getting close.
No comments:
Post a Comment