Sfoglia il codice sorgente

Implements a nozzle cleaning pattern generator (G12)

João Brázio 8 anni fa
parent
commit
b05a75655a
6 ha cambiato i file con 228 aggiunte e 15 eliminazioni
  1. 6
    0
      .travis.yml
  2. 38
    0
      Marlin/Configuration.h
  3. 32
    15
      Marlin/Marlin_main.cpp
  4. 7
    0
      Marlin/SanityCheck.h
  5. 112
    0
      Marlin/clean_nozzle.h
  6. 33
    0
      Marlin/point_t.h

+ 6
- 0
.travis.yml Vedi File

@@ -211,6 +211,12 @@ script:
211 211
   - opt_enable PRINTCOUNTER
212 212
   - build_marlin
213 213
   #
214
+  # Test CLEAN_NOZZLE_FEATURE
215
+  #
216
+  - restore_configs
217
+  - opt_enable AUTO_BED_LEVELING_FEATURE CLEAN_NOZZLE_FEATURE FIX_MOUNTED_PROBE
218
+  - build_marlin
219
+  #
214 220
   #
215 221
   ######## STANDARD LCD/PANELS ##############
216 222
   #

+ 38
- 0
Marlin/Configuration.h Vedi File

@@ -788,6 +788,44 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
788 788
 #define PREHEAT_2_FAN_SPEED     0 // Value from 0 to 255
789 789
 
790 790
 //
791
+// Clean Nozzle Feature -- EXPERIMENTAL
792
+//
793
+// When enabled allows the user to send G12 to start the nozzle cleaning
794
+// process, the G-Code accepts two parameters:
795
+//   "P" for pattern selection
796
+//   "S" for defining the number of strokes/repetitions
797
+//
798
+// Available list of patterns:
799
+//   P0: This is the default pattern, this process requires a sponge type
800
+//       material at a fixed bed location, the cleaning process is based on
801
+//       "strokes" i.e. back-and-forth movements between the starting and end
802
+//       points.
803
+//
804
+//   P1: This starts a zig-zag pattern between (Xs, Ys) and (Xe, Ye), "S"
805
+//       defines the number of zig-zag triangles to be done. Each "side"
806
+//       cannot be less than 5mm. As an example "G12 P1 S3" will execute:
807
+//
808
+//                                                /|   /|   /| (Xe, Ye)
809
+//                                               / |  / |  / |
810
+//                                              /  | /  | /  |
811
+//                                    (Xs, Ys) /   |/   |/   |
812
+//
813
+//
814
+// Caveats: End point Z should use the same value as Start point Z.
815
+//
816
+// Attention: This is an EXPERIMENTAL feature, in the future the G-code arguments
817
+// may change to add new functionality like different wipe patterns.
818
+//
819
+//#define CLEAN_NOZZLE_FEATURE
820
+
821
+#if ENABLED(CLEAN_NOZZLE_FEATURE)
822
+  #define CLEAN_NOZZLE_STROKES  12
823
+  #define CLEAN_NOZZLE_START_PT { 30, 30, (Z_MIN_POS + 1), 0}
824
+  #define CLEAN_NOZZLE_END_PT   {100, 60, (Z_MIN_POS + 1), 0}
825
+  //                            {  X,  Y,               Z, E}
826
+#endif
827
+
828
+//
791 829
 // Print job timer
792 830
 //
793 831
 // Enable this option to automatically start and stop the

+ 32
- 15
Marlin/Marlin_main.cpp Vedi File

@@ -106,8 +106,9 @@
106 106
  * G3  - CCW ARC
107 107
  * G4  - Dwell S<seconds> or P<milliseconds>
108 108
  * G5  - Cubic B-spline with XYZE destination and IJPQ offsets
109
- * G10 - retract filament according to settings of M207
110
- * G11 - retract recover filament according to settings of M208
109
+ * G10 - Retract filament according to settings of M207
110
+ * G11 - Retract recover filament according to settings of M208
111
+ * G12 - Clean tool
111 112
  * G20 - Set input units to inches
112 113
  * G21 - Set input units to millimeters
113 114
  * G28 - Home one or more axes
@@ -1703,6 +1704,10 @@ static void clean_up_after_endstop_or_probe_move() {
1703 1704
     do_blocking_move_to(x, current_position[Y_AXIS], current_position[Z_AXIS], feed_rate);
1704 1705
   }
1705 1706
 
1707
+  inline void do_blocking_move_to_y(float y) {
1708
+    do_blocking_move_to(current_position[X_AXIS], y, current_position[Z_AXIS]);
1709
+  }
1710
+
1706 1711
   inline void do_blocking_move_to_z(float z, float feed_rate = 0.0) {
1707 1712
     do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z, feed_rate);
1708 1713
   }
