Quadrature Shaft Encoders

The documentation says that the encoder counts 360 per revolution, but my physical testing only gets about a 250 count per revolution. Any thoughts?

The sample program for Shaft Encoders defines a left and right encoder, but only the left is used? What is the purpose of the right?

Documentation says the Shaft Encoder can sense direction, but I find no explanation as to how. Help!

When you are testing the counts, did you make sure that either 1. whatever you are turning is directly inserted the shaft encoder aka directly driven, or 2. whatever you are turning is geared 1:1 with an axle that goes through your shaft encoder?

I do not know the sample program off the top of my head, but since only the left is used, I am assuming that it is for driving straight. If a robot is driving straight, hypothetically both the shaft encoder readings would be the same. Both encoders are used when a robot is turning.

As for the direction sensing, you can tell if something is rotating forward or backwards if the counts are increasing or decreasing.

Hope this helps.

I found some old encoders had issues but never diagnosed why. Maybe pop open the back and make sure it is clean. Also possible but unlikely that you spun too fast.

Here is a PDF that explains it pretty well. An encoder with only one sensor cannot tell the direction but the quad encoders have two sensors. When one sensor fires before the other then it can determine the direction.

In some of the demo videos they start using both encoders to keep the robot travel straight. It compares the encoders to each other and adjusts the motors if one side gets ahead. You really only need one encoder to measure distance but having two improves your chances of arriving at a destination on the field.

Optical Shaft Encoder Instruction Sheet

To test the encoder for the 360 ticks per rotation you may want to use the Debug mode with RobotC (or other software) and watch the signals coming from the encoder to make sure that it is triggering the Cortex properly.

So quad encoder means 4 states (2 digital pins each being high or low)

high high
low high
low low
high low

high high
low high
low low
high low

You have to always follow that pattern and it loops around. You can tell which direction an encoder is moving by seeing if it is moving up or down that pattern.

The example is probably just sloppily written and does not take into account that 1 side of the drive train could be driving slower than the other.

VEX used to sell shaft encoders with only 1 wire, these are different from the Quad encoders we are all talking about and can’t sense direction.

Optical Encoders can read incorrectly (skip counts) if they are rotated too quickly or if they pick up electrical noise. You can try gearing them down so that they will be read more reliably by the Vex microcontrollers. The I2C version used by the Vex Cortex is probably more reliable.

They’re digital sensors. Not that I’m an expert, but it seems unlikely that there could be enough interference to cause it to read the opposite state. Skipping counts also seems dubious as the cortex is using hardware interrupts for them.
The IMEs are not nearly as reliable and gearing encoders down only introduces slop and decreases the resolution of an already low resolution sensor

I’ve had this issue before, and the fix turned out to be pretty simple. I completely disassembled the encoder and liberally applied electronics cleaner. Seemed to make them work just fine again. Hope this helps.

I’ve had luck with just a wet paper towel. That was a good fox too. Foxes are pretty simple. They are just little red bushy dogs. Unless they are grey. I wipe every last little surface down with a paper towel. Even the LED and the sensor. Then I dry it off and put it back together and it works. I have done this several times.

I’ve usually just had to clean the photodiode/sensor area. I used pre-moistened lens/screen cleaning wipes or just a damp paper towel.

You must have other kinds of foxes in New England; here in Kentucky foxes are never simple.

One thing I’ve found is that junk from dirty tiles can sometimes get stuck in the holes in the disc of the encoder. Even if there isn’t anything evident to the naked eye, if you’re having problems with the encoder in my opinion it’s better to just clean everything. Better to do it right the first time than have to open it up again. But hey, whatever works works.

RIGHT HERE IN KENTUCKY :smiley:

You make a very good point. Once the hood’s up, the hard work’s done. So cleaning everything makes sense.

Caught that, did you? I thought I could slide that one by.

After the rousing speech, one of the kids did this:

What ports do you have the quad encoder plugged into?