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.

Be very careful about this.

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:


vel //Your old velocity
pos //Old position

pos = pos + old_vel*dt+ 1/2(a*dt^2)
vel = vel+a*dt

Please note that your dt is how often this code executes, so if you execute every 4 milliseconds dt will be .004 (assuming in seconds) The trick is that the accelerometer (KOP one at least) puts out a value in g’s which is equal to 9.81 m/s^2 so you will have to convert that number before you put it into that equation. Good luck.

That was the idea behind the accelerometer.