Page 1 of 1

9250: Acc->OK, Gyro->OK, Magnet=Error

Posted: Wed Aug 01, 2018 1:22 am
by viktor_au
Gear: Arduino Uno R3(smd), LCD20x4(i2c), mpu9250(Unbranded/Generic)
What is done:
FC8 is updated
Uno is tested in different project - OK
LCD20x4 is tested - OK
The same mpu9250 tested with same Uno- in Arduino IDE (Brian R Taylor project:mpu_9250_bolder_library) - OK

Any help?

Test results

Re: 9250: Acc->OK, Gyro->OK, Magnet=Error

Posted: Wed Aug 01, 2018 1:25 am
by viktor_au
FC8 project file

Re: 9250: Acc->OK, Gyro->OK, Magnet=Error

Posted: Wed Aug 01, 2018 11:48 am
by mnf
I would guess it is getting stuck in the until flag_magnet_update =1 loop in the Magnet macro - so no new data is arriving,
if new data is received then the "no new data" message can never be reached (the flag will always = 1) - you could add a loop counter and give up testing after a specific number of loops (and I would add a short delay to the loop too?)

ie until flag_magnet_update = 1 OR tries =100

(I'd also make the flag variable local to the macro (and initialise it to 0 there (unless memory is very tight))

Martin

Re: 9250: Acc->OK, Gyro->OK, Magnet=Error

Posted: Wed Aug 01, 2018 1:08 pm
by viktor_au
I think the flag can be 0 or 1.
I did what you said and increased the time inside the accelerometer loop and magnetometer loop.
Accelerometer returns 1.
Magnetometer returns nothing. Not 1, not 0. No readings at all. I think this is a problem
Thanks mate.

Re: 9250: Acc->OK, Gyro->OK, Magnet=Error

Posted: Wed Aug 01, 2018 4:34 pm
by Benj
Just investigating this for you now.

Re: 9250: Acc->OK, Gyro->OK, Magnet=Error

Posted: Wed Aug 01, 2018 5:50 pm
by Benj
Right I think I have now fixed the issue, it was a bit more complex then I originally thought to access the magnetometer device hidden inside the MPU9250.

I've now pushed the new component to the Flowcode 8 update system.

Let us know how you get on.

Re: 9250: Acc->OK, Gyro->OK, Magnet=Error

Posted: Wed Aug 01, 2018 10:28 pm
by viktor_au
Thank you Benj for help.

What is done:
FC8 -> updated

Results:
UpdateCompassData flag returns 1. (OK now.)
The program is not frozen and Acc/Gyro readings -> OK

However:
Magnetometer ->CollectXYZData->Returns Zero (not X, not Y, not Z do return any data)

Re: 9250: Acc->OK, Gyro->OK, Magnet=Error

Posted: Fri Aug 03, 2018 1:40 pm
by Benj
Thanks for letting me know.

I have had another go at the component source and for me it is now working correctly.

I've pushed the new component to the update system now so you should be able to check for updates and get the new version.

Let me know how you get on.

Re: 9250: Acc->OK, Gyro->OK, Magnet=Error

Posted: Sat Aug 04, 2018 12:58 am
by viktor_au
Thanks Benj.
After I updated the FC8 I have the same results.
However.
If your setup works (now) I have to look at my hardware/software setup.
I am not sure what do I do wrong (and what do I have to change) but I will update this post shortly.

Re: 9250: Acc->OK, Gyro->OK, Magnet=Error

Posted: Sun Aug 05, 2018 11:47 am
by viktor_au
FC8_9250_Error_3.jpg
FC8_9250_Error_3.jpg (129.48 KiB) Viewed 9092 times
As Benj mentioned before: The magnetometer setup is a little bit complex than the gyroscope and the accelerometer.

I did some recearch and found:
MPU9250 is one of the most advanced combined Accelerometer, Gyroscope and Compass small size sensors currently available. They have many advanced features, including low pass filtering, motion detection, and even a programmable specialized processor. Having nearly 130 registers however, with many settings, they are also very difficult to work with from code, so many users do recommend to use the Bosch BMO055 (It has the Sensor Fusion engine built in, generating the acceleration / heading / quarternion information right outside the box without any MCU post-processing ).
The MPU-9150 contains the MPU-6050 and an AK8975 magnetometer from AKM. The MPU-9250 contains a MPU-6500 and AK8963. The same differences between gyro/accel are the same you see with 6050 v. 6500.
There are different versions of 9250 on market. Some have 5v to 3.3v circuit, some do not.

What was the problem in my project: 9250 magnetometer (AK8963) did not return XYZ data with flag =1.

After I read the datasheet I changed the magnetometer:
Sensor properties->Compass data rate from 8 Hz to 100 Hz.
The problem was solved.

Gear used: Arduino Uno R3 smd, 9250 module (3.3v), LCD 20x4 i2c. At one stage I used the level shifter and tried the 8Hz again. Level shifter did not help.
Note: mpu9250 Channel property has to be selected every time FC8 project is loaded, otherwise the field is empty and FC8 produces from 9250 the -1 results.

Reading the WHOAMI
Who Am I - reg117, address 0x75
The returned value was 113 or 0x71.

Sensor properties->Compass data rate or MPU-9250/AK8963 Sample and Readout Rate.
The AK8963 datasheet says that there are three modes for reading the data: SINGLE, CONT1 and CONT2. The CONT1 mode provides a data rate of 8 Hz and CONT2 provides the 100 Hz. In a Single mode ...the Sensor tag puts the magnetometer to sleep after every read (?).

Looks like Uno does not like the default setup of 8Hz and works only in 100Hz data rate. Again, I can be wrong, but it is the 'Continuous measurement mode 2' which makes Uno run.

P.S.: My register reading knowledge is zero. I hope Benj will find time to explain why CNTL reading shows 0...0011 instead of 0...0110.