Browse Source

Merge pull request #8342 from thinkyhead/bf1_fixes_for_117

[1.1] Fix PROBE_MANUALLY on kinematic bots
Scott Lahteine 7 years ago
parent
commit
d60619f8e5
No account linked to committer's email address
3 changed files with 34 additions and 46 deletions
  1. 26
    38
      Marlin/Marlin_main.cpp
  2. 1
    1
      Marlin/SanityCheck.h
  3. 7
    7
      Marlin/planner.h

+ 26
- 38
Marlin/Marlin_main.cpp View File

@@ -376,16 +376,16 @@ uint8_t marlin_debug_flags = DEBUG_NONE;
376 376
 /**
377 377
  * Cartesian Current Position
378 378
  *   Used to track the native machine position as moves are queued.
379
- *   Used by 'line_to_current_position' to do a move after changing it.
379
+ *   Used by 'buffer_line_to_current_position' to do a move after changing it.
380 380
  *   Used by 'SYNC_PLAN_POSITION_KINEMATIC' to update 'planner.position'.
381 381
  */
382 382
 float current_position[XYZE] = { 0.0 };
383 383
 
384 384
 /**
385 385
  * Cartesian Destination
386
- *   A temporary position, usually applied to 'current_position'.
386
+ *   The destination for a move, filled in by G-code movement commands,
387
+ *   and expected by functions like 'prepare_move_to_destination'.
387 388
  *   Set with 'gcode_get_destination' or 'set_destination_from_current'.
388
- *   'line_to_destination' sets 'current_position' to 'destination'.
389 389
  */
390 390
 float destination[XYZE] = { 0.0 };
391 391
 
@@ -1633,7 +1633,7 @@ inline float get_homing_bump_feedrate(const AxisEnum axis) {
1633 1633
  * Move the planner to the current position from wherever it last moved
1634 1634
  * (or from wherever it has been told it is located).
1635 1635
  */
1636
-inline void line_to_current_position() {
1636
+inline void buffer_line_to_current_position() {
1637 1637
   planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate_mm_s, active_extruder);
1638 1638
 }
1639 1639
 
@@ -1641,10 +1641,9 @@ inline void line_to_current_position() {
1641 1641
  * Move the planner to the position stored in the destination array, which is
1642 1642
  * used by G0/G1/G2/G3/G5 and many other functions to set a destination.
1643 1643
  */
1644
-inline void line_to_destination(const float fr_mm_s) {
1644
+inline void buffer_line_to_destination(const float fr_mm_s) {
1645 1645
   planner.buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], fr_mm_s, active_extruder);
1646 1646
 }
1647
-inline void line_to_destination() { line_to_destination(feedrate_mm_s); }
1648 1647
 
1649 1648
 inline void set_current_from_destination() { COPY(current_position, destination); }
1650 1649
 inline void set_destination_from_current() { COPY(destination, current_position); }
@@ -1772,19 +1771,19 @@ void do_blocking_move_to(const float &rx, const float &ry, const float &rz, cons
1772 1771
     if (current_position[Z_AXIS] < rz) {
1773 1772
       feedrate_mm_s = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS);
1774 1773
       current_position[Z_AXIS] = rz;
1775
-      line_to_current_position();
1774
+      buffer_line_to_current_position();
1776 1775
     }
1777 1776
 
1778 1777
     feedrate_mm_s = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
1779 1778
     current_position[X_AXIS] = rx;
1780 1779
     current_position[Y_AXIS] = ry;
1781
-    line_to_current_position();
1780
+    buffer_line_to_current_position();
1782 1781
 
1783 1782
     // If Z needs to lower, do it after moving XY
1784 1783
     if (current_position[Z_AXIS] > rz) {
1785 1784
       feedrate_mm_s = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS);
1786 1785
       current_position[Z_AXIS] = rz;
1787
-      line_to_current_position();
1786
+      buffer_line_to_current_position();
1788 1787
     }
1789 1788
 
1790 1789
   #endif
