|
@@ -207,7 +207,7 @@ skew_factor_t Planner::skew_factor; // Initialized by settings.load()
|
207
|
207
|
|
208
|
208
|
xyze_long_t Planner::position{0};
|
209
|
209
|
|
210
|
|
-uint32_t Planner::cutoff_long;
|
|
210
|
+uint32_t Planner::acceleration_long_cutoff;
|
211
|
211
|
|
212
|
212
|
xyze_float_t Planner::previous_speed;
|
213
|
213
|
float Planner::previous_nominal_speed_sqr;
|
|
@@ -2271,23 +2271,22 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
2271
|
2271
|
// Compute and limit the acceleration rate for the trapezoid generator.
|
2272
|
2272
|
const float steps_per_mm = block->step_event_count * inverse_millimeters;
|
2273
|
2273
|
uint32_t accel;
|
2274
|
|
- if (!block->steps.a && !block->steps.b && !block->steps.c) {
|
2275
|
|
- // convert to: acceleration steps/sec^2
|
2276
|
|
- accel = CEIL(settings.retract_acceleration * steps_per_mm);
|
2277
|
|
- TERN_(LIN_ADVANCE, block->use_advance_lead = false);
|
|
2274
|
+ if (!block->steps.a && !block->steps.b && !block->steps.c) { // Is this a retract / recover move?
|
|
2275
|
+ accel = CEIL(settings.retract_acceleration * steps_per_mm); // Convert to: acceleration steps/sec^2
|
|
2276
|
+ TERN_(LIN_ADVANCE, block->use_advance_lead = false); // No linear advance for simple retract/recover
|
2278
|
2277
|
}
|
2279
|
2278
|
else {
|
2280
|
2279
|
#define LIMIT_ACCEL_LONG(AXIS,INDX) do{ \
|
2281
|
2280
|
if (block->steps[AXIS] && max_acceleration_steps_per_s2[AXIS+INDX] < accel) { \
|
2282
|
|
- const uint32_t comp = max_acceleration_steps_per_s2[AXIS+INDX] * block->step_event_count; \
|
2283
|
|
- if (accel * block->steps[AXIS] > comp) accel = comp / block->steps[AXIS]; \
|
|
2281
|
+ const uint32_t max_possible = max_acceleration_steps_per_s2[AXIS+INDX] * block->step_event_count / block->steps[AXIS]; \
|
|
2282
|
+ NOMORE(accel, max_possible); \
|
2284
|
2283
|
} \
|
2285
|
2284
|
}while(0)
|
2286
|
2285
|
|
2287
|
2286
|
#define LIMIT_ACCEL_FLOAT(AXIS,INDX) do{ \
|
2288
|
2287
|
if (block->steps[AXIS] && max_acceleration_steps_per_s2[AXIS+INDX] < accel) { \
|
2289
|
|
- const float comp = (float)max_acceleration_steps_per_s2[AXIS+INDX] * (float)block->step_event_count; \
|
2290
|
|
- if ((float)accel * (float)block->steps[AXIS] > comp) accel = comp / (float)block->steps[AXIS]; \
|
|
2288
|
+ const float max_possible = float(max_acceleration_steps_per_s2[AXIS+INDX]) * float(block->step_event_count) / float(block->steps[AXIS]); \
|
|
2289
|
+ NOMORE(accel, max_possible); \
|
2291
|
2290
|
} \
|
2292
|
2291
|
}while(0)
|
2293
|
2292
|
|
|
@@ -2336,7 +2335,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
2336
|
2335
|
#endif
|
2337
|
2336
|
|
2338
|
2337
|
// Limit acceleration per axis
|
2339
|
|
- if (block->step_event_count <= cutoff_long) {
|
|
2338
|
+ if (block->step_event_count <= acceleration_long_cutoff) {
|
2340
|
2339
|
LIMIT_ACCEL_LONG(A_AXIS, 0);
|
2341
|
2340
|
LIMIT_ACCEL_LONG(B_AXIS, 0);
|
2342
|
2341
|
LIMIT_ACCEL_LONG(C_AXIS, 0);
|
|
@@ -2352,7 +2351,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
2352
|
2351
|
block->acceleration_steps_per_s2 = accel;
|
2353
|
2352
|
block->acceleration = accel / steps_per_mm;
|
2354
|
2353
|
#if DISABLED(S_CURVE_ACCELERATION)
|
2355
|
|
- block->acceleration_rate = (uint32_t)(accel * (4096.0f * 4096.0f / (STEPPER_TIMER_RATE)));
|
|
2354
|
+ block->acceleration_rate = (uint32_t)(accel * (sq(4096.0f) / (STEPPER_TIMER_RATE)));
|
2356
|
2355
|
#endif
|
2357
|
2356
|
#if ENABLED(LIN_ADVANCE)
|
2358
|
2357
|
if (block->use_advance_lead) {
|
|
@@ -3020,7 +3019,7 @@ void Planner::reset_acceleration_rates() {
|
3020
|
3019
|
max_acceleration_steps_per_s2[i] = settings.max_acceleration_mm_per_s2[i] * settings.axis_steps_per_mm[i];
|
3021
|
3020
|
if (AXIS_CONDITION) NOLESS(highest_rate, max_acceleration_steps_per_s2[i]);
|
3022
|
3021
|
}
|
3023
|
|
- cutoff_long = 4294967295UL / highest_rate; // 0xFFFFFFFFUL
|
|
3022
|
+ acceleration_long_cutoff = 4294967295UL / highest_rate; // 0xFFFFFFFFUL
|
3024
|
3023
|
TERN_(HAS_LINEAR_E_JERK, recalculate_max_e_jerk());
|
3025
|
3024
|
}
|
3026
|
3025
|
|