In practice, you use one signal as an interrupt. When that fires, you know the encoder has moved. You then sample the other signal to get direction.
Though, I seem to recall that there are cases where this scheme can cause you to loose exact positioning (like if the shaft is slightly vibrating just between two encoding positions). I believe if you want perfect positioning data, you have to track every edge and run it through a simple state machine. I’ll try to find a reference and post back…
Page 4 of the manual for the sensor said that sample code to help you get started is available on the Vex website but the code for testing sensors isn’t updated for new sensors such as the new Quadrature Optical Shaft Encoder and the Potentiometer.
You can also read Optical Encoders using a Motor Controller IC such as the Microchip dsPIC30F2010, which has a Quadrature Encoder Input (QEI). I have used it to measure speed and direction of motors used in my robot applications. The dsPIC30F2010 also has 6 complementary PWM outputs that can drive all kinds of DC motors.
I am trying to program a quadrature encoder to sense degrees and direction of rotation, but I’m having a bit of trouble. I plugged one end of the sensor into a digital port, but the ones and zeros don’t seem to correspond to any of the movements. It might be something obvious that I’m just missing, but I would appreciate any input possible.
Robofreak asked about using quadrature with Easy C. As of release 2.0 of easy C, you can’t get direction info and there is no way of working with interrupts. Post 5 has nothing to do with Easy C. The question “when is it going to be available for Easy C?” is still very valid!