|
@@ -153,8 +153,7 @@ float Planner::previous_speed[NUM_AXIS],
|
153
|
153
|
|
154
|
154
|
#if ENABLED(LIN_ADVANCE)
|
155
|
155
|
float Planner::extruder_advance_k, // Initialized by settings.load()
|
156
|
|
- Planner::advance_ed_ratio, // Initialized by settings.load()
|
157
|
|
- Planner::position_float[NUM_AXIS] = { 0 };
|
|
156
|
+ Planner::advance_ed_ratio; // Initialized by settings.load()
|
158
|
157
|
#endif
|
159
|
158
|
|
160
|
159
|
#if ENABLED(ULTRA_LCD)
|
|
@@ -170,9 +169,6 @@ Planner::Planner() { init(); }
|
170
|
169
|
void Planner::init() {
|
171
|
170
|
block_buffer_head = block_buffer_tail = 0;
|
172
|
171
|
ZERO(position);
|
173
|
|
- #if ENABLED(LIN_ADVANCE)
|
174
|
|
- ZERO(position_float);
|
175
|
|
- #endif
|
176
|
172
|
ZERO(previous_speed);
|
177
|
173
|
previous_nominal_speed = 0.0;
|
178
|
174
|
#if ABL_PLANAR
|
|
@@ -679,10 +675,6 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
|
679
|
675
|
}
|
680
|
676
|
#endif
|
681
|
677
|
|
682
|
|
- #if ENABLED(LIN_ADVANCE)
|
683
|
|
- const float mm_D_float = SQRT(sq(a - position_float[X_AXIS]) + sq(b - position_float[Y_AXIS]));
|
684
|
|
- #endif
|
685
|
|
-
|
686
|
678
|
const long da = target[X_AXIS] - position[X_AXIS],
|
687
|
679
|
db = target[Y_AXIS] - position[Y_AXIS],
|
688
|
680
|
dc = target[Z_AXIS] - position[Z_AXIS];
|
|
@@ -711,29 +703,17 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
|
711
|
703
|
//*/
|
712
|
704
|
|
713
|
705
|
// DRYRUN ignores all temperature constraints and assures that the extruder is instantly satisfied
|
714
|
|
- if (DEBUGGING(DRYRUN)) {
|
|
706
|
+ if (DEBUGGING(DRYRUN))
|
715
|
707
|
position[E_AXIS] = target[E_AXIS];
|
716
|
|
- #if ENABLED(LIN_ADVANCE)
|
717
|
|
- position_float[E_AXIS] = e;
|
718
|
|
- #endif
|
719
|
|
- }
|
720
|
708
|
|
721
|
709
|
long de = target[E_AXIS] - position[E_AXIS];
|
722
|
710
|
|
723
|
|
- #if ENABLED(LIN_ADVANCE)
|
724
|
|
- float de_float = e - position_float[E_AXIS]; // Should this include e_factor?
|
725
|
|
- #endif
|
726
|
|
-
|
727
|
711
|
#if ENABLED(PREVENT_COLD_EXTRUSION) || ENABLED(PREVENT_LENGTHY_EXTRUDE)
|
728
|
712
|
if (de) {
|
729
|
713
|
#if ENABLED(PREVENT_COLD_EXTRUSION)
|
730
|
714
|
if (thermalManager.tooColdToExtrude(extruder)) {
|
731
|
715
|
position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
|
732
|
716
|
de = 0; // no difference
|
733
|
|
- #if ENABLED(LIN_ADVANCE)
|
734
|
|
- position_float[E_AXIS] = e;
|
735
|
|
- de_float = 0;
|
736
|
|
- #endif
|
737
|
717
|
SERIAL_ECHO_START();
|
738
|
718
|
SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
|
739
|
719
|
}
|
|
@@ -742,10 +722,6 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
|
742
|
722
|
if (labs(de * e_factor[extruder]) > (int32_t)axis_steps_per_mm[E_AXIS_N] * (EXTRUDE_MAXLENGTH)) { // It's not important to get max. extrusion length in a precision < 1mm, so save some cycles and cast to int
|
743
|
723
|
position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
|
744
|
724
|
de = 0; // no difference
|
745
|
|
- #if ENABLED(LIN_ADVANCE)
|
746
|
|
- position_float[E_AXIS] = e;
|
747
|
|
- de_float = 0;
|
748
|
|
- #endif
|
749
|
725
|
SERIAL_ECHO_START();
|
750
|
726
|
SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP);
|
751
|
727
|
}
|
|
@@ -753,6 +729,10 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
|
753
|
729
|
}
|
754
|
730
|
#endif // PREVENT_COLD_EXTRUSION || PREVENT_LENGTHY_EXTRUDE
|
755
|
731
|
|
|
732
|
+ #if ENABLED(LIN_ADVANCE)
|
|
733
|
+ float de_float = de * steps_to_mm[E_AXIS_N];
|
|
734
|
+ #endif
|
|
735
|
+
|
756
|
736
|
// Compute direction bit-mask for this block
|
757
|
737
|
uint8_t dm = 0;
|
758
|
738
|
#if CORE_IS_XY
|
|
@@ -1350,30 +1330,28 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
|
1350
|
1330
|
|
1351
|
1331
|
#if ENABLED(LIN_ADVANCE)
|
1352
|
1332
|
|
1353
|
|
- //
|
1354
|
|
- // Use LIN_ADVANCE for blocks if all these are true:
|
1355
|
|
- //
|
1356
|
|
- // esteps : We have E steps todo (a printing move)
|
1357
|
|
- //
|
1358
|
|
- // block->steps[X_AXIS] || block->steps[Y_AXIS] : We have a movement in XY direction (i.e., not retract / prime).
|
1359
|
|
- //
|
1360
|
|
- // extruder_advance_k : There is an advance factor set.
|
1361
|
|
- //
|
1362
|
|
- // block->steps[E_AXIS] != block->step_event_count : A problem occurs if the move before a retract is too small.
|
1363
|
|
- // In that case, the retract and move will be executed together.
|
1364
|
|
- // This leads to too many advance steps due to a huge e_acceleration.
|
1365
|
|
- // The math is good, but we must avoid retract moves with advance!
|
1366
|
|
- // de_float > 0.0 : Extruder is running forward (e.g., for "Wipe while retracting" (Slic3r) or "Combing" (Cura) moves)
|
1367
|
|
- //
|
1368
|
|
- block->use_advance_lead = esteps
|
1369
|
|
- && (block->steps[X_AXIS] || block->steps[Y_AXIS])
|
|
1333
|
+ /**
|
|
1334
|
+ *
|
|
1335
|
+ * Use LIN_ADVANCE for blocks if all these are true:
|
|
1336
|
+ *
|
|
1337
|
+ * esteps && (block->steps[X_AXIS] || block->steps[Y_AXIS]) : This is a print move
|
|
1338
|
+ *
|
|
1339
|
+ * extruder_advance_k : There is an advance factor set.
|
|
1340
|
+ *
|
|
1341
|
+ * esteps != block->step_event_count : A problem occurs if the move before a retract is too small.
|
|
1342
|
+ * In that case, the retract and move will be executed together.
|
|
1343
|
+ * This leads to too many advance steps due to a huge e_acceleration.
|
|
1344
|
+ * The math is good, but we must avoid retract moves with advance!
|
|
1345
|
+ * de > 0 : Extruder is running forward (e.g., for "Wipe while retracting" (Slic3r) or "Combing" (Cura) moves)
|
|
1346
|
+ */
|
|
1347
|
+ block->use_advance_lead = esteps && (block->steps[X_AXIS] || block->steps[Y_AXIS])
|
1370
|
1348
|
&& extruder_advance_k
|
1371
|
1349
|
&& (uint32_t)esteps != block->step_event_count
|
1372
|
|
- && de_float > 0.0;
|
|
1350
|
+ && de > 0;
|
1373
|
1351
|
if (block->use_advance_lead)
|
1374
|
1352
|
block->abs_adv_steps_multiplier8 = LROUND(
|
1375
|
1353
|
extruder_advance_k
|
1376
|
|
- * (UNEAR_ZERO(advance_ed_ratio) ? de_float / mm_D_float : advance_ed_ratio) // Use the fixed ratio, if set
|
|
1354
|
+ * (UNEAR_ZERO(advance_ed_ratio) ? de * steps_to_mm[E_AXIS_N] / HYPOT(da * steps_to_mm[X_AXIS], db * steps_to_mm[Y_AXIS]) : advance_ed_ratio) // Use the fixed ratio, if set
|
1377
|
1355
|
* (block->nominal_speed / (float)block->nominal_rate)
|
1378
|
1356
|
* axis_steps_per_mm[E_AXIS_N] * 256.0
|
1379
|
1357
|
);
|
|
@@ -1387,12 +1365,6 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
|
1387
|
1365
|
|
1388
|
1366
|
// Update the position (only when a move was queued)
|
1389
|
1367
|
COPY(position, target);
|
1390
|
|
- #if ENABLED(LIN_ADVANCE)
|
1391
|
|
- position_float[X_AXIS] = a;
|
1392
|
|
- position_float[Y_AXIS] = b;
|
1393
|
|
- position_float[Z_AXIS] = c;
|
1394
|
|
- position_float[E_AXIS] = e;
|
1395
|
|
- #endif
|
1396
|
1368
|
|
1397
|
1369
|
recalculate();
|
1398
|
1370
|
|
|
@@ -1418,12 +1390,6 @@ void Planner::_set_position_mm(const float &a, const float &b, const float &c, c
|
1418
|
1390
|
nb = position[Y_AXIS] = LROUND(b * axis_steps_per_mm[Y_AXIS]),
|
1419
|
1391
|
nc = position[Z_AXIS] = LROUND(c * axis_steps_per_mm[Z_AXIS]),
|
1420
|
1392
|
ne = position[E_AXIS] = LROUND(e * axis_steps_per_mm[_EINDEX]);
|
1421
|
|
- #if ENABLED(LIN_ADVANCE)
|
1422
|
|
- position_float[X_AXIS] = a;
|
1423
|
|
- position_float[Y_AXIS] = b;
|
1424
|
|
- position_float[Z_AXIS] = c;
|
1425
|
|
- position_float[E_AXIS] = e;
|
1426
|
|
- #endif
|
1427
|
1393
|
stepper.set_position(na, nb, nc, ne);
|
1428
|
1394
|
previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest.
|
1429
|
1395
|
ZERO(previous_speed);
|
|
@@ -1448,16 +1414,8 @@ void Planner::set_position_mm_kinematic(const float position[NUM_AXIS]) {
|
1448
|
1414
|
* Sync from the stepper positions. (e.g., after an interrupted move)
|
1449
|
1415
|
*/
|
1450
|
1416
|
void Planner::sync_from_steppers() {
|
1451
|
|
- LOOP_XYZE(i) {
|
|
1417
|
+ LOOP_XYZE(i)
|
1452
|
1418
|
position[i] = stepper.position((AxisEnum)i);
|
1453
|
|
- #if ENABLED(LIN_ADVANCE)
|
1454
|
|
- position_float[i] = position[i] * steps_to_mm[i
|
1455
|
|
- #if ENABLED(DISTINCT_E_FACTORS)
|
1456
|
|
- + (i == E_AXIS ? active_extruder : 0)
|
1457
|
|
- #endif
|
1458
|
|
- ];
|
1459
|
|
- #endif
|
1460
|
|
- }
|
1461
|
1419
|
}
|
1462
|
1420
|
|
1463
|
1421
|
/**
|
|
@@ -1471,9 +1429,6 @@ void Planner::set_position_mm(const AxisEnum axis, const float &v) {
|
1471
|
1429
|
const uint8_t axis_index = axis;
|
1472
|
1430
|
#endif
|
1473
|
1431
|
position[axis] = LROUND(v * axis_steps_per_mm[axis_index]);
|
1474
|
|
- #if ENABLED(LIN_ADVANCE)
|
1475
|
|
- position_float[axis] = v;
|
1476
|
|
- #endif
|
1477
|
1432
|
stepper.set_position(axis, v);
|
1478
|
1433
|
previous_speed[axis] = 0.0;
|
1479
|
1434
|
}
|