HMC5883 Self-Test question (closed)

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:

HMC5883 Self-Test question (closed)

Post by viktor_au »

First of all thanks to Ben for creating a HMC5883 component.

This magnetometer HMC5883 has a self-test function.
By trying to do that function I have some problems getting values out of array XYZ[6].
I can see Z values changing, but X and Y returns zero. I am not sure, maybe X and Y suppose to return zero.

Question
Is it a good idea to save the magnetometer readings in one go to an array or read one data register after another?
Is it possible to give an example of reading the magnetometer XYZ data?
Thank you.
Attachments
array-1.jpg
array-1.jpg (36.02 KiB) Viewed 2721 times
Last edited by viktor_au on Thu Aug 08, 2019 12:09 am, edited 1 time in total.

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: HMC5883 Self-Test question

Post by Benj »

Hello,

Can you post your program, I think I can see what you have done wrong but need to see the program to be sure.
Is it a good idea to save the magnetometer readings in one go to an array or read one data register after another?
All at once is faster and therefore probably the recommended option.
The UpdateCompassData macro basically collects all 6 readings for you allowing you to then pull out the readings at your convenience.
Is it possible to give an example of reading the magnetometer XYZ data?
Here's a very brief example.
HMC5883L.fcfx
(9.45 KiB) Downloaded 161 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: HMC5883 Self-Test question

Post by viktor_au »

Thanks Ben

The program is attached.
Attachments
HMC58883Test_2.fcfx
(42.64 KiB) Downloaded 151 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: HMC5883 Self-Test question

Post by Benj »

Ok you were only reading a single register before and storing into XYZ[5].

I've changed this so now you read all 6 registers and store into XYZ[0]-[5].
HMC58883Test_2.fcfx
(48.23 KiB) Downloaded 173 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: HMC5883 Self-Test question

Post by viktor_au »

Thank you Ben.
Understood my mistake

Post Reply