AN****
Freescale Semiconductor
Application Note
Tilt Sensing Using Linear Accelerometers
by: Kimberly Tuck
Accelerometer Systems and Applications Engineering
Tempe, AZ
INTRODUCTION Calibration Technique for Accelerometers. Even though the
offset is trimmed, offset can shift due to packaging stresses,
This application note explains the importance of
aging and external mechanical stresses due to mounting and
understanding how to acquire a reliable and accurate tilt
orientation.This results in offset calibration error. It is important
reading for accelerometer applications by comparing the
to implement a 0g calibration routine for the accelerometer to
advantages and disadvantages of various tilt measurement
compensate for the 0g offset.
techniques. Accelerometers used for tilt sensing require high
resolution to meet the demands of many new emerging MEASUREMENT TECHNIQUES
applications such as tilt enabled computer mouse/pointers,
This section discusses the different ways to implement tilt
motion enabled video game solutions and PDA-cell phone/
comparing different ways to measure the corresponding angle
mp3 player screen navigation.
from the acceleration output.
The overall benefit of the accelerometer for tilting
applications used in PDAs for screen navigations is a new
Measuring Tilt using One Axis
method to view, scroll, select and move with a minimum
In the case of a dual-axis accelerometer (XY) mounted
number of buttons required. This concept affords a PDA with
perpendicular to gravity the tilt algorithm is limited to one axis
a larger screen area for viewing. Navigation through menus is
of sensitivity. As shown in Figure 1 the accelerometer is tilted
made easier with the ability to make selections based on tilt.
along the X-axis. The Y-axis remains at 0g output throughout
The choices are highlighted and then can be selected either
the full rotation of the X-axis in this case.
by using a physical execute button on the PDA or by using
click or double click tap detection of the accelerometer. The
+y
user can make selections in a menu driven environment this
way. Also the accelerometer can also be used to sense the tilt +x
+x
of the PDA to change from landscape to portrait using gravity
to change the screen orientation for viewing.
Interactive video games are becoming increasingly
popular. Accelerometers are used to detect the tilting motions
1g
of the joystick for the game.This has created games where the
1g
user can feel more immersed in the game.
Tilt is a static measurement. The force of gravity is used as Figure 1. Dual-Axis Accelerometer with One Axis of Tilt
an input to determine the orientation of an object calculating
If one axis (X-axis) is used to calculate the tilted angle of the
the degree of tilt.The accelerometer will experience
accelerometer the following trigonometry relationship is used:
acceleration in the range from -1g to +1g through 180 of tilt.
V OUTX = V OFF + S sin
1g = - 9.8 m/s2
Where: VOUTx is the voltage output from the X-axis of the
0G OFFSET CALIBRATION
accelerometer, VOFF is the offset voltage, and S is the
Accuracy and repeatability is a general concern for nearly sensitivity of the accelerometer.
all accelerometer applications. The accuracy of the tilt
The acceleration output on the X-axis due to gravity is
measurement can be improved by using a 0g-offset
equal to the following:
calibration technique to compensate for offset errors. Refer to
V OUTX V OFF
Freescale application note AN3447, Implementing Auto-Zero
A X =
-
S
Freescale Semiconductor, Inc., 2007. All rights reserved.
Measuring Tilt using a Two Axis Solution
In order to solve for the angle of tilt the equation becomes
the following:
The resolution problems and tilt orientation difficulties can
1
= sin ( AX ) be addressed by mounting the accelerometer vertically so that
the Y-axis is parallel to gravity, or by using a tri-axis
accelerometer using at least 2 of the 3 axis. Using more than
one axis to calculate tilt produces a more accurate solution.
y
y
x
x
1g
1g
Figure 3. Using a (Dual- or Tri-Axis) Accelerometer with
Two Axes for Measuring Tilt
Figure 2. Accelerometer Output (g's) Tilting from -90 to
+90 with a One Axis Measurement
This graph shows the output in g s of the accelerometer as
it tilts from -90 to +90 . Notice that the tilt sensitivity
diminishes between -90 and -45 and between +45 to
+90 . This resolution problem between these values makes
this method of calculating the angle of tilt inaccurate when the
accelerometer output is near the +1g or -1g range. A dual-axis
accelerometer horizontally mounted would be limited by this
Figure 4. Sine Function of the X Output and Cosine
method of calculating tilt and would not be accurate over a
Function of the Y Output
360 rotation. It would only be useful for angle measurements
between -45 to +45 of tilt. The graph above shows that when using a two axis solution
Another disadvantage of the single axis measurement tilt the component due to gravity on the X-axis follows the sine
technique is that it is impossible to know the difference function while the component due to gravity acting on the
between two tilt angles that result in the same sensor output. Y-axis follows the cosine function. Notice that the tilt sensitivity
The output is a sine function, so for example it would be (slope of the line) in the X-direction is at its maximum while the
impossible to know from a 0.5g output reading if the Y-sensitivity is at its minimum and visa versa. Therefore the
accelerometer was tilted 30 or 150 by looking at the maximum tilt sensitivity can be maintained if both the X and
accelerometer output. One would have to be aware of the the Y outputs are combined.
correct orientation of the accelerometer and have a sense for Table 1 displays 360 of tilt with the acceleration output of
the quadrant of tilt. This disadvantage is overcome by using a the X component and Y components due to gravity. Also the
two axis measurement tilt technique and is explained in the change in gravity with the change in angle is analyzed through
next section. the full rotation for both components. The two sensitivities are
combined which results in a constant output of 17.45mg/ .
AN3461
Sensors
2 Freescale Semiconductor
Table 1. Tilt using the X and Y-axis
dg/dDeg AX dg/dDeg AY sqrt(TSX^2+TSY sqrt(AX^2+AY^2
Angle AX (g s) AY (g s)
TSX(mg/ ) TSY(mg/ ) ^2) (mg) ) (g)
0 0.000 17.452 1.000 -0.152 17.45 1.00
30 0.500 15.038 0.866 -8.858 17.45 1.00
60 0.866 8.594 0.500 -15.190 17.45 1.00
90 1.000 -0.152 0.000 -17.452 17.45 1.00
120 0.866 -8.858 -0.500 -15.038 17.45 1.00
150 0.500 -15.190 -0.866 -8.594 17.45 1.00
180 0.000 -17.452 -1.000 0.152 17.45 1.00
210 -0.500 -15.038 -0.866 8.858 17.45 1.00
240 -0.866 -8.594 -0.500 15.190 17.45 1.00
270 -1.000 0.152 0.000 17.452 17.45 1.00
300 -0.866 8.858 0.500 15.038 17.45 1.00
330 -0.500 15.190 0.866 8.594 17.45 1.00
Basic Trigonometry X-axis experiences a 0g acceleration. The combined
acceleration is always 1g.
2 2
A= A X + A Y = 1g
AY The sensor is most responsive to changes in tilt when the
sensitive axis is perpendicular to the force of gravity. When
1g
perpendicular to the force of gravity the accelerometer
experiences approximately 17.45mg per degree tilt. It is least
AX
responsive when the sensitive axis is parallel to the force of
gravity in the +1g or -1g orientation, with a responsiveness of
Figure 5. Basic Trigonometry only 0.15mg per degree of tilt. This is clearly displayed in
Figure 6 where the absolute value of the tilt sensitivity was
The acceleration in the X-axis in Table 1 is calculated by the
taken. As the X-axis is at its minimum tilt sensitivity the Y-axis
following equation:
is at its maximum tilt sensitivity. By combining the X and
A X = sin Y-axis solving for the tilt angle using arctan (AX/AY), a constant
tilt sensitivity of 17.45mg can be maintained through a 360
The acceleration on the Y-axis is calculated with:
rotation.
A Y = cos
If the combination of the X acceleration and the Y acceleration
is used:
AX
= tan
-
AY
The tilt sensitivity equation mg/ was calculated by taking
the difference between the acceleration output between
1 degree at that point. For example, the tilt sensitivity at 15 is
calculated by the following:
sin ( 16 ) sin ( 15 ) = 16.818
The Y-axis is 90 from the X-axis and therefore it makes
sense that the Y-axis experiences a 1g acceleration while the
Figure 6. Tilt Sensitivity versus Tilt Angle
AN3461
Sensors
Freescale Semiconductor 3
Quadrant Orientation Now the acceleration due to gravity on the X-axis,
Y-axis and Z-axis are combined. The resultant sum of the
accelerations from the three axes is equal to 1g when the
90
accelerometer is static.
Q2 Q1 2 2 2
A X + A Y + A Z = 1g
AX + AX +
AY - AY +
180
180 0 A/D Converter Resolution Limitations
Q3 Q4
Discrete values are used when the signal is digitized and
AX - AX -
AY - AY + therefore the resolution is limited by the number of bits in the
A/D converter. Table 2 displays the 8-bit A/D converter values
for the X and Z-axis assuming an ideal rotation about the
270
y axis.
Figure 7. Quadrants of a 360 Degree Rotation
The 3.3V supply voltage is divided by 255 (28-1) steps from
It is important to know the sign of the X and Y accelerations the A/D converter. This value is divided by the sensitivity of
to determine the quadrant of tilt that is applicable because the 0.8V/g to solve for the acceleration due to gravity at each step.
outputs from the first and third quadrant will be the same and
3.3V
the outputs from the second and fourth quadrant will also be = 16.176mg
-
255 0.8mV l g
the same. For example tan (45) = 1 and tan (225) = 1. When
taking the arctan of a positive value the tilt angle is in either the Therefore each increasing bit will account for an additional
first or third quadrant. Knowing the sign of AX and AY will 16.176mg.
determine exactly which quadrant. When taking the arctan of From Table 2 it can be seen that a single axis solution will
a negative value the tilt angle is in either the second or fourth produce a decreasing resolution as the device is tilted from 0
quadrant. Knowing the sign of AX and AY will determine to 90, but a two axis solution will produce a fairly steady
exactly which quadrant the accelerometer is tilting through. resolution throughout the entire tilt range.
The angle calculation based on acceleration of a single axis
If in Quadrant 1 = arctan (AX/AY)
is the following:
If in Quadrant 2 = arctan (AX/AY) + 180
= sin 1 ( A X )
If in Quadrant 3 = arctan (AX/AY) + 180
If in Quadrant 4 = arctan (AX/AY) + 360
The resolution goes from 0.927 degrees to 9.332, which is
unacceptable for a tilt application.The resolution gets
Measuring Tilt using a Three Axis Solution
increasingly worse through the tilt.
In order to define the angles of the accelerometer in three The angle calculation based on acceleration of two axes is
dimensions the pitch, roll and theta are sensed using all three the following:
outputs of the accelerometer. Pitch is defined as the angle AX
= tan 1
-
A Z
of the X-axis relative to ground. Roll is defined as the angle
of the Y-axis relative to the ground. Theta is the angle of
The resolution is between 0.748 - 1.317 throughout the
the Z axis relative to gravity.
entire tilt range. Again this shows the improved accuracy of
using two axes to calculate tilt. Figure 6 displays the
y
y
z z
z z
y
comparison of these two methods using the 8-bit A/D
y
converter.
x x
NOTE: The same analysis applies for angles from 91 to
x x
360 in the other three quadrants.
Using a 10-bit A/D converter the 3.3V supply voltage is
Figure 8. Three Axis for Measuring Tilt
divided by 1023 (210-1) steps from the A/D converter. This
AX value is then divided by the sensitivity of 0.8V/g to solve for the
= arc tan
-
acceleration due to gravity at each step.
A2 + A 2
Y Z
3.3V
= 4.032mg
-
AY 1023 0.8mV l g
= arc tan
-
A + A2 2 Using a 10-bit A/D converter with a 2 axis solution the
X Z
resolution is between 0.171 and 0.327 throughout the tilt
range, while the 1 axis solution resolution starts out at 0.231
2 2
A X + A Y
= arc tan at 0 and increases to 5.147 as it approaches 90 . A higher
-
AZ resolution is achievable with a bigger A/D converter. The
AN3461
Sensors
4 Freescale Semiconductor
comparison using the 10-bit A/D converter is shown in
Figure 10.
Figure 10. Tilt Resolution for a One or Two Axis Tilt
Figure 9. Tilt Resolution for a One or Two axis Tilt
Algorithm Using a 10-Bit A/D Converter
Algorithm Using an 8-Bit A/D Converter
Table 2. A/D converter values for AX and AZ for tilt from 0 to 90
Angle Angle Resolution Resolution
A/D AX Ax- g's A/D AZ Az-g's 1-Axis 2-Axes 1-Axis 2=Axis
128 0.0000 190 1.0029 0.0000 0.0000 0.9269 0.9240
129 0.0162 190 1.0029 0.9269 0.9240 0.9269 0.9240
130 0.0324 190 1.0029 1.8540 1.8476 0.9271 0.9236
131 0.0485 190 1.0029 2.7816 2.7702 0.9276 0.9226
132 0.0647 190 1.0029 3.7100 3.6914 0.9283 0.9212
133 0.0809 190 1.0029 4.6393 4.6106 0.9293 0.9193
134 0.0971 190 1.0029 5.5698 5.5275 0.9305 0.9169
135 0.1132 189 0.9868 6.5018 6.5463 0.9320 1.0188
136 0.1294 189 0.9868 7.4356 7.4716 0.9338 0.9253
137 0.1456 189 0.9868 8.3713 8.3929 0.9357 0.9214
138 0.1618 189 0.9868 9.3093 9.3099 0.9380 0.9170
139 0.1779 189 0.9868 10.2499 10.2222 0.9405 0.9122
140 0.1941 189 0.9868 11.1932 11.1292 0.9433 0.9070
141 0.2103 188 0.9706 12.1396 12.2251 0.9464 1.0959
142 0.2265 188 0.9706 13.0894 13.1340 0.9498 0.9089
143 0.2426 188 0.9706 14.0428 14.0362 0.9535 0.9022
144 0.2588 188 0.9706 15.0003 14.9314 0.9574 0.8952
145 0.2750 187 0.9544 15.9620 16.0736 0.9617 1.1422
146 0.2912 187 0.9544 16.9284 16.9661 0.9664 0.8926
147 0.3074 187 0.9544 17.8998 17.8503 0.9714 0.8842
148 0.3235 187 0.9544 18.8765 18.7258 0.9767 0.8755
149 0.3397 186 0.9382 19.8590 19.9037 0.9825 1.1780
150 0.3559 186 0.9382 20.8475 20.7723 0.9886 0.8685
151 0.3721 185 0.9221 21.8426 21.9745 0.9951 1.2023
152 0.3882 185 0.9221 22.8447 22.8337 1.0021 0.8591
153 0.4044 185 0.9221 23.8543 23.6821 1.0095 0.8484
154 0.4206 184 0.9059 24.8717 24.9048 1.0175 1.2227
155 0.4368 184 0.9059 25.8976 25.7407 1.0259 0.8359
156 0.4529 183 0.8897 26.9325 26.9802 1.0349 1.2395
157 0.4691 183 0.8897 27.9770 27.8015 1.0445 0.8212
AN3461
Sensors
Freescale Semiconductor 5
Table 2. A/D converter values for AX and AZ for tilt from 0 to 90 (continued)
Angle Angle Resolution Resolution
A/D AX Ax- g's A/D AZ Az-g's
1-Axis 2-Axes 1-Axis 2=Axis
158 0.4853 182 0.8735 29.0317 29.0546 1.0547 1.2531
159 0.5015 181 0.8574 30.0973 30.3236 1.0656 1.2690
160 0.5176 181 0.8574 31.1746 31.1225 1.0772 0.7989
161 0.5338 180 0.8412 32.2642 32.3998 1.0896 1.2774
162 0.5500 180 0.8412 33.3670 33.1785 1.1029 0.7787
163 0.5662 179 0.8250 34.4840 34.4608 1.1170 1.2823
164 0.5824 178 0.8088 35.6162 35.7539 1.1322 1.2931
165 0.5985 178 0.8088 36.7646 36.5014 1.1484 0.7476
166 0.6147 177 0.7926 37.9306 37.7939 1.1659 1.2925
167 0.6309 176 0.7765 39.1153 39.0939 1.1847 1.2999
168 0.6471 175 0.7603 40.3202 40.3999 1.2050 1.3060
169 0.6632 174 0.7441 41.5471 41.7108 1.2269 1.3109
170 0.6794 173 0.7279 42.7977 43.0251 1.2506 1.3143
171 0.6956 172 0.7118 44.0741 44.3415 1.2764 1.3164
172 0.7118 171 0.6956 45.3787 45.6585 1.3046 1.3171
173 0.7279 170 0.6794 46.7141 46.9749 1.3354 1.3164
174 0.7441 169 0.6632 48.0834 48.2892 1.3693 1.3143
175 0.7603 168 0.6471 49.4901 49.6001 1.4068 1.3109
176 0.7765 167 0.6309 50.9386 50.9061 1.4484 1.3060
177 0.7926 166 0.6147 52.4336 52.2061 1.4950 1.2999
178 0.8088 165 0.5985 53.9811 53.4986 1.5476 1.2925
178 0.8088 164 0.5824 53.9811 54.2461 1.5476 0.7476
179 0.8250 163 0.5662 55.5885 55.5392 1.6073 1.2931
180 0.8412 162 0.5500 57.2646 56.8215 1.6761 1.2823
180 0.8412 161 0.5338 57.2646 57.6002 1.6761 0.7787
181 0.8574 160 0.5176 59.0207 58.8775 1.7561 1.2774
181 0.8574 159 0.5015 59.0207 59.6764 1.7561 0.7989
182 0.8735 158 0.4853 60.8714 60.9454 1.8507 1.2690
183 0.8897 157 0.4691 62.8363 62.1985 1.9649 1.2531
183 0.8897 156 0.4529 62.8363 63.0198 1.9649 0.8212
184 0.9059 155 0.4368 64.9424 64.2593 2.1061 1.2395
184 0.9059 154 0.4206 64.9424 65.0952 2.1061 0.8359
185 0.9221 153 0.4044 67.2289 66.3179 2.2866 1.2227
185 0.9221 152 0.3882 67.2289 67.1663 2.2866 0.8484
185 0.9221 151 0.3721 67.2289 68.0255 2.2866 0.8591
186 0.9382 150 0.3559 69.7573 69.2277 2.5283 1.2023
186 0.9382 149 0.3397 69.7573 70.0963 2.5283 0.8685
187 0.9544 148 0.3235 72.6329 71.2742 2.8756 1.1780
187 0.9544 147 0.3074 72.6329 72.1497 2.8756 0.8755
187 0.9544 146 0.2912 72.6329 73.0339 2.8756 0.8842
187 0.9544 145 0.2750 72.6329 73.9264 2.8756 0.8926
188 0.9706 144 0.2588 76.0694 75.0686 3.4366 1.1422
188 0.9706 143 0.2426 76.0694 75.9638 3.4366 0.8952
188 0.9706 142 0.2265 76.0694 76.8660 3.4366 0.9022
188 0.9706 141 0.2103 76.0694 77.7749 3.4366 0.9089
189 0.9868 140 0.1941 80.6678 78.8708 4.5983 1.0959
AN3461
Sensors
6 Freescale Semiconductor
Table 2. A/D converter values for AX and AZ for tilt from 0 to 90 (continued)
Angle Angle Resolution Resolution
A/D AX Ax- g's A/D AZ Az-g's
1-Axis 2-Axes 1-Axis 2=Axis
189 0.9868 139 0.1779 80.6678 79.7778 4.5983 0.9070
189 0.9868 138 0.1618 80.6678 80.6901 4.5983 0.9122
189 0.9868 137 0.1456 80.6678 81.6071 4.5983 0.9170
189 0.9868 136 0.1294 80.6678 82.5284 4.5983 0.9214
189 0.9868 135 0.1132 80.6678 83.4537 4.5983 0.9253
190 1.0029 134 0.0971 90.0000 84.4725 9.3322 1.0188
190 1.0029 133 0.0809 90.0000 85.3894 9.3322 0.9169
190 1.0029 132 0.0647 90.0000 86.3086 9.3322 0.9193
190 1.0029 131 0.0485 90.0000 87.2298 9.3322 0.9212
190 1.0029 130 0.0324 90.0000 88.1524 9.3322 0.9226
190 1.0029 129 0.0162 90.0000 89.0760 9.3322 0.9236
190 1.0029 128 0.0000 90.0000 90.0000 9.3322 0.9240
AN3461
Sensors
Freescale Semiconductor 7
How to Reach Us:
Home Page:
www.freescale.com
Web Support:
http://www.freescale.com/support
USA/Europe or Locations Not Listed:
Freescale Semiconductor, Inc.
Technical Information Center, EL516
2100 East Elliot Road
Tempe, Arizona 85284
+1-800-***-**** or +1-480-***-****
www.freescale.com/support
Europe, Middle East, and Africa: Information in this document is provided solely to enable system and software
Freescale Halbleiter Deutschland GmbH implementers to use Freescale Semiconductor products. There are no express or
Technical Information Center implied copyright licenses granted hereunder to design or fabricate any integrated
Schatzbogen 7
circuits or integrated circuits based on the information in this document.
81829 Muenchen, Germany
+44-129*-***-*** (English)
+46 8 52200080 (English) Freescale Semiconductor reserves the right to make changes without further notice to
+49-89-921**-*** (German) any products herein. Freescale Semiconductor makes no warranty, representation or
+33 1 69 35 48 48 (French)
guarantee regarding the suitability of its products for any particular purpose, nor does
www.freescale.com/support
Freescale Semiconductor assume any liability arising out of the application or use of any
product or circuit, and specifically disclaims any and all liability, including without
Japan:
limitation consequential or incidental damages. Typical parameters that may be
Freescale Semiconductor Japan Ltd.
Headquarters provided in Freescale Semiconductor data sheets and/or specifications can and do vary
ARCO Tower 15F in different applications and actual performance may vary over time. All operating
1-8-1, Shimo-Meguro, Meguro-ku, parameters, including Typicals, must be validated for each customer application by
Tokyo 153-0064 customer s technical experts. Freescale Semiconductor does not convey any license
Japan under its patent rights nor the rights of others. Freescale Semiconductor products are
012*-****** or +81 3 5437 9125
not designed, intended, or authorized for use as components in systems intended for
*******.*****@*********.***
surgical implant into the body, or other applications intended to support or sustain life,
or for any other application in which the failure of the Freescale Semiconductor product
Asia/Pacific:
could create a situation where personal injury or death may occur. Should Buyer
Freescale Semiconductor Hong Kong Ltd.
Technical Information Center purchase or use Freescale Semiconductor products for any such unintended or
2 Dai King Street unauthorized application, Buyer shall indemnify and hold Freescale Semiconductor and
Tai Po Industrial Estate its officers, employees, subsidiaries, affiliates, and distributors harmless against all
Tai Po, N.T., Hong Kong claims, costs, damages, and expenses, and reasonable attorney fees arising out of,
+800-****-**** directly or indirectly, any claim of personal injury or death associated with such
*******.****@*********.***
unintended or unauthorized use, even if such claim alleges that Freescale
Semiconductor was negligent regarding the design or manufacture of the part.
For Literature Requests Only:
Freescale Semiconductor Literature Distribution Center
P.O. Box 5405 Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc.
Denver, Colorado 80217
All other product or service names are the property of their respective owners.
1-800-***-**** or 303-***-****
Fax: 303-***-**** Freescale Semiconductor, Inc. 2007. All rights reserved.
****************************@************.***
AN3461
Rev. 6
06/2007
S
© Freescale Semiconductor, Inc., 2007. All rights reserved.