## Re: [Gumstix-users] use of an accelerometer.

 Re: [Gumstix-users] use of an accelerometer. From: Chad Robinson - 2007-07-27 00:40:19 ```Albert Dahan wrote: > Hi Dave, > > Thanks for making that clear. > > Any idea how I can read the distance if the GPS isn't available? > > I need to determine the kilometers made by a car without using a > pulse or can solution, is that possible? > You can still do it with an accelerometer, it's just harder and will build up error over time. It's called dead reckoning. You need to read the accelerometer VERY fast (this may be beyond the reach of a slow MCU and ADC) and make sure you never accelerate beyond its limits (or you won't know how far beyond the limits you were). Basically, as often as you can, you sample the accelerometer. If it says you're accelerating, you calculate speed by continually adding (or subtracting for negative Gs - slowing down) your acceleration value from your current speed, and you calculate position by adding speed * sample time to old position. You need to be able to sample at least twice as fast as your expected acceleration period. So, you probably won't ever be very good at telling when somebody smacked you with a hammer and knocked you three feet over, but you could be OK at telling that somebody pushed you that same distance if it wasn't so abrupt. Ideally you want some other reference to calibrate this to. It would be MUCH more accurate if you had a speed reading from a wheel, say, or if you could periodically hope that you could sample GPS and update. High-end car GPS units do this so they can get better than the accuracy they get with GPS - they use GPS to get you to within 100ft or whatever the accuracy is at that time, then dead reckoning WITHIN that box. If you want to do this, be prepared for a lot of complexity, code, and frustrating. It takes a LOT of effort and skill to do this accurately, and good dead-reckoning systems for things like submarines and airplanes can cost hundreds of thousands of dollars. Regards, Chad ```