Bladeren bron

Merge pull request #2063 from chris-bo/autobed_sled

improve sled handling
Scott Lahteine 10 jaren geleden
bovenliggende
commit
bd20bd5444
6 gewijzigde bestanden met toevoegingen van 82 en 36 verwijderingen
  1. 7
    0
      Marlin/Conditionals.h
  2. 58
    36
      Marlin/Marlin_main.cpp
  3. 5
    0
      Marlin/pins_MEGATRONICS_3.h
  4. 4
    0
      Marlin/pins_RAMBO.h
  5. 4
    0
      Marlin/pins_RAMPS_13.h
  6. 4
    0
      Marlin/pins_SANGUINOLOLU_11.h

+ 7
- 0
Marlin/Conditionals.h Bestand weergeven

@@ -276,6 +276,13 @@
276 276
     #define MAX_PROBE_Y (min(Y_MAX_POS, Y_MAX_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
277 277
   #endif
278 278
 
279
+   /**
280
+    * Sled Options
281
+    */ 
282
+  #ifdef Z_PROBE_SLED
283
+    #define Z_SAFE_HOMING
284
+  #endif
285
+  
279 286
   /**
280 287
    * MAX_STEP_FREQUENCY differs for TOSHIBA
281 288
    */

+ 58
- 36
Marlin/Marlin_main.cpp Bestand weergeven

@@ -650,8 +650,8 @@ void setup() {
650 650
   #endif
651 651
 
652 652
   #ifdef Z_PROBE_SLED
653
-    pinMode(SERVO0_PIN, OUTPUT);
654
-    digitalWrite(SERVO0_PIN, LOW); // turn it off
653
+    pinMode(SLED_PIN, OUTPUT);
654
+    digitalWrite(SLED_PIN, LOW); // turn it off
655 655
   #endif // Z_PROBE_SLED
656 656
 
657 657
   setup_homepin();
@@ -1516,6 +1516,47 @@ static void setup_for_endstop_move() {
1516 1516
 
1517 1517
 #endif // ENABLE_AUTO_BED_LEVELING
1518 1518
 
1519
+
1520
+#ifdef Z_PROBE_SLED
1521
+
1522
+  #ifndef SLED_DOCKING_OFFSET
1523
+    #define SLED_DOCKING_OFFSET 0
1524
+  #endif
1525
+
1526
+  /**
1527
+   * Method to dock/undock a sled designed by Charles Bell.
1528
+   *
1529
+   * dock[in]     If true, move to MAX_X and engage the electromagnet
1530
+   * offset[in]   The additional distance to move to adjust docking location
1531
+   */
1532
+  static void dock_sled(bool dock, int offset=0) {
1533
+    if (!axis_known_position[X_AXIS] || !axis_known_position[Y_AXIS]) {
1534
+      LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN);
1535
+      SERIAL_ECHO_START;
1536
+      SERIAL_ECHOLNPGM(MSG_POSITION_UNKNOWN);
1537
+      return;
1538
+    }
1539
+
1540
+    if (dock) {
1541
+      float oldXpos = current_position[X_AXIS]; // save x position
1542
+      do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING); // rise Z   
1543
+      do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset - 1, current_position[Y_AXIS], current_position[Z_AXIS]);  // Dock sled a bit closer to ensure proper capturing                                                                                                                           
1544
+      digitalWrite(SLED_PIN, LOW); // turn off magnet
1545
+      do_blocking_move_to(oldXpos, current_position[Y_AXIS], current_position[Z_AXIS]); // return to position before docking
1546
+    } else {
1547
+      float oldXpos = current_position[X_AXIS]; // save x position
1548
+      float z_loc = current_position[Z_AXIS];
1549
+      if (z_loc < Z_RAISE_BEFORE_PROBING + 5) z_loc = Z_RAISE_BEFORE_PROBING;
1550
+      do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset, current_position[Y_AXIS], z_loc); // this also updates current_position
1551
+      digitalWrite(SLED_PIN, HIGH); // turn on magnet
1552
+      do_blocking_move_to(oldXpos, current_position[Y_AXIS], current_position[Z_AXIS]); // return to position before docking
1553
+    }
1554
+  }
1555
+
1556
+#endif // Z_PROBE_SLED
1557
+
1558
+
1559
+
1519 1560
 /**
1520 1561
  * Home an individual axis
1521 1562
  */
