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.
Gilbert
Posts: 16
Joined: Sun Sep 09, 2018 11:10 am

MPU 9250 generating garbage

Post by Gilbert » Mon Oct 29, 2018 12:49 pm

Hi,

I have hooked up a MPU9250 gyro to my Pyboard and the connection seems OK exept for the gyro and accelaration data being garbage.
Temperature reading is OK and 'mag' seem OK too.
The gyro data looks like it is acceleration data (shaking the 9250 produces high values) and the acceleration data is very random but always low values.

In the past I 'played' with Arduino and the MPU 6050 and I remember that the 6050 interrupt pin was also connected and used, to avoid buffer overflow. But apparrently this is not the case with this Python approach ..?

Help!

Gilbert

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

Re: MPU 9250 generating garbage

Post by OutoftheBOTS_ » Mon Oct 29, 2018 9:15 pm

the acceleration reads linear force this is gravity + g-forces. usually g-force is very low so a acceleration mainly reads the direction of gravity. Try rotating the MPY9250 so that gravity is pulling on it at a different angle and see if the values change

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

Re: MPU 9250 generating garbage

Post by Gilbert » Tue Oct 30, 2018 9:58 am

Thanks.

You are right, the MPU8250 is indeed working properly.
What confused me is that I was expecting to see X,Y an Z angles (as with Arduino) instead of "turn rates" (angle change rates).
After doing some reading and research I understand now that I can produce these angles myself.
Is there any advice you can give me to get this done? (articles, programs, etc)

Gilbert

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

Re: MPU 9250 generating garbage

Post by OutoftheBOTS_ » Tue Oct 30, 2018 10:20 am

Yes the naming of the sensors is quite confusing.

The gyro is in fact not a gyro but a sensor that reads angular force (rate of rotation).

The accelerator-meter doesn't read acceleration but rather reads linear force (mainly the pull of gravity).

The only correctly named sensor is the magnetometer that does in fact measure the force created by magnetic pull.

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

Re: MPU 9250 generating garbage

Post by pythoncoder » Tue Oct 30, 2018 11:15 am

@Gilbert have you seen the resources here?
Peter Hinch
Index to my micropython libraries.

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

Re: MPU 9250 generating garbage

Post by Gilbert » Tue Oct 30, 2018 12:33 pm

Hi Peter (pythoncoder),

Thanks!
I was planning to contact you regarding this subject, as I have seen that you were (are) very much envolved in the development of the IMU9250 driver which I am using.
I suppose that "micropython-fusion" is what you have in mind when pointing me to these resources?

Gilbert

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

Re: MPU 9250 generating garbage

Post by pythoncoder » Tue Oct 30, 2018 1:15 pm

I hadn't appreciated that you're already using our driver. But the sensor fusion module may also be of interest.
Peter Hinch
Index to my micropython libraries.

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

Re: MPU 9250 generating garbage

Post by Gilbert » Tue Oct 30, 2018 2:17 pm

well, I think I will need the sensor fusion module if I want to have the angles as well. (And I guess I will need these (at least the Z-axis) to make a balancing two wheeler.)

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

Balancing robots

Post by pythoncoder » Wed Oct 31, 2018 8:39 am

A balancing robot doesn't usually need Madgwick sensor fusion. You might like to study this forum thread, which includes work done by myself and others. My effort uses the accelerometer and gyro only whose readings may be combined using complementary filters or by Kalman filtering. The latter is supposedly better, but I found little difference. These fusion methods are much faster and simpler than full Madgwick sensor fusion.

In my experience the key to building a balancing robot is in the mechanical design, especially isolating the sensor from vibration. Having plenty of mass at the top aids stability. My first attempt wouldn't balance at all. The second works but really needs to be rebuilt with more powerful motors. I think these would improve the speed of the PID loop; they would certainly improve its ability to negotiate inclines.
Peter Hinch
Index to my micropython libraries.

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

Re: MPU 9250 generating garbage

Post by Gilbert » Wed Oct 31, 2018 6:12 pm

Thanks.
I gave it already a quick glance and I noticed that Jeffm speaks of a "target angle" which suggest that he worked with angles.
But I will have a much closer look.
(A couple of years ago I made a balanced 2-wheeler with Arduino using just a target angle and a PID controller. It worked so and so.
And then the summer came calling me outside and I never touched it again :-))

Post Reply