Browse Source

Reduce Step Smoothing ceiling to 50% CPU usage (#18719)

Jason Smith 3 years ago
parent
commit
a847f37d43
No account linked to committer's email address
2 changed files with 7 additions and 5 deletions
  1. 3
    3
      Marlin/src/module/stepper.cpp
  2. 4
    2
      Marlin/src/module/stepper.h

+ 3
- 3
Marlin/src/module/stepper.cpp View File

@@ -2099,11 +2099,11 @@ uint32_t Stepper::block_phase_isr() {
2099 2099
       #if ENABLED(ADAPTIVE_STEP_SMOOTHING)
2100 2100
         uint8_t oversampling = 0;                           // Assume no axis smoothing (via oversampling)
2101 2101
         // Decide if axis smoothing is possible
2102
-        uint32_t max_rate = current_block->nominal_rate;    // Get the maximum rate (maximum event speed)
2102
+        uint32_t max_rate = current_block->nominal_rate;    // Get the step event rate
2103 2103
         while (max_rate < MIN_STEP_ISR_FREQUENCY) {         // As long as more ISRs are possible...
2104 2104
           max_rate <<= 1;                                   // Try to double the rate
2105
-          if (max_rate >= MAX_STEP_ISR_FREQUENCY_1X) break; // Don't exceed the estimated ISR limit
2106
-          ++oversampling;                                   // Increase the oversampling (used for left-shift)
2105
+          if (max_rate < MIN_STEP_ISR_FREQUENCY)            // Don't exceed the estimated ISR limit
2106
+            ++oversampling;                                 // Increase the oversampling (used for left-shift)
2107 2107
         }
2108 2108
         oversampling_factor = oversampling;                 // For all timer interval calculations
2109 2109
       #else

+ 4
- 2
Marlin/src/module/stepper.h View File

@@ -229,8 +229,10 @@
229 229
 #define MAX_STEP_ISR_FREQUENCY_2X   ((F_CPU) / ISR_EXECUTION_CYCLES(2))
230 230
 #define MAX_STEP_ISR_FREQUENCY_1X   ((F_CPU) / ISR_EXECUTION_CYCLES(1))
231 231
 
232
-// The minimum allowable frequency for step smoothing will be 1/10 of the maximum nominal frequency (in Hz)
233
-#define MIN_STEP_ISR_FREQUENCY MAX_STEP_ISR_FREQUENCY_1X
232
+// The minimum step ISR rate used by ADAPTIVE_STEP_SMOOTHING to target 50% CPU usage
233
+// This does not account for the possibility of multi-stepping.
234
+// Perhaps DISABLE_MULTI_STEPPING should be required with ADAPTIVE_STEP_SMOOTHING.
235
+#define MIN_STEP_ISR_FREQUENCY (MAX_STEP_ISR_FREQUENCY_1X / 2)
234 236
 
235 237
 //
236 238
 // Stepper class definition

Loading…
Cancel
Save