MicroBahner / MobaTools

Arduino library for model railroaders
GNU Lesser General Public License v2.1
77 stars 10 forks source link

Open-drain GPIO in MotoStepper #38

Open kf1375 opened 1 week ago

kf1375 commented 1 week ago

Hi @MicroBahner,

Since many stepper motor drivers must be controlled by Open Drain output, it would be great to support this. Currently, I achieved this by changing some lines in the "src\utilities\MoToStepper.cpp" and "src\utilities\MoToStepperNo8266.inc" but it would be great if this existed in the library.

Thanks

MicroBahner commented 5 days ago

Hi kf375, Can you give an example of such a stepper driver? So far I have never seen a stepper driver that requires an OpenDrain output at the Arduino.

kf1375 commented 3 days ago

Thanks for your reply,

image

https://www.omc-stepperonline.com/digital-stepper-drive-1-0-3-2a-18-30vdc-for-nema-17-23-stepper-motor-dm332t

As an example this driver motor requires an OpenDrain output.

MicroBahner commented 3 days ago

It doesn't need an OpenDrain output. If you use Vcc=5V, you can safely connect PUL, DIR and ENA directly to an Arduino OUTPUT. There are a lot of drivers with such an optoisolated input. All work well together with MoToStepper.

kf1375 commented 2 hours ago

As well as I am using ESP32, the Vcc would be 3V3. Both when the pin is low and when the pin is high, the current passes through the input diode of the optocoupler. Is it not safer to drive the pins in OpenDrain mode? It will ensure that the optocouplers will completely turn off and turn on.