Encoder Trouble

We use Java and have Grayhill 63R encoders that do not work. We have checked the wiring and it is fine. The a and b signals are taking up 2 different channels, it has power and ground, and the wires are not broken. The constructor is :
driveLeftEncoder = new Encoder(3, 4, false, EncodingType.k4X);
We also remembered to start and reset it. When printing the values, the encoder always returns 0 for the get() method, .25 for the getDistance() method, 1 for getRaw(),and true or false at random for getDirection(). Unless we stop then start it, the rate is 0, and when we do it is a random value. Also without stopping and starting it, it always returns true for getStopped(). We are utterly confused as to what is wrong and would appreciate any help.

An issue that can easily get over looked is do you have your encoder reset inside a while function? And would you also mind posting your code?

Another thing crucial to getting Encoders to work is using the setDistancePerPulse() method.

You experimentally determine this constant by rolling the robot over a pre-determined distance, and recording the number of pulses from the get() method.

Then it’s as easy as dividing distance by the number of pulses, and using the setDistancePerPulse() before getting the distance.

Hope this helps.

If this still doesn’t work, maybe try posting the code, and we can look it over.

For the past two weeks our team has tried to get our US Digital encoder working. We cannot read any values from the encoder at all. Our wiring is the same as this:

And our code is attached.

We have tried to test everything that we could think of. Please help us find what is wrong so we can get them working. Thank you very much for your help, we really appreciate it.

Are you really connecting the encoders to the DCS PWM outputs rather than the DIO?

Maybe he meant PWM cable

I hope so. But that needs to be confirmed.

Sorry for the confusion, we are connecting them via pwm cable to the “DIGITAL I/O” on the digital sidecar.

Does your team have access to an oscilloscope, even a cheap one?

Yes, we do own an oscilloscope.

Look at the output of the encoder(s). See if there’s any signal coming out.

You may have to carefully strip the insulation of a small section of the signal wires.

I was taught by an smart EE to use a scribe to poke through the insulation of the wire, then touch the probe to the scribe. Super easy, and the wire isn’t exposed when you’re done (you should still warp it in electrical tape afterward)

The same guy taught me to strip wire using small side cutters, another handy trick.

We are getting signals from channel a and channel b. (it looks like a pwm signal)

Of course. Thank you. I suppose you could use a needle or a pin in a pinch.

A and B should be in quadrature. Are they?

I’m afraid we have gone from our meeting today so I will have to postpone tests to tomorrow. Also, (sorry for being ignorant) what does “in quadrature” mean?

Quadrature means the A-Channel signal overlaps the B-Channel signal by exactly half. The encoder can’t tell which way it’s rotating without it. If the A-Channel is first, the motor is rotating one way. If the B-Channel is first, the motor is rotating the other way. If you can test both channels on your scope, the graphs should like like the ones below, depending on the way the motor is rotating.

Good description :slight_smile:

Quadrature means the A-Channel signal overlaps the B-Channel signal by exactly half.

Exactly 90 degrees (one quarter).

If you’re talking about how it rotates, yes, but if you look at at the graph of the output, it’s split in half.

No, I’m talking about the 90 degree phase shift between the A and B signals.

If it were half (180 degrees), it would look like this:

     |-----|     |-----|     |-----|
     |     |     |     |     |     |
_____|     |_____|     |_____|     |_____

-----|     |-----|     |-----|     |-----
     |     |     |     |     |     |     
     |_____|     |_____|     |_____|