9-axis MotionTracking gyroscope accelerometer magnetometer

Please add any feature requests for Flowcode version 7 here

Moderator: Benj

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

9-axis MotionTracking gyroscope accelerometer magnetometer

Post by stefan.erni »

Hi Ben

First of all a praise. Using flowcode to use various motion sensors is incredibly practical. Also the simulation is wonderful.
FC7_mag_comp.PNG
(20.63 KiB) Downloaded 5877 times

In the meantime, there are many 9-axis sensors. Why not integrate a 9-axis in FC8?




My suggestion is the MPU 9250. (the old mpu6050 with only 6 axis is already inFC7)
mpu92520_.PNG
(188.53 KiB) Downloaded 5877 times
The MPU-9250 is a 9-axis MotionTracking device that combines a 3-axis gyroscope, 3-axis accelerometer, 3-axis magnetometer and a Digital Motion Processor™ (DMP) all in a small 3x3x1mm package.There are already various breakout boards from this sensor. Also small board with the sensor and Bosch digital pressure sensor. Sparkfun offers a small board with Microchip CPU and MPU 9250. For hardware developers, there are symbols and modele for eagle and altium has it also even with a 3D model.
All2.PNG
(263.15 KiB) Downloaded 5877 times
https://store.invensense.com/datasheets ... REV1.0.pdf
https://www.seeedstudio.com/Grove-IMU-9 ... -2400.html
https://www.seeedstudio.com/Grove-IMU-10DOF-p-2386.html
https://www.sparkfun.com/products/13762
https://www.sparkfun.com/products/14001d

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: 9-axis MotionTracking gyroscope accelerometer magnetometer

Post by Benj »

That looks great, thanks I'll get it on the list.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: 9-axis MotionTracking gyroscope accelerometer magnetometer

Post by stefan.erni »

Hi Ben
Do you have some news about it?
will be the chip connected with I2C or SPI, or both?

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: 9-axis MotionTracking gyroscope accelerometer magnetometer

Post by Benj »

Hello,

I've made a start using I2C but not finished yet.

Going forward for v8 I am making the underlying CAL components do more of the hard work and allowing them to easily be switched on and off so we should be able to support both comms interfaces reasonably easily.

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: 9-axis MotionTracking gyroscope accelerometer magnetometer

Post by Benj »

I've had a go at a first pass using I2C.

If you have a sensor available then would you mind testing out the component for me. The datasheet is not very clear so I have made a number of assumptions which could easily be incorrect.

Simply copy the attached into your "Flowcode 7/components" directory and restart Flowcode and the device will be present in the Sensors component dropdown.
MPU9250_AccelGyroMagnet.fcpx
(7.3 KiB) Downloaded 330 times
Looks like a nice device so will have to get my hands on a couple.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: 9-axis MotionTracking gyroscope accelerometer magnetometer

Post by stefan.erni »

Hi Ben

Thats nice.
I will also order some small boards because my own board is not quite finished yet.
So I can start testing on monday.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: 9-axis MotionTracking gyroscope accelerometer magnetometer

Post by stefan.erni »

Hi Ben

Tomorrow the sensors will arrive at my place.
I have written a program for STM32F469 (touchscreen-board)

And the simulation works .....
I have still one question...
How can I read the values from the gyro and the compass?
Flowcode_stm32f469i_touchscreen_mpu_test1.fcfx
(21.54 KiB) Downloaded 357 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: 9-axis MotionTracking gyroscope accelerometer magnetometer

Post by Benj »

Hello,
Tomorrow the sensors will arrive at my place.
Brilliant, let us know how you get on. I've ordered a board too but from China so not sure when it will arrive.
How can I read the values from the gyro and the compass?
The same way you do with the accelerometer.

Code: Select all

UpdateAccelerometerData()
AX = CollectXYZ(0)
AY = CollectXYZ(1)
AZ = CollectXYZ(2)

