I am using a 3-axis Honeywell compass. To enable an accurate heading
value from the compass, a tilt-correction algorithm is required, to
resolve the orientation of the sensors to the earth. Honeywell supply
a good algorithm for this, and it works in all ways EXCEPT for the
case where pitch is negative, which results in heading values going
haywire.
We have a 3-axis Analogue accelerometer sensor made of 2x 2-axis 2g
sensors, and have accurate tilt angles right now.
What is the appropriate algorithm to resolve the compass heading,
relative to the orientation (IE tilt correction) of the device.
If the supplied Honeywell algorithm is correct, what may be the reason
we get nonsence values for negative pitch angles?
I would also be interested in comments about how we could resolve
compass heading without accelerometer / tilt correction. Can't be
done? Or is there a lateral thinking approach to this issue! An
example being we assuming the device maintains a reasonably constant
orientation - IE does not roll around at random inside a soccer ball,
but would be mostly upright, say in a car etc, with smaller
orientation changes around a common axis (flat road on average but
with hills). This real world assumption may help fix or limit the
algorithms in some way. Alternatively we may look at the degree of
change from orientation to orientation, such that going EW may show
higher amount of change compared to NS, so we use any axis change to
detect our tilt as a function of the change or rate of change etc.
Alternatively we may detect small abberations in a compass, such as
when a metal object is nearby briefly. This disturbance may help fix
the orientation in some way. Alternatively we may detect some cyclical
change in magnetic waves which could be used in some way. Perhaps the
common road model shows device rising and falling over hills, as
opposed to rolling heavily. When turning corners, device is usually
flat as intersections or corners are not heavily banked like a
racetrack. This real-world model may enable us to limit our algorithms
in some way. These are all brainstormed suggestions, but perhaps you
have other ideas!
REFERENCE MATERIAL
http://www.ssec.honeywell.com/magnetic/datasheets/sae.pdf
To compensate a compass for tilt, knowing the
roll and pitch is only half the battle. The magnetometer
must now rely on all three magnetic axes (X, Y, Z) so
that the earthÕs field can be fully rotated back to a
horizontal orientation. In Figure 8, a compass is shown
with roll (q) and pitch (f) tilt angles referenced to the
right and forward level directions of the observer or
vehicle. The X, Y, and Z magnetic readings can be
transformed back to the horizontal plane (XH, YH) by
applying the rotational equations shown below:
XH = X*cos(f) + Y*sin(q)*sin(f) - Z*cos(q)*sin(f)
YH = Y*cos(q) + Z*sin(q) (4)
Azimuth = arcTan (YH / XH)
Once the X and Y magnetic readings are in the
horizontal plane, equations (3) can be used to determine
the azimuth. For speed in processing the rotational
operations, a sine and cosine lookup table can be stored
in program memory to minimized computation time.
A block diagram for a tilt compensated compass
is shown in Figure 9 with a serial bus interface. After the
azimuth is determined, the declination correction can be
applied to find true north according to the geographic
region of operation. |