2018-03-20 10:33 AM
Hi!
Fairly new to programming and embedded software in general but I'm having a problem with interpreting the values I am receiving from the magnetometer registers.
I'm able to get a value between 0 and 255 for each register (both high and low for X,Y and Z). I can't seem to workout what to do with these values; any help would/point in the right direction would be greatly appreciated!
Thanks,
Fraser
EDIT:
For anyone searching this in look for help, I have a github on this project:
https://github.com/FrazLaw/RoboPot
.The code isn't perfect but it may help someone else, like myself, looking for some assistance as it can be a fairly difficult task if you've never done something like this before.
Fraser
#e-compasses #e-compass #lsm303agrSolved! Go to Solution.
2018-03-21 12:23 AM
Hello,
There are lots of similar questions here, have a look at this one, for example:
https://community.st.com/0D50X00009XkXHfSAN
(search for a keyword 'interpretation', by the way the interpretation principle is the same for accelerometer and gyroscope)You are saying you can read a value of 0..255, but that is wrong. The registers are two, High and Low, see datasheet page 66 and 67:
The value is stored as a signed 16 bit value (2nd complement format).
Just a quick reminder of the usual process:
1) select a range (according to the datasheet) - this will give you the sensitivity
2) select an output data rate (how often you want the sensor to measure the data)
3) start measuring (there are modes for separate or combined accelerometer and gyroscope operation)
4) wait for the data to be ready, read it and interpret it
David
2018-03-21 12:23 AM
Hello,
There are lots of similar questions here, have a look at this one, for example:
https://community.st.com/0D50X00009XkXHfSAN
(search for a keyword 'interpretation', by the way the interpretation principle is the same for accelerometer and gyroscope)You are saying you can read a value of 0..255, but that is wrong. The registers are two, High and Low, see datasheet page 66 and 67:
The value is stored as a signed 16 bit value (2nd complement format).
Just a quick reminder of the usual process:
1) select a range (according to the datasheet) - this will give you the sensitivity
2) select an output data rate (how often you want the sensor to measure the data)
3) start measuring (there are modes for separate or combined accelerometer and gyroscope operation)
4) wait for the data to be ready, read it and interpret it
David
2018-03-21 04:50 AM
Thank you! That's cleared it up a bit.
Fraser