Several projects on my bench are waiting for me to create a high quality compass. I tried earlier with some rat shack parts but have since picked up a pair of GY-80 so everything is on one package. (3/comp, 3/accel, 3/gyro, 1/pressure)
I FINALLY got the tilt compensation working last night. While the guides I found online contained examples of implementing the formula, they were all very light on the nature of the sensor data, including orientation, sign, and range. Having passed the hurdle, I intend to write a library that allows for easy identification of arbitrary compass and tilt hardware and orientations. (I'll look into kalman filtering at a later time)
Before I get into that however, I would like to make sure I am making the most accurate use of the sensor data. And that brings me to calibration. The compass and the accelerometer have similar but separate problems.
The accelerometer provides an integer in the range ~ -270 - +255 for the x and the y axis. Problem 1: is 0,0 level? Problem 2: are -270 and +255 actualy the same magnitude? (-90 / +90 deg, or at least, are they equal opposites?) Right now I don't have any simple way to put the board precisely level or at any well-calibrated angle. I'd like to assume one or the other though. Currently my code is assuming 0,0 is always level, and is scaling the outputs separately to produce a range of +/- 230. (-270 and +255 are used to scale the negative and positive offsets separately) Another strategy I am considering is to assume that 0,0 is NOT necessarily level, but that -270 nd +255 ARE equal magnitudes, and use that to redefine level (in that case, at -7.5) Comments?
The compass could have the same issue of zeroing, but in its case I'm aware there will be a much greater variance in field strength generated, as the numbers are only meaningful when compared relative to each other to provide an angle. But the zeroing question remains, is a reading of 0 exactly 90 degrees off from magnetic axis? I assume in this case I can't simply add a zeroing bias, but have to convert to an angle and then add to that instead. But again I really have no easy way to provide it with a "perfect north" fixture to mesure to see how far it's off. Comments?
Lastly, I've got several bits of hardare here, I'm sure they vary in quality. Anyone care to toss their hat into the ring and praise or bash on the quality of some of the available accelerometers and gyros?