Monday, March 28, 2011

Heel and pitch angle from accelerometer

In the development of my custom tilt-compensated compass, I have chosen to use the SCA3000 3-axis accelerometer.

One important benefit of having an accelerometer is that it can also provide the boat’s heel and pitch angles. But first, the accelerometer has to be properly calibrated.

The Freescale AN3447 Application Note (“Implementing Auto-Zero Calibration Technique for Accelerometers”) describes 4 different techniques to calibrate an accelerometer. In order of decreasing accuracy, they are:

1. Manual 0g X, Y, Z Full Range Calibration
2. Simple 0g X, Y, Z calibration
3. Freefall Calibration
4. Simple 0g X, 0g Y, +1g Z calibration

The last one (no. 4), although not the most accurate, is the more convenient to use and provides good performance in many applications. A complete implementation can be found here: http://mbed.org/cookbook/IMU.

But for my project, I definitively want to go with the most accurate technique (no. 1) in order to meet the design goals.

Here is a description of the setup used for the calibration.


I am using a development board with the new ATmega128A chip.


The ATmega128A chip can be operated at any voltage between 2.7 and 5.5 V, replacing both the ATmega128 (5V) and ATmega128L (3.3V). I am using the board at 3.3 V, with the onboard crystal of 7.3728 MHz. (There is room on the board for installing a 16 MHz crystal for 5V operation). The development board is powered from the USB port of a laptop.

The Sparkfun SCA3000 breakout board is connected trough the SPI bus plus a reset line. The breakout board is also powered from the USB port, as it has its own 3.3V voltage regulator that cannot be bypassed.

A calibration routine has been programmed in the ATmega128A that continually reads the accelerometer outputs, and after each bunch of 64 readings, send the average of each axis on the serial port with Hyperterminal showing the results on a laptop.

The calibration technique requires that you record the maximum and minimum values independantly for the 3 axis. The reason that we take an average over 64 values instead of an instantaneous value is to cancel the noise that would otherwise lead to overestimate the sensitivity. The AN3447 Application Note describes the process as tedious, and yes it is. You have to be patient and explore all the minute positions around the min and max values of each axis, while taking care of recording output values only when the accelerometer is completely at rest.

This is what I get after calibrating:




The sensitivity is calculated as (max- min)/2 and the 0-g bias as (max – sensitivity). In the datasheet of the SCA3000, the nominal sensitivity is reported as 1333 counts /g. From now on, the g-value for each axis will be calculated as:

               Ax (or Ay or Az) = (measurement – bias) / sensitivity.

Theoretically, we should find that SQRT(Ax2 + Ay2 + Az2  ) = 1. In practice, there will be a small difference that we can eliminate by normalizing the results. But it is not required if all we want is to calculate the heel and pitch angles, as the results will be the same with or without normalization.
The Freescale AN3461 Application Note (“Tilt Sensing Using Linear Accelerometers”) explains how you can get the best numerical resolution from a 3-axis accelerometer by calculating the heel and pitch angles as:  

Once calibrated, this is what I observe with the breadboad sitting still on the table.  This is a measurement of the actual alignment offset of the accelerometer vs the breadboard (in fact vs the ground) :
heel = -0.52 deg, pitch = 0.57 deg.



UPDATE :
I am now using an improved procedure for accelerometer calibration, which adds a correction for axis misalignments (cross-talk).
See:


No comments:

Post a Comment