You are on page 1of 6

ALGORITHMS FOR DATA LOGGER SENSOR FUSION

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

1.0 Description of the device


The SLD-A and SLD-AHR are the first generation products from the SimpleMEMS team. The
objective of these products is to provide a standalone, battery operated logger that can collect
sensors measurement at selectable rate and store them to an SD card or stream them through
a virtual serial port over USB. All data are time stamped and may be converted to engineering
units if desired. These loggers have numerous applications such as measuring vibration moni-
toring, kinesiology, education, science experiments and unmanned vehicles.
The block diagram of the SLD-AHR sensor suite is shown below. It consists of a 3-axis
magnetometer, 3-axis accelerometers, 3-axis solid-state gyroscope, and a temperature sensor.
The SDL-A does not include the magnetometer or gyroscope as shown in Figure 1.

Figure 1. Block diagram of SLD-AHR


Features and Capabilities
 9-axis sensing capabilities as shown in the block diagram (SLD-AHR)
 Selectable sampling rate from 1Hz to 256Hz in integer multiples of 2 (512, 1024Hz for
accelerometer only)
Algorithms for SLD-AHR 12/7/2013

 400mAh rechargeable battery (via USB) capable of 12 hours of continuous operation at


maximum 9-axis sampling rate (256Hz)
 Real-time clock is used for time stamping saved data. Clock maintains date and time as
long as internal battery is not completely drained.
 Data are stored in a 2GB SD card as comma separated values (.csv) which is easily
read by Microsoft Excel or MATLAB.
 The 2GB card has the capability of storing 24 hours of continuous operation. The data
can be transferred easily to any computer that has USB connection running Windows,
Linux or Macintosh operating systems.
 While the device is connected to USB data can be streamed in real-time at all logging
sampling rates. While streaming, data is not logged to the card.
 Operating temperature range of the device is -25C to 65C. Note that battery life is
degraded by extreme temperatures.

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

The following are information on the sensors we used.

Gyroscope: A gyroscope is a device used to measure the rate of turn. With


advances in MEMS technology over recent years, gyroscopes have become
readily available in the consumer market.
In this logger, we use a MEMS 3-axis gyroscope from Maxim Integrated part #:
Max21000 with built-in temperature sensor. The axis definition of the gyro is as
shown.
The gyro has selectable ranges from ± 31.25 to ± 2000 /sec range. The output
minimum detectable turn rate is 0.01/sec and the gyro zero drift at constant temperature is
0.05/sec (estimated). The noise RMS is 0.2/sec for a bandwidth of 50Hz. The gyro turn-on
zero bias varies to ±10 /sec depending on temperature.

© 2013 by OBZ Technologies LLC. All rights reserved. 2


www.simplemems.com
Algorithms for SLD-AHR 12/7/2013

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

2.0 Derivation of Tilt while stationary from 3-axis accelerometer

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.

© 2013 by OBZ Technologies LLC. All rights reserved. 3


www.simplemems.com
Algorithms for SLD-AHR 12/7/2013

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.

2.1 Heading Estimation with Magnetometer

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

X h  H x cos   H y sin  sin   H z cos  sin  (3)

Yh  ( H y cos   H z sin  ) (4)

Z h   H x sin   H y cos  sin   H z cos  cos  (5)

The heading angle  is thus calculated as

  tan 1 Yh / X h  . (6)

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.

© 2013 by OBZ Technologies LLC. All rights reserved. 4


www.simplemems.com
Algorithms for SLD-AHR 12/7/2013

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 

Figure 3. Earth frame, body frame and Euler angles , , 

===== Complete report has the details and MATLAB scripts

4.0 Magnetic Sensor Heading Field Calibration

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

© 2013 by OBZ Technologies LLC. All rights reserved. 5


www.simplemems.com
Algorithms for SLD-AHR 12/7/2013

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

[1] Caruso M. J., “Applications of Magnetoresistive sensors in navigation systems”, Sensors


and Actuators, pp. 15-21, 1997.
[2] Grammalidis N. and Strintzis M, “Head detection and tracking by 2-D and 3-D ellipsoid”,
IEEE, 2000.
[3] Marchent et al., Electronic Compass Calibration, US Patent #4,539,760 – 1985.

===== Complete report has the details and MATLAB scripts

© 2013 by OBZ Technologies LLC. All rights reserved. 6


www.simplemems.com

You might also like