not sure how effective that will be , it would probably need to be calibrated every time you relocate it (or maybe even rotate it) . don't forget its own orientation is its only reference point . ...
Type: Posts; User: richard; Keyword(s):
not sure how effective that will be , it would probably need to be calibrated every time you relocate it (or maybe even rotate it) . don't forget its own orientation is its only reference point . ...
I must add , the vector does not point north . it indicates the [ direction and magnitude ] of the magnet field relative to the device orientation.
the link I posted is for accelerometers but...
if the device is held so that the xy plane is perfectly!!!! level then the xy angle is magnetic north (sort of). if the device is tilted then the xy angle needs to compensated for that tilt . the...
maybe this will help
http://www.starlino.com/imu_guide.html
turns out that the premise of using this chip alone as a compass is basically flawed. it can't do its own tilt compensation because the earths magnetic field is not necessarily parallel to the earth...
I bought one to play with
after looking at the raw data I came up with this , works ok if device is held level , tilt compensation is elusive at this stage
...
from the pbp manual
your prg as provided does nothing with the "Z" reading
the term you have designated as azimuth is derived from azimuth = x ATN -y ie an " x " and a " y " reading , these readings are a...
looks like you are converting azimuth to degrees twice
once here
'Calculate Azimuth
GOSUB GetAzimuth
'Calculated Heading in Degrees
brads = azimuth 'get angle
your degree calc is incorrect
degr = brads*360/256 this will overflow a word var causing errors
degr = brads */ 360
is the better way
to get the azimuth result in degrees
azimuth = ( x ATN -y) */ 360
this should fix the i2c errors
'****************************************************************
'* Name : COMPASS_818.BAS *
'* Author : [select...
the i2c read uses the word var readingx the byte var x is the "scaled" result from that reading
if you can't work that out post your code so we can see what your doing {in code tags }
you can do a similar thing with y axis too ,
my routine will give the same result as the scale offset method its just much quicker and simpler.
don't forget the ATN result is in radians so deg =...
thanks for confirming that henrik ,saves me the trouble .
I worked that out with the windows7 calculator (in programmer mode) it makes it easy to visualise some solutions , another feature sadly...
it works on paper , i'm curious to compile it and see what happens , i'm feeling a cast from word to byte and only a 4 bit r-shift might allow the loss of the sign bit to be ignorable . if it works...
am I wrong or would right shifting the reading 4 give the same answer without all the math
x var byte
reading var word
x= reading>>4