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

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 44 times
Been thanked: 60 times
Contact:

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

Post 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
Attachments
FC8_9250_Error_1.jpg
FC8_9250_Error_1.jpg (49.64 KiB) Viewed 6911 times
FC8_9250_Error_2.jpg
FC8_9250_Error_2.jpg (35.35 KiB) Viewed 6911 times
FC8_9250_Error_3.jpg
FC8_9250_Error_3.jpg (58 KiB) Viewed 6911 times

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 44 times
Been thanked: 60 times
Contact:

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

Post by viktor_au »

FC8 project file
Attachments
Uno_LCD20x4_i2c_2.fcfx
(37.81 KiB) Downloaded 207 times

mnf
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

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

Post 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

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 44 times
Been thanked: 60 times
Contact:

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

Post 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.
Attachments
Uno_LCD20x4_i2c_3.fcfx
(40.43 KiB) Downloaded 215 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

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

Post by Benj »

Just investigating this for you now.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

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

Post 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.

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 44 times
Been thanked: 60 times
Contact:

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

Post 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)
Attachments
m_flag=1.JPG
m_flag=1.JPG (33.15 KiB) Viewed 6861 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

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

Post 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.

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 44 times
Been thanked: 60 times
Contact:

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

Post 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.

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 44 times
Been thanked: 60 times
Contact:

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

Post by viktor_au »

FC8_9250_Error_3.jpg
FC8_9250_Error_3.jpg (129.48 KiB) Viewed 6780 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.
Attachments
WhoAmI.jpg
WhoAmI.jpg (42.6 KiB) Viewed 6780 times

Post Reply