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
 /**
376
 /**
377
  * Cartesian Current Position
377
  * Cartesian Current Position
378
  *   Used to track the native machine position as moves are queued.
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
  *   Used by 'SYNC_PLAN_POSITION_KINEMATIC' to update 'planner.position'.
380
  *   Used by 'SYNC_PLAN_POSITION_KINEMATIC' to update 'planner.position'.
381
  */
381
  */
382
 float current_position[XYZE] = { 0.0 };
382
 float current_position[XYZE] = { 0.0 };
383
 
383
 
384
 /**
384
 /**
385
  * Cartesian Destination
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
  *   Set with 'gcode_get_destination' or 'set_destination_from_current'.
388
  *   Set with 'gcode_get_destination' or 'set_destination_from_current'.
388
- *   'line_to_destination' sets 'current_position' to 'destination'.
389
  */
389
  */
390
 float destination[XYZE] = { 0.0 };
390
 float destination[XYZE] = { 0.0 };
391
 
391
 
1633
  * Move the planner to the current position from wherever it last moved
1633
  * Move the planner to the current position from wherever it last moved
1634
  * (or from wherever it has been told it is located).
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
   planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate_mm_s, active_extruder);
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
  * Move the planner to the position stored in the destination array, which is
1641
  * Move the planner to the position stored in the destination array, which is
1642
  * used by G0/G1/G2/G3/G5 and many other functions to set a destination.
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
   planner.buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], fr_mm_s, active_extruder);
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
 inline void set_current_from_destination() { COPY(current_position, destination); }
1648
 inline void set_current_from_destination() { COPY(current_position, destination); }
1650
 inline void set_destination_from_current() { COPY(destination, current_position); }
1649
 inline void set_destination_from_current() { COPY(destination, current_position); }
1772
     if (current_position[Z_AXIS] < rz) {
1771
     if (current_position[Z_AXIS] < rz) {
1773
       feedrate_mm_s = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS);
1772
       feedrate_mm_s = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS);
1774
       current_position[Z_AXIS] = rz;
1773
       current_position[Z_AXIS] = rz;
1775
-      line_to_current_position();
1774
+      buffer_line_to_current_position();
1776
     }
1775
     }
1777
 
1776
 
1778
     feedrate_mm_s = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
1777
     feedrate_mm_s = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
1779
     current_position[X_AXIS] = rx;
1778
     current_position[X_AXIS] = rx;
1780
     current_position[Y_AXIS] = ry;
1779
     current_position[Y_AXIS] = ry;
1781
-    line_to_current_position();
1780
+    buffer_line_to_current_position();
1782
 
1781
 
1783
     // If Z needs to lower, do it after moving XY
1782
     // If Z needs to lower, do it after moving XY
1784
     if (current_position[Z_AXIS] > rz) {
1783
     if (current_position[Z_AXIS] > rz) {
1785
       feedrate_mm_s = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS);
1784
       feedrate_mm_s = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS);
1786
       current_position[Z_AXIS] = rz;
1785
       current_position[Z_AXIS] = rz;
1787
-      line_to_current_position();
1786
+      buffer_line_to_current_position();
1788
     }
1787
     }
1789
 
1788
 
1790
   #endif
1789
   #endif
3933
     // Move all carriages together linearly until an endstop is hit.
3932
     // Move all carriages together linearly until an endstop is hit.
3934
     current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = (DELTA_HEIGHT + home_offset[Z_AXIS] + 10);
3933
     current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = (DELTA_HEIGHT + home_offset[Z_AXIS] + 10);
3935
     feedrate_mm_s = homing_feedrate(X_AXIS);
3934
     feedrate_mm_s = homing_feedrate(X_AXIS);
3936
-    line_to_current_position();
3935
+    buffer_line_to_current_position();
3937
     stepper.synchronize();
3936
     stepper.synchronize();
3938
 
3937
 
