17
MEMS Inertial Sensors and
Magnetic Sensors
Everything was sensory and I never saw the structure
in anything.
—Gill Kane
17.1 Introduction
Inertial sensors consist of accelerometer and gyroscope sensors. A unit with gyro-
scopes and accelerometers is also called an inertial measurement unit (IMU). These
sensors can be utilized for motion detection applications. Inertial sensors are also
used in combination with magnetometer sensors to achieve better measurements.
Advances in MEMS technology have revolutionized the inertial sensors indus-
try. MEMS sensors have significant advantages over non-MEMS sensors in terms
of size, energy consumption, reliability, and cost. The emergence of miniaturized
MEMS inertial sensors has provided the possibility of adopting such sensors in the
expanded range of consumer electronic products.
In this chapter the basic principles of accelerometer, magnetometer, and gyro-
scope sensors are described and their error sources are introduced.
17.2 Inertial Sensors
Inertial sensors function based on inertial forces. These sensors capture the external
motion forces acting on them. These forces consist of acceleration and angular
rotation. The measured forces are used to calculate the acceleration and angular
rotation of the body. Knowing the acceleration forces acting upon the body, it
should be possible (in theory) to determine the translational motion of the body.
387388 17. MEMS Inertial Sensors and Magnetic Sensors
Accelerometers sensors respond to the forces associated with acceleration and
gyroscopes sensors are sensitive to the angular rotations.
Inertial sensors have various applications in different areas. These sensors are
applied for navigations video gaming interface, automotive, motion detection for
health monitoring, monitoring of machinery vibration, mobile phones, vibration
detection of buildings, sports training, etc. Maenaka 08 Bhattacharyya et al. 13.
The combination of accelerometers and gyroscopes is called IMU. Sometimes
the IMU has magnetometers in addition to accelerometers and gyroscopes. The
IMU is commonly used to measure the inertial forces in three dimensions. In the
following, accelerometer and gyroscope sensors are described.
17.2.1 Accelerometers
Accelerometers detect the acceleration due to external forces acting on objects.
The output of an accelerometer is a combination of the acceleration due to Earth’s
gravity and the linear acceleration due to motion. Each sensor responds to the
acceleration along a specific axis. In the past, accelerometers could sense the
acceleration in just one axis, but recently tri-axis accelerometers have become
available in the market. To measure the acceleration in three dimensions with one-
axis accelerometer, three accelerometers were used. These sensors were positioned
so that their sensitive axes were oriented east-west, north-south, and vertically. The
tri-axis accelerometer has three orthogonal axes that can sense the acceleration
forces in three dimensions.
The acceleration associated with external forces acting on an object can be
explained by Newton’s second law of motion: “A force F acting on a body of mass
m causes the body to accelerate with respect to the inertial space” Titterton and
Weston 04.
The mathematical representation of Newton’s second law of motion is shown
in Equation 17.1, where a is the acceleration and m represents the mass. The force
(F) is what causes acceleration to the body. The force origin can be either the
result of body motion or Earth’s gravity(g).
F = ma (17.1)
A basic form of accelerometer consists of a small mass that is connected to a
case through a spring. The mass is also called proof or seismic mass. Figure 17.1
shows the basic form of the accelerometer.
When an external force is applied to the case, because of the mass inertia,
it shows resistance against the movement. Consequently, it creates tension or
extension in the springs, and the mass position with respect to the case will change.
The mass displacement makes the output of the sensor vary. This variation is used
to measure the acceleration Titterton and Weston 04.
Figure 17.2 depicts the accelerometer when a force is applied to it along its
sensitive axis.17.2. Inertial Sensors 389
Figure 17.1: Basic accelerometer.
Figure 17.2: Accelerometer response to the external forces.
There are also MEMS accelerometers that are built based on other tech-
niques such as capacitive-based displacement accelerometers, piezoelectric and
piezoresistive-based accelerometers, and resonant element accelerometers. Nikolic
and Renaut 0.
17.2.2 Gyroscopes
Gyroscope sensors are devices to measure the angular motion of an object. The
sensor output is proportional to its rotation. Some gyroscopes measure the angular
velocity (rate gyroscopes) while other gyroscopes measure the orientation (angle
gyroscopes).
Gyroscopes have been made based on different technologies. These sensors
can be categorized into three major groups including mechanical gyroscopes,390 17. MEMS Inertial Sensors and Magnetic Sensors
Side Note 17.1: Calibration Process
Before performing any process on the inertial sensors, it is important to
calibrate them. The calibration equation for the inertial sensor output can
be expressed as:
G =M:(S:G + b) (17.3)
c r
Where G is the calibrated data, G is raw data, S is the scale factor, b
c r
represents the bias, and M is misalignment matrix. Each of these variables
can usually be found in the sensor data sheet.
optical gyroscopes, and MEMS gyroscopes.
Mechanical gyroscopes typically consist of a spinning wheel mounted in two
gimbals. The wheel can rotate in three axis. It works based on the effect of
conservation of angular momentum.
There are two types of optical gyroscopes including fiber optic gyroscopes
(FOG) and ring laser gyroscopes (RLG) Woodman 07. FOGs use a coil of
optical fiber and two light beams to measure rotation. Two light beams, in opposite
directions, are entered into the coil and travel at constant speed. When the sensor
is rotating, the light traveling in the direction of rotation traverses a longer path
compared to the light traveling in the opposite direction. This is called the “Sagnac
effect.” By measuring the path length, the angular rate of rotation can be computed.
Ring laser gyroscopes consist of a closed loop tube with three arms. At each corner
of the tube a mirror is placed and the tube is filled with helium-neon gas. These
sensors also work based on the “Sagnac effect.”
MEMS gyroscopes work based on the Coriolis effect. If a mass m is moving
with velocity v in a reference frame rotating at angular velocity w, then a force
F will work upon the mass as shown in Equation 17.2. These sensors measure
the Coriolis acceleration acting on a vibrating element which is used as proof
mass Shaeffer 13. The vibrating elements are available in the form of a tuning
fork or a vibrating wheel. All MEMS gyroscopes are rate gyroscopes.
F = 2m(w v) (17.2)
MEMS gyroscopes have many advantages compared to mechanical and optical
gyroscopes. MEMS gyroscopes have low power consumption, small size, low
weight, and low maintenance cost, among other features.
17.3 MEMS Inertial Sensor Errors
Inertial sensors suffer from several sources of errors. The error origin can be an
environmental disturbance (such as temperature, magnetic field, or air pressure),17.3. MEMS Inertial Sensor Errors 391
measurement equipment, or random noises Dorobantu and Gerlach 04.
The inertial sensor errors can be classified into two major categories, including
systematic (deterministic) errors and random (stochastic) errors. Both types of
errors affect the accuracy of inertial sensor measurements. Therefore, to enhance
the performance of the inertial sensors it is necessary to detect and compensate for
such errors Zander 07.
Systematic errors can be estimated by reference measurement. The calibration
process is used to estimate and compensate systematic errors. Scale factor, constant
bias, misalignment, nonlinearity, and sign asymmetry are categorized as systematic
errors. Unfortunately, even after the calibration process the data extracted from the
sensors are contaminated with other types of errors.
Random noises consist of high-frequency and low-frequency components. To
remove the high-frequency noises different noise removal techniques have been
used, such as Wavelet, low pass filters, and neural networks. The low-frequency
noises are modeled using random processes. Different random processes are
utilized to model the inertial sensor’s low-frequency noises such as random walk,
constant random, and Gauss–Markov random processes El 08a.
To extract accurate and meaningful data from the sensor output, it is necessary
to compensate all types of errors; otherwise the results would not be reliable. Some
types of common inertial sensor errors are described next.
17.3.1 Angle Random Walk
Angle random walk (ARW) is the white noise added on the sensor output. This
noise usually results from the power supplies or semiconductor devices. The power
spectral density of angle random walk is shown in Equation 17.4, where Q is the
angle random walk coefficient.
2
s( f)= Q (17.4)
17.3.2 Rate Random Walk
Rate random walk (RRW) is a random noise with unknown origin El 08b. The
power spectral density of this noise is:
2
k 1
s( f)= (17.5)
2
2p f
where k is the rate random walk coefficient.392 17. MEMS Inertial Sensors and Magnetic Sensors
17.3.3 Flicker Noise
1
Flicker noise is a non-stationary noise whose power spectra is proportional to f .
The power spectrum shows that most of the power of this noise appears in low
frequencies.
17.3.4 Quantization Noise
Quantization noise is the result of the digitalization process. A finite number of
bits is used for storing the signal values, so information is lost and the digital signal
is slightly different compared to the original analog signal.
17.3.5 Sinusoidal Noise
The sensor’s output exhibits an additive sinusoidal noise component. The reason
is because these sensors work around a resonant frequency. Therefore, a pseudo-
deterministic sinusoidal noise is seen in the output signal.
17.3.6 Bias Error
Bias error is a nonzero output signal which appears in the sensor output when
input is zero. The bias offset causes the sensor output to offset from the true data
by a constant value. This error is not dependent on external forces applied to the
sensor. Bias error can be divided into three categories, including a static part (or
bias offset), a random part (or drift), and a temperature dependent part Naranjo
and Hgskolan 08. The static bias and temperature bias can be compensated in the
calibration process. Static bias can be measured by averaging the sensor output
for a zero input signal. To compensate for this bias, it should be subtracted from
the output data. The drift bias has a random nature and cannot be fixed in the
calibration process. It should be treated as a stochastic error. Bias error is presented
in Figure 17.3.
17.3.7 Scale Factor Error
The scale factor error is linear deviation of the input-output gradient from unity.
Similar to the bias error, the scale factor error can be divided into a static part, a
drift part, and a temperature-dependent part. This effect is depicted in Figure 17.4.
This error may arise from aging or manufacturing tolerance. Grewal et al. 07 To
compensate for the scale factor error the data should be multiplied with a constant
factor Zander 07.
17.3.8 Scale Factor Sign Asymmetry Error
The scale factor sign asymmetry effect is the spontaneous change of at least one
point in the measurement curve. This error is shown in Figure 17.5.17.3. MEMS Inertial Sensor Errors 393
Figure 17.3: Bias error.
Figure 17.4: Scale factor error.
17.3.9 Misalignment (Cross-Coupling) Error
This error is a systematic error and comes from the misalignment of the sensitive
axes of the sensor with respect to the axes of the body frame Groves 13. This
error appears because of manufacturing imperfection and can be compensated
through the calibration process. Figure 17.6 shows the sensor’s X, Y, and Z axis
misalignment with respect to the body frame.
17.3.10 Non-Linearity Error
The scale factor phenomenon does not always happen in a linear form; sometimes
it appears in the form of second or higher order function Lawrence 98. This
effect happens because of the material properties and geometric shape of the
sensor Zander 07. This effect is shown in Figure 17.7.394 17. MEMS Inertial Sensors and Magnetic Sensors
Figure 17.5: Scale factor sign asymmetry error.
Figure 17.6: Axis misalignment.
17.3.11 Dead Zone Error
The dead zone effect is an apparent discontinuity in the output data. The sensor
does not sense the applied forces in the interval in which the discontinuity happens.
This interval is called a “dead zone.” Figure 17.8 depicts the dead zone effect.
17.3.12 Temperature Effect
Changes in the environment temperature affect the output of MEMS sensors. A
temperature sensor is usually added to the inertial measurement units to be used
for compensating the temperature effect.17.4. Magnetometers 395
Figure 17.7: Non-linearity error.
Figure 17.8: Dead zone error.
17.4 Magnetometers
For centuries, navigators have been acquainted with the Earth’s magnetic field
effect. The earliest evidence about compass navigation is ascribed to the Chinese
and dated 250 years B.C. Campbell 03. Traditional magnetometers (compass)
were simple instruments that pointed approximately to magnetic north. A small
magnetized arrow aligns itself to be parallel with the horizontal component of the
Earth’s magnetic field.
The Earth’s magnetic field is produced by the Earth and also interacting fields
from the Sun, called the solar wind. The solar wind is the stream of high-energy
charged particles, which are released outward from the Sun continuously. To
explain the source of Earth’s magnetism, many hypotheses have been asserted. But
only the “Dynamo Effect” mechanism is now considered plausible Campbell 03.
The Earth is composed of four layers, including outer crust, mantle, outer core,
and inner core. The temperature at the mantle layer, at the boundary with the396 17. MEMS Inertial Sensors and Magnetic Sensors
Figure 17.9: Geographic and magnetic poles.
outer core, is over 4000 Celsius, which is hot enough to liquefy the outer core.
The outer core consists of molten iron. In this theory, the Earth’s magnetism is
attributed to the convection currents of molten iron in this layer.
The north pole of the Earth’s magnet is on the side of geographical south and
vice versa. The geographical north and south axis, which is defined by the Earth’s
rotational axis, does not coincide with the axis of the Earth’s magnet Butler 92.
The best approximation of discrepancy between magnetic pole and geographical
pole is 11:5 . This is so-called magnetic declination. Figure 17.9 presents the
location of geographic and magnetic poles.
Three-axis MEMS magnetometers provide more information than traditional
magnetometers. They measure the magnitude and direction of two horizontal and
one vertical component of the magnetic field. The tri-axis magnetometer projects
Earth’s field vector in three orthogonal vectors. This data can be described in two
ways:
• Magnetic field can be described by three orthogonal components. In this
arrangement, the positive values point northward in X-axis, eastward in
Y-axis, and downward in Z-axis. It uses the right-hand system to present the
magnetic field. Figure 17.10. illustrates this presentation of magnetic field.
The total field strength is calculated as:
p p
2 2 2 2 2
F = X +Y + Z = H + Z (17.6)
• In the second representation, the components include the horizontal mag-
nitude (H), the declination angle (D), and the inclination angle (I). The
inclination angle is the angle between horizontal plane and the field vector,
which measures positive downward. The declination and the inclination
angles can be computed by following equations.
X = H cos(D) (17.7)17.5. MEMS Magnetometer Errors 397
Y = H sin(D) (17.8)
Y
D= arctan( ) (17.9)
X
Z
I= arctan( ) (17.10)
H
Figure 17.10: Earth’s magnetic vector.
17.5 MEMS Magnetometer Errors
MEMS magnetometers are subject to bias error, scale factor error, misalignment
errors, and stochastic noise Ji et al. 11 Renaudin et al. 10. Furthermore, the
local magnetic fields can disturb the sensor output. Such disturbance is categorized
into groups as Garton et al. 09:
• Soft iron disturbance: Soft iron disturbance is caused by the ferromagnetic
objects in the vicinity of the magnetometer. These objects can distort the
direction of the magnetic field.
• Hard iron disturbance: Hard iron effect is the result of the presence of any
permanent magnetic field surrounding the sensor. The permanent magnetic
field causes a constant bias on the sensor output.
Magnetometer Soft and Hard Iron Compensation
If a magnetometer, which has already compensated for the soft and hard iron
effects, is turned around on the vertical axis about 360 degrees in a horizontal
surface then plotting of the X axis with respect to the Y axis would be a circle398 17. MEMS Inertial Sensors and Magnetic Sensors
Figure 17.11: Magnetometer without presence of hard and soft iron disturbances.
Figure 17.12: Hard iron effect on magnetometer.
centered in zero Säll and Merkel 11. Figure 17.11 depicts the ideal plot of the X
axis with respect to the Y axis when hard and soft iron disturbances are removed.
Presence of hard iron error would shift the center of the circle, as is shown in
Figure 17.12. In fact the hard iron effect adds offset to the data. This offset can be
compensated in the calibration process by measuring the maximum and minimum
values for each axis after turning the sensor about 360 degrees. If the maximum
and minimum values for each specific axis are the same with different signs, then
there is not hard iron error. Otherwise offset is calculated and removed with the
following steps for each axis:
• sum= data + data
maximumvalue minimumvalue
• bias= sum=2
• data= data bias
Soft iron disturbance would change the circle to the elliptic shape as depicted
in Figure 17.13.
To perform the soft iron correction it is recommended to carry out the hard
iron and tilt correction prior to the soft iron to adjust the origin of the ellipse at the17.5. MEMS Magnetometer Errors 399
Figure 17.13: Soft iron effect on magnetometer.
Figure 17.14: Soft iron effect on magnetometer.
center (Figure 17.14). A simple approach to make up for soft iron is presented
here Konvalin 09.
First the rotation angle from X axis is calculated as:
q
2 2
r= (x + y ) (17.11)
1 1
y
1
q = arcsin( ) (17.12)
r
Now, the rotation matrix is defined as:
cosq sinq
R= (17.13)
sinq cosq400 17. MEMS Inertial Sensors and Magnetic Sensors
Figure 17.15: Soft and hard Iron effect on magnetometer data.
Figure 17.16: Sphere fitted calibrated magnetometer data.
Now the ellipse should turn using rotational matrix. Once the rotation is done the
major and minor axes of the ellipse are aligned with the X and Y axes.
v ˆ= Rv (17.14)17.5. MEMS Magnetometer Errors 401
The next step is to scale the major axis of the ellipse to reshape it to a circle. The
scale factor is calculated as:
q
S= (17.15)
r
Figure 17.15 shows the recorded output of a magnetometer which is not
compensated for the soft and hard iron effect after moving the sensor randomly
in different orientations. It can be seen that the data lie on an ellipsoid instead of
a sphere. To correct, the data ellipsoid form should be transformed to a sphere.
®
In Yury 09 a MATLAB program is provided to fit an ellipsoid to a sphere. The
compensated data are shown in Figure 17.16.
Further Reading
Describing the techniques for implementing and evaluating inertial MEMS sensors
was skipped in this chapter. If you are interested in MEMS inertial sensors design
and instrumentation, you can find related information in the book Strapdown
Inertial Navigation Technology Titterton and Weston 04.This page intentionally left blank This page intentionally left blank18
Kalman Filters
It’s not about how much movement you do, how much
interaction there is, it just reeks of credibility if it’s
real. If it’s contrived, it seems to work for a while for
the people who can’t filter out the real and unreal.
—Fred Durst
18.1 Introduction
Kalman filtering is an advanced approach for controlling complex and dynamic
systems. One Kalman filtering applications is fusing inertial and magnetic sen-
sors data to produce reliable measurements. Many people believe this is a very
complicated approach and give up learning and using this filter. In this chapter the
background theory of Kalman filtering is described in a simple way, avoiding deep
and complicated mathematical explanation. Once you understand how it works,
you can implement it for your system. Notice that even if you cannot conceive
how it works, you can implement it for your system by following the filter’s steps.
18.2 Least Squares Estimator
The Kalman filter is a least squares error estimator. An estimator is a statistic that
uses the observed data to calculate an estimate of a given quantity. In this section,
the concept of least squares estimator is described.
The least squares (LSQ) is a recursive algorithm to design linear adaptive filters.
One of its variations is known as recursive least squares (RLS). The LSQ approach
is a method for estimating optimal data from noisy data Grewal and Andrews 11.
The algorithm computes the filter coefficients that minimize the cost function
which is the sum of weighted error squares. The RLS algorithm defines error as the
discrepancy between the desired signal and the actual signal. This method was first
403404 18. Kalman Filters
published by Andien-Marie Legendre, but it is mostly attributed to Carl Friedrich
Gauss. Gauss describe this method in the following way: “the most probable
value of the unknown quantities will be that in which the sum of the squares of the
differences between the actually observed and the computed values multiplied by
numbers that measure the degree of precision is a minimum” Simon 06.
A system can be described in matrix form Sorenson 85, as shown in Equation
18.1. This equation can be written as shown in Equation 18.2, where Z is the
observed dependent signal, x represents the original signal which carries the
information and v is the measurement error.
2 3 2 32 3 2 3
z h h h h x v
1 11 12 13 1n 1 1
6 7 6 76 7 6 7
z h h h h x v
2 21 22 23 2n 2 2
6 7 6 76 7 6 7
6 7 6 76 7 6 7
z h h h h x v
3 31 32 33 3n 3 3
6 7=6 76 7+6 7 (18.1)
6 7 6 76 7 6 7
. . . . . . .
.
. . . . . . . .
4 5 4 54 5 4 5
.
. . . . . . .
z h h h h x v
l l1 l2 l3 ln l l
Z = Hx + v (18.2)
k k k
The overall objective is to estimate values of vector x, which is represented
with x ˆ notation, in a way that minimizes the estimated measurement error (Hx ˆ Z).
To solve the problem of finding x ˆ Gauss assume the signal x and the observed data
to be linearly related.
The difference between measured data and calculated data is called the residual.
In the least-squares method, the best estimation minimizes the sum of the squares
of the residuals, as shown in Equation 18.3.
m n
2 2 2
e (x ˆ)=(Hx ˆ Z) = h x ˆ z (18.3)
i j j i
å å
i=1 j=1
To minimize the error it is required to find the value of x ˆ Grewal and Andrews 11
such that:
2
¶e
= 0 (18.4)
¶x ˆ
k
or
m n m
2 h h x ˆ z= 2 h Hx ˆ z = 0 (18.5)
ik i j j i i j i
å å å
i=1 j=1 i=0
Equation 18.5 can be written as Equations 18.6, 18.7 and 18.8. Equation 18.7 is
called the normal form for linear least squares problems Grewal and Andrews 11.
T
2H Hx ˆ z= 0 (18.6)
T T
H Hx ˆ= H z (18.7)18.3. Kalman Filters 405
T 1 T
x ˆ=(H H) H z (18.8)
18.3 Kalman Filters
The Kalman filter was named after Rudolf Emil Kalman. He was born in 1930
in Hungary and emigrated to the United States during World War II Grewal and
Andrews 11.
He completed his bachelor’s and master’s degrees in electrical engineering at
Massachusetts Institute of Technology and received his PhD at Columbia Univer-
sity in 1957. His famous paper describing a recursive estimator was published in
1960 Kalman 60. The estimator is called the Kalman filter and also is known as
linear quadratic estimation.
The Kalman filter has been applied in a wide range of applications and research
areas, including economic modeling, process control, navigation, tracking objects,
and earthquake prediction Gibbs 11. It has been used notably in the area of
navigation, estimation, and tracking.
The Kalman filter is a recursive algorithm which measures consecutive noisy
data samples over time and estimates the variables in a way that minimizes the
mean square error. The Kalman filter algorithm consists of the following two steps:
• Prediction (or Time Update) step.
• Correction (or Measurement Update) step.
In the prediction step, the Kalman filter predicts the state of the system and
calculates the error covariance for the next step. In the correction step, the filter
incorporates received measurements to correct its prediction. In general, the
prediction step is responsible for forecasting the state of the system ahead in time
and the correction step adjusts the prediction by applying the real measurement at
the time.
The Kalman filter estimates the state of a system at a time (t+1) by using the
state of the system at time (t). The prediction-correction cycle is depicted in Figure
18.1.
18.4 Discrete Kalman Filters
The discrete Kalman filter, which is applicable for linear systems, is described in
this section. The discrete Kalman filter is much more frequently used than the
continuous Kalman filter. Even in applications in which the system’s model is
continuous, because the measurement is mostly performed in a discrete manner,
the discrete Kalman filter is often used.406 18. Kalman Filters
In order to apply the Kalman filter, it is necessary to find the mathematical
description of your system. This mathematical description is called the “system
model.” This model relates inputs of the systems to the outputs with some differ-
ential equations. Sometimes it is difficult to find the mathematical model for the
system. To understand the “system model,” you need to have knowledge about the
state-space representation. The system model for the discrete time linear systems
can be described by the state transition Equation 18.9:
x = Ax + w ; k 0 (18.9)
k+1 k k
where x is the state vector at time k, which is an(n 1) column vector. A is the
k
state transition matrix, which is an(nn) matrix, and w represents the zero-mean
k
state noise vector, which is(n 1)column vector.
The Kalman filter minimizes the effect of the noise w on the signal x. The state
variable, x , describes a physical quantity of the system such as velocity, position,
k
force, etc. The matrix A has constant elements. The Kalman filter formulation
assumes that the measurement is linearly related to the states as indicated in
Equation 18.10:
Z = Hx + v (18.10)
k k k
where z is measurement of x at time k, which is an (m 1) column vector. H
k
represents the observation matrix, which is an(m n) matrix, and v is the zero-
k
mean measurement noise, which is an (m 1) column vector. The matrix H
includes constant elements and represents how each state variable is related to the
measurements.
The Kalman filter was developed under the following assumptions:
• The initial state, x is uncorrelated to both the system and measurement
0
noises with known mean and covariance as described in Equations 18.11
and 18.12:
m = Ex (18.11)
0 0
Figure 18.1: Kalman filter cycle.
Advise:Why You Wasting Money in Costly SEO Tools, Use World's Best Free SEO Tool Ubersuggest.