@@ -1538,6 +1579,13 @@ static void homeaxis(AxisEnum axis) {
1538 1579
     current_position[axis] = 0;
1539 1580
     sync_plan_position();
1540 1581
 
1582
+    #ifdef Z_PROBE_SLED
1583
+      // Get Probe
1584
+      if (axis == Z_AXIS) {
1585
+        if (axis_home_dir < 0) dock_sled(false);
1586
+      }
1587
+    #endif
1588
+    
1541 1589
     #if SERVO_LEVELING && !defined(Z_PROBE_SLED)
1542 1590
 
1543 1591
       // Deploy a probe if there is one, and homing towards the bed
@@ -1634,6 +1682,13 @@ static void homeaxis(AxisEnum axis) {
1634 1682
     endstops_hit_on_purpose(); // clear endstop hit flags
1635 1683
     axis_known_position[axis] = true;
1636 1684
 
1685
+    #ifdef Z_PROBE_SLED
1686
+    // bring probe back
1687
+      if (axis == Z_AXIS) {
1688
+        if (axis_home_dir < 0) dock_sled(true);
1689
+      } 
1690
+    #endif
1691
+
1637 1692
     #if SERVO_LEVELING && !defined(Z_PROBE_SLED)
1638 1693
 
1639 1694
       // Deploy a probe if there is one, and homing towards the bed
@@ -1708,39 +1763,6 @@ static void homeaxis(AxisEnum axis) {
1708 1763
 
1709 1764
 #endif // FWRETRACT
1710 1765
 
1711
-#ifdef Z_PROBE_SLED
1712
-
1713
-  #ifndef SLED_DOCKING_OFFSET
1714
-    #define SLED_DOCKING_OFFSET 0
1715
-  #endif
1716
-
1717
-  /**
1718
-   * Method to dock/undock a sled designed by Charles Bell.
1719
-   *
1720
-   * dock[in]     If true, move to MAX_X and engage the electromagnet
1721
-   * offset[in]   The additional distance to move to adjust docking location
1722
-   */
1723
-  static void dock_sled(bool dock, int offset=0) {
1724
-    if (!axis_known_position[X_AXIS] || !axis_known_position[Y_AXIS]) {
1725
-      LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN);
1726
-      SERIAL_ECHO_START;
1727
-      SERIAL_ECHOLNPGM(MSG_POSITION_UNKNOWN);
1728
-      return;
1729
-    }
1730
-
1731
-    if (dock) {
1732
-      do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset, current_position[Y_AXIS], current_position[Z_AXIS]); // this also updates current_position
1733
-      digitalWrite(SERVO0_PIN, LOW); // turn off magnet
1734
-    } else {
1735
-      float z_loc = current_position[Z_AXIS];
1736
-      if (z_loc < Z_RAISE_BEFORE_PROBING + 5) z_loc = Z_RAISE_BEFORE_PROBING;
1737
-      do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset, Y_PROBE_OFFSET_FROM_EXTRUDER, z_loc); // this also updates current_position
1738
-      digitalWrite(SERVO0_PIN, HIGH); // turn on magnet
1739
-    }
1740
-  }
1741
-
1742
-#endif // Z_PROBE_SLED
1743
-
1744 1766
 /**
1745 1767
  *
1746 1768
  * G-Code Handler functions
@@ -2584,7 +2606,7 @@ inline void gcode_G28() {
2584 2606
     #endif // !DELTA
2585 2607
 
2586 2608
     #ifdef Z_PROBE_SLED
2587
-      dock_sled(true, -SLED_DOCKING_OFFSET); // dock the probe, correcting for over-travel
2609
+      dock_sled(true); // dock the probe
2588 2610
     #elif defined(Z_PROBE_ALLEN_KEY) //|| defined(SERVO_LEVELING)
2589 2611
       stow_z_probe();
2590 2612
     #endif

+ 5
- 0
Marlin/pins_MEGATRONICS_3.h Bestand weergeven

@@ -8,6 +8,11 @@
8 8
 
9 9
 #define LARGE_FLASH        true
10 10
 
11
+
12
+#ifdef Z_PROBE_SLED
13
+  #define SLED_PIN         -1
14
+#endif
15
+
11 16
 // Servo support
12 17
 #ifdef NUM_SERVOS
13 18
   #define SERVO0_PIN       46 //AUX3-6

+ 4
- 0
Marlin/pins_RAMBO.h Bestand weergeven

@@ -22,6 +22,10 @@
22 22
   #endif
23 23
 #endif
24 24
 
25
+#ifdef Z_PROBE_SLED
26
+  #define SLED_PIN         -1
27
+#endif
28
+
25 29
 #undef X_MS1_PIN
26 30
 #undef X_MS2_PIN
27 31
 #undef Y_MS1_PIN

+ 4
- 0
Marlin/pins_RAMPS_13.h Bestand weergeven

@@ -134,6 +134,10 @@
134 134
   #endif
135 135
 #endif
136 136
 
137
+#ifdef Z_PROBE_SLED
138
+  #define SLED_PIN         -1
139
+#endif
140
+
137 141
 #ifdef ULTRA_LCD
138 142
 
139 143
   #ifdef NEWPANEL

+ 4
- 0
Marlin/pins_SANGUINOLOLU_11.h Bestand weergeven

@@ -44,6 +44,10 @@
44 44
   #define FAN_PIN            4
45 45
 #endif
46 46
 
47
+#ifdef Z_PROBE_SLED
48
+  #define SLED_PIN         -1
49
+#endif
50
+
47 51
 #ifdef NUM_SERVOS
48 52
   #define SERVO0_PIN          -1
49 53
 

Laden…
Annuleren
Opslaan