Should I use a Pot or an encoder, and how?

I’m having a problem, I’m trying to figure how I would count the revolutions of the driveshaft in autonomous so I can create a simple distance = (2 * revolutions * 3.14159) equation. However, with the refresh rate I don’t think I could correctly count revolutions without errors.

What you really should use is called a quadrature encoder and you can find some sample code for it on

Also, I think you need wheel radius in that equation. :slight_smile:

I think that you need to use interups… that way the refresh rate of your user_routines wont matter…

You need to use encoders. Pots can only rotate a certian number of degrees before hitting their physical limits. If you search encoders on these forums you should find alot of good info.

An alternate method would be to use a hardware counter. Have the counter count the encoder ticks, then read them whenever you’re ready. That way, timing doesn’t matter at all. Well, I guess if you’re trying to figure out speed you’d need to know the amount of time between reads…