Pārlūkot izejas kodu

Duet Smart Effector support (#16641)

Bob Kuhn 4 gadus atpakaļ
vecāks
revīzija
0d166f9c7d

+ 7
- 0
Marlin/Configuration.h Parādīt failu

@@ -915,6 +915,13 @@
915 915
   #define Z_PROBE_RETRACT_X X_MAX_POS
916 916
 #endif
917 917
 
918
+// Duet Smart Effector (for delta printers) - https://bit.ly/2ul5U7J
919
+// When the pin is defined you can use M672 to set/reset the probe sensivity.
920
+//#define DUET_SMART_EFFECTOR
921
+#if ENABLED(DUET_SMART_EFFECTOR)
922
+  #define SMART_EFFECTOR_MOD_PIN  -1  // Connect a GPIO pin to the Smart Effector MOD pin
923
+#endif
924
+
918 925
 //
919 926
 // For Z_PROBE_ALLEN_KEY see the Delta example configurations.
920 927
 //

+ 4
- 0
Marlin/src/MarlinCore.cpp Parādīt failu

@@ -827,6 +827,10 @@ void setup() {
827 827
     L64xxManager.init();  // Set up SPI, init drivers
828 828
   #endif
829 829
 
830
+  #if ENABLED(SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD)
831
+    OUT_WRITE(SMART_EFFECTOR_MOD_PIN, LOW);   // Put Smart Effector into NORMAL mode
832
+  #endif
833
+
830 834
   #if ENABLED(MAX7219_DEBUG)
831 835
     max7219.init();
832 836
   #endif

+ 99
- 0
Marlin/src/gcode/config/M672.cpp Parādīt failu

@@ -0,0 +1,99 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 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
+#include "../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD)
26
+
27
+#include "../gcode.h"
28
+#include "../../HAL/shared/Delay.h"
29
+#include "../parser.h"
30
+
31
+/**
32
+ * M672 - Set/reset Duet Smart Effector sensitivity
33
+ *
34
+ *  One of these is required:
35
+ *    S<sensitivity> - 0-255
36
+ *    R              - Flag to reset sensitivity to default
37
+ */
38
+
39
+/**
40
+ * The Marlin format for the M672 command is different than shown in the Duet Smart Effector
41
+ * documentation https://duet3d.dozuki.com/Wiki/Smart_effector_and_carriage_adapters_for_delta_printer
42
+ *
43
+ * To set custom sensitivity:
44
+ *   Duet:   M672 S105:aaa:bbb
45
+ *   Marlin: M672 Saaa
46
+ *
47
+ *   (where aaa is the desired sensitivity and bbb is 255 - aaa).
48
+ *
49
+ * Revert sensitivity to factory settings:
50
+ *   Duet:   M672 S105:131:131
51
+ *   Marlin: M672 R
52
+ */
53
+
54
+#define M672_PROGBYTE    105								// magic byte to start programming custom sensitivity
55
+#define M672_ERASEBYTE   131								// magic byte to clear custom sensitivity
56
+
57
+//
58
+// Smart Effector byte send protocol:
59
+//
60
+//  0  0  1  0       ... always 0010
61
+//  b7 b6 b5 b4 ~b4  ... hi bits, NOT last bit
62
+//  b3 b2 b1 b0 ~b0  ... lo bits, NOT last bit
63
+//
64
+void M672_send(uint8_t b) {    // bit rate requirement: 1KHz +/- 30%
65
+  for (uint8_t bits = 0; bits < 14; bits++) {
66
+    switch (bits) {
67
+      default: { OUT_WRITE(SMART_EFFECTOR_MOD_PIN, !!(b & 0x80)); b <<= 1; break; } // send bit, shift next into place
68
+      case  7:
69
+      case 12: { OUT_WRITE(SMART_EFFECTOR_MOD_PIN, !!(b & 0x80));          break; } // send bit. no shift
70
+      case  8:
71
+      case 13: { OUT_WRITE(SMART_EFFECTOR_MOD_PIN,  !(b & 0x80)); b <<= 1; break; } // send inverted previous bit
72
+      case  0: case  1:                                   // 00
73
+      case  3: { OUT_WRITE(SMART_EFFECTOR_MOD_PIN, LOW); break; }   // 0010
74
+      case  2: { OUT_WRITE(SMART_EFFECTOR_MOD_PIN, HIGH); break; }  // 001
75
+    }
76
+    DELAY_US(1000);
77
+  }
78
+}
79
+
80
+void GcodeSuite::M672() {
81
+  if (parser.seen('R')) {
82
+    M672_send(M672_ERASEBYTE);
83
+    M672_send(M672_ERASEBYTE);
84
+  }
85
+  else if (parser.seenval('S')) {
86
+    const int8_t M672_sensitivity = parser.value_byte();
87
+    M672_send(M672_PROGBYTE);
88
+    M672_send(M672_sensitivity);
89
+    M672_send(255 - M672_sensitivity);
90
+  }
91
+  else {
92
+    SERIAL_ECHO_MSG("!'S' or 'R' parameter required.");
93
+    return;
94
+  }
95
+
96
+  OUT_WRITE(SMART_EFFECTOR_MOD_PIN, LOW);  // Keep Smart Effector in NORMAL mode
97
+}
98
+
99
+#endif // SMART_EFFECTOR && SMART_EFFECTOR_MOD_PIN

+ 25
- 21
Marlin/src/gcode/gcode.cpp Parādīt failu

@@ -562,14 +562,6 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
562 562
         case 206: M206(); break;                                  // M206: Set home offsets
563 563
       #endif
564 564
 
565
-      #if ENABLED(DELTA)
566
-        case 665: M665(); break;                                  // M665: Set delta configurations
567
-      #endif
568
-
569
-      #if ENABLED(DELTA) || HAS_EXTRA_ENDSTOPS
570
-        case 666: M666(); break;                                  // M666: Set delta or multiple endstop adjustment
571
-      #endif
572
-
573 565
       #if ENABLED(FWRETRACT)
574 566
         case 207: M207(); break;                                  // M207: Set Retract Length, Feedrate, and Z lift
575 567
         case 208: M208(); break;                                  // M208: Set Recover (unretract) Additional Length and Feedrate
@@ -714,7 +706,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
714 706
       #endif
715 707
 
716 708
       #if ENABLED(SDSUPPORT)
717
-        case 524: M524(); break;                                   // M524: Abort the current SD print job
709
+        case 524: M524(); break;                                  // M524: Abort the current SD print job
718 710
       #endif
719 711
 
720 712
       #if ENABLED(SD_ABORT_ON_ENDSTOP_HIT)
@@ -725,14 +717,6 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
725 717
         case 575: M575(); break;                                  // M575: Set serial baudrate
726 718
       #endif
727 719
 
728
-      #if HAS_BED_PROBE
729
-        case 851: M851(); break;                                  // M851: Set Z Probe Z Offset
730
-      #endif
731
-
732
-      #if ENABLED(SKEW_CORRECTION_GCODE)
733
-        case 852: M852(); break;                                  // M852: Set Skew factors
734
-      #endif
735
-
736 720
       #if ENABLED(ADVANCED_PAUSE_FEATURE)
737 721
         case 600: M600(); break;                                  // M600: Pause for Filament Change
738 722
         case 603: M603(); break;                                  // M603: Configure Filament Change
@@ -742,21 +726,37 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
742 726
         case 605: M605(); break;                                  // M605: Set Dual X Carriage movement mode
743 727
       #endif
744 728
 
729
+      #if ENABLED(DELTA)
730
+        case 665: M665(); break;                                  // M665: Set delta configurations
731
+      #endif
732
+
733
+      #if ENABLED(DELTA) || HAS_EXTRA_ENDSTOPS
734
+        case 666: M666(); break;                                  // M666: Set delta or multiple endstop adjustment
735
+      #endif
736
+
737
+      #if ENABLED(SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD)
738
+        case 672: M672(); break;                                  // M672: Set/clear Duet Smart Effector sensitivity
739
+      #endif
740
+
745 741
       #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
746 742
         case 701: M701(); break;                                  // M701: Load Filament
747 743
         case 702: M702(); break;                                  // M702: Unload Filament
748 744
       #endif
749 745
 
750
-      #if ENABLED(MAX7219_GCODE)
751
-        case 7219: M7219(); break;                                // M7219: Set LEDs, columns, and rows
752
-      #endif
753
-
754 746
       #if ENABLED(GCODE_MACROS)
755 747
         case 810: case 811: case 812: case 813: case 814:
756 748
         case 815: case 816: case 817: case 818: case 819:
757 749
         M810_819(); break;                                        // M810-M819: Define/execute G-code macro
758 750
       #endif
759 751
 
752
+      #if HAS_BED_PROBE
753
+        case 851: M851(); break;                                  // M851: Set Z Probe Z Offset
754
+      #endif
755
+
756
+      #if ENABLED(SKEW_CORRECTION_GCODE)
757
+        case 852: M852(); break;                                  // M852: Set Skew factors
758
+      #endif
759
+
760 760
       #if ENABLED(PROBE_TEMP_COMPENSATION)
761 761
         case 871: M871(); break;                                  // M871: Print/reset/clear first layer temperature offset values
762 762
       #endif
@@ -847,6 +847,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
847 847
         case 1000: M1000(); break;                                // M1000: Resume from power-loss
848 848
       #endif
849 849
 
850
+      #if ENABLED(MAX7219_GCODE)
851
+        case 7219: M7219(); break;                                // M7219: Set LEDs, columns, and rows
852
+      #endif
853
+
850 854
       default: parser.unknown_command_error(); break;
851 855
     }
852 856
     break;

+ 6
- 1
Marlin/src/gcode/gcode.h Parādīt failu

@@ -228,7 +228,8 @@
228 228
  * M603 - Configure filament change: "M603 T<tool> U<unload_length> L<load_length>". (Requires ADVANCED_PAUSE_FEATURE)
229 229
  * M605 - Set Dual X-Carriage movement mode: "M605 S<mode> [X<x_offset>] [R<temp_offset>]". (Requires DUAL_X_CARRIAGE)
230 230
  * M665 - Set delta configurations: "M665 H<delta height> L<diagonal rod> R<delta radius> S<segments/s> B<calibration radius> X<Alpha angle trim> Y<Beta angle trim> Z<Gamma angle trim> (Requires DELTA)
231
- * M666 - Set/get offsets for delta (Requires DELTA) or dual endstops (Requires [XYZ]_DUAL_ENDSTOPS).
231
+ * M666 - Set/get offsets for delta (Requires DELTA) or dual endstops. (Requires [XYZ]_DUAL_ENDSTOPS)
232
+ * M672 - Set/Reset Duet Smart Effector's sensitivity. (Requires SMART_EFFECTOR and SMART_EFFECTOR_MOD_PIN)
232 233
  * M701 - Load filament (Requires FILAMENT_LOAD_UNLOAD_GCODES)
233 234
  * M702 - Unload filament (Requires FILAMENT_LOAD_UNLOAD_GCODES)
234 235
  * M810-M819 - Define/execute a G-code macro (Requires GCODE_MACROS)
@@ -850,6 +851,10 @@ private:
850 851
     static void M666();
851 852
   #endif
852 853
 
854
+  #if ENABLED(SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD)
855
+    static void M672();
856
+  #endif
857
+
853 858
   #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
854 859
     static void M701();
855 860
     static void M702();

+ 3
- 0
Marlin/src/pins/pinsDebug_list.h Parādīt failu

@@ -1488,3 +1488,6 @@
1488 1488
 #if PIN_EXISTS(TOUCH_INT)
1489 1489
   REPORT_NAME_DIGITAL(__LINE__, TOUCH_INT_PIN)
1490 1490
 #endif
1491
+#if PIN_EXISTS(SMART_EFFECTOR_MOD)
1492
+  REPORT_NAME_DIGITAL(__LINE__, SMART_EFFECTOR_MOD_PIN)
1493
+#endif

Notiek ielāde…
Atcelt
Saglabāt