# Driving step motors using microstep drivers with teensy 4

I am trying to drive two stepper motors NEMA23 with two DM542 microstep driver (one for each) and a Teensy 4.1 as controller: http://tinel.com/uploads/DM542.pdf

Please find datasheet of DM542 here: https://kitaez-cnc.com/f/dm542.pdf

I am able to drive both motors if I am using an Arduino Mega2560 as controller without issue. However when I switch to a Teensy 4.1 after changing some parameters in my software for compatibility between Arduino and Teensy, I thought to be able to drive my stepper motors. However with the Teensy the motors starts to run and then stops randomly.

Output of Arduino is +5V instead of +3.3V for Teensy, so I am using a LLC (transistor based), to convert +3.3V to +5V to feed input of DM542 which need (+5V to +24V as input).

My DM542 is connected in cathode mode. The only difference between the two configuration (the one with Arduino and the one with Teensy) is that my STEP signal is inverted and that I am using a LLC to convert my step signal +3.3V to +5V.

This image will explain better:

My questions/remarks:

• output of LLC (HV1) has a pull up resistor 10 kohm and in the datasheet of DM542, if you drive with a +5V signal you must not have any resistance in the PUL(STEP) line and on the other lines (DIR and EN). Can it be my issue ? I put a resistor in parallel to decrease the value of the pull-up, it's working better but my motors still stop randomly before ending their respective cycles.

• DM542 is currently in cathode mode, should I plug it in anode mode ? What is the better ?

• output of my LLC (BOB-12009) is not +5V, why ? Should I use another LLC ?

• the signal sent to DM542 is inverted because LLC transistor (BSS138) is closed when Teensy send no signal to LV1 and is open when Teensy send +3.3V signal to LV1. Can it be an issue to have the signal inverted if DM542 is connected in cathode mode ?

• can it be a software issue ? My code is running without error and the libraries I am using are compatible between arduino and teensy.

Thank you a lot for your help, I am really stuck and I don't understand what I am doing wrong here...

• Comments are not for extended discussion; this conversation has been moved to chat. – SamGibson Apr 24 at 13:01
• Your blue block diagram shows STEP, DIR and EN connections to the motor. I think that's a copy and paste error. – Transistor Apr 25 at 7:22

You really don't want to use that type of logic level converter. Fine for I2C, but not much else. Note - these do not invert and only actively pull low. The DM542 datasheet gives you a hint on how to drive it. I'd suggest some BSS138 mosfets would be suitable. Basically 0V to the drain, port pin -> 10 Ohm resistor-> mosfet gate. Source to - of input to DM542. This WILL invert the signal, but due to the circuit a LOGIC 1 on the teensy will turn on the opto. Home free.

• So if I use my DM542 driver in common annode mode means STEP-/DIR-/ENA- connected to my controller (Teensy), I don't necessary need a LLC even if my controller output is +3.3V ? I just need to connect to STEP-/ENA-/DIR- NMOS transistors as it's described into §9 "Typical connection" of DM542 datasheet ? I only need a LLC if I connect my controller to positive inputs of DM542 driver ? Thanks – Armand Apr 22 at 12:08
• I think someone needs to draw a schematic to clarify the situation. Your use of LLC is confusing as it is a general term. You can't connect the GPIO of the teensy directly to STEP- as the circuit requires 5V on the STEP+. The teensy would not like this. You require extra circuitry like I described- ie three BSS138 mosfets and three 10Ohm resistors. This is one form of a LLC (logic level converter) of which there are many. – Kartman Apr 22 at 12:17
• I just added a small schematic into my issue description. STEP-/DIR-/EN- are already connected to 3 different BSS138 N-CH MOSFET. I just draw the logic on the STEP- but it's the same for EN- and DIR-. – Armand Apr 22 at 12:34
• That is not what I described. – Kartman Apr 22 at 12:43

Question

How to use MCU (Teens4, STM32, Rpi4B, Rpi Pico) and DM542 microstep driver to control NEMA 17 / NEMA 24 stepper motors?

1. There are many possible causes of trouble. I opened the DM542 module coveer and found three optocouplers EL817c and current limiting resistors 270Ω. One cause is on the input side of the DM542. The three EL817C each needs 5mA to 20mA to enable/trigger. The 20mA current can be from a common cathode source driver, or common anode sink driver.

1. Now I am going to wire up HCT125 to DM542

/ to continue, ...

/ to continue, ...

References

/ to continue ,...

Appendices

Contents

Appendix A - DM542 Microstepper Configuration Settings

Appendix B - DM542 HCT125 3V3 to 5V0 Common Cathode Wiring

Appendix C - DM542 Setting up and Troubleshooting Check List


Appendix A - Microstepper Configuration Settings

Appendix B - Wiring Diagram for HCT125 Common Cathode Configuration

Appendix C - DM542 Setting up and Troubleshooting Check List

Introduction

/ to continue, ...