Is there a stepper motor library that works on GIGA?

The accelstepper library doesn't seem to work on the GIGA. I can drive the motors with basic code, but with the library, the direction works, but the steps don't. I suspect the pulse width may be an issue, something to do with the GIGA. The code works fine on Uno and Mega boards. Has anybody successfully driven steppers with the GIGA/ If so, what library works?

I looked into this before, the default pulse width with AccelStepper is indeed very short on the Giga, use setMinPulseWidth(5), or whatever is required by the driver.

Note that that the actual pulse width may be +/- 1us so bear that in mind.

1us is the default in the AccelStepper code:

The setMinPulseWidth() doc says it is effectively 20us, but that's on slower hardware where the pulse gets stretched out.

setMinPulseWidth()

void AccelStepper::setMinPulseWidth ( unsigned int minWidth )

Sets the minimum pulse width allowed by the stepper driver. The minimum practical pulse width is approximately 20 microseconds. Times less than 20 microseconds will usually result in 20 microseconds or so.

Parameters

[in] minWidth The minimum pulse width in microseconds.

To get 20us, I guess on Uno 2 x digitalWrite() takes @14 us, and delayMicroseconds() etc takes the remaining 6us.

I measured the pulse time with a scope using a Giga and the default 1 microseconds, and found that a lot of pulses actually less than 1us. With a set pulse width of 5us, I got pulses in the range 4-5 us.

Two conclusions:

  1. Giga is hella fast compared to an Uno
  2. delayMicroseconds() is not very accurate down to 1us

The delayMicroseconds doc says so:

This function works very accurately in the range 3 microseconds and up to 16383. We cannot assure that delayMicroseconds will perform precisely for smaller delay-times. Larger delay times may actually delay for an extremely brief time.

Thanks all. The driver specs state the minimum low level pulse duration needs to be >4 microseconds. It has a maximum step frequency (in microstepping) of 200 kHz, i.e. 5 microseconds, so makes sense to set setMinPulseWidth to no less than 5.

OK so the "MinPulseWidth" set to 5 solved the problem, however now the "Stepper.run()" being called from within "loop()" makes the steppers jump, whenever something else inside the loop happens. In other words, the "stepper.run()" needs to be within a timer based interrupt. Is this possible?

It's possible, but I doubt that is the right solution.

A solution for the GIGA is to use mbed flipper ticker function. This works a treat, simply set up a periodic interrupt timer that calls the stepper.run().