Go Down

### Topic: Accelerometer Displacement (Read 1 time)previous topic - next topic

#### bebo_stunner ##### Nov 18, 2013, 07:17 pm
Hi

I have a Tinker-kit accelerometer connected to my arduino, I am able to read a value for acceleration in both the X and Y axis as i move the sensor.

I need to find the value of displacement which requires the acceleration to be integrated twice, does anybody have any information on a method to do this?

#### PeterH #1
##### Nov 18, 2013, 08:10 pm
You would do this by numerical integration.

The change in speed over a time interval is the average acceleration multiplied by the duration. This is very convenient to evaluate iteratively:

Code: [Select]
`currentAcceleration = readAcceleration();averageAcceleration = (currentAcceleration + previousAcceleration) / 2;currentSpeed = previousSpeed + (averageAcceleration * duration);averageSpeed = (currentSpeed  + previousSpeed) / 2;currentDisplacement = previousDisplacement + (averageSpeed * duration);previousAcceleration = currentAcceleration;previousSpeed = currentSpeed ;previousDisplacement = currentDisplacement;`

You would need to execute that code periodically. The blink without delay example shows how to do that.

You will need to deal with scaling according to the units that you're using for acceleration, speed, distance and time.

Go Up