Pārlūkot izejas kodu

Revert "Merge pull request #8608 from thinkyhead/bf1_planner_split_first"

This reverts commit 0eef0ff0de, reversing
changes made to d8582b7506.
Scott Lahteine 7 gadus atpakaļ
vecāks
revīzija
298a357a43
2 mainītis faili ar 67 papildinājumiem un 114 dzēšanām
  1. 62
    98
      Marlin/planner.cpp
  2. 5
    16
      Marlin/planner.h

+ 62
- 98
Marlin/planner.cpp Parādīt failu

@@ -688,35 +688,69 @@ void Planner::calculate_volumetric_multipliers() {
688 688
 #endif // PLANNER_LEVELING
689 689
 
690 690
 /**
691
- * Planner::_buffer_steps
691
+ * Planner::_buffer_line
692 692
  *
693
- * Add a new linear movement to the buffer (in terms of steps).
693
+ * Add a new linear movement to the buffer in axis units.
694 694
  *
695
- *  target    - target position in steps units
695
+ * Leveling and kinematics should be applied ahead of calling this.
696
+ *
697
+ *  a,b,c,e   - target positions in mm and/or degrees
696 698
  *  fr_mm_s   - (target) speed of the move
697 699
  *  extruder  - target extruder
698 700
  */
699
-void Planner::_buffer_steps(const int32_t target[XYZE], float fr_mm_s, const uint8_t extruder) {
701
+void Planner::_buffer_line(const float &a, const float &b, const float &c, const float &e, float fr_mm_s, const uint8_t extruder) {
702
+
703
+  // The target position of the tool in absolute steps
704
+  // Calculate target position in absolute steps
705
+  //this should be done after the wait, because otherwise a M92 code within the gcode disrupts this calculation somehow
706
+  const long target[XYZE] = {
707
+    LROUND(a * axis_steps_per_mm[X_AXIS]),
708
+    LROUND(b * axis_steps_per_mm[Y_AXIS]),
709
+    LROUND(c * axis_steps_per_mm[Z_AXIS]),
710
+    LROUND(e * axis_steps_per_mm[E_AXIS_N])
711
+  };
712
+
713
+  // When changing extruders recalculate steps corresponding to the E position
714
+  #if ENABLED(DISTINCT_E_FACTORS)
715
+    if (last_extruder != extruder && axis_steps_per_mm[E_AXIS_N] != axis_steps_per_mm[E_AXIS + last_extruder]) {
716
+      position[E_AXIS] = LROUND(position[E_AXIS] * axis_steps_per_mm[E_AXIS_N] * steps_to_mm[E_AXIS + last_extruder]);
717
+      last_extruder = extruder;
718
+    }
719
+  #endif
700 720
 
701 721
   const int32_t da = target[X_AXIS] - position[X_AXIS],
702 722
                 db = target[Y_AXIS] - position[Y_AXIS],
703 723
                 dc = target[Z_AXIS] - position[Z_AXIS];
704 724
 
705
-  int32_t de = target[E_AXIS] - position[E_AXIS];
706
-
707
-  /* <-- add a slash to enable
708
-    SERIAL_ECHOPAIR("  _buffer_steps FR:", fr_mm_s);
709
-    SERIAL_ECHOPAIR(" A:", target[A_AXIS]);
725
+  /*
726
+  SERIAL_ECHOPAIR("  Planner FR:", fr_mm_s);
727
+  SERIAL_CHAR(' ');
728
+  #if IS_KINEMATIC
729
+    SERIAL_ECHOPAIR("A:", a);
730
+    SERIAL_ECHOPAIR(" (", da);
731
+    SERIAL_ECHOPAIR(") B:", b);
732
+  #else
733
+    SERIAL_ECHOPAIR("X:", a);
710 734
     SERIAL_ECHOPAIR(" (", da);
711
-    SERIAL_ECHOPAIR(" steps) B:", target[B_AXIS]);
712
-    SERIAL_ECHOPAIR(" (", db);
713
-    SERIAL_ECHOLNPGM(" steps) C:", target[C_AXIS]);
714
-    SERIAL_ECHOPAIR(" (", dc);
715
-    SERIAL_ECHOLNPGM(" steps) E:", target[E_AXIS]);
716
-    SERIAL_ECHOPAIR(" (", de);
717
-    SERIAL_ECHOLNPGM(" steps)");
735
+    SERIAL_ECHOPAIR(") Y:", b);
736
+  #endif
737
+  SERIAL_ECHOPAIR(" (", db);
738
+  #if ENABLED(DELTA)
739
+    SERIAL_ECHOPAIR(") C:", c);
740
+  #else
741
+    SERIAL_ECHOPAIR(") Z:", c);
742
+  #endif
743
+  SERIAL_ECHOPAIR(" (", dc);
744
+  SERIAL_CHAR(')');
745
+  SERIAL_EOL();
718 746
   //*/
719 747
 
748
+  // DRYRUN ignores all temperature constraints and assures that the extruder is instantly satisfied
749
+  if (DEBUGGING(DRYRUN))
750
+    position[E_AXIS] = target[E_AXIS];
751
+
752
+  int32_t de = target[E_AXIS] - position[E_AXIS];
753
+
720 754
   #if ENABLED(PREVENT_COLD_EXTRUSION) || ENABLED(PREVENT_LENGTHY_EXTRUDE)
721 755
     if (de) {
722 756
       #if ENABLED(PREVENT_COLD_EXTRUSION)
@@ -1023,7 +1057,6 @@ void Planner::_buffer_steps(const int32_t target[XYZE], float fr_mm_s, const uin
1023 1057
     // Segment time im micro seconds
1024 1058
     uint32_t segment_time_us = LROUND(1000000.0 / inverse_secs);
1025 1059
   #endif
1026
-
1027 1060
   #if ENABLED(SLOWDOWN)
1028 1061
     if (WITHIN(moves_queued, 2, (BLOCK_BUFFER_SIZE) / 2 - 1)) {
1029 1062
       if (segment_time_us < min_segment_time_us) {
@@ -1217,12 +1250,12 @@ void Planner::_buffer_steps(const int32_t target[XYZE], float fr_mm_s, const uin
1217 1250
     vmax_junction = MINIMUM_PLANNER_SPEED; // Set default max junction speed
1218 1251
 
1219 1252
     // Skip first block or when previous_nominal_speed is used as a flag for homing and offset cycles.
1220
-    if (block_buffer_head != block_buffer_tail && previous_nominal_speed > 0.0) {
1253
+    if (moves_queued() && !UNEAR_ZERO(previous_nominal_speed)) {
1221 1254
       // Compute cosine of angle between previous and current path. (prev_unit_vec is negative)
1222 1255
       // NOTE: Max junction velocity is computed without sin() or acos() by trig half angle identity.
1223
-      float cos_theta = - previous_unit_vec[X_AXIS] * unit_vec[X_AXIS]
1224
-                        - previous_unit_vec[Y_AXIS] * unit_vec[Y_AXIS]
1225
-                        - previous_unit_vec[Z_AXIS] * unit_vec[Z_AXIS] ;
1256
+      const float cos_theta = - previous_unit_vec[X_AXIS] * unit_vec[X_AXIS]
1257
+                              - previous_unit_vec[Y_AXIS] * unit_vec[Y_AXIS]
1258
+                              - previous_unit_vec[Z_AXIS] * unit_vec[Z_AXIS];
1226 1259
       // Skip and use default max junction speed for 0 degree acute junction.
1227 1260
       if (cos_theta < 0.95) {
1228 1261
         vmax_junction = min(previous_nominal_speed, block->nominal_speed);
@@ -1262,24 +1295,25 @@ void Planner::_buffer_steps(const int32_t target[XYZE], float fr_mm_s, const uin
1262 1295
     }
1263 1296
   }
1264 1297
 
1265
-  if (moves_queued && !UNEAR_ZERO(previous_nominal_speed)) {
1298
+  if (moves_queued > 1 && !UNEAR_ZERO(previous_nominal_speed)) {
1266 1299
     // Estimate a maximum velocity allowed at a joint of two successive segments.
1267 1300
     // If this maximum velocity allowed is lower than the minimum of the entry / exit safe velocities,
1268 1301
     // then the machine is not coasting anymore and the safe entry / exit velocities shall be used.
1269 1302
 
1270 1303
     // The junction velocity will be shared between successive segments. Limit the junction velocity to their minimum.
1271
-    const bool prev_speed_larger = previous_nominal_speed > block->nominal_speed;
1272
-    const float smaller_speed_factor = prev_speed_larger ? (block->nominal_speed / previous_nominal_speed) : (previous_nominal_speed / block->nominal_speed);
1273 1304
     // Pick the smaller of the nominal speeds. Higher speed shall not be achieved at the junction during coasting.
1274
-    vmax_junction = prev_speed_larger ? block->nominal_speed : previous_nominal_speed;
1305
+    vmax_junction = min(block->nominal_speed, previous_nominal_speed);
1306
+
1275 1307
     // Factor to multiply the previous / current nominal velocities to get componentwise limited velocities.
1276 1308
     float v_factor = 1;
1277 1309
     limited = 0;
1310
+
1278 1311
     // Now limit the jerk in all axes.
1312
+    const float smaller_speed_factor = vmax_junction / previous_nominal_speed;
1279 1313
     LOOP_XYZE(axis) {
1280 1314
       // Limit an axis. We have to differentiate: coasting, reversal of an axis, full stop.
1281
-      float v_exit = previous_speed[axis], v_entry = current_speed[axis];
1282
-      if (prev_speed_larger) v_exit *= smaller_speed_factor;
1315
+      float v_exit = previous_speed[axis] * smaller_speed_factor,
1316
+            v_entry = current_speed[axis];
1283 1317
       if (limited) {
1284 1318
         v_exit *= v_factor;
1285 1319
         v_entry *= v_factor;
@@ -1374,79 +1408,9 @@ void Planner::_buffer_steps(const int32_t target[XYZE], float fr_mm_s, const uin
1374 1408
 
1375 1409
   recalculate();
1376 1410
 
1377
-} // _buffer_steps()
1378
-
1379
-/**
1380
- * Planner::_buffer_line
1381
- *
1382
- * Add a new linear movement to the buffer in axis units.
1383
- *
1384
- * Leveling and kinematics should be applied ahead of calling this.
1385
- *
1386
- *  a,b,c,e   - target positions in mm and/or degrees
1387
- *  fr_mm_s   - (target) speed of the move
1388
- *  extruder  - target extruder
1389
- */
1390
-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) {
1391
-  // When changing extruders recalculate steps corresponding to the E position
1392
-  #if ENABLED(DISTINCT_E_FACTORS)
1393
-    if (last_extruder != extruder && axis_steps_per_mm[E_AXIS_N] != axis_steps_per_mm[E_AXIS + last_extruder]) {
1394
-      position[E_AXIS] = LROUND(position[E_AXIS] * axis_steps_per_mm[E_AXIS_N] * steps_to_mm[E_AXIS + last_extruder]);
1395
-      last_extruder = extruder;
1396
-    }
1397
-  #endif
1398
-
1399
-  // The target position of the tool in absolute steps
1400
-  // Calculate target position in absolute steps
1401
-  const int32_t target[XYZE] = {
1402
-    LROUND(a * axis_steps_per_mm[X_AXIS]),
1403
-    LROUND(b * axis_steps_per_mm[Y_AXIS]),
1404
-    LROUND(c * axis_steps_per_mm[Z_AXIS]),
1405
-    LROUND(e * axis_steps_per_mm[E_AXIS_N])
1406
-  };
1407
-
1408
-  /* <-- add a slash to enable
1409
-    SERIAL_ECHOPAIR("  _buffer_line FR:", fr_mm_s);
1410
-    #if IS_KINEMATIC
1411
-      SERIAL_ECHOPAIR(" A:", a);
1412
-      SERIAL_ECHOPAIR(" (", target[A_AXIS]);
1413
-      SERIAL_ECHOPAIR(" steps) B:", b);
1414
-    #else
1415
-      SERIAL_ECHOPAIR(" X:", a);
1416
-      SERIAL_ECHOPAIR(" (", target[X_AXIS]);
1417
-      SERIAL_ECHOPAIR(" steps) Y:", b);
1418
-    #endif
1419
-    SERIAL_ECHOPAIR(" (", target[Y_AXIS]);
1420
-    #if ENABLED(DELTA)
1421
-      SERIAL_ECHOPAIR(" steps) C:", c);
1422
-    #else
1423
-      SERIAL_ECHOPAIR(" steps) Z:", c);
1424
-    #endif
1425
-    SERIAL_ECHOPAIR(" (", target[Z_AXIS]);
1426
-    SERIAL_ECHOPAIR(" steps) E:", e);
1427
-    SERIAL_ECHOPAIR(" (", target[E_AXIS]);
1428
-    SERIAL_ECHOLNPGM(" steps)");
1429
-  //*/
1430
-
1431
-  // DRYRUN ignores all temperature constraints and assures that the extruder is instantly satisfied
1432
-  if (DEBUGGING(DRYRUN))
1433
-    position[E_AXIS] = target[E_AXIS];
1434
-
1435
-  // Always split the first move in two so it can chain
1436
-  if (!blocks_queued()) {
1437
-    DISABLE_STEPPER_DRIVER_INTERRUPT();
1438
-    #define _BETWEEN(A) (position[A##_AXIS] + target[A##_AXIS]) >> 1
1439
-    const int32_t between[XYZE] = { _BETWEEN(X), _BETWEEN(Y), _BETWEEN(Z), _BETWEEN(E) };
1440
-    _buffer_steps(between, fr_mm_s, extruder);
1441
-    _buffer_steps(target, fr_mm_s, extruder);
1442
-    ENABLE_STEPPER_DRIVER_INTERRUPT();
1443
-  }
1444
-  else
1445
-    _buffer_steps(target, fr_mm_s, extruder);
1446
-
1447 1411
   stepper.wake_up();
1448 1412
 
1449
-} // _buffer_line()
1413
+} // buffer_line()
1450 1414
 
1451 1415
 /**
1452 1416
  * Directly set the planner XYZ position (and stepper positions)

+ 5
- 16
Marlin/planner.h Parādīt failu

@@ -349,28 +349,17 @@ class Planner {
349 349
     #endif
350 350
 
351 351
     /**
352
-     * Planner::_buffer_steps
353
-     *
354
-     * Add a new linear movement to the buffer (in terms of steps).
355
-     *
356
-     *  target    - target position in steps units
357
-     *  fr_mm_s   - (target) speed of the move
358
-     *  extruder  - target extruder
359
-     */
360
-    static void _buffer_steps(const int32_t target[XYZE], float fr_mm_s, const uint8_t extruder);
361
-
362
-    /**
363 352
      * Planner::_buffer_line
364 353
      *
365
-     * Add a new linear movement to the buffer in axis units.
354
+     * Add a new direct linear movement to the buffer.
366 355
      *
367
-     * Leveling and kinematics should be applied ahead of calling this.
356
+     * Leveling and kinematics should be applied ahead of this.
368 357
      *
369
-     *  a,b,c,e   - target positions in mm and/or degrees
370
-     *  fr_mm_s   - (target) speed of the move
358
+     *  a,b,c,e   - target position in mm or degrees
359
+     *  fr_mm_s   - (target) speed of the move (mm/s)
371 360
      *  extruder  - target extruder
372 361
      */
373
-    static void _buffer_line(const float &a, const float &b, const float &c, const float &e, const float &fr_mm_s, const uint8_t extruder);
362
+    static void _buffer_line(const float &a, const float &b, const float &c, const float &e, float fr_mm_s, const uint8_t extruder);
374 363
 
375 364
     static void _set_position_mm(const float &a, const float &b, const float &c, const float &e);
376 365
 

Notiek ielāde…
Atcelt
Saglabāt