2
\$\begingroup\$

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: incorrect encoder waveform 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?

\$\endgroup\$
3
  • 1
    \$\begingroup\$ This seems like straightforward analog crosstalk. A schematic showing the encoder, passives, long cables, etc may help explain the reason. Also, it's hard to see the scale of the bump; is the crosstalk severe enough that you're getting incorrect readings or it falls outside the valid input HIGH/LOW ranges for your microcontroller? \$\endgroup\$
    – nanofarad
    Oct 7, 2022 at 1:05
  • 1
    \$\begingroup\$ check that supply voltage to the encoder is correct, and measure signal voltages. \$\endgroup\$ Oct 7, 2022 at 3:20
  • \$\begingroup\$ This optical module requires a +5V DC supply. Could you be using it with a microcontroller having a DC supply less than +5V? Or could you be supplying the optical module with a ~3.5v DC supply instead of the required +5V? Both these scenarios are big no-no. \$\endgroup\$
    – glen_geek
    Oct 7, 2022 at 14:02

1 Answer 1

1
\$\begingroup\$

Nanofarad was correct. The person who assembled the device I'm working on twisted the wires of the E8T encoder together to prevent a mess of loose wires. Once I untwisted the wires I was able to read square waveforms without a bump.

I was able to read from the E5 encoders(the ones that worked from the beginning) since those are not part of an assembled device yet and no one twisted those wires as part of the assembly process.

I'm a mechanical engineer so a lot of these electronics things are not super intuitive for me. Thanks for everyone's help. I really mean it. I was tearing my hair out for a few days trying to solve this one.

\$\endgroup\$
0

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .