rdeliaus
Posts: 1
Joined: Thu Feb 13, 2020 11:37 pm

MPU-9250 Magnetometer Wide Range of Values

Thu Feb 13, 2020 11:55 pm

I'm using the following Python Code with the SparkFun IMU Breakout MPU-9250 SiP.

https://github.com/jefmenegazzo/MPU9250

I'm calibrating the sensors before any movement begins. The Accelerometer and Gyroscope readings appear to be fine, however the readings I am getting from the Magnetometer are showing a wide range of values.

I have the MPU-9250 mounted with two motors/wheels in a robot on a raised platform (so it doesn't move during testing). I first calibrate the Magnetometer which reads near zero values. Upon starting and stopping the motors (again no real movement), the Magnetometer values swing pretty wildly (-10 + 20). What is really strange is when the motors are stopped, the Magnetometer values never goes back to near zero but it keeps these high values, again the bot never moves during this test.

I also isolated the 3.3v power to a clean source to make sure noise was not a factor at least in the power line.

I suspect this is either a problem with the calibration function, or the physical layout / circuit/device. Any thoughts on this are appreciated.

Thanks.

Raspberry Pi Zero W
MPU-9250 using I2C communication
3.3v source (also tried 3.5v & 3.7v)

BBUK
Posts: 142
Joined: Tue Dec 18, 2012 10:34 am

Re: MPU-9250 Magnetometer Wide Range of Values

Thu Feb 20, 2020 4:03 pm

How close is the sensor to the motors? (Motors have a large magnetic field associated with them and that field will change as the shaft rotates).

I'm messing around with magnetometers quite a lot at the moment for one of my projects and something I have found is that previously unmagnetised metal around the sensors can easily get magnetised and throw readings off...

BBUK

ElEscalador
Posts: 786
Joined: Tue Dec 15, 2015 4:55 pm
Location: Detroit, MI USA
Contact: Website

Re: MPU-9250 Magnetometer Wide Range of Values

Thu Feb 20, 2020 4:49 pm

Motors make wicked big magnetic fields and even saturating the magnetometer itself and then turning the motors off it can take a while before the magnetometer ever reads the uncorrupted reading again. Generally speaking, magnetometers are not really useful for indoor robots - too many metal things that warp the earth's field. Instead, we mostly use odometry with the accelerometer and gyro - into a kalman filter, ideally.
Robotics tips, hacks, book extras https://youtube.com/c/practicalrobotics

blimpyway
Posts: 222
Joined: Mon Mar 19, 2018 1:18 pm

Re: MPU-9250 Magnetometer Wide Range of Values

Sun Feb 23, 2020 1:31 pm

The magnetometer in 9250 is meant to detect earth's magnetic field intensity and direction.

That's one reason you will probably never reach a place where it reports zero. You should not expect that.

Being quite sensitive it also is easily affected by
nearby functioning power equipment, being either own motors or nearby power lines carrying current.

Also iron used in buildings will distort the earth's field so it's difficult to obtain a reliable sense of orientation based on magnetic sensor readings.

Might be possible, I recall reading about some research attempting to obtain position estimation by mapping these variations in every room/position in a building and estimating position by recording and recognising these... distorting patterns which change from one place to another.

It probably still isn't too reliable.

Return to “Automation, sensing and robotics”