Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
5 years, 4 months ago.
How to get time value from accelerometer readings
Hi,
I am doing a project with ADXL313. my goal is to study the rotational behavior of accelerometer. For that, I need to extract the velocity value from accelerometer data. I am very confused as the accelerometer gives the output in mg/LSB form how we can extract the velocity data from there. To get acceleration value I divide the readings of accelerometer and after that calculate the magnitude by sqrt(x^2+y^2) but now I am confused that how I will calculate the velocity if I don't have the time value as we know the formula for calculating velocity is a/t. please help me to solve this issue.
2 Answers
5 years, 4 months ago.
Hello Nivedita,
Quote:
as we know the formula for calculating velocity is a/t
That formula is wrong. Velocity can be calculated from acceleration as integral over time. The correct formula is:
v
= v
0 + Integral of a
over t
(from t
0 to t
current)
Where:
v
is velocityv
0 is the initial (starting) velocity at timet
0a
is the acceleration varying over the timet
t
0 is the initial (starting) timet
is the time variablet
current is the time at which we calculate the velocity
Acceleration and also velocity are vectors. To calculate acceleration in Cartesian coordinate system the formula shall be applied for each coordinate (x, y and z). One can use a Timer
to produce time data associated with the measured acceleration but because the calculation involves integration, small errors in the acceleration lead to a large build up of error in the calculated velocity. And there are also other things to consider:
- The output of ADXL313 is affected by Earth gravity. No one (including an ADXL313 sensor) is able to distinguish a gravitational field from acceleration (as explained by A.Einstein in his thought experiment "Elevator Action").
- A spinning ADXL313 will show increased acceleration in the radial direction but the sensor won't actually travel off the position.
To sum it up, I think it's impossible to reliably calculate velocity using just data measured by an ADXL313 sensor.
5 years, 4 months ago.
First, review the formula for velocity... it is integration of acceleration over time (a*dT where dT needs to be made as small as possible). If, for example, the accelerometer only outputs updates at 10Hz then dT can not be smaller than 0.1. But, as you will found out, this too can lead to errors. So review Kalman filtering before just assuming you can do a simple integration.
Hi Bellis Thanks for the answer. I am sorry for the wrong formula. Yes velocity = Acceleration *Time. I want to ask one thing that I set my frequency in code as 50 Hz so according to this time will be 0.02. Will it be constant? Actually, in my code, I am using the Butterworth filter. So How to consider time in this scenario.
posted by 05 Aug 2019Nivedita There are still going to be issues with the how the data is post-processed. Yes, the time step needs to match so in your case 20ms would be correct. Just applying a Butterworth filter will not solve velocity errors as you are going to find out. I found a university article which addresses noise in accelerometers and what happens when you use a Butterworth filter on them. https://cgm.engr.ucdavis.edu/library/signal-processing-and-filtering-of-raw-accelerometer-records/ Enjoy
posted by 05 Aug 2019