@@ -3933,7 +3932,7 @@ inline void gcode_G4() {
3933 3932
     // Move all carriages together linearly until an endstop is hit.
3934 3933
     current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = (DELTA_HEIGHT + home_offset[Z_AXIS] + 10);
3935 3934
     feedrate_mm_s = homing_feedrate(X_AXIS);
3936
-    line_to_current_position();
3935
+    buffer_line_to_current_position();
3937 3936
     stepper.synchronize();
3938 3937
 
3939 3938
     // If an endstop was not hit, then damage can occur if homing is continued.
@@ -4264,27 +4263,20 @@ void home_all_axes() { gcode_G28(true); }
4264 4263
   #endif
4265 4264
 
4266 4265
   inline void _manual_goto_xy(const float &rx, const float &ry) {
4267
-    const float old_feedrate_mm_s = feedrate_mm_s;
4266
+
4268 4267
     #if MANUAL_PROBE_HEIGHT > 0
4269 4268
       const float prev_z = current_position[Z_AXIS];
4270
-      feedrate_mm_s = homing_feedrate(Z_AXIS);
4271
-      current_position[Z_AXIS] = MANUAL_PROBE_HEIGHT;
4272
-      line_to_current_position();
4269
+      do_blocking_move_to_z(MANUAL_PROBE_HEIGHT, homing_feedrate(Z_AXIS));
4273 4270
     #endif
4274 4271
 
4275
-    feedrate_mm_s = MMM_TO_MMS(XY_PROBE_SPEED);
4276
-    current_position[X_AXIS] = rx;
4277
-    current_position[Y_AXIS] = ry;
4278
-    line_to_current_position();
4272
+    do_blocking_move_to_xy(rx, ry, MMM_TO_MMS(XY_PROBE_SPEED));
4279 4273
 
4280 4274
     #if MANUAL_PROBE_HEIGHT > 0
4281
-      feedrate_mm_s = homing_feedrate(Z_AXIS);
4282
-      current_position[Z_AXIS] = prev_z; // move back to the previous Z.
4283
-      line_to_current_position();
4275
+      do_blocking_move_to_z(prev_z, homing_feedrate(Z_AXIS));
4284 4276
     #endif
4285 4277
 
4286
-    feedrate_mm_s = old_feedrate_mm_s;
4287
-    stepper.synchronize();
4278
+    current_position[X_AXIS] = rx;
4279
+    current_position[Y_AXIS] = ry;
4288 4280
 
4289 4281
     #if ENABLED(PROBE_MANUALLY) && ENABLED(LCD_BED_LEVELING)
4290 4282
       lcd_wait_for_move = false;
@@ -4314,7 +4306,7 @@ void home_all_axes() { gcode_G28(true); }
4314 4306
     #if ENABLED(MESH_G28_REST_ORIGIN)
4315 4307
       current_position[Z_AXIS] = Z_MIN_POS;
4316 4308
       set_destination_from_current();
4317
-      line_to_destination(homing_feedrate(Z_AXIS));
4309
+      buffer_line_to_destination(homing_feedrate(Z_AXIS));
4318 4310
       stepper.synchronize();
4319 4311
     #endif
4320 4312
   }
@@ -4406,7 +4398,7 @@ void home_all_axes() { gcode_G28(true); }
4406 4398
         else {
4407 4399
           // One last "return to the bed" (as originally coded) at completion
4408 4400
           current_position[Z_AXIS] = Z_MIN_POS + MANUAL_PROBE_HEIGHT;
4409
-          line_to_current_position();
4401
+          buffer_line_to_current_position();
4410 4402
           stepper.synchronize();
4411 4403
 
4412 4404
           // After recording the last point, activate home and activate
@@ -6563,17 +6555,13 @@ inline void gcode_M17() {
6563 6555
   #if IS_KINEMATIC
6564 6556
     #define RUNPLAN(RATE_MM_S) planner.buffer_line_kinematic(destination, RATE_MM_S, active_extruder)
6565 6557
   #else
6566
-    #define RUNPLAN(RATE_MM_S) line_to_destination(RATE_MM_S)
6558
+    #define RUNPLAN(RATE_MM_S) buffer_line_to_destination(RATE_MM_S)
6567 6559
   #endif
6568 6560
 
6569 6561
   void do_pause_e_move(const float &length, const float fr) {
6570 6562
     current_position[E_AXIS] += length;
6571 6563
     set_destination_from_current();
6572
-    #if IS_KINEMATIC
6573
-      planner.buffer_line_kinematic(destination, fr, active_extruder);
6574
-    #else
6575
-      line_to_destination(fr);
6576
-    #endif
6564
+    RUNPLAN(fr);
6577 6565
     stepper.synchronize();
6578 6566
   }
6579 6567
 
@@ -12596,7 +12584,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
12596 12584
    * Prepare a mesh-leveled linear move in a Cartesian setup,
12597 12585
    * splitting the move where it crosses mesh borders.
12598 12586
    */
12599
-  void mesh_line_to_destination(float fr_mm_s, uint8_t x_splits = 0xFF, uint8_t y_splits = 0xFF) {
12587
+  void mesh_line_to_destination(const float fr_mm_s, uint8_t x_splits = 0xFF, uint8_t y_splits = 0xFF) {
12600 12588
     int cx1 = mbl.cell_index_x(current_position[X_AXIS]),
12601 12589
         cy1 = mbl.cell_index_y(current_position[Y_AXIS]),
12602 12590
         cx2 = mbl.cell_index_x(destination[X_AXIS]),
@@ -12608,7 +12596,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
12608 12596
 
12609 12597
     if (cx1 == cx2 && cy1 == cy2) {
12610 12598
       // Start and end on same mesh square
12611
-      line_to_destination(fr_mm_s);
12599
+      buffer_line_to_destination(fr_mm_s);
12612 12600
       set_current_from_destination();
12613 12601
       return;
12614 12602
     }
@@ -12635,7 +12623,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
12635 12623
     }
12636 12624
     else {
12637 12625
       // Already split on a border
12638
-      line_to_destination(fr_mm_s);
12626
+      buffer_line_to_destination(fr_mm_s);
12639 12627
       set_current_from_destination();
12640 12628
       return;
12641 12629
     }
@@ -12659,7 +12647,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
12659 12647
    * Prepare a bilinear-leveled linear move on Cartesian,
12660 12648
    * splitting the move where it crosses grid borders.
12661 12649
    */
12662
-  void bilinear_line_to_destination(float fr_mm_s, uint16_t x_splits = 0xFFFF, uint16_t y_splits = 0xFFFF) {
12650
+  void bilinear_line_to_destination(const float fr_mm_s, uint16_t x_splits = 0xFFFF, uint16_t y_splits = 0xFFFF) {
12663 12651
     int cx1 = CELL_INDEX(X, current_position[X_AXIS]),
12664 12652
         cy1 = CELL_INDEX(Y, current_position[Y_AXIS]),
12665 12653
         cx2 = CELL_INDEX(X, destination[X_AXIS]),
@@ -12671,7 +12659,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
12671 12659
 
12672 12660
     if (cx1 == cx2 && cy1 == cy2) {
12673 12661
       // Start and end on same mesh square
12674
-      line_to_destination(fr_mm_s);
12662
+      buffer_line_to_destination(fr_mm_s);
12675 12663
       set_current_from_destination();
12676 12664
       return;
12677 12665
     }
@@ -12698,7 +12686,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
12698 12686
     }
12699 12687
     else {
12700 12688
       // Already split on a border
12701
-      line_to_destination(fr_mm_s);
12689
+      buffer_line_to_destination(fr_mm_s);
12702 12690
       set_current_from_destination();
12703 12691
       return;
12704 12692
     }
@@ -12878,7 +12866,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
12878 12866
       }
12879 12867
     #endif // HAS_MESH
12880 12868
 
12881
-    line_to_destination(MMS_SCALED(feedrate_mm_s));
12869
+    buffer_line_to_destination(MMS_SCALED(feedrate_mm_s));
12882 12870
     return false;
12883 12871
   }
12884 12872
 

+ 1
- 1
Marlin/SanityCheck.h View File

@@ -797,7 +797,7 @@ static_assert(1 >= 0
797 797
    */
798 798
 
799 799
   #if ENABLED(DELTA)
800
-    #error "MESH_BED_LEVELING does not yet support DELTA printers."
800
+    #error "MESH_BED_LEVELING is not compatible with DELTA printers."
801 801
   #elif GRID_MAX_POINTS_X > 9 || GRID_MAX_POINTS_Y > 9
802 802
     #error "GRID_MAX_POINTS_X and GRID_MAX_POINTS_Y must be less than 10 for MBL."
803 803
   #endif

+ 7
- 7
Marlin/planner.h View File

@@ -356,18 +356,18 @@ class Planner {
356 356
      *  fr_mm_s  - (target) speed of the move (mm/s)
357 357
      *  extruder - target extruder
358 358
      */
359
-    static FORCE_INLINE void buffer_line_kinematic(const float rtarget[XYZE], const float &fr_mm_s, const uint8_t extruder) {
359
+    static FORCE_INLINE void buffer_line_kinematic(const float cart[XYZE], const float &fr_mm_s, const uint8_t extruder) {
360 360
       #if PLANNER_LEVELING
361
-        float lpos[XYZ] = { rtarget[X_AXIS], rtarget[Y_AXIS], rtarget[Z_AXIS] };
362
-        apply_leveling(lpos);
361
+        float raw[XYZ] = { cart[X_AXIS], cart[Y_AXIS], cart[Z_AXIS] };
362
+        apply_leveling(raw);
363 363
       #else
364
-        const float * const lpos = rtarget;
364
+        const float * const raw = cart;
365 365
       #endif
366 366
       #if IS_KINEMATIC
367
-        inverse_kinematics(lpos);
368
-        _buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], rtarget[E_AXIS], fr_mm_s, extruder);
367
+        inverse_kinematics(raw);
368
+        _buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], cart[E_AXIS], fr_mm_s, extruder);
369 369
       #else
370
-        _buffer_line(lpos[X_AXIS], lpos[Y_AXIS], lpos[Z_AXIS], rtarget[E_AXIS], fr_mm_s, extruder);
370
+        _buffer_line(raw[X_AXIS], raw[Y_AXIS], raw[Z_AXIS], cart[E_AXIS], fr_mm_s, extruder);
371 371
       #endif
372 372
     }
373 373
 

Loading…
Cancel
Save