Newbie question on pulse width using the Stepper library

I'm using an arduino uno r3 and did a comparison between a DRV8833 and the DM320T stepper driver with a stepper motor and am a bit confused...

when I run my motor (200 steps/rev) on the DRV8833 and drive it 200 steps, it does a full rev as expected

when i use the DM320T with microstepping=2 and drive it for 400 steps, it does a quarter rev, which was unexpected

in the DM320T manual, i see a spec that indicates that the minimum pulse width is 7.5 microseconds. when i look in the source code for Stepper.cpp, it looks to me like a pulse is sent by sequential calls of digitalWrite() while in some other places online, I see code that inserts a call of delayMicroseconds(pulseWidthMicros) between the digitalWrite() calls.

if the Stepper library is not doing a pause for the pulse width, is there a way to determine what it is? I'm trying to figure out if my DM320T is confused about pulse width, or if the microstepping is not working correctly by a factor of 4...

thanks!

Maybe show the code?

If Stepper.h is used with a step+dir driver with the one of the quadrature output schemes, you need to send 4x the number of steps and the pulsewidths are two steps wide.

Stepper.h in 2-wire mode sends these signals:

... so it takes 4 steps to cycle a "Pulse" line once.

(ref Stepper Driver with Quadrature from Stepper.h or Encoder)

ah, i see--the 4x makes sense now. is there a way to determine max pulse rate, and therefore max speed?

sorry to have neglected to show the code before--here's the code that resulted in a quarter turn with 2x microstepping:

#include <Stepper.h>

const int stepsPerRevolution = 400;
Stepper myStepper(stepsPerRevolution, 8, 9);

void setup() {
myStepper.setSpeed(20); 
Serial.begin(9600);
}

void loop() {
Serial.println("clockwise"); //controls the direction of the stepper motor;
myStepper.step(stepsPerRevolution);
delay(500); //the delay time between turns;
Serial.println("counterclockwise");
myStepper.step(-stepsPerRevolution);
delay(500);
}

Determine it from what? The 7.5us minimum pulse rate? If that is the length of two segments of the Stepper.h quadrature cycle, then Stepper.h would need to step twice as fast, or 3.75us/step, or 1/3.75e-6=266666.7steps/sec. I'm not sure how fast stepper.h can go, but 267kSteps/sec or 266666.7/1600*60=10000 RPM seems pretty high. I'd bet the overhead of Stepper.h limits it quite a bit.

determine it from the arduino uno r3 specs... i.e., how many microseconds between sequential digitalWrite() calls?

also, i forgot to say thanks for your response re: quadrature--that was really helpful!

With stepper.h there's also the overhead of computing when to call, and actually calling the next step.

How fast do you need to spin your motor?

There are other stepper libraries that may work with your driver for your purposes.

I actually don't need it to spin very fast, but I observed some behaviors in the 2 stepper motors i tried that made me wonder if I was reaching a limit with higher levels of microstepping when trying to smooth/quiet my motor.

and thanks for the other library suggestions--I'll check them out!

All three of those libraries do acceleration, which is important if you are trying to reach high speed. Sending high-speed pulses without acceleration is asking for skipped steps.

just for giggles, i did some timing tests for single digitalWrite() and single steps with speed set to 2147483647 (step_delay is very small at that speed) in 2, 4, and 5 wire mode on my uno r3 and got the following avg timings in microseconds:
single digitalWrite(): 3.4
fast digital write (direct port manipulation): .25
2-wire single-step: 33.53 (29.8k steps/sec)
4-wire single-step: 42.85
5-wire single-step: 46.81

i have no particular question about this, just found it interesting

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.