MPU-9250 Teensy Library

BMI160/BMM150 Librariies

Hi Brian

If you are interested I found two BMI160 accel/gyro libraries that will run out of the box on the Teensy, I know because I tested them:

1. The first one is based on the CurieIMU BMI160 library by hanyazou that he has since modified from when I was using it on a CurieIMU to run on any Arduino with the BMI160: https://github.com/hanyazou/BMI160-Arduino

2. The second is by DFRobot that is pretty much a direct implementation of the BOSCH BMI160 sensor API that you can find here: https://github.com/DFRobot/DFRobot_BMI160.

There is a third library I found that allows for linking a BMM150 to the BMI160 and reading them together. This version I have not tested yet. You can find it here: https://github.com/KZSLAB/BMI160_Arduino_Library
 
Hi Brian

Tests to perform on potential replacement sensors.

Mike

I haven't actually done this test yet, but I have a bunch of sensors sitting around, so I should probably design an experiment and try it out. Assuming all the potential sensors meet the requirements (i.e. necessary sample rate, full scale ranges, etc), then I think the following are important:
1. Noise
2. Stability at constant temperature
3. Stability over varying temperature
4. G sensitivity
5. Cross axis error

The noise and stability tests are probably the easiest to measure. Simply recording the sensor over a long period of time at a stable temperature and forcing the sensor through a temperature range.

For the G sensitivity and cross axis error, I'll have to think about whether simple tests can be designed for those.
 
Hi Brian,
Been busy testing the BMM with the BMI sensor. I ran a short 2 hour test just to see the sensor noise at 2g/250dps and to see if there is was any variation as time progressed. It actually looked pretty good at least at room temp. Last time I did this with a couple of sensors I put it in the freezer and then just let it warm up as I was taking data. Maybe I will do that later. Here is an excel spreadsheet of the data for the accel and gryo.

View attachment RawData.zip

I also ran it with a couple of Kalman filters (my new version of YAKF, which I posted on the other thread I think and NXPMotionSense that is used for the propshield) and they gave me some good results. I didn't notice much of a yaw drift as we saw before. But just as a side note I never could get the 9250 working correctly with the NXPMotionSense Kalman Filter.

I just downloaded your uNAV-AHRS code to give it a try. I will keep you posted on how that goes.

v/R
Mike

UPDATE: I tried your uNAV-AHRS 7-state and it would start fine but go over to NaN's. Any idea why that would happen?
 
Last edited:
Hi Brian
Got it finally working - was an error on my part - forgot to change the gryo data to rads/sec. Anyway as in previous 9250 testing roll and pitch stayed very stable but yaw would start drifting after a few minutes. Just thought I let you know. I was a relatively slow drift as compared to before.

Mike
 
Hi Brian.
More info for you. Since I couldn't give up on comparing these sensors with the 9250 and our stable of Kalman filters I decided to test with your first uNav code base that started the other thread and see what would happen. Here is the complete sketch: View attachment microNav_Bosch_ver.zip. After letting it run for about an hour or so and me moving it around at the beginning yaw stayed very stable +/- 1 deg or so. In the figure below you are going to see 2 spikes in yaw, the first is me intentionally rotating and shaking the IMU to see what would happen and putting it back into about the same position that I started. The second spike I am not sure what happened I may have bumped the desk by accident.

Picture1.png

Enjoy
Mike
 
All my tests are pretty much at room temp. Its kinda of cool in the house today but when its my testing was done with AC on. So not sure how much of an impact there would be. BTW the BMM150 has the ability to do temperature compensation in case you didn't notice.
 
Hi Brian
Have another data point for you using the bmi160/bmm9250 combo. Yaw vs chip temp.
Picture1.png

Pretty obvious the conclusion. Probably same thing happens with the MPU-9250

Regards
Mike
 
Decided to check out the BMI160 to see variations in the raw counts vs temperature. Used real scientific method - put in the fridge for a couple of minutes and then shone a high intensity desk lamp on it :) The first column represents ax, ay and az while the second column represents the gryo variation:
Picture1.jpg

Interestingly enough gyro not really affected by temperature but on the other hand the accelerometers are. Ran the tests at 2g and 250dps.

Regards
Mike

EDIT: Years ago I did this for the MPU-6050 and generated temperature compensation curves: http://cc.bingj.com/cache.aspx?q=mp...lang=en-US&w=5Cfx8qk1N-7NEqorlvvAPJlT7WE2Ijgq wonder if the same applies to the 9250
 
Me again Brian. Did the same experiment the MPU-9250 using Onehorse's version of the 9250.
Picture1.jpg

Edit: I also just plotted the magnetometer values and noticed the sensitivity to disturbances. When I first start the tested I moved the heat source closer to the MPU9250 and you can see the shift to a steady state from about 20 to 25 degs. After that I was moving the heat source (My desk lamp - all metal) a little closer each time and again you see the shift in mag readings.
Picture1.jpg
 
Last edited:
At least all the temperature variations are pretty linear! Seems like we could come up with a compensation factor based on testing like this; it would just be a scale factor and bias.
 
going to work on this a bit, did something similar a few years back but have to remember how I did it. :)
 
Hey Brian

Was incorporating the temp correction curves for Onehorse's MPU9250 but was getting some strangeness with conversions. Was getting reverse spikes in temperature readings, in other words, it would stay steady at 28degs and then spike down to 21 degress. This is also dependent on SRD, Accel and gryo range. Also, the cal correction always seemed be spiking as well. Yet when I printed only the raw counts and temp it seemed to work fine. Also, kept having problems with making it work with i2c_t3 at any other speed than 100K. I switched to a different MPU-9250 breakout board (brand new) and same thing happened.

So, I converted Kris Winer's MPU-9250 sketch into a library format and ran it at 8g and 500dps. Seems to working much better even at 400K with Wire. He does one thing interesting when I sets up his initial biases for the accelerometer - he sets a temperature compensation bit in the accelerometer register. So I ran a couple of tests using the various Kalman filters I been playing with. The funny thing is the only one that seems to working, i.e., stable is your original microNav code. Here are the results:
Picture1.png

If setting the accel temp compensation bit is working only have to worry about the gyro which I have an idea on.
 
Not sure why - except to play with SPI - I have a pair of amazon SPI/i2c MPU 9250's coming $7.20 each - will have to find an SPI library for them - that is what you were using right Mike?

In case I want to try this:
Code:
	// Asynch support (DMA )
#ifdef SPI_HAS_TRANSFER_ASYNC
	bool transfer(const void *txBuffer, void *rxBuffer, size_t count,  EventResponderRef  event_responder);
 
I2C with my library? Are you using a Teensy and can you let me know your Arduino and Teensyduino version numbers?

ESP32 has been messed up - got a TON of issue reports this last week regarding I2C for all of my sensor libs and it's definitely the ESP32 core's implementation of a repeated start that got messed up.
 
Hi Brian,

Yep. I2C with your library. The one I converted from Kris seems to be working. I am using Arduino IDE 1.8.7 with Teensyduino 1.44-beta-2. Strange - thought I installed 1.44.

Mike

EDIT: Guess what I did install the 1.44 but the splash and about still shows beta2.
 
Hi Brian,

Yep. I2C with your library. The one I converted from Kris seems to be working. I am using Arduino IDE 1.8.7 with Teensyduino 1.44-beta-2. Strange - thought I installed 1.44.

Mike

EDIT: Guess what I did install the 1.44 but the splash and about still shows beta2.

Thanks, installing and I'll see what I can find about it.
 
Back
Top