Summarize the problem: TLDR: I am having trouble reading the signals from an optical encoder to track the position of a stepper motor(I know that it’s redundant to use encoders on stepper motors. It’s a long story.). I am unable to read the A/B signals correctly. I think this might be due to the strange waveform that my encoder is outputting. Please skip to the bottom of this post to see the waveform.
To be more specific about the encoder problem: sometimes when I move the stepper motor, the encoder causes the increment counter to increase and decrease so it appears that the motor is in the same place. (The increment counter changes like this: 256 -> 257 -> 256 -> 257 -> etc). Othertimes, the encoder reads that the motor is only turning in one direction in one direction, regardless of whether I am turning the motor clockwise or counterclockwise(the increment counter only increases when it should be decreasing).
Provide details and any research: The encoder in question is US Digital's E8T-500-197-S-H-M-2(500 CPR), (https://www.usdigital.com/products/encoders/incremental/kit/e8t/?q=E8T-500-197-S-H-M-2) attached to a NEMA 17 motor. I am reading the signals on an Arduino Mega using hardware interrupt pins 2 and 3. The encoder is powered using the 5v/ground of the Arduino Mega.
When appropriate, describe what you’ve tried: I think that my Arduino and Arduino sketch are working perfectly. I think this because I happen to have a different encoder(US Digital’s E5-400-197-IE-S-D-D-B(400 CPR) https://www.usdigital.com/products/encoders/incremental/kit/e5/) that I can compare the E8T encoder to.
The E5 encoder consistently increments the position counter by 'y' everytime I send Gcode commands to the stepper motor to move distance 'x'. The E5 encoder also tracks positive and negative movement accurately. I have attached the E5 encoder attached to my Arduino using the same interrupt pins as the E8T, and the E5 encoder is powered by the Arduino just like the E8T. The E5 has an index pin that I'm not using. The setup is identical, so I don't think there's anything wrong with my Arduino/Arduino sketch.
I analyzed the signal from the E8T encoder using an oscilloscope, and I got these waveforms that have a bump in both the A and B signals when the waveforms are high: I don't think there is anything wrong with the encoder itself since I have 3 E8T encoders and they all output the same waveforms with bumps. I don't think there is anything wrong with my scope since I checked the signal from the E5 encoders and I get a normal square wave.
Has anyone seen this problem before? If so, what should I do to solve it?