Browse Source

Merge pull request #2063 from chris-bo/autobed_sled

improve sled handling
Scott Lahteine 10 years ago
parent
commit
bd20bd5444

+ 7
- 0
Marlin/Conditionals.h View File

276
     #define MAX_PROBE_Y (min(Y_MAX_POS, Y_MAX_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
276
     #define MAX_PROBE_Y (min(Y_MAX_POS, Y_MAX_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
277
   #endif
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
    * MAX_STEP_FREQUENCY differs for TOSHIBA
287
    * MAX_STEP_FREQUENCY differs for TOSHIBA
281
    */
288
    */

+ 58
- 36
Marlin/Marlin_main.cpp View File

650
   #endif
650
   #endif
651
 
651
 
652
   #ifdef Z_PROBE_SLED
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
   #endif // Z_PROBE_SLED
655
   #endif // Z_PROBE_SLED
656
 
656
 
657
   setup_homepin();
657
   setup_homepin();
1516
 
1516
 
1517
 #endif // ENABLE_AUTO_BED_LEVELING
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
  * Home an individual axis
1561
  * Home an individual axis
1521
  */
1562
  */
1538
     current_position[axis] = 0;
1579
     current_position[axis] = 0;
1539
     sync_plan_position();
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
     #if SERVO_LEVELING && !defined(Z_PROBE_SLED)
1589
     #if SERVO_LEVELING && !defined(Z_PROBE_SLED)
1542
 
1590
 
1543
       // Deploy a probe if there is one, and homing towards the bed
1591
       // Deploy a probe if there is one, and homing towards the bed
1634
     endstops_hit_on_purpose(); // clear endstop hit flags
1682
     endstops_hit_on_purpose(); // clear endstop hit flags
1635
     axis_known_position[axis] = true;
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
     #if SERVO_LEVELING && !defined(Z_PROBE_SLED)
1692
     #if SERVO_LEVELING && !defined(Z_PROBE_SLED)
1638
 
1693
 
1639
       // Deploy a probe if there is one, and homing towards the bed
1694
       // Deploy a probe if there is one, and homing towards the bed
1708
 
1763
 
1709
 #endif // FWRETRACT
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
  * G-Code Handler functions
1768
  * G-Code Handler functions
2584
     #endif // !DELTA
2606
     #endif // !DELTA
2585
 
2607
 
2586
     #ifdef Z_PROBE_SLED
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
     #elif defined(Z_PROBE_ALLEN_KEY) //|| defined(SERVO_LEVELING)
2610
     #elif defined(Z_PROBE_ALLEN_KEY) //|| defined(SERVO_LEVELING)
2589
       stow_z_probe();
2611
       stow_z_probe();
2590
     #endif
2612
     #endif

+ 5
- 0
Marlin/pins_MEGATRONICS_3.h View File

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

+ 4
- 0
Marlin/pins_RAMBO.h View File

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

+ 4
- 0
Marlin/pins_RAMPS_13.h View File

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

+ 4
- 0
Marlin/pins_SANGUINOLOLU_11.h View File

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

Loading…
Cancel
Save