We are having issues getting values from our am-3132 (E4T) encoder, connected to our ToughBox Mini with Dual CIM input.
We currently have it wired as follows:
Orange Wire --> DIO 5 / 5V
Brown Wire --> DIO 5 / GND
Yellow Wire (Channel B) --> DIO 5 / S
Blue Wire (Channel A) --> DIO 6* / S
*Nothing is wired to GND or 5V
Code (Java):
Encoder enc = new Encoder(5,6); //robotInit()
enc.reset() //robotInit()
enc.getDistance(); //teleopPeriodic()
So far we have tried:
Switching the DIO ports used
Swapping Channel A and B wires
Reading DIO ports using get() --> We found DIO 5 oscillates between true/false when the wheels are turning, DIO 6 stays constant false
Is this in a looping section of your code (like teleop periodic)? If so, you’re calling reset every time before you get your distance, so it gets reset to zero every time.
Also, what do you mean nothing is wired to GND and 5v? It’s clearly being powered as you can tell it’s oscillating.
A little more info we discovered: the encoder values oscillate between 0 and 0.25 when the motors are moving and stay constant at 0 when they aren’t moving. Does that help clear things up?
Also try checking the outputs of get() or getRaw() from the encoder object (not the DIO object). These should give raw encoder counts rather than a distance.
Oscillating like that means one of the two signal wires is not connected properly. We had a similar issue and it turned out to be the crimp was on insulation and not on the conductive bit of the wire.
This is standard for this sort of encoder. They made a cable that goes to two three pin pwm connections, so one cable provides power and ground to the encoder and the second connection is needed only for the second signal wire.
So from what I can tell, your DIO 6 (channel B) seems to be disconnected. Connect up a multimeter (or a oscilloscope if you’re feeling fancy) and see if you can get a signal anywhere on the wire (at the connector to the encoder, solder joint to the board). From there you can figure out which portion you need to replace.
Thanks for the suggestions everyone. Unfortunately, nothing we tried solved the problem. The encoder still inconsistently oscillates between 0-n*0.25 where n is the number of ticks/rev set in the code.
Here’s what we tried:
Resoldering the connections to eliminate any possibility of faulty wiring
Setting the ticks/revolution in the code among other parameters specified in WPI Screensteps
Switching the wiring to see if the oscillation jumped pins (it did)
Reading the raw output of the encoder
Sadly, nothing we tried got us usable values from the encoder. I guess this means our encoder itself is busted. My advice for anyone reading this thread in the future is to be extra careful when assembling the optical encoders and avoid touching the sensor as much as possible. Thanks again for the help!
did you use all the little spacer tools when installing the encoder to the shaft? alignment is very important. it’s also easy to damage the little glass disk. Also verify the cover of the encoder is fully snapped down, one of my students failed to fully snap it down once, and the difference is subtle (you should hear two clicks when installing).
if you take the cover off (carefully) and post a picture (in focus), we can look to see if it looks an installation error.