Tracking Distance on one Axis with an Accelerometer

Click For Summary

Discussion Overview

The discussion revolves around the method of tracking distance on a single axis using an accelerometer for a rocket project. Participants explore the mathematical approach to integrate acceleration data over time to derive distance, while also addressing potential inaccuracies in the proposed method.

Discussion Character

  • Technical explanation, Debate/contested, Mathematical reasoning

Main Points Raised

  • One participant outlines a method for calculating distance using acceleration data, involving updates to speed and distance based on discrete time intervals.
  • Another participant questions the accuracy of using "New speed" as representative of the entire time interval, suggesting it only reflects the speed at the end of the interval.
  • A third participant clarifies that the method assumes constant speed during the execution of the code, which may lead to inaccuracies.
  • A suggestion is made to improve accuracy by averaging accelerations and velocities at the ends of the interval, along with a reference to a numerical integration method for better results.
  • One participant expresses hesitation about sharing code due to concerns over others' ability to interpret it.

Areas of Agreement / Disagreement

Participants express differing views on the accuracy of the proposed method for calculating distance, with some acknowledging its potential inaccuracies while others suggest alternative approaches. No consensus is reached on the best method to use.

Contextual Notes

Participants note limitations in the initial approach, particularly regarding the assumption of constant speed and the implications of using end-of-interval speed for calculations. The discussion does not resolve these limitations.

ferret_guy
Messages
18
Reaction score
0
I need to track Distance on one Axis with an Accelerometer for a rocket project (i know there are bettor ways t do this but i am dead set on this one) I was thinking as follows,

Code:
Read Accelerometer
Accelerometer*Δt=Δv
Current speed+Δv=New speed
distance+New speed*Δt=New distance
 
Physics news on Phys.org
distance+New speed*Δt=New distance

Isn't "New speed" the speed only at the end of the interval "delta t", not for the whole duration of delta t?
 
This function is repeated many times so that is the speed that is dirived from the inatil meshurment and the Δt is the time since the last meshurment so were assuming that your travling at a constant speed for the time it takes to exicute the pice of code
 
bahamagreen said:
distance+New speed*Δt=New distance

Isn't "New speed" the speed only at the end of the interval "delta t", not for the whole duration of delta t?

Yes. It will still work, but is inaccurate. A better simple method is averaging accelerations and velocities at the ends of the interval:

PHP:
velocityX[0] = 0 // we assume the device was static when we started recording acc
positionX[0] = 0

for every sample i > 0:
    dt = time[i-1] - time[i] // if sampling rate is constant simply use 1 / frequency here
    velocityX[i] = velocityX[i-1] + (accX[i] + accX[i-1]) / (2 * dt)   
    positionX[i] = positionX[i-1] + (velocityX[i] + velocityX[i-1]) / (2 * dt)

Better is:
http://doswa.com/2009/01/02/fourth-order-runge-kutta-numerical-integration.html
 
Thank you I was hesitant about posting code because I dident know how many people wold be able to interpret it
 

Similar threads

  • · Replies 47 ·
2
Replies
47
Views
5K
Replies
11
Views
24K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 25 ·
Replies
25
Views
9K
  • · Replies 4 ·
Replies
4
Views
9K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 15 ·
Replies
15
Views
7K
  • · Replies 4 ·
Replies
4
Views
16K