Shaft Encoder Range of Values?

I didn’t search too in depth for this, but I was wondering what values the Optical Shaft Encoders span. Do they do negative values? Do they have a cap (i.e. 1023)?

And also, what is the code to reset the encoders to 0? Is it just


SensorValue[encoder] = 0;

?

Lastly, what is the second wire connected to some of the newer encoders for, and how are they programmed?

The new Quadrature Optical Shaft Encoders (Quadrature meaning that there are two sensors which would be the new ones with two wires) do go into negative values. As far as I know, there is no cap. I was testing one today and it never reached a max, which makes sense really because it’s a continuous rotation and only sends whether or not it can see through the disc.

Yes, your code is correct to reset the encoders to zero.

The question about the second wire also follows up the negative values. The second wire sends the same value, but shifted. If the shift comes before, it show the wheel moving in a certain direction and sets the values to negative. If the shift comes after, the wheel is moving in the other and the values are positive. To program this, one cable goes to an analog/digital port, while the other goes to an interrupt port. I’m not familar with EasyC, but in RobotC there is a sensor configuration where you can set that all up. If you are using only one cable, which cannot detect direction but can still detect rotation, you would select a rotation sensor. If you want to use both, which can detect direction and rotation, you are using a quadrature encoder.

Check out the Inventor’s Guide page. It does a fine job explaining it, actually.


David

Since the VEX PIC microcontroller uses short int’s, the max is either +/- 32768 - see http://en.wikipedia.org/wiki/Integer_(computer_science)