How to calculate Distance from Accelerometer Data

  • #1
Vikrant Mohanty
3
0
Hi All,
I am a beginner in embedded world. Currently I am working on MPU9250 motion sensor. My objective of project is to calculate the distance in real time using accelerometer. e.g. If I am at point A (i.e located at 5cm on X-axis) and I am willing to move towards point B (i.e. located at 50cm on X-axis) then the movement from A->B should show changes in distance as 5,6,7,---10---50 cm. Similarly movement from B->A should show changes in distance as 50,49,48----30,29,----5 cm.

My project is very generic and it is to be implemented on embedded processor, so I don't need any costlier algorithm like kalmaan etc. I had gone through many forums for accomplishing this task. I am using double Integration and also filtering the noise and managing the drift as well.

The issue I am currently facing is that, I am getting data , which varies even when the sensor stand still. Due to which the final estimated distance is getting change continuously. Also when I move the sensor the overall estimated displacement is coming out to be very low. Also the changes in X,Y & Z are not so simultaneous during changes in position. Please suggest me some direction to eliminate the issue.

Currently my displacement algorithm is -
V[t] = V[t-1] + (A[t]+A[t-1])*T/2-----Where T is my sampling interval set by RTOS. 100msec
Pos[t] = Pos[t-1] + (V[t]+V[t-1])*T/2


Thanks
 

Answers and Replies

  • #2
lewando
Homework Helper
Gold Member
1,367
144
You will never completely eliminate the issue--you will always have some displacement error. You can try to identify individual sources of error and control the ones that are controllable. If you are using single axis acceleration to determine displacement, then you should minimize the "tilt" of the sensor at all times throughout the motion. If your end result looks very low, what does your intermediate data look like? Does the raw acceleration data correspond to the actual applied accelerations? Does your filtered acceleration data look reasonable? Can you reduce your sample interval or is that a hard limit of the RTOS? What is the full-scale range setting are you using? What is the maximum acceleration you are applying?
 
  • #3
anorlunda
Staff Emeritus
Insights Author
11,207
8,622
What you described is called inertial navigation. A Google search for that phrase returns 1500000 hits. I'm sure you can find much useful info online.
 
  • #4
JBA
Science Advisor
Gold Member
1,542
461
You can calculate the distance by directly using your test acceleration values rather than velocity by using (A*T^2)/2 rather than the velocity in the second factor of your "Pos[t] = Pos[t-1] + (V[t]+V[t-1])*T/2" equation.

The resulting accuracy will be determinate upon the time increment you select for each acceleration value interval.
 
  • #5
cosmik debris
733
170
The integration adds quite a bit of noise, you can use the FFT method for calculating velocity and position if you have enough processing power.
 
  • #6
Aaron Crowl
67
21
I looked at the data sheet for this and I was wondering what "G" range you programmed it for. I assume that if you are walking around with this device that you programmed it for the 2G range.

How are you reading the device? Are you sure you are getting samples at precise intervals?
 
  • #7
Vikrant Mohanty
3
0
I looked at the data sheet for this and I was wondering what "G" range you programmed it for. I assume that if you are walking around with this device that you programmed it for the 2G range.

How are you reading the device? Are you sure you are getting samples at precise intervals?
Yes I am getting samples at precise interval. May I know what makes you assume that the device is programmed for 2g since I haven't post any readings of the device.

Moreover the device is programmed for 8g as I am using a TI sensortag which provide all necessary software settings. With this settings I had confirmed gravity vector at parallel surface i.e. x=0, y=0, z=1. Similar readings obtained for all other surface when placed resting. Also for any quick movement I found the acceleration changing from low to high value.
If you can guide me specifically about your assumption I can check accordingly.
 
  • #8
Aaron Crowl
67
21
Low range settings may be more appropriate for walking. You would get better accuracy. Higher range settings would be better suited for detecting things like impacts. 8g sounds pretty high but I could be wrong. Are you maxxing the output value when you quickly move the device? If not, you could try a lower setting.

Could you describe how you are filtering the data and what the sample rate is?
 
  • #9
Vikrant Mohanty
3
0
Hello Aaron,

Yes, with 2G setting I got quite a good variation for movement. For 8G setting this was not the case, as I have to give a fast jerk for obtaining it. Thanks for your advice. Now, the output seems to be more stable.
 
  • #10
Aaron Crowl
67
21
Glad to help.
 

Suggested for: How to calculate Distance from Accelerometer Data

Replies
49
Views
3K
  • Last Post
Replies
2
Views
51
Replies
4
Views
776
Replies
2
Views
2K
Replies
8
Views
969
Replies
10
Views
2K
Replies
14
Views
1K
  • Last Post
Replies
11
Views
1K
Replies
2
Views
1K
Replies
5
Views
2K
Top