Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accelerometer to relative position

Before I reinvent the wheel I wanted to see if anyone can share code or tips for the following:

In order to get relative position of the iPhone, one needs to

  • Set the accelerometer read rate
  • Noise filter the accelerometer response
  • Convert it to a vector
  • Low pass filter the vector to find gravity
  • Subtract gravity from the raw reading to find the user caused acceleration
  • Filter the user caused acceleration to get the frequencies you are interested in ( probably bandpass depending on the application)
  • Integrate to find relative speed
  • Integrate to find position

So what I'm hoping is that people have already written some or all of the above and can provide tips, or better yet code.

A few questions I haven't found the answer to:

What is the frequency response of the iPhone accelerometer? What hardware filters exist between the accelerometer and the analog to digital converter?

What is the fastest reading rate the accelerometer delegate can be called without duplicating reading values?

Differences in the above for the various phones?

Any good tips for designing the filters, such as cutoff frequency for separating gravity and user motion?

Any code or tips for the integration steps? Any reason to integrate in the cartesion coordinate system rather than as vector, or vise versa?

Any other experiences, tips, or information that one should know prior to implementing this?

like image 908
Adam Davis Avatar asked Oct 30 '10 02:10

Adam Davis


People also ask

Can you use an accelerometer to determine position?

Because they can accurately determine the speed, direction and position of a body in motion, accelerometers play an indispensable role in providing digital electronic circuits with real-world information for a multitude of applications.

How do you get position data from an accelerometer?

Re: Get a Position from Gyroscope and Accelerometer You need a magnetometer to calculate the attitude (rotation). Use the attitude to filter out the gravity acceleration from the raw accelerometer values so you're left with linear acceleration. Integrate it twice to get velocity and position and voila!

Can you get displacement from an accelerometer?

Figure 5 presents a general formula for displacement. Displacement or position measurement can be yielded directly from accelerometer output, at each interval, over time. Thus displacement is accumulative and any offset error is additive.

Can accelerometer be used for tilt measurement?

Accelerometers can be used for measuring both dynamic and static measurements of acceleration. Tilt is a static measurement where gravity is the acceleration being measured. Therefore, to achieve the highest degree resolution of a tilt measurement, a low-g, high- sensitivity accelerometer is required.


1 Answers

As I find information out, I'll be collecting it in this answer.

Hardware

The 3GS uses an ST LIS331DL 3-axis ±2g/±8g digital accelerometer.

The iPhone 4 and iPad use an ST LIS331DLH 3-axis ±2g/±4g/±8g digital accelerometer.

They are both capable of being read at 100Hz and 400Hz, although on the iPhone 3G (under iOS 4.1) the accelerometer delegate is not called more frequently than 100Hz even if setUpdateInterval is set for faster updates. I do not know if the API permits faster updates on the iPhone 4, and Apple's documentation merely states that the maximum is determined by the hardware of the iPhone. (TBD)

The A/D converter is on the same silicon as the MEM sensor, which is good for noise immunity.

The DL version is 8 bits (3GS) while the DLH version is 12 bits (iPhone 4). The maximum bias (offset) in the DL version is twice the bias of the DLH (0.04g vs 0.02g) version.

The data sheet for the DLH reports acceleration noise density, but that value is not reported on the DL datasheet. Noise density is reasonably low at 218 μg/√Hz for the DLH.

Both sensors give either 100Hz sampling or 400Hz sampling speeds, with no custom rate. The sensor discards values if the iPhone doesn't read the output register at the set sampling rate.

The "typical" full scale value for the DL sensor is ±2.3g, but ST only guarantees that it's at least ±2g.

Temperature effects on the sensor are present and measurable, but not very significant.

TBD:

  • Is the hardware filter turned on, and what are the filtering characteristics?
  • How noisy is the power supply to the accelerometer? (Anybody just happen to have the iPhone schematic laying around?)
  • The accelerometer uses an internal clock to provide timing for the sample rate and A/D conversion. The datasheet does not indicate the accuracy, precision, or temperature sensitivity of this clock. For accurate time analysis the iPhone must use an interrupt to sense when a sample is done and record the time in the interrupt. (whether this is done or not is unknown, but it's the only way to get accurate timing information)

API

Requesting lower than 100Hz sampling rates results in getting selected samples, while discarding the rest. If a sampling rate that is not a factor of 100Hz is requested in software, the time intervals between real sensor readings cannot be even. Apple does not guarantee even sampling rates even if a factor of 100 is used.

It appears that the API provides no software filtering.

The API does scale the raw accelerometer value into a double representing Gs. The scaling factor used is unknown, and whether this is different for each phone (ie, calibrated) and whether the calibration occurs on an ongoing basis to account fo sensor drift is unknown. Online reports seem to suggest that the iPhone does re-calibrate itself on occasion when it's lying flat on a surface.

Results from simple testing suggest that the API sets the sensor to ±2g for the 3GS, which is generally fine for handheld movements.

TBD:

  • Does Apple calibrate each unit so that the UIAccelerometer reports 1G as 1G? Apple's documentation specifically warns against using the device for sensitive measurement applications.
  • Does the reported NSTimeInterval represent when the values were read from the accelerometer, or when the accelerometer interrupt indicated that new values were ready?
like image 170
Adam Davis Avatar answered Nov 15 '22 01:11

Adam Davis