VEX Optical encoder

How do I reset the optical encoder at end of travel? For example, reset encoder at one end of rack gear, turn on motor, wait until bumper switch hits “bumper”, reset encoder, turn on motor in reverse, wait until bumper switch hits “bumper”, reset encoder, and repeat. Another example, reset encoder, turn on motor, wait until encoder reports 250 units, reset encoder, turn on motor in reverse, wait until encoder reports 250 units, reset encoder, and repeat.

I don’t have the Vex Optical Encoder, but the motion of Optical Encoders are endless, just like in a Mouse…

Take a look at the EasyC code supplied for use with the encoder. I’m pretty sure that it has a function call you can invoke to reset the running count of the encoder’s generated interrupts.

As it rotates, the encoder generates an endless stream of interrupts. It is the software that counts those interrupts and reports them as a growing sum.

It is also the software, EasyC or ordinary hand-written C, that initializes that count to some value and that can later change it to any chosen value.

Blake

Such as:


PresetEncoder (encoder port number, 0);