# Measure vertical distance travelled

I wonder if it's usually practical to use an accelerometer to measure the height of a ball tossed in the air. That is, would it be accurate to integrate the acceleration measured over time twice? An accelerometer like the MPU6050 has DMP for calculating pitch, roll, and yaw but nothing for height. Would it be too slow to integrate ay twice on a low-end MCU like the MSP430?

Edit: The height of travel will be less than 10cm.

• No. It is not very practical. Use a barometer instead. – mkeith Dec 27 '16 at 7:04
• @mkeith I'm actually expecting a height of less than 100mm, so I don't think there'll be any significant change in pressure. – John M. Dec 27 '16 at 7:43
• A lot of the MEMS barometers I've seen can discern a cm or so of altitude change. Not what I'd call 'stellar performance' for your application, but then, I don't know what precision you need. – Sam Dec 27 '16 at 20:32

All an accelerometer will give you is time of flight.

while the ball is in the air it's in free-fall and the accelerometer will read zero.

if you can assume a level playing field you can calculate maximum height from time of flight.

for 10cm height time of flight will be about 200ms

throw in a 3 axis gyro, and you can estimate how hard it was thrown and and how much of that throw was vertical, but time of flight is probably still your best bet.

• Right. But why a gyro and not an accelerometer? Wouldn't I want to measure the linear acceleration instead? – John M. Dec 27 '16 at 10:58
• @JohnMunroe - Unless you can guarantee that the ball is thrown along the sensitive axis of the accelerometer, you'll need a 3-axis accelerometer, along with some software to combine the 3 axes worth of data to synthesize the actual acceleration, and even then you won't know if the throw was vertical - that's what you need the gyros for. You'd need to determine the local g vector (most easily done at rest, but not necessarily), then keep track of rotations to determine the vertical component of your launch acceleration. And gyro drift will be the biggest source of error. – WhatRoughBeast Dec 27 '16 at 13:44
• @WhatRoughBeast If I'm only interested in the vertical displacement, wouldn't only the vertical linear acceleration be relevant? That is, there'd be no need to keep track of rotations - am I right? – John M. Dec 27 '16 at 16:31
• @JohnMunroe - Only if "you can guarantee that the ball is thrown along the sensitive axis of the accelerometer". Can you make that guarantee? If so, you only need one. – WhatRoughBeast Dec 27 '16 at 16:37
• from a frame of reference of an observer standing on the ground, timing the flight is equivalent to integrating the gravitational acceleration, it won't tell you current height, but when it lands (about 100ms late) you'll know how high it went. (assuming no aerodynamic effects) – Jasen Dec 29 '16 at 5:38