Interference on analog pin while using TB6600 stepper driver

I have super weird issue that I can't wrap my head around. Most basic setup, driving TB6600, while reading analog input. Analog is connected directly to the ground and reading 0, unless TB6600 direction pin is high, then I get noise (in the lower range) on the analog pin, despite being grounded. Where is the signal coming from? It behaves this way even if external power is disconnected from the TB6600, but TB is using optocouplers for inputs. It only works correctly if I break connection to TB6600, either direction pin or ground, step pin does not seem to affect the readout. Disclaimer, I'm using ESP32 with Micropython, but I believe this is electrical problem. Does anyone have an idea what could be wrong?

If you think it is an electrical problem, then please supply a schematic of how you have this all wired together. We are unable to see it from here.

Paul

Sure, here it is. I said earlier that only dir pin causes problems, but step pin does too, just is ON so briefly that it does not trip my code.

i had problems with encoder outputs when the motor was running. while i fixed it well enough with some software, i think passing the output thru a NE555 as a schmitt trigger would help.

Are you using a breadboard for connections?

Paul

Paul_KD7HB:
Are you using a breadboard for connections?

I owe you a beer. Wired everything spider style and now it works. But I used lousy wires to make connections (female-female to male-male) and it periodically reappeared as I twisted and turned the package looking for exact source of problem, but then it went completely and I was unable to pin point the issue. I still don't understand how it could happen previously as ground rail is isolated on my breadboard and any shorts were not physically possible to occur, unless stress on wires caused shorts right in the MCU ground pin area (I had everything connected in that corner). Lesson learned. Many thanks, Paul.