UpdateCompassData()
CX = CollectXYZ(0)
CY = CollectXYZ(1)
CZ = CollectXYZ(2)

UpdateGyroData()
GX = CollectXYZ(0)
GY = CollectXYZ(1)
GZ = CollectXYZ(2)

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: 9-axis MotionTracking gyroscope accelerometer magnetometer

Post by stefan.erni »

Hi Ben

The MPU9250 is working !

Temparatur,Accelerometer,Gyro looks good

Compass is not ok. It's shows me always -1 on all axis, but in the simulation it's ok.

With the 32F469Discovery Board it's not possible to choose a hardware I2C port, with the picboard it's working.
I suspect my 32F469IDiscovery.fcdx is not ok.

I used a Sparkfun SEN-13762 for 12,51 €

https://www.digikey.ch/product-detail/d ... UR&lang=de
https://learn.sparkfun.com/tutorials/mp ... 1503401756
Flowcode_stm32f469i_touchscreen_mpu_test1.fcfx
(25.92 KiB) Downloaded 310 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: 9-axis MotionTracking gyroscope accelerometer magnetometer

Post by Benj »

Hello,

Thanks for letting us know. It could be the magnetometer needs further initialising to start producing values, I'll have a look for you.

We don't currently support the I2C hardware peripherals on the ST ARM devices as they are subtly different from the other microcontroller devices. We have made efforts to get this working and have made progress but it's proved more difficult than expected so currently we only support the software I2C channels.

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: 9-axis MotionTracking gyroscope accelerometer magnetometer

Post by Benj »

Have you set the AD0 property to Ground or +VCC?

Looks like the magnetometer address might be wrong for the +VCC setting but should be correct for the Ground setting?

From other libraries it appears the magnetometer address doesn't change whereas I assumed it would like the accelerometer address does.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: 9-axis MotionTracking gyroscope accelerometer magnetometer

Post by stefan.erni »

Hi Ben
I tested the adresspin and FC7 setting in all positions for the Pin A0 on the board and for the setting for the Pin A0 gnd/Vcc on FC7
There is a reversed fuction ....
Pin A0 | FC7 |
0 | 0 | bad
1 | 0 | ok
0 | 1 | ok
1 | 1 | bad

Unfortunately the compass never works

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: 9-axis MotionTracking gyroscope accelerometer magnetometer

Post by Benj »

Hi Stefan,

That's brilliant many thanks for testing that out for me. I have now reversed the bit so it should now work as expected with the AD0 Pin property.

I've also added a new property which enables the compass for either 8Hz or 100Hz operation. Hopefully this should solve the problems you were having with the magnetometer portion.
MPU9250_AccelGyroMagnet.fcpx
(7.39 KiB) Downloaded 243 times

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: 9-axis MotionTracking gyroscope accelerometer magnetometer

Post by stefan.erni »

Hi Ben

Thank You for solving. The adress is ok now.
Pin A0 | FC7 |
0 | 0 | ok
1 | 1 | ok
Unfortunately the compass is not working.

Sometimes chip manufacturers pack different sensors into one chip.
I suspect there is a AK8963 magnetometer built-in. And then this sensor has a strange address

"
Pass-Through mode is useful for configuring the external sensors, or for keeping the MPU-9250 in a low-power mode when only the external sensors are used. In this mode, the system processor can still access MPU-9250 data through the I2C interface.
Pass-Through mode is also used to access the AK8963 magnetometer directly from the host. In this configuration the slave address for the AK8963 is 0X0C or 12 decimal.
"

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: 9-axis MotionTracking gyroscope accelerometer magnetometer

Post by Benj »

Ok close but no cigar. I already have the AK8963 datasheet as the magnetometer registers weren't included in the MPU-9250 datasheet.

Here is what I am currently doing.
AccelMagAddr.jpg
AccelMagAddr.jpg (24.55 KiB) Viewed 16788 times
I use the Accel Address for reading back the Accel/Gyro/Temperature and the Compass Address for reading back the Magnetometer.

The addresses already contain the bit shift for the added R/W bit.

I'll have another look through some of the other code libraries later today and see if I can find anything useful.

If you look at the value returned from the initialise function then what value do you get back?
255 = Accelerometer not returning correct value
254 = Magnetometer not returning correct value
0 = Both devices replying correctly

If you're getting 254 then this implies the Magnetometer address is wrong or we are doing something incorrectly when trying to talk to it.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: 9-axis MotionTracking gyroscope accelerometer magnetometer

Post by stefan.erni »

I get a 255

255 = Accelerometer not returning correct value

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: 9-axis MotionTracking gyroscope accelerometer magnetometer

Post by Benj »

Well I wouldn't have expected that! Hmm I've turned off all the checks and now just enable the accel and magnetometer.

Before I would bail out and not do the magnetometer initialise if the accel or magnetometer checks failed.
MPU9250_AccelGyroMagnet.fcpx
(7.5 KiB) Downloaded 252 times

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: 9-axis MotionTracking gyroscope accelerometer magnetometer

Post by stefan.erni »

Hi Ben

I have already used the MPU9250 with FC7.
Now I have problems with FC8. Once I initialize the component, the program remains frozen. but the interrupt still goes ...

I used a Pic32MZ2048ECG

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: 9-axis MotionTracking gyroscope accelerometer magnetometer

Post by stefan.erni »

Hi Ben

When I choosed in the propertis from the MPU9250 => Stop Delay to "yes" then the MPU9250 is working

Stefan

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: 9-axis MotionTracking gyroscope accelerometer magnetometer

Post by stefan.erni »

Hi Ben

I dont now why every time I load the program I have to set the I2C from the MPU to channel 5.....

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: 9-axis MotionTracking gyroscope accelerometer magnetometer

Post by stefan.erni »

Hi Ben

The MPU9250 is comfortabel to use with FC8.
The small problem is that I have to select I2C channel nr 5, every time I load the program in FC8.

But the bigger problem where I have is the update accelerometer needs 2.6mS

If I set the clock to 1 Mega (it's 1 Mega in the hardware) and needs 2.6mS
If I set the clock to 400k (it's 400k in the hardware) and needs 2.8mS
So checked the time from the first clock to the last clock..... it's only 96uS.
Can You have a look why there is a long waiting time?

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: 9-axis MotionTracking gyroscope accelerometer magnetometer

Post by Benj »

Hello,

I can't see anything specific in the component that could be causing the slowdown between comms. We basically set the address and then clock in 6 bytes in a single transaction before storing into RAM to be picked up by the CollectXYZ macro. I can't see the RAM access taking ms, should be very quick.

Are you drawing to a display in between sampling the accelerometer or anything else that could account for the additional delay.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: 9-axis MotionTracking gyroscope accelerometer magnetometer

Post by stefan.erni »

Hi Ben

No I do not do anything in this time. But I use a lot of Ram (64K) for a 2 buffer, but I dont read/write at this time.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: 9-axis MotionTracking gyroscope accelerometer magnetometer

Post by stefan.erni »

Hi Ben

In my program I use a free Pin for my osciloscope. Before I update the acelerometer I turn it on and after I collect the date I turn it off.

So it needs 2.6ms for this. On the green channel I show the I2C bus. This just need 115us

In this way, I can not used it in my system with 2kHz samplerate..... I just have 0.5ms time for all.....

Then I removed my big RAM. Did not help. I did a measurment to test the collect date. This need just 280ns

MPU9250_slow 0.png
(21.1 KiB) Downloaded 4329 times
update 0.png
(15.83 KiB) Downloaded 4329 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: 9-axis MotionTracking gyroscope accelerometer magnetometer

Post by Benj »

Hello,

Please can you post your program and we will have a look for you.

Post Reply