Shop OBEX P1 Docs P2 Docs Learn Events
Time measurement/Using an accelerometer to calculate current position. — Parallax Forums

Time measurement/Using an accelerometer to calculate current position.

JoMoJoMo Posts: 19
edited 2008-01-23 17:38 in Propeller 1
Hi,
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?

thanks
-Joe
·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-01-23 00:42
    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 BakerPaul Baker Posts: 6,351
    edited 2008-01-23 01:05
    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
    Propeller Applications Engineer

    Parallax, Inc.
  • JoMoJoMo Posts: 19
    edited 2008-01-23 01:06
    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.

    thanks
    Joe
  • rjo_rjo_ Posts: 1,825
    edited 2008-01-23 04:20
    Joe,

    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[noparse]:)[/noparse]. 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.

    Rich
  • simonlsimonl Posts: 866
    edited 2008-01-23 10:53
    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?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,

    Simon
    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 smile.gif
  • JoMoJoMo Posts: 19
    edited 2008-01-23 17:38
    Hi all,

    Paul-
    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.

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

    rjo_-
    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
    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.
    thanks
    -Joe
    ·
Sign In or Register to comment.