3939
     // If an endstop was not hit, then damage can occur if homing is continued.
3938
     // If an endstop was not hit, then damage can occur if homing is continued.
4264
   #endif
4263
   #endif
4265
 
4264
 
4266
   inline void _manual_goto_xy(const float &rx, const float &ry) {
4265
   inline void _manual_goto_xy(const float &rx, const float &ry) {
4267
-    const float old_feedrate_mm_s = feedrate_mm_s;
4266
+
4268
     #if MANUAL_PROBE_HEIGHT > 0
4267
     #if MANUAL_PROBE_HEIGHT > 0
4269
       const float prev_z = current_position[Z_AXIS];
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
     #endif
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
     #if MANUAL_PROBE_HEIGHT > 0
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
     #endif
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
     #if ENABLED(PROBE_MANUALLY) && ENABLED(LCD_BED_LEVELING)
4281
     #if ENABLED(PROBE_MANUALLY) && ENABLED(LCD_BED_LEVELING)
4290
       lcd_wait_for_move = false;
4282
       lcd_wait_for_move = false;
4314
     #if ENABLED(MESH_G28_REST_ORIGIN)
4306
     #if ENABLED(MESH_G28_REST_ORIGIN)
4315
       current_position[Z_AXIS] = Z_MIN_POS;
4307
       current_position[Z_AXIS] = Z_MIN_POS;
4316
       set_destination_from_current();
4308
       set_destination_from_current();
4317
-      line_to_destination(homing_feedrate(Z_AXIS));
4309
+      buffer_line_to_destination(homing_feedrate(Z_AXIS));
4318
       stepper.synchronize();
4310
       stepper.synchronize();
4319
     #endif
4311
     #endif
4320
   }
4312
   }
4406
         else {
4398
         else {
4407
           // One last "return to the bed" (as originally coded) at completion
4399
           // One last "return to the bed" (as originally coded) at completion
4408
           current_position[Z_AXIS] = Z_MIN_POS + MANUAL_PROBE_HEIGHT;
4400
           current_position[Z_AXIS] = Z_MIN_POS + MANUAL_PROBE_HEIGHT;
4409
-          line_to_current_position();
4401
+          buffer_line_to_current_position();
4410
           stepper.synchronize();
4402
           stepper.synchronize();
4411
 
4403
 
4412
           // After recording the last point, activate home and activate
4404
           // After recording the last point, activate home and activate
6563
   #if IS_KINEMATIC
6555
   #if IS_KINEMATIC
6564
     #define RUNPLAN(RATE_MM_S) planner.buffer_line_kinematic(destination, RATE_MM_S, active_extruder)
6556
     #define RUNPLAN(RATE_MM_S) planner.buffer_line_kinematic(destination, RATE_MM_S, active_extruder)
6565
   #else
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
   #endif
6559
   #endif
6568
 
6560
 
6569
   void do_pause_e_move(const float &length, const float fr) {
6561
   void do_pause_e_move(const float &length, const float fr) {
6570
     current_position[E_AXIS] += length;
6562
     current_position[E_AXIS] += length;
6571
     set_destination_from_current();
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
     stepper.synchronize();
6565
     stepper.synchronize();
6578
   }
6566
   }
6579
 
6567
 
12596
    * Prepare a mesh-leveled linear move in a Cartesian setup,
12584
    * Prepare a mesh-leveled linear move in a Cartesian setup,
12597
    * splitting the move where it crosses mesh borders.
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
     int cx1 = mbl.cell_index_x(current_position[X_AXIS]),
12588
     int cx1 = mbl.cell_index_x(current_position[X_AXIS]),
12601
         cy1 = mbl.cell_index_y(current_position[Y_AXIS]),
12589
         cy1 = mbl.cell_index_y(current_position[Y_AXIS]),
12602
         cx2 = mbl.cell_index_x(destination[X_AXIS]),
12590
         cx2 = mbl.cell_index_x(destination[X_AXIS]),
12608
 
12596
 
12609
     if (cx1 == cx2 && cy1 == cy2) {
12597
     if (cx1 == cx2 && cy1 == cy2) {
12610
       // Start and end on same mesh square
12598
       // Start and end on same mesh square
12611
-      line_to_destination(fr_mm_s);
12599
+      buffer_line_to_destination(fr_mm_s);
12612
       set_current_from_destination();
12600
       set_current_from_destination();
12613
       return;
12601
       return;
12614
     }
12602
     }
12635
     }
12623
     }
