# Stepper Driver pulses control (with Arduino)

I intend to control the speed of a stepper motor thanks to a driver connected to Arduino (Mega).

Basically the driver has, among others, 2 pins, PUL+ (Vcc) and PUL- (GND, common cathode), and each time a cycle LOW / HIGH is executed on these pins, the motor does one (micro)step (in "single pulse mode", there is another pin for the direction, but that doesn't matter in the context of this question).

The driver manual says

Question: I'm wondering about "dutycycle of pulse is recommended 50%": since the level reference seems to be HIGH, according to the graph below, does it mean that the HIGH level following a LOW, when doing a pulse, has to be at least the same duration as the LOW, or do they both simply need to obey by the $$\\ge 2.5\text{μs}\$$ rule? (and in this case why does the manual mention the recommended 50% duty cycle?)

Added details: the Arduino loop will be quite complex, and based (empirically) on the speed of the Mega, I initially thought about doing a LOW for $$\50\text{μs}\$$ followed by a HIGH of at least $$\50\text{μs}\$$ for a max speed of $$\\dfrac{1}{1600\cdot 10^{-4}} = 6.25\$$ RPS (1600 microsteps setting). And when reaching the max speed the LOW might last more than $$\50\text{μs}\$$ (due to Arduino doing other things in the meantime), while the following HIGH might last less, thus we could have something like

$$\text{LOW}_{80\text{μs}} \to \text{HIGH}_{50\text{μs}} \to \text{LOW}_{70\text{μs}} \to \text{HIGH}_{50\text{μs}} \to ...$$

• ask the manufacturer why they are recommending 50% duty cycle Feb 19, 2021 at 19:15

The duty cycle is not really what contains the information, so it is uncritical in general. Instead you trigger steps by providing the driver with edges (unlike servos, which are typically controlled by duty cycle). A short voltage spike or dip (sth like 1% or 99% duty cycle) might not be seen by the driver, though. A 50% duty cycle like in the image is just what you would normally do: equally long high and low times. But, as I mentioned, it's uncritical and you should be fine if the duty cycle varies between maybe 30-70% (probably depends on the speed). Finally, I suggest you try to find out how extreme the duty cycle can be for the driver to still work properly. Then add some margin.

Another thing is your sketch. If you get problems because the loop() has too much else to do, you might want to change your implementation (using interrupts is an idea).

The maximum is for the stepper motor driver to understand what you're asking it to do. The other answers are correct in that you don't really need to worry too much about the duty cycle. But if the pulse is too short (Less than 2.5us) it might not be detected.

I did a project with steppers, using 800 steps per revolution, and I found that the motor would miss steps if I didn't wait long enough. Here is a web-site that can help you calculate how fast you can step the motor. The limit won't be the spec on this driver unless you are really using a high number of microsteps. You need to know the motor's microHenrys and it max current allowed (or that you can drive), and also the voltage.

https://www.daycounter.com/Calculators/Stepper-Motor-Calculator.phtml

The manual says on p8...
c) t3: Pulse width not less than 2.5us;
d) t4: Low level width not less than 2.5us.

Obvious a single pulse has no duty cycle. Translation to English may cause confusion.