Professional Documents
Culture Documents
SIMPLEMEMS TEAM
www.simplemems.com
12/7/2013
Summary
The objective of this document is to explain and demonstrate, in simulation, the software algo-
rithms for SLD-AHR data logger. This will entail the following:
Sensor background and technology
Heading and attitude calculation under static conditions
Kalman filter data fusion and orientation calculations for dynamic conditions
Heading sensor calibration algorithm
Calculation for power spectral density from acceleration measurement
Sensors Specifications
The overall specifications of the sensors are as shown in the following Table.
SLD-AHR
Accelerometer +/- 2, 4,8, 16 G
Magnetometer +/- 1.3, 1.9, 2.5, 4.0, 4.7, 5.6, 8.1 Gauss
Gyroscope +/-31.25, 62.5,125,250,500,1000,2000 deg/sec
Battery 400 mAh
Real –time Clock +/-20 ppm
Sampling rate 1,2,4,8,16,32,64,128, 256 Hz
Memory Card 2GB
It is recommended to collect gyro output at the beginning of the test under static condition to
estimate the turn-on zero bias. For detailed component specifications, please visit the link
below
http://datasheets.maximintegrated.com/en/ds/MAX21000.pdf
Accelerometer/Magnetometer:
The accelerometer and magnetometer module is an ST Microelectronics part #: LSM303DLHC.
This part provides 3-axis acceleration and 3-axis magnetic field measurements. The direction of
acceleration is as shown in the figure below.
The accuracy of each sensor depends on the range. In general, under mostly static conditions
±2G is selected on the accelerometer. This will result in a resolution of 1mG and 1.6mG of noise
assuming the bandwidth is 50Hz. Using these numbers tilt can be resolved to 0.5. It should be
noted that there is a bias on the accelerometer of ±20mG. Thus, we recommend placing the
sensor on a relatively flat table to estimate this bias before testing. For detailed information on
the module, click the link below
http://www.st.com/web/en/catalog/sense_power/FM89/SC1449/PF251940
Presently, low-g dual-axis (X, Y) accelerometers are often used in tilt-sensing applications
where the force of gravity is used as an input to determine the orientation of an object as shown
in Figure 2. The sensor is most responsive to changes in tilt when the sensitive axis is perpen-
dicular to the force of gravity, yielding a sensitivity of approximately 17.45mg/° of tilt. The sensor
is least responsive to changes in tilt when the sensitive axis is oriented in its +1g or –1g posi-
tion, yielding an approximate sensitivity of only 0.15mg/° of tilt as shown in Table 1.
1g
Ax
Ay
Az
Figure 2. 3-axis accelerometer output
The tilt (Pitch and roll) calculations based on the output of 2-axis accelerometer is [2]:
sin 1 (a x / G)
sin 1 (a y / G)
(1)
The problem with this technique is that at roll or pitch angle above 45° as shown in the Table
below. To meet the specifications of roll angle (0-360°), a 3-axis accelerometer will be needed.
The Earth’s magnetic field ranges from 0.23 to 0.66 Gauss depending on the location. In the
case of a 0.5Gauss total field, a range of the magnetic sensor of 1.3Gauss will be sufficient.
This will result in 2mGauss resolution and will be able to resolve the heading within 0.5. It
should be noted that removing the bias of the magnetometer requires in-situ calibration which is
explained in [1,2]. Calculating the heading
Where Hx, Hy, Hz are the magnetometer measured field in Gauss, Xh, Yh are the magnetic
field transformed to Earth frame, is the heading angle in degrees. Note that this arctan
function must be a 4-quadrant operation to properly resolve the data. In Microsoft Excel this is
calculated with atan2(Xh,Yh) and in Matlab it is atan2(Yh,Xh).
In general the vertical earth magnetic field is 3-5 times the horizontal magnetic field, However,
magnetic field in steel vehicles could be a problem which will require calibration as discussed
later in Section 4.0.
3.0 Derivation of the Attitude Equations and Kalman Filter --- IN FULL REPORT
The following is the derivation of the attitude equations. Euler angles representations is the
standard in the literature. They are simpler to understand. Euler angles use the conventions
, and which are the yaw, pitch and roll respectively, which represent positive rotation
about the z, y and x body axes in turn, with the positive x-axis pointing forward, positive y point-
ing right and positive z pointing down as shown in Figure 3.
The orientation of the body frame with respect to the fixed frame can be determined in the fol-
lowing manner:
1. Rotate the object about its body z axis through the yaw angle (Earth z axis and body z axis co-
incide during this first rotation).
2. Rotate the object about its body y axis through the pitch angle .
3. Rotate the object about its body x axis through the roll angle .
Euler angles propagation with time and its relationship with body rotation velocities are as
shown in Equation 8.
̇ ( )
̇ (7)
̇
xb ye
yb
xe
ze
zb
There is a need to calibrate the heading sensor for every installation due to hard/soft iron. An
easy check is to calculate the heading function as shown below:
v X h2 Yh2
Strictly speaking, this term should trace a circle at all headings, i.e. v values should be equal at
all heading angles for the 2D case. If not, which is the most common case, the magnetometer
has to be calibrated as shown in Figure 4. The circle around zero shown in Figure 4 left,
becomes an ellipse offset from zero as shown in Figure 4 right due to hard and soft iron.
Hard iron effect is to offset the circle due to the present of magnets around the sensor. Soft iron
is effect is to distort the circle making it an ellipse due to the present of magnetic material
around the sensor. Both effects can be calibrated by curve fitting.
Figure 4. Uniform magnetic field results in a constant length of the field vector (Left), Hard and
soft iron effects change the length of the magnetic field vector and offset it from zero trans-
forming the circle into an ellipse (Right).
References