waspinator / AccelStepper

Fork of AccelStepper
http://www.airspayce.com/mikem/arduino/AccelStepper/
Other
146 stars 86 forks source link

Teensy 4.0 (ARM Cortex-M7) cyclic cranky vibration #39

Closed siteswapjuggler closed 2 months ago

siteswapjuggler commented 2 months ago

Hello,

I'm working on a project where I would like to replace Teensy 3.2 (which does not exist anymore) with Teensy 4.0.

I just did some testing apparently everything works well, I mean the motor is turning, accelerating and changing direction but there is some strange cranky vibration in the motor with the Teensy 4.0.

It looks like it's missing some steps or interruption anyhow.

As far as I did test I successfully get rid of the problem by choosing 150 MHz CPU Speed instead of 600 MHz. It also works with 24 MHz. All other CPU Speed option doesn't work.

Considering the CPU Speed factor could it be a counter type overflow. Too many cyle to wait resulting in overflow the variable. Resulting in cycling offset ????

Well any solution to use it at full speed would be welcome, for now I'll go for 150 MHz :-)

Have a nice day

siteswapjuggler commented 2 months ago

Ok problem solved using stepper.setMinPulseWidth(2);

My theory is that the standard library use a minimum pulse of 1µs which never apply on most processor because they are too slow or their timer not precise enough. Per example Arduino Uno minimum delayMicroseconds is 4µs.

The Teensy 4.0 running at 600 MHz is fast enough to achieve 1µs delay therefore it can cause problem with some driver like the DRV8825 which need 1.9µs minimum PulseWidth.

Hope it could help people with the same problem.