@@ -2712,6 +2717,23 @@ inline void gcode_G4() {
2712 2717
 
2713 2718
 #endif //FWRETRACT
2714 2719
 
2720
+#if ENABLED(CLEAN_NOZZLE_FEATURE) && ENABLED(AUTO_BED_LEVELING_FEATURE)
2721
+  #include "clean_nozzle.h"
2722
+
2723
+  inline void gcode_G12() {
2724
+    // Don't allow nozzle cleaning without homing first
2725
+    if (!axis_homed[X_AXIS] || !axis_homed[Y_AXIS] || !axis_homed[Z_AXIS]) {
2726
+      axis_unhomed_error(true);
2727
+      return;
2728
+    }
2729
+
2730
+    uint8_t const pattern = code_seen('P') ? code_value_ushort() : 0;
2731
+    uint8_t const strokes = code_seen('S') ? code_value_ushort() : CLEAN_NOZZLE_STROKES;
2732
+
2733
+    CleanNozzle::start(pattern, strokes);
2734
+  }
2735
+#endif
2736
+
2715 2737
 #if ENABLED(INCH_MODE_SUPPORT)
2716 2738
   /**
2717 2739
    * G20: Set input mode to inches
@@ -6748,12 +6770,10 @@ void process_next_command() {
6748 6770
 
6749 6771
       // G2, G3
6750 6772
       #if ENABLED(ARC_SUPPORT) && DISABLED(SCARA)
6751
-
6752 6773
         case 2: // G2  - CW ARC
6753 6774
         case 3: // G3  - CCW ARC
6754 6775
           gcode_G2_G3(codenum == 2);
6755 6776
           break;
6756
-
6757 6777
       #endif
6758 6778
 
6759 6779
       // G4 Dwell
@@ -6762,23 +6782,25 @@ void process_next_command() {
6762 6782
         break;
6763 6783
 
6764 6784
       #if ENABLED(BEZIER_CURVE_SUPPORT)
6765
-
6766 6785
         // G5
6767 6786
         case 5: // G5  - Cubic B_spline
6768 6787
           gcode_G5();
6769 6788
           break;
6770
-
6771 6789
       #endif // BEZIER_CURVE_SUPPORT
6772 6790
 
6773 6791
       #if ENABLED(FWRETRACT)
6774
-
6775 6792
         case 10: // G10: retract
6776 6793
         case 11: // G11: retract_recover
6777 6794
           gcode_G10_G11(codenum == 10);
6778 6795
           break;
6779
-
6780 6796
       #endif // FWRETRACT
6781 6797
 
6798
+      #if ENABLED(CLEAN_NOZZLE_FEATURE) && ENABLED(AUTO_BED_LEVELING_FEATURE)
6799
+        case 12:
6800
+          gcode_G12(); // G12: Clean Nozzle
6801
+          break;
6802
+      #endif // CLEAN_NOZZLE_FEATURE
6803
+
6782 6804
       #if ENABLED(INCH_MODE_SUPPORT)
6783 6805
         case 20: //G20: Inch Mode
6784 6806
           gcode_G20();
@@ -6787,7 +6809,7 @@ void process_next_command() {
6787 6809
         case 21: //G21: MM Mode
6788 6810
           gcode_G21();
6789 6811
           break;
6790
-      #endif
6812
+      #endif // INCH_MODE_SUPPORT
6791 6813
 
6792 6814
       case 28: // G28: Home all axes, one at a time
6793 6815
         gcode_G28();
@@ -6797,7 +6819,7 @@ void process_next_command() {
6797 6819
         case 29: // G29 Detailed Z probe, probes the bed at 3 or more points.
6798 6820
           gcode_G29();
6799 6821
           break;
6800
-      #endif
6822
+      #endif // AUTO_BED_LEVELING_FEATURE
6801 6823
 
6802 6824
       #if HAS_BED_PROBE
6803 6825
 
@@ -6816,7 +6838,6 @@ void process_next_command() {
6816 6838
               break;
6817 6839
 
6818 6840
         #endif // Z_PROBE_SLED
6819
-
6820 6841
       #endif // HAS_BED_PROBE
6821 6842
 
6822 6843
       case 90: // G90
@@ -6845,7 +6866,6 @@ void process_next_command() {
6845 6866
         break;
6846 6867
 
6847 6868
       #if ENABLED(SDSUPPORT)
6848
-
6849 6869
         case 20: // M20 - list SD card
6850 6870
           gcode_M20(); break;
6851 6871
         case 21: // M21 - init SD card
@@ -6878,7 +6898,6 @@ void process_next_command() {
6878 6898
 
6879 6899
         case 928: //M928 - Start SD write
6880 6900
           gcode_M928(); break;
6881
-
6882 6901
       #endif //SDSUPPORT
6883 6902
 
6884 6903
       case 31: //M31 take time since the start of the SD print or an M109 command
@@ -6948,11 +6967,9 @@ void process_next_command() {
6948 6967
       #endif
6949 6968
 
6950 6969
       #if ENABLED(HOST_KEEPALIVE_FEATURE)
6951
-
6952 6970
         case 113: // M113: Set Host Keepalive interval
6953 6971
           gcode_M113();
6954 6972
           break;
6955
-
6956 6973
       #endif
6957 6974
 
6958 6975
       case 140: // M140: Set bed temp

+ 7
- 0
Marlin/SanityCheck.h Vedi File

@@ -646,4 +646,11 @@
646 646
   #error "ABS_PREHEAT_FAN_SPEED is now PREHEAT_2_FAN_SPEED. Please update your configuration."
647 647
 #endif
648 648
 
649
+/**
650
+ * Nozzle cleaning
651
+ */
652
+#if ENABLED(CLEAN_NOZZLE_FEATURE) && DISABLED(AUTO_BED_LEVELING_FEATURE)
653
+  #error You must enable AUTO_BED_LEVELING_FEATURE for CLEAN_NOZZLE_FEATURE to work
654
+#endif
655
+
649 656
 #endif //SANITYCHECK_H

+ 112
- 0
Marlin/clean_nozzle.h Vedi File

@@ -0,0 +1,112 @@
1
+/*
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+#ifndef __CLEAN_NOZZLE_H__
24
+#define __CLEAN_NOZZLE_H__
25
+
26
+#include "Marlin.h"
27
+#include "point_t.h"
28
+
29
+/**
30
+ * @brief CleanNozzle class
31
+ *
32
+ * @todo: Do not ignore the end.z value and allow XYZ movements
33
+ * @todo: Currently this feature needs AUTO_BED_LEVELING_FEATURE to be active
34
+ *  due to the do_blocking_move_to*() functions.
35
+ */
36
+class CleanNozzle {
37
+  private:
38
+    /**
39
+     * @brief Stroke clean pattern
40
+     * @details Wipes the nozzle back and forth in a linear movement
41
+     *
42
+     * @param start point_t defining the starting point
43
+     * @param end point_t defining the ending point
44
+     * @param strokes number of strokes to execute
45
+     */
46
+    static void stroke(point_t const &start, point_t const &end, uint8_t const &strokes)
47
+    __attribute__ ((optimize ("Os"))) {
48
+      // Move to the starting point
49
+      do_blocking_move_to_xy(start.x, start.y);
50
+      do_blocking_move_to_z(start.z);
51
+
52
+      // Start the stroke pattern
53
+      for (uint8_t i = 0; i < (strokes >>1); i++) {
54
+        do_blocking_move_to_xy(end.x, end.y);
55
+        do_blocking_move_to_xy(start.x, start.y);
56
+      }
57
+    }
58
+
59
+    /**
60
+     * @brief Zig-zag clean pattern
61
+     * @details Apply a zig-zag cleanning pattern
62
+     *
63
+     * @param start point_t defining the starting point
64
+     * @param end point_t defining the ending point
65
+     * @param triangles number of triangles to execute
66
+     */
67
+    static void zigzag(point_t const &start, point_t const &end, uint8_t const &triangles)
68
+    __attribute__ ((optimize ("Os"))) {
69
+      // Move to the starting point
70
+      do_blocking_move_to_xy(start.x, start.y);
71
+      do_blocking_move_to_z(start.z);
72
+
73
+      // Calculate the triangle side
74
+      float const a = fabs(end.x - start.x) / triangles;
75
+
76
+      // Don't allow the sides (a, b) to be smaller than 5mm
77
+      if (a < 5 || fabs(end.y - start.y) < 5) return;
78
+
79
+      // Start the zig-zag pattern
80
+      for (uint8_t i = 0; i < triangles; i++) {
81
+        float const x = start.x + (a * (i + 1));
82
+        do_blocking_move_to_xy(x, end.y);
83
+        do_blocking_move_to_y(start.y);
84
+      }
85
+    }
86
+
87
+  public:
88
+    /**
89
+     * @brief Clean the nozzle
90
+     * @details Starts the selected clean procedure pattern
91
+     *
92
+     * @param pattern one of the available patterns
93
+     * @param argument depends on the cleaning pattern
94
+     */
95
+    static void start(uint8_t const &pattern, uint8_t const &argument)
96
+    __attribute__ ((optimize ("Os"))) {
97
+      switch (pattern) {
98
+        case 1:
99
+          CleanNozzle::zigzag(
100
+            CLEAN_NOZZLE_START_PT,
101
+            CLEAN_NOZZLE_END_PT, argument);
102
+          break;
103
+
104
+        default:
105
+          CleanNozzle::stroke(
106
+            CLEAN_NOZZLE_START_PT,
107
+            CLEAN_NOZZLE_END_PT, argument);
108
+      }
109
+    }
110
+};
111
+
112
+#endif

+ 33
- 0
Marlin/point_t.h Vedi File

@@ -0,0 +1,33 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+#ifndef __POINT_T__
24
+#define __POINT_T__
25
+
26
+struct point_t {
27
+  float x;
28
+  float y;
29
+  float z;
30
+  float e;
31
+};
32
+
33
+#endif

Loading…
Annulla
Salva