How to program REV Through Bore Encoder

REV-11-1271 We want to use this encoder in absolute mode but aren’t sure how to program it. We’ve got this encoder attached to an item which controls the angle that the ball ejected from the shooter. For this application, we’ll never get a full revolution of the motor shaft. It’ll probably turn no more than 90 degrees. Our goal is to get a precise value from the encoder to control exactly which angle we want for the shooter.

We’re using Java though I suspect the answers to my question will apply to C++ as well.

First…do we plug it into the Rio PWM pins or the Analog input pins? We’ve been experimenting using it as an Analog input.

Our simple test simply looked at getAverageVoltage. We did get somewhat meaningful answers but there was far too much variation. Without moving the motor, values fluctuated as much as .5volts.

Further experimentation such as changing the number of bits using setAverageBits gave us more stable values but we don’t understand why.

The AEAT-8800-Q24 data sheet says

“The absolute angle measurement provides an instant indication of the magnet’s angular position with a selectable and one-time programmable resolution of 10, 12, 14, or 16 bits.”

This sounds like it would be useful if I knew what to do with it.

Can anyone explain how this should work, from a software perspective for those of us with very limited electrical background?

Many thanks

Tldr You plug it into one of the DIO ports, and read it with the DutyCycleEncoder class in wpilib.

The PWM ports are specifically output ports, and it’s not an analog signal, but it’s actual a ratio of high time vs low time as a digital signal. So reads with a DIO, and then just the DutyCycleEncoder class to easily read the values.

1 Like

Thanks! That worked great.