optical shaft encoder

1 and 2 digital, white in to the center, battery is fresh of the charger plus new backup battery.

First, by no reading, does that mean you are not getting any data in the debug stream, or you are getting bad data (all 0’s etc.)?

First make sure that your cortex is on, even if it is connected to your computer. The sensor can only be powered from a battery, not the computer.

Second, if you are getting data that is random numbers around 0, the lens on the sensor is dirty. Disassemble the sensor, and blot on the lens to clean it.

How are you running the system? Do you have just a cortex connected to the computer with the USB A-A? Or are you using a VEXnet remote with the programming hardware cable?

The debug is showing 0. I have tryed useing a a-to-a cable along with a programming hardware cable. I have opened the encoder and cleaned it. nothing.

Well you seem to be doing everything correctly. It’s difficult to know what to suggest. Even with incorrect code you should see the encoder count change in the sensor debug window unless your code constantly sets the encoder count to 0.

Have you selected the physical robot as the target, sometimes I use the PC emulator and forget to change back.

You may have a bad encoder - try a different encoder.

The cortex may be damaged - try different ports on the cortex, do other sensors work on those ports? does a limit switch work etc.

Posting your code will help us better solve the problem.

looks like i had a bad encoder. thanks for all the help.

Thanks to all who have provided input in this thread. The Wiki and product pages for the Optical Shaft Encoder have been updated per the recommendations and insight pointed out in the posts above.

As always, if you find something egregiously out of date or incorrect on any official VEX Robotics website, feel free to post here on the forums or send an email to support@vex.com .

Does anyone know what 1 inch is in ticks. I am using a quadrature encoder. 360 ticks is one rotation

That depends on your gear ratio, the size of your output wheel, etc.

can you give me an equation to help me figure out the answer

can you give me an equation to help me figure out the answer

The equation for circumference is pidiameter. If you are using 4" wheels then each revolution would be 3.144 or 12.56". Since each revolution is also 360 encoder ticks, you can equate 12.56 to 360.

inches per revolution = piwheel diameter = 3.144 = 12.56
ticks per revolution = 360
ticks per inch = 360/12.56 = 28.7

Wow. Sorry to comment on a post that’s been inactive for 2 years… but I have an issue that this post may have explained. It was mentioned:

Just curious if these two products are identical. We have a quad encoder on each side of our chassis. When testing, one of them seemed to grow dramatically faster than the other. Not sure if it was exactly a 90:360 ratio… but probably similar.

Are these similar looking?


So no, the old encoder only had 1 wire. If an encoder is declared as a quad encoder in the motor sensor setup and is only reading 90 ish counts per revolution the most likely cause is a dusty disk inside the encoder.

Quad encoders look for this pattern. If the state moves along the pattern forwards the count goes up and vice versa.
low low
low high
high high
high low

So an encoder with half of it completely broken will be stuck oscillating between 2 values (0 and 1) or (0 and -1) because it can only see these 2 states.
low high
high high

So an encoder declared as quadrature can only read 90 counts if both sides are working intermittently.


Do i have to multiply the 360 if i have 2 shaft encoder (1 in each side)
3602 / 4Pi