Calibration Of iPhone Accelerometers

Calibration Of iPhone Accelerometers

Abstract

For a stationary iPhone, the accelerometer values measured with each of the iPhone axes should be +1 with a positive axis direction pointing down, or –1 with a negative axis pointing down. It appears that the accelerometers in stationary iPhones need to be calibrated as the magnitude of the values measured along an axis can vary from iPhone to iPhone; furthermore, the magnitudes can also vary in the opposite directions of each axis. The measured values for stationary iPhones can be found to be greater or less than +1 or –1.

Introduction

The following will focus on a calibration procedure for correcting the accelerometer readings externally using a spreadsheet. Thus can be used to make corrections for experiments based on externally post processing of accelerometer data. This link, accelerometer, is good reading about various type of accelerometers, and provides excellent information on accelerometer applications. It was surprising that such variations occur, but it is what it is. Hence the need to calibrate, which maybe a good lesson for anyone involved in performing experiments with data collection, as calibration maybe necessary as with accelerometers. The calibration procedure is relatively simple and will result in three linear equations, one for each axis. The equations can then be applied to correct measured accelerometer values for each axis. It should be understood that though the calibration equations are simple linear equations, they would vary from iPhone to iPhone. To obtain accelerometer data an app that collects data from the iPhone sensors is needed, and should provide access to the data via a file of some type. Data formatted as comma separated values (CVS) is perfect. Apps can be found in the Apple iTunes App Store.

Procedure 

Before proceeding it should be understood what the orientation of the iPhone’s three axes are, see figure 1:
        
Figure 1

These axes should be considered as fixed to the mobile device’s body. Hence will be referred to as the body frame axes. Note the +z-axis is pointing away from the front and is always perpendicular to the face of the iPhone. The x-axis is along the short length and the y-axis along the long length. The +y-axis is toward the “on” button on the top right of the iPhone. The orientation of the axes follows the Right-Hand Rule. As these axes are to be fixed to the mobile devices body, rotating the device will rotate the axes to maintain their configuration with respect to the devices shape as per figure 1.

An Excel workbook is provided that calculates the linear calibration equations that can be used to correct accelerometer data. You may use as you wish. The Excel workbook has been automated as best as I could. So data can be entered and calculations are performed automatically. Take care not to delete or clear cells that have equations. Download and save a master, always work on a copy.

1.    Collect data for many seconds with the positive x-axis pointing down. This author collected about 400 points. Then rotate the mobile device 180 deg, and collect data for the negative x-axis as previously performed. Repeat this procedure for each axis.
2.    Transfer data to a spreadsheet.
3.    Analyze each accelerometer data set by obtaining the average and standard deviation. Do for positive x-axis, then negative x-Axis. Repeat for the y and z axes. You should end-up with an average value for each positive and negative axis respectively. Spreadsheets have functions that perform these calculations easily. The standard deviation is used as a sort of goodness of the data. If the standard deviation value is greater that 0.025, consider retaking of that data set.
4.    For each axis, use the “two-point formula” with the following point sets:
a.    Point 1, (-1, average value for negative x-axis); and Point 2, (+1, average value for positive x-axis).
b.    Point 1, (-1, average value for negative y-axis); and Point 2, (+1, average value for positive y-axis).
c.    Point 1, (-1, average value for negative z-axis); and Point 2, (+1, average value for positive z-axis).

Note: in two dimensions a point is define as containing two values defined as (x, y). e.g. in the above, for “a. Point 1”, x = -1, and y = average value for negative x-axis. For point 2, x = +1, and y = average value for positive x-axis. Similarly for the other axes.

Applying the “two point formula” for each axis results in three equations of the form y = m x + b. Where m = the slope, and b = the intercept. Thus, corrected x-axis accelerometer values = the slope value for x-axis multiplied by uncorrected x-axis accelerometer values, plus the x-axis intercept value. And similarly for the other axes.

You can create your own analysis with your own tools. However you may use this Excel workbooks. Note the various worksheets: x-axis, y-axis, z-axis, …. Paste, replacing current data in columns (“delete contents” before pasting) with the corresponding data sets, in each respective worksheets. Take care not to replace the cells performing the calculations. The spreadsheets will calculate the slopes and the intercept to form the equations for correcting accelerometer values as per above. You may then use the equations to correct accelerometer data for your experiments. In the Excel workbook provided, the calibration equations obtained in the x, y, z axis worksheet are automatically used on the data in the Sensor Data worksheet, and results are contained in the Analysis worksheet.

Conclusion

Familiarity with using Excel is assumed. Utilizing a spreadsheet the iPhone accelerometers can be calibrated to correct errors inherent in the measured values. You can obtain simple linear equations for each axis to correct the data extracted. It is recommended that you save the downloaded Excel spreadsheet as a master and work with a copy. This calibration should be needed only once. However, if you drop your iPnone then consider repeating the calibration procedure. It is not like that it changed, but then …… In the Excel workbook are other sheets where the author used accelerometer and magnetometer data for other calculations. These calculations will be explained in the next publication.


1 comment:

  1. Hi there, awesome site. I thought the topics you posted on were very interesting. I tried to add your RSS to my feed reader and it a few. take a look at it, hopefully I can add you and follow.

    ReplyDelete