Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Hi J,This is wrong, look at msg #99
x_c = (m11 * x_0) + (m12 * x_0) + (m13 * x_0)
y_c = (m21 * y_0) + (m22 * y_0) + (m23 * y_0)
z_c = (m31 * z_0) + (m32 * z_0) + (m33 * z_0)
There are others, but correct this first.
Hi J,Underscores don't matter. You can use any variable names you want.
Look again #99. Calibrated values should be calculated like this
Xc = m11 * X0 + m12 * Y0 + m13 * Z0
Yc = m21 * X0 + m22 * Y0 + m23 * Z0
Zc = m31 * X0 + m32 * Y0 + m33 * Z0
Then you have not given any values for m11- m33 and bias values Bx By Bz
Try first to send the calibrated values to terminal and look if they are reasonable.
Hi J,Fine!
Could you test it now:
Start with y pointing to north and rotate 360 degrees clockwise, for example in 45 degrees steps.
Display x, y for each step.
Hi,
Does this look correct for the first OCTANT?
'0 - 45 degrees x / y < 1 And x > 0, y > 0
'angle = Arctan( x / y ) × 57.3
If x_c / y_c < 1 Then
If x_c > 0 Then
If y_c > 0 Then
deg = Arctan(y_c / x_c) * 57.3
Endif
Endif
Endif
This gives double digit incorrect figures, with a max of 41.38 when Y is approx 0-90 DEG.
C.
Hi S,You state in comments:
'angle = Arctan( x / y ) × 57.3
but your code has the x and y reversed:
deg = Arctan(y_c / x_c) * 57.3
Pick the right one?
If you want to have the angle clockwise from north, the x values should be negated.Hi J,
Here's a test, showing X,Y,Z READings in 45DEG steps on a terminal.
C.
Hi S,Does any of this take into account magnetic north vs geographic north? That is, if pointing to geographic north, -9Deg (351 Deg) may make sense if that points to the magnetic pole. These external devices can only sense magnetic north.
Hi J,If you want to have the angle clockwise from north, the x values should be negated.
Then with the values from msg #108, 0 is about - 9 or 351 degrees.
45 ~ 35 degrees and 90 ~ 86 degrees.
There is quite a lot deviation between values with the same angle of the sensor.
Negate: Xc = - XcHi J,
How do I negate X values? Can this be done at the two's compliment stage?
I noticed the deviation in values, also when using MAGMASTER. I can perhaps average them out in some way.
I slowed down the number of READings/sec, also lowered the sensitivity from 16BIT to 14BIT, has this helped?
C.
Hi J,Negate: Xc = - Xc
If changed to 14bit, maybe the 2's complement has to be changed too?
The variation is smaller now.
Can you rotate the full circle.
Take away the space between - and XcHi J,
x_c = - x_c Doesn't compile in OSH BASIC, I'll come back to it later.
....
C.