Page 1 of 2

MPU 9250 generating garbage

Posted: Mon Oct 29, 2018 12:49 pm
by Gilbert
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

Re: MPU 9250 generating garbage

Posted: Mon Oct 29, 2018 9:15 pm
by OutoftheBOTS_
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

Re: MPU 9250 generating garbage

Posted: Tue Oct 30, 2018 9:58 am
by Gilbert
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

Re: MPU 9250 generating garbage

Posted: Tue Oct 30, 2018 10:20 am
by OutoftheBOTS_
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.

Re: MPU 9250 generating garbage

Posted: Tue Oct 30, 2018 11:15 am
by pythoncoder
@Gilbert have you seen the resources here?

Re: MPU 9250 generating garbage

Posted: Tue Oct 30, 2018 12:33 pm
by Gilbert
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

Re: MPU 9250 generating garbage

Posted: Tue Oct 30, 2018 1:15 pm
by pythoncoder
I hadn't appreciated that you're already using our driver. But the sensor fusion module may also be of interest.

Re: MPU 9250 generating garbage

Posted: Tue Oct 30, 2018 2:17 pm
by Gilbert
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.)

Balancing robots

Posted: Wed Oct 31, 2018 8:39 am
by pythoncoder
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.

Re: MPU 9250 generating garbage

Posted: Wed Oct 31, 2018 6:12 pm
by Gilbert
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 :-))