# Finding distance using accelerometer..

I am trying to use the data from the accelerometer to find the distance the robot has traveled, but I’m not sure how to do this.
Help?

I am using labview.

In the world that a high school physics class exists in, it is quite simple. Integrate acceleration once and you get velocity. Integrate velocity and you get position. Done and Done.

Unfortunately, the real world is a jerk and gravity keeps on keeping us down. If your accelerometer isn’t perfectly aligned, gravity will affect your side to side acceleration. This will show up as a constant small acceleration. Your velocity will continue to climb and your calculated position will soon be in a different country.

Assuming you can compensate for gravity, you will probably need to use the gyro as well to detect orientation. If you turn 90 degrees, X becomes Y and vis-versa. The gyro will help you with this.

The accelerometer is very good at sensing acceleration, impacts and tilt.I think it will mostly be used for traction control and “I just hit something in autonomous, RUN AWAY” applications this year. It is sketchy for velocity and a pain in the butt for position.

That being said, go for it.

Thanks, but I should of made myself clearer.
I am asking for help on the actual programming in labview.
And about the gyro, is it absolutely necessary?
I thought that the axis rotated with the the accelerometer.
I’m not looking for actual position so much as just knowing the actual distance traveled.

To “integrate” a signal, just keep adding it to an accumulator on a regular basis. Use a timed loop (there’s one provided for you in the Basic robot template) with a shift register to hold the accumulated value.

That’s basically the same thing, isn’t it?

If your wheels don’t slip, encoders on the axle or gearbox give a much easier way to measure distance traveled. That’s not a good assumption with acetal wheels on FRP, though.

What are you struggling with? Do you understand the math behind it? If so I would highly suggest using a c block to do it in, yes you can use LV code but I have always found it rather poor for representing math. (It is just too expanded)

If you want to know the distance you traveled along a given axis and not your position you could probably do w/o a gyro. If you want to do any sort of positioning I would suggest using a gyro.

Now, Eric is correct when he says they have to be mounted flush, the exception being that you could write code to auto zero it at the beginning of a match.

Your code is going to look similar to this:

``````