12636
     else {
12624
     else {
12637
       // Already split on a border
12625
       // Already split on a border
12638
-      line_to_destination(fr_mm_s);
12626
+      buffer_line_to_destination(fr_mm_s);
12639
       set_current_from_destination();
12627
       set_current_from_destination();
12640
       return;
12628
       return;
12641
     }
12629
     }
12659
    * Prepare a bilinear-leveled linear move on Cartesian,
12647
    * Prepare a bilinear-leveled linear move on Cartesian,
12660
    * splitting the move where it crosses grid borders.
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
     int cx1 = CELL_INDEX(X, current_position[X_AXIS]),
12651
     int cx1 = CELL_INDEX(X, current_position[X_AXIS]),
12664
         cy1 = CELL_INDEX(Y, current_position[Y_AXIS]),
12652
         cy1 = CELL_INDEX(Y, current_position[Y_AXIS]),
12665
         cx2 = CELL_INDEX(X, destination[X_AXIS]),
12653
         cx2 = CELL_INDEX(X, destination[X_AXIS]),
12671
 
12659
 
12672
     if (cx1 == cx2 && cy1 == cy2) {
12660
     if (cx1 == cx2 && cy1 == cy2) {
12673
       // Start and end on same mesh square
12661
       // Start and end on same mesh square
12674
-      line_to_destination(fr_mm_s);
12662
+      buffer_line_to_destination(fr_mm_s);
12675
       set_current_from_destination();
12663
       set_current_from_destination();
12676
       return;
12664
       return;
12677
     }
12665
     }
12698
     }
12686
     }
12699
     else {
12687
     else {
12700
       // Already split on a border
12688
       // Already split on a border
12701
-      line_to_destination(fr_mm_s);
12689
+      buffer_line_to_destination(fr_mm_s);
12702
       set_current_from_destination();
12690
       set_current_from_destination();
12703
       return;
12691
       return;
12704
     }
12692
     }
12878
       }
12866
       }
12879
     #endif // HAS_MESH
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
     return false;
12870
     return false;
12883
   }
12871
   }
12884
 
12872
 

+ 1
- 1
Marlin/SanityCheck.h View File

797
    */
797
    */
798
 
798
 
799
   #if ENABLED(DELTA)
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
   #elif GRID_MAX_POINTS_X > 9 || GRID_MAX_POINTS_Y > 9
801
   #elif GRID_MAX_POINTS_X > 9 || GRID_MAX_POINTS_Y > 9
802
     #error "GRID_MAX_POINTS_X and GRID_MAX_POINTS_Y must be less than 10 for MBL."
802
     #error "GRID_MAX_POINTS_X and GRID_MAX_POINTS_Y must be less than 10 for MBL."
803
   #endif
803
   #endif

+ 7
- 7
Marlin/planner.h View File

356
      *  fr_mm_s  - (target) speed of the move (mm/s)
356
      *  fr_mm_s  - (target) speed of the move (mm/s)
357
      *  extruder - target extruder
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
       #if PLANNER_LEVELING
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
       #else
363
       #else
364
-        const float * const lpos = rtarget;
364
+        const float * const raw = cart;
365
       #endif
365
       #endif
366
       #if IS_KINEMATIC
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
       #else
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
       #endif
371
       #endif
372
     }
372
     }
373
 
373
 

Loading…
Cancel
Save