|
@@ -698,35 +698,69 @@ void Planner::calculate_volumetric_multipliers() {
|
698
|
698
|
#endif // PLANNER_LEVELING
|
699
|
699
|
|
700
|
700
|
/**
|
701
|
|
- * Planner::_buffer_steps
|
|
701
|
+ * Planner::_buffer_line
|
702
|
702
|
*
|
703
|
|
- * Add a new linear movement to the buffer (in terms of steps).
|
|
703
|
+ * Add a new linear movement to the buffer in axis units.
|
704
|
704
|
*
|
705
|
|
- * target - target position in steps units
|
|
705
|
+ * Leveling and kinematics should be applied ahead of calling this.
|
|
706
|
+ *
|
|
707
|
+ * a,b,c,e - target positions in mm and/or degrees
|
706
|
708
|
* fr_mm_s - (target) speed of the move
|
707
|
709
|
* extruder - target extruder
|
708
|
710
|
*/
|
709
|
|
-void Planner::_buffer_steps(const int32_t target[XYZE], float fr_mm_s, const uint8_t extruder) {
|
|
711
|
+void Planner::_buffer_line(const float &a, const float &b, const float &c, const float &e, float fr_mm_s, const uint8_t extruder) {
|
|
712
|
+
|
|
713
|
+ // The target position of the tool in absolute steps
|
|
714
|
+ // Calculate target position in absolute steps
|
|
715
|
+ //this should be done after the wait, because otherwise a M92 code within the gcode disrupts this calculation somehow
|
|
716
|
+ const long target[XYZE] = {
|
|
717
|
+ LROUND(a * axis_steps_per_mm[X_AXIS]),
|
|
718
|
+ LROUND(b * axis_steps_per_mm[Y_AXIS]),
|
|
719
|
+ LROUND(c * axis_steps_per_mm[Z_AXIS]),
|
|
720
|
+ LROUND(e * axis_steps_per_mm[E_AXIS_N])
|
|
721
|
+ };
|
|
722
|
+
|
|
723
|
+ // When changing extruders recalculate steps corresponding to the E position
|
|
724
|
+ #if ENABLED(DISTINCT_E_FACTORS)
|
|
725
|
+ if (last_extruder != extruder && axis_steps_per_mm[E_AXIS_N] != axis_steps_per_mm[E_AXIS + last_extruder]) {
|
|
726
|
+ position[E_AXIS] = LROUND(position[E_AXIS] * axis_steps_per_mm[E_AXIS_N] * steps_to_mm[E_AXIS + last_extruder]);
|
|
727
|
+ last_extruder = extruder;
|
|
728
|
+ }
|
|
729
|
+ #endif
|
710
|
730
|
|
711
|
731
|
const int32_t da = target[X_AXIS] - position[X_AXIS],
|
712
|
732
|
db = target[Y_AXIS] - position[Y_AXIS],
|
713
|
733
|
dc = target[Z_AXIS] - position[Z_AXIS];
|
714
|
734
|
|
715
|
|
- int32_t de = target[E_AXIS] - position[E_AXIS];
|
716
|
|
-
|
717
|
|
- /* <-- add a slash to enable
|
718
|
|
- SERIAL_ECHOPAIR(" _buffer_steps FR:", fr_mm_s);
|
719
|
|
- SERIAL_ECHOPAIR(" A:", target[A_AXIS]);
|
|
735
|
+ /*
|
|
736
|
+ SERIAL_ECHOPAIR(" Planner FR:", fr_mm_s);
|
|
737
|
+ SERIAL_CHAR(' ');
|
|
738
|
+ #if IS_KINEMATIC
|
|
739
|
+ SERIAL_ECHOPAIR("A:", a);
|
|
740
|
+ SERIAL_ECHOPAIR(" (", da);
|
|
741
|
+ SERIAL_ECHOPAIR(") B:", b);
|
|
742
|
+ #else
|
|
743
|
+ SERIAL_ECHOPAIR("X:", a);
|
720
|
744
|
SERIAL_ECHOPAIR(" (", da);
|
721
|
|
- SERIAL_ECHOPAIR(" steps) B:", target[B_AXIS]);
|
722
|
|
- SERIAL_ECHOPAIR(" (", db);
|
723
|
|
- SERIAL_ECHOLNPGM(" steps) C:", target[C_AXIS]);
|
724
|
|
- SERIAL_ECHOPAIR(" (", dc);
|
725
|
|
- SERIAL_ECHOLNPGM(" steps) E:", target[E_AXIS]);
|
726
|
|
- SERIAL_ECHOPAIR(" (", de);
|
727
|
|
- SERIAL_ECHOLNPGM(" steps)");
|
|
745
|
+ SERIAL_ECHOPAIR(") Y:", b);
|
|
746
|
+ #endif
|
|
747
|
+ SERIAL_ECHOPAIR(" (", db);
|
|
748
|
+ #if ENABLED(DELTA)
|
|
749
|
+ SERIAL_ECHOPAIR(") C:", c);
|
|
750
|
+ #else
|
|
751
|
+ SERIAL_ECHOPAIR(") Z:", c);
|
|
752
|
+ #endif
|
|
753
|
+ SERIAL_ECHOPAIR(" (", dc);
|
|
754
|
+ SERIAL_CHAR(')');
|
|
755
|
+ SERIAL_EOL();
|
728
|
756
|
//*/
|
729
|
757
|
|
|
758
|
+ // DRYRUN ignores all temperature constraints and assures that the extruder is instantly satisfied
|
|
759
|
+ if (DEBUGGING(DRYRUN))
|
|
760
|
+ position[E_AXIS] = target[E_AXIS];
|
|
761
|
+
|
|
762
|
+ int32_t de = target[E_AXIS] - position[E_AXIS];
|
|
763
|
+
|
730
|
764
|
#if ENABLED(PREVENT_COLD_EXTRUSION) || ENABLED(PREVENT_LENGTHY_EXTRUDE)
|
731
|
765
|
if (de) {
|
732
|
766
|
#if ENABLED(PREVENT_COLD_EXTRUSION)
|
|
@@ -1033,7 +1067,6 @@ void Planner::_buffer_steps(const int32_t target[XYZE], float fr_mm_s, const uin
|
1033
|
1067
|
// Segment time im micro seconds
|
1034
|
1068
|
uint32_t segment_time_us = LROUND(1000000.0 / inverse_secs);
|
1035
|
1069
|
#endif
|
1036
|
|
-
|
1037
|
1070
|
#if ENABLED(SLOWDOWN)
|
1038
|
1071
|
if (WITHIN(moves_queued, 2, (BLOCK_BUFFER_SIZE) / 2 - 1)) {
|
1039
|
1072
|
if (segment_time_us < min_segment_time_us) {
|
|
@@ -1227,12 +1260,12 @@ void Planner::_buffer_steps(const int32_t target[XYZE], float fr_mm_s, const uin
|
1227
|
1260
|
vmax_junction = MINIMUM_PLANNER_SPEED; // Set default max junction speed
|
1228
|
1261
|
|
1229
|
1262
|
// Skip first block or when previous_nominal_speed is used as a flag for homing and offset cycles.
|
1230
|
|
- if (block_buffer_head != block_buffer_tail && previous_nominal_speed > 0.0) {
|
|
1263
|
+ if (moves_queued() && !UNEAR_ZERO(previous_nominal_speed)) {
|
1231
|
1264
|
// Compute cosine of angle between previous and current path. (prev_unit_vec is negative)
|
1232
|
1265
|
// NOTE: Max junction velocity is computed without sin() or acos() by trig half angle identity.
|
1233
|
|
- float cos_theta = - previous_unit_vec[X_AXIS] * unit_vec[X_AXIS]
|
1234
|
|
- - previous_unit_vec[Y_AXIS] * unit_vec[Y_AXIS]
|
1235
|
|
- - previous_unit_vec[Z_AXIS] * unit_vec[Z_AXIS] ;
|
|
1266
|
+ const float cos_theta = - previous_unit_vec[X_AXIS] * unit_vec[X_AXIS]
|
|
1267
|
+ - previous_unit_vec[Y_AXIS] * unit_vec[Y_AXIS]
|
|
1268
|
+ - previous_unit_vec[Z_AXIS] * unit_vec[Z_AXIS];
|
1236
|
1269
|
// Skip and use default max junction speed for 0 degree acute junction.
|
1237
|
1270
|
if (cos_theta < 0.95) {
|
1238
|
1271
|
vmax_junction = min(previous_nominal_speed, block->nominal_speed);
|
|
@@ -1272,24 +1305,25 @@ void Planner::_buffer_steps(const int32_t target[XYZE], float fr_mm_s, const uin
|
1272
|
1305
|
}
|
1273
|
1306
|
}
|
1274
|
1307
|
|
1275
|
|
- if (moves_queued && !UNEAR_ZERO(previous_nominal_speed)) {
|
|
1308
|
+ if (moves_queued > 1 && !UNEAR_ZERO(previous_nominal_speed)) {
|
1276
|
1309
|
// Estimate a maximum velocity allowed at a joint of two successive segments.
|
1277
|
1310
|
// If this maximum velocity allowed is lower than the minimum of the entry / exit safe velocities,
|
1278
|
1311
|
// then the machine is not coasting anymore and the safe entry / exit velocities shall be used.
|
1279
|
1312
|
|
1280
|
1313
|
// The junction velocity will be shared between successive segments. Limit the junction velocity to their minimum.
|
1281
|
|
- const bool prev_speed_larger = previous_nominal_speed > block->nominal_speed;
|
1282
|
|
- const float smaller_speed_factor = prev_speed_larger ? (block->nominal_speed / previous_nominal_speed) : (previous_nominal_speed / block->nominal_speed);
|
1283
|
1314
|
// Pick the smaller of the nominal speeds. Higher speed shall not be achieved at the junction during coasting.
|
1284
|
|
- vmax_junction = prev_speed_larger ? block->nominal_speed : previous_nominal_speed;
|
|
1315
|
+ vmax_junction = min(block->nominal_speed, previous_nominal_speed);
|
|
1316
|
+
|
|
1317
|
+ const float smaller_speed_factor = vmax_junction / previous_nominal_speed;
|
|
1318
|
+
|
1285
|
1319
|
// Factor to multiply the previous / current nominal velocities to get componentwise limited velocities.
|
1286
|
1320
|
float v_factor = 1;
|
1287
|
1321
|
limited = 0;
|
1288
|
1322
|
// Now limit the jerk in all axes.
|
1289
|
1323
|
LOOP_XYZE(axis) {
|
1290
|
1324
|
// Limit an axis. We have to differentiate: coasting, reversal of an axis, full stop.
|
1291
|
|
- float v_exit = previous_speed[axis], v_entry = current_speed[axis];
|
1292
|
|
- if (prev_speed_larger) v_exit *= smaller_speed_factor;
|
|
1325
|
+ float v_exit = previous_speed[axis] * smaller_speed_factor,
|
|
1326
|
+ v_entry = current_speed[axis];
|
1293
|
1327
|
if (limited) {
|
1294
|
1328
|
v_exit *= v_factor;
|
1295
|
1329
|
v_entry *= v_factor;
|
|
@@ -1384,79 +1418,9 @@ void Planner::_buffer_steps(const int32_t target[XYZE], float fr_mm_s, const uin
|
1384
|
1418
|
|
1385
|
1419
|
recalculate();
|
1386
|
1420
|
|
1387
|
|
-} // _buffer_steps()
|
1388
|
|
-
|
1389
|
|
-/**
|
1390
|
|
- * Planner::_buffer_line
|
1391
|
|
- *
|
1392
|
|
- * Add a new linear movement to the buffer in axis units.
|
1393
|
|
- *
|
1394
|
|
- * Leveling and kinematics should be applied ahead of calling this.
|
1395
|
|
- *
|
1396
|
|
- * a,b,c,e - target positions in mm and/or degrees
|
1397
|
|
- * fr_mm_s - (target) speed of the move
|
1398
|
|
- * extruder - target extruder
|
1399
|
|
- */
|
1400
|
|
-void Planner::_buffer_line(const float &a, const float &b, const float &c, const float &e, const float &fr_mm_s, const uint8_t extruder) {
|
1401
|
|
- // When changing extruders recalculate steps corresponding to the E position
|
1402
|
|
- #if ENABLED(DISTINCT_E_FACTORS)
|
1403
|
|
- if (last_extruder != extruder && axis_steps_per_mm[E_AXIS_N] != axis_steps_per_mm[E_AXIS + last_extruder]) {
|
1404
|
|
- position[E_AXIS] = LROUND(position[E_AXIS] * axis_steps_per_mm[E_AXIS_N] * steps_to_mm[E_AXIS + last_extruder]);
|
1405
|
|
- last_extruder = extruder;
|
1406
|
|
- }
|
1407
|
|
- #endif
|
1408
|
|
-
|
1409
|
|
- // The target position of the tool in absolute steps
|
1410
|
|
- // Calculate target position in absolute steps
|
1411
|
|
- const int32_t target[XYZE] = {
|
1412
|
|
- LROUND(a * axis_steps_per_mm[X_AXIS]),
|
1413
|
|
- LROUND(b * axis_steps_per_mm[Y_AXIS]),
|
1414
|
|
- LROUND(c * axis_steps_per_mm[Z_AXIS]),
|
1415
|
|
- LROUND(e * axis_steps_per_mm[E_AXIS_N])
|
1416
|
|
- };
|
1417
|
|
-
|
1418
|
|
- /* <-- add a slash to enable
|
1419
|
|
- SERIAL_ECHOPAIR(" _buffer_line FR:", fr_mm_s);
|
1420
|
|
- #if IS_KINEMATIC
|
1421
|
|
- SERIAL_ECHOPAIR(" A:", a);
|
1422
|
|
- SERIAL_ECHOPAIR(" (", target[A_AXIS]);
|
1423
|
|
- SERIAL_ECHOPAIR(" steps) B:", b);
|
1424
|
|
- #else
|
1425
|
|
- SERIAL_ECHOPAIR(" X:", a);
|
1426
|
|
- SERIAL_ECHOPAIR(" (", target[X_AXIS]);
|
1427
|
|
- SERIAL_ECHOPAIR(" steps) Y:", b);
|
1428
|
|
- #endif
|
1429
|
|
- SERIAL_ECHOPAIR(" (", target[Y_AXIS]);
|
1430
|
|
- #if ENABLED(DELTA)
|
1431
|
|
- SERIAL_ECHOPAIR(" steps) C:", c);
|
1432
|
|
- #else
|
1433
|
|
- SERIAL_ECHOPAIR(" steps) Z:", c);
|
1434
|
|
- #endif
|
1435
|
|
- SERIAL_ECHOPAIR(" (", target[Z_AXIS]);
|
1436
|
|
- SERIAL_ECHOPAIR(" steps) E:", e);
|
1437
|
|
- SERIAL_ECHOPAIR(" (", target[E_AXIS]);
|
1438
|
|
- SERIAL_ECHOLNPGM(" steps)");
|
1439
|
|
- //*/
|
1440
|
|
-
|
1441
|
|
- // DRYRUN ignores all temperature constraints and assures that the extruder is instantly satisfied
|
1442
|
|
- if (DEBUGGING(DRYRUN))
|
1443
|
|
- position[E_AXIS] = target[E_AXIS];
|
1444
|
|
-
|
1445
|
|
- // Always split the first move in two so it can chain
|
1446
|
|
- if (!blocks_queued()) {
|
1447
|
|
- DISABLE_STEPPER_DRIVER_INTERRUPT();
|
1448
|
|
- #define _BETWEEN(A) (position[A##_AXIS] + target[A##_AXIS]) >> 1
|
1449
|
|
- const int32_t between[XYZE] = { _BETWEEN(X), _BETWEEN(Y), _BETWEEN(Z), _BETWEEN(E) };
|
1450
|
|
- _buffer_steps(between, fr_mm_s, extruder);
|
1451
|
|
- _buffer_steps(target, fr_mm_s, extruder);
|
1452
|
|
- ENABLE_STEPPER_DRIVER_INTERRUPT();
|
1453
|
|
- }
|
1454
|
|
- else
|
1455
|
|
- _buffer_steps(target, fr_mm_s, extruder);
|
1456
|
|
-
|
1457
|
1421
|
stepper.wake_up();
|
1458
|
1422
|
|
1459
|
|
-} // _buffer_line()
|
|
1423
|
+} // buffer_line()
|
1460
|
1424
|
|
1461
|
1425
|
/**
|
1462
|
1426
|
* Directly set the planner XYZ position (and stepper positions)
|