MPU 9250 generating garbage

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
OutoftheBOTS_
Posts: 662
Joined: Mon Nov 20, 2017 10:18 am

Re: MPU 9250 generating garbage

Post by OutoftheBOTS_ » Thu Nov 01, 2018 10:32 am

I have not yet built a balance bot but it 1 of those on my bucket list to build.

I have seen some pretty advanced balance bots built from Lego mindstorms. They use an IR controller to drive them around. I have seen guys build them to carry weight up inclines. I can't find right now the videos to the really advanced balance bot from Lego but here is some simple ones https://www.youtube.com/watch?v=P6b60zf1g18

All the Lego balance bots are just made with gyro sensor.

Online
User avatar
pythoncoder
Posts: 3652
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Balancing robots

Post by pythoncoder » Thu Nov 01, 2018 11:46 am

OutoftheBOTS_ wrote:
Thu Nov 01, 2018 10:32 am
...All the Lego balance bots are just made with gyro sensor.
I find that very surprising. I did a lot of reading around the subject when my first attempt failed and every solution I encountered used acceleration and gyro sensors (the former so that the robot "knows" its angle to the vertical). The video suggests that their devices use a position encoder but that doesn't provide the same information. I guess you could aim to infer its angle to the vertical by integrating the gyro, but that assumes that the device is accurately vertical when switched on. And integration tends to cause initial errors and offsets to increase with time...

Those Lego robots are very good, and have better stability than my effort which "hunts" noticeably when stationary.
Peter Hinch

Gilbert
Posts: 16
Joined: Sun Sep 09, 2018 11:10 am

Re: MPU 9250 generating garbage

Post by Gilbert » Thu Nov 01, 2018 1:13 pm

I am convinced that the Lego gyro itself uses gravity to maintain steady angles, but I think that (reasonable steady) angles are indeed enough to make balancing vehicles work.
I remember that the Arduino 6050 driver was very steady (after allowing it +/- 20 seconds to stabilize): I moved, turned and shaked the circuit and when I put it back in the original position I read the same XYZ angles as before the shaking.

A lengthly explaination and approach can be found here: https://www.youtube.com/watch?v=4BoIE8Y ... e=youtu.be which at the end flows into this one https://www.youtube.com/watch?v=j-kE0AMEWy4.

OutoftheBOTS_
Posts: 662
Joined: Mon Nov 20, 2017 10:18 am

Re: MPU 9250 generating garbage

Post by OutoftheBOTS_ » Thu Nov 01, 2018 8:24 pm

OK so many have hacked the lego gyro sensor and lego have now even put the sensor schematics online in their developers section.

The lego gyro sensor uses a ISZ-2510 sensor it is the bottom of the line sensor from the makers of the MPU9650. It is only a 1 axis gyro sensor. Lego then put a STM8 MCU on it to run the code to sample the the sensor at a high freq and calculate the bearing based upon rotation * time. The STM8 MCU then outputs this data on UART the same as all the other Lego sensors for the LEGO brick to read. The Lego brick can request either the rate of rotation(raw data) or the bearing(processed data).

The balance bot doesn't know if it is up right or not it just knows if it rotating(falling over) and the program is just a PID that stops the bot from rotating.

There is videos of people taking this robot to extreme and putting holder in the front of the bot that you can place weights in. When it is balancing you place a weight in the front of it and it has to re-balance without falling over. They then drive it up an down slopes and over bumps while holding the weight.

OutoftheBOTS_
Posts: 662
Joined: Mon Nov 20, 2017 10:18 am

Re: MPU 9250 generating garbage

Post by OutoftheBOTS_ » Fri Nov 02, 2018 12:15 am

I have also seen them build Lego balance bots with a distance sensor that reads how far away the ground is on 1 side to know whether it is falling over by the ground getting closer or further away on that side.

Online
User avatar
pythoncoder
Posts: 3652
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: MPU 9250 generating garbage

Post by pythoncoder » Fri Nov 02, 2018 8:29 am

OutoftheBOTS_ wrote:
Thu Nov 01, 2018 8:24 pm
...
The balance bot doesn't know if it is up right or not it just knows if it rotating(falling over) and the program is just a PID that stops the bot from rotating...
It can't be as simple as that, because there are an infinite number of solutions to that equation. One of which is the bot being oriented vertically and being stationary. The others have the bot at a fixed angle to the vertical but moving with constant acceleration.

Perhaps that is why they have encoders on the wheels so they can feed position (or its first or second derivative) into the PID.

If so, it begs the question why. Surely an accelerometer is cheaper than two incremental encoders?
Peter Hinch

OutoftheBOTS_
Posts: 662
Joined: Mon Nov 20, 2017 10:18 am

Re: MPU 9250 generating garbage

Post by OutoftheBOTS_ » Fri Nov 02, 2018 11:38 am

pythoncoder wrote:
Fri Nov 02, 2018 8:29 am
OutoftheBOTS_ wrote:
Thu Nov 01, 2018 8:24 pm
...
The balance bot doesn't know if it is up right or not it just knows if it rotating(falling over) and the program is just a PID that stops the bot from rotating...
It can't be as simple as that, because there are an infinite number of solutions to that equation. One of which is the bot being oriented vertically and being stationary. The others have the bot at a fixed angle to the vertical but moving with constant acceleration.

Perhaps that is why they have encoders on the wheels so they can feed position (or its first or second derivative) into the PID.

If so, it begs the question why. Surely an accelerometer is cheaper than two incremental encoders?
Yes there is encoders on the wheels and it aims to get a stable balance with 0 rotation on wheels.

The program is amazing simple the big art is in tuning the 3 varibles of the PID and the high performance bots I think have 2 PIDs.

You can see the simple program running the bot in the video they show the LabView program that is running on the bricks and there is links as well. see here http://robotsquare.com/2014/07/01/tutor ... ing-robot/

I found here a python version of this code as you can program the Lego brick in python using EV3DEV see https://github.com/laurensvalk/segway/b ... /segway.py

Post Reply