View Full Version : Time measurement/Using an accelerometer to calculate current position.

01-23-2008, 05:24 AM
I have a·question about making time measurements. Which·may be painfully obvious to do. (It's just that I am good at missing the obvious, especially the·painful variety).

Here is the scenario:
I want to measure the distance traveled using a single·3-Axis accelerometer to determine my position
(relative to the initial start of events) and·display that·position in real-time (every few milliseconds).
The entire event would take place in a small area, a room for example, and would last a only a few minutes.

I know that the method of using an accelerometer to do determine distance·will·propagate any errors introduced, but I hope that won't be a big problem·if the·distance traveled and·over all begin/end elapsed time is relatively short (distance being reset at the start of each run time).

Since I would like·the position granularity to be smallish (to the centimeter or so) that leaves GPS out.
Alluding to a side question: How would you·go about measuring the current position of something·during a·walkabout in a room? Since GPS won't help me, the accelerometer was my next approach.

But my main question here is:
Using the Prop, what would be the best method for measuring the time from start of the event
so that I can use that value to calculate the distance traveled in real-time?

Could I simply start a new cog that waits every nth milliseconds which then increments a counter?
Where if·n=10·then 10 counter hits = 100 msecs.· Is there a better way?


Mike Green
01-23-2008, 07:42 AM
You already have a timebase running (the system clock - CNT). For events up to around 50 seconds, you just save CNT at the start of the event, then subtract that from CNT to get the elapsed time in clock units (usually 12.5ns). If you need longer intervals, you can use the two counters that are in each cog. One gets set up to produce a pulse once a second and the other is triggered by that pulse and keeps a count of the seconds.· You could use the same I/O pin for both and don't even have to connect it to anything.

You're probably not going to get the kind of accuracy you want for "dead reckoning" because the accelerometers you're likely to use are not that accurate.

You might be better off using a combination of IR distance sensing and ultrasonic distance sensing (like the PING) since there are walls usually within range. If there are a lot of obstacles (like people or furniture) that might not work that well either.

Paul Baker
01-23-2008, 08:05 AM
Another means for achieving quite good dead reckoning is using an optical mouse. Movement in the y direction is your linear travel, and if you have the optical sensor some distance from your vehicle's pivot point, when you rotate the X direction can be translated into an angle of rotation through trig equations.

Paul Baker (mailto:pbaker@parallax.com)
Propeller Applications Engineer
[/url][url=http://www.parallax.com] (http://www.parallax.com)
Parallax, Inc. (http://www.parallax.com)

01-23-2008, 08:06 AM
Hi Mike,
Thanks for the suggestions and information.
I am using this accelerometer:
Triple Axis Accelerometer Breakout - LIS3LV02DQ (http://www.sparkfun.com/commerce/product_info.php?products_id=758)

I can't·use ultrasonics or IR, as potentially are·may be no landmarks to ping.


01-23-2008, 11:20 AM

I studied your exact issue for a couple of days with a dual axis, mems type unit from RadioShack. What I found was that there was a patterned error, part of which was no doubt due to the fact that I wasn't compensating for ambient temperature...In fact, without correction I felt that the unit could be used as a better temperature sensor than as an accelerometer... it is a nice problem, more than worth your time.

(I think we probably also have to correct for atmospheric pressure too but I have no idea how to do either right now:). I intend to get back to the issue one of these nights.

The spec on your unit is .025 percent per degree C... with a footnote... " typical specifications are not guaranteed." You have to convert that error into a per second acceleration error and then you can compute the distance error by integrating over time... my guess is that you will end up having to settle for short runs or really dealing with the engineering challenge.

But if you are just talking about short runs around a room with uniform temperature, then you can zero out the errors, leaving you with the problem of distinguishing between acceleration and tilt, which is not trivial. Martin Hebel was looking at using the Parallax ultrasound pinger for short distance/high accuracy measurements, but I don't know if he got there or got deflected. I want to do this for my car, so I'm considering placing a couple of pingers at the corners to see what it will do for me.

I also never figured out which temperature to measure... I think a thermistor on the chip is the way to go.


01-23-2008, 05:53 PM
I once saw (but typically can't find now) a post that suggested placing a resistor over the accelerometer. The idea was that the resistor would heat the accelerometer to a constant temperature, and cancel out / stabilise the error. No idea what value resistor to use, or what that's do for battery life, but I guess it's an option?


www.norfolkhelicopterclub.co.uk (http://www.norfolkhelicopterclub.co.uk)
You'll always have as many take-offs as landings, the trick is to be sure you can take-off again ;-)
BTW: I type as I'm thinking, so please don't take any offense at my writing style http://forums.parallax.com/images/smilies/smile.gif

01-24-2008, 12:38 AM
Hi all,

The Optical·Mouse idea is an interesting one. One of the challenges there·would be to extend the focal point·as my application is a hand held device. I like the concept though.

Thanks, not sure·how much of a·problem the ambient·temperature is yet with this device, but I will keep that in mind.

rjo_ (http://forums.parallax.com/member.php?u=48782)-
yeah,·I figured if I·had short runs I could mitigate the errors somewhat.
The temperature issue I will need to investigate.
As for tilt vs translation,·adding·a gyroscope came to mind, then I found this:
· (http://www.sparkfun.com/commerce/product_info.php?products_id=741)http://www.sparkfun.com/commerce/product_info.php?products_id=741
Can't find any docs on this as a whole unit so I suspect the onboard·gyroscope and an accelerometer are not integrated with each other in any meaningful way, so I could just get a gryo separately.

As usual this is turning out to be trickier than I had hoped.