[2.0.x] Always honor minimum period on stepper pulse generation, and fix timing calculations#11004
[2.0.x] Always honor minimum period on stepper pulse generation, and fix timing calculations#11004thinkyhead merged 2 commits intoMarlinFirmware:bugfix-2.0.xfrom ejtagle:always_honor_maximum_step_rate
Conversation
Marlin/src/module/stepper.cpp
Outdated
There was a problem hiding this comment.
Likewise. If MINIMUM_STEPPER_PULSE isn't defined, this won't compile either.
I assumed we would ensure a maximum stepper rate by limiting the frequency of the ISR (giving time back to the main loop) not by adding a pulse delay even when Anyway, as I've pointed out above, if |
|
Yes, @thinkyhead : The problem happens when multistepping (DISABLE_MULTI_STEPPING disabled, and that is the default) with multistepping, when on the same stepper ISR we send more than one step pulse. When that happens, and MINIMUM_STEPPER_PULSE_TIME == 0, previously the multistepping was done at the maximum rate possible, with no delays at all! Very dangerous, as there are stepper drivers that will simply ignore the stepping pulses ... 👎 |
Yeah, I just noticed that. So, most of the time for 32-bit multi-stepping probably won't be invoked, so not a big deal. |
|
Initially i thought that, but it´s not the case. Z axis usually has a high number of pulses per mm (in my case, 4000) so it happens to be invoked more often than thought initially ;) |
|
And on AVR it is even worse, and manifests itself as losing steps when going too fast ... Does it sound familiar to you ? ;) |
|
Even if the drivers support the associated stepping rate, the mechanical hardware could lose steps. The situation worsens as soon as you start increasing microstepping. |
Yes, but in real-world terms it seems to be absent until sometime after 1.1.8… |
|
I´d say... Luckily it is absent... 👍 ... Something i have noticed lately is that everything seems to be settling down nicely. Less and less reports of layer shifts, people that say latest bugfix seems to be solving their issues... Very nice! 👍 |
|
Theoretically ADDED_STEP_DELAY will always be > 0, as the pulse width is always <= 0.5* pulse period, and pulse period is always > 0 |
By rubber-bands and duct tape.
I'm sure we're getting much closer to the ideal! |
Makes sense. But someone might decide to set |
|
If it tries, then an error should be printed. Again, no driver allows that. Pulse is always recommended to be 50% of the period or less. An incorrect value will most of the time mean badly configured Marlin and bug reports you probably don´t want (I call it: Defensive programming!) Of course, i am the culprit of some of the bugs that we are fixing... But not all of them... For example, the serial errors were my fault, as some of the stepper and endstops... |
|
Now, rechecking this, ADDED_STEP_DELAY could become negative if the MINIMUM__STEP_PULSE > 1/MAXIMUM_STEPPER_RATE .. Trust me, i`d cause a compilation error on that case ;) |
|
The only case where i would leave out the timing code is if the user did not define any limits at all... And in such case, i'd personally just disallow compilation - That is asking for trouble! |
|
Some HALs use a static function to define |
|
Yes, that is right |
Always honor minimum period on stepper pulse generation, and fix timing calculations Signed-off-by: etagle <ejtagle@hotmail.com>
If
MINIMUM_STEPPER_PULSE_TIMEwas 0, then the minimum period was ignored. Enforce respecting the maximum stepper rate always.Also fix the improper calculations of timer counts to enforce that maximum stepper rate: Timer counts are not the same as instruction cycle count, so we must convert it using the pulse timer prescaler define