Browse Source

FILAMENT_WIDTH_SENSOR feature

Scott Lahteine 7 years ago
parent
commit
4f1eadf41f

+ 0
- 16
Marlin/src/Marlin.cpp View File

186
   ;
186
   ;
187
 #endif
187
 #endif
188
 
188
 
189
-#if ENABLED(FILAMENT_WIDTH_SENSOR)
190
-  bool filament_sensor = false;                                 // M405 turns on filament sensor control. M406 turns it off.
191
-  float filament_width_nominal = DEFAULT_NOMINAL_FILAMENT_DIA,  // Nominal filament width. Change with M404.
192
-        filament_width_meas = DEFAULT_MEASURED_FILAMENT_DIA;    // Measured filament diameter
193
-  uint8_t meas_delay_cm = MEASUREMENT_DELAY_CM,                 // Distance delay setting
194
-          measurement_delay[MAX_MEASUREMENT_DELAY + 1];         // Ring buffer to delayed measurement. Store extruder factor after subtracting 100
195
-  int8_t filwidth_delay_index[2] = { 0, -1 };                   // Indexes into ring buffer
196
-#endif
197
-
198
 #if ENABLED(FILAMENT_RUNOUT_SENSOR)
189
 #if ENABLED(FILAMENT_RUNOUT_SENSOR)
199
   static bool filament_ran_out = false;
190
   static bool filament_ran_out = false;
200
 #endif
191
 #endif
667
   #include "gcode/probe/M401_M402.h"
658
   #include "gcode/probe/M401_M402.h"
668
 #endif
659
 #endif
669
 
660
 
670
-#if ENABLED(FILAMENT_WIDTH_SENSOR)
671
-  #include "gcode/sensor/M404.h"
672
-  #include "gcode/sensor/M405.h"
673
-  #include "gcode/sensor/M406.h"
674
-  #include "gcode/sensor/M407.h"
675
-#endif
676
-
677
 void quickstop_stepper() {
661
 void quickstop_stepper() {
678
   stepper.quick_stop();
662
   stepper.quick_stop();
679
   stepper.synchronize();
663
   stepper.synchronize();

+ 0
- 9
Marlin/src/Marlin.h View File

211
   extern uint8_t baricuda_valve_pressure, baricuda_e_to_p_pressure;
211
   extern uint8_t baricuda_valve_pressure, baricuda_e_to_p_pressure;
212
 #endif
212
 #endif
213
 
213
 
214
-#if ENABLED(FILAMENT_WIDTH_SENSOR)
215
-  extern bool filament_sensor;         // Flag that filament sensor readings should control extrusion
216
-  extern float filament_width_nominal, // Theoretical filament diameter i.e., 3.00 or 1.75
217
-               filament_width_meas;    // Measured filament diameter
218
-  extern uint8_t meas_delay_cm,        // Delay distance
219
-                 measurement_delay[];  // Ring buffer to delay measurement
220
-  extern int8_t filwidth_delay_index[2]; // Ring buffer indexes. Used by planner, temperature, and main code
221
-#endif
222
-
223
 #if ENABLED(ADVANCED_PAUSE_FEATURE)
214
 #if ENABLED(ADVANCED_PAUSE_FEATURE)
224
   extern AdvancedPauseMenuResponse advanced_pause_menu_response;
215
   extern AdvancedPauseMenuResponse advanced_pause_menu_response;
225
 #endif
216
 #endif

Marlin/src/gcode/sensor/M406.h → Marlin/src/feature/filwidth.cpp View File

20
  *
20
  *
21
  */
21
  */
22
 
22
 
23
-/**
24
- * M406: Turn off filament sensor for control
25
- */
26
-void gcode_M406() {
27
-  filament_sensor = false;
28
-  calculate_volumetric_multipliers();   // Restore correct 'volumetric_multiplier' value
29
-}
23
+#include "../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(FILAMENT_WIDTH_SENSOR)
26
+
27
+#include "filwidth.h"
28
+
29
+bool filament_sensor = false;                                 // M405/M406 turns filament sensor control ON/OFF.
30
+float filament_width_nominal = DEFAULT_NOMINAL_FILAMENT_DIA,  // Nominal filament width. Change with M404.
31
+      filament_width_meas = DEFAULT_MEASURED_FILAMENT_DIA;    // Measured filament diameter
32
+uint8_t meas_delay_cm = MEASUREMENT_DELAY_CM,                 // Distance delay setting
33
+        measurement_delay[MAX_MEASUREMENT_DELAY + 1];         // Ring buffer to delayed measurement. Store extruder factor after subtracting 100
34
+int8_t filwidth_delay_index[2] = { 0, -1 };                   // Indexes into ring buffer
35
+
36
+#endif // FILAMENT_WIDTH_SENSOR

Marlin/src/gcode/sensor/M404.h → Marlin/src/feature/filwidth.h View File

20
  *
20
  *
21
  */
21
  */
22
 
22
 
23
-/**
24
- * M404: Display or set (in current units) the nominal filament width (3mm, 1.75mm ) W<3.0>
25
- */
26
-void gcode_M404() {
27
-  if (parser.seen('W')) {
28
-    filament_width_nominal = parser.value_linear_units();
29
-  }
30
-  else {
31
-    SERIAL_PROTOCOLPGM("Filament dia (nominal mm):");
32
-    SERIAL_PROTOCOLLN(filament_width_nominal);
33
-  }
34
-}
23
+#ifndef __FILWIDTH_H__
24
+#define __FILWIDTH_H__
25
+
26
+#include "../inc/MarlinConfig.h"
27
+
28
+extern bool filament_sensor;                                  // M405/M406 turns filament sensor control ON/OFF.
29
+extern float filament_width_nominal,                          // Nominal filament width. Change with M404.
30
+             filament_width_meas;                             // Measured filament diameter
31
+extern uint8_t meas_delay_cm,                                 // Distance delay setting
32
+               measurement_delay[MAX_MEASUREMENT_DELAY + 1];  // Ring buffer to delayed measurement. Store extruder factor after subtracting 100
33
+extern int8_t filwidth_delay_index[2];                        // Indexes into ring buffer
34
+
35
+#endif // __FILWIDTH_H__

Marlin/src/gcode/sensor/M405.h → Marlin/src/gcode/feature/filwidth/M404-M407.cpp View File

20
  *
20
  *
21
  */
21
  */
22
 
22
 
23
+#include "../../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(FILAMENT_WIDTH_SENSOR)
26
+
27
+#include "../../../feature/filwidth.h"
28
+#include "../../../module/planner.h"
29
+#include "../../../module/temperature.h"
30
+#include "../../../Marlin.h"
31
+#include "../../gcode.h"
32
+
33
+/**
34
+ * M404: Display or set (in current units) the nominal filament width (3mm, 1.75mm ) W<3.0>
35
+ */
36
+void GcodeSuite::M404() {
37
+  if (parser.seen('W')) {
38
+    filament_width_nominal = parser.value_linear_units();
39
+  }
40
+  else {
41
+    SERIAL_PROTOCOLPGM("Filament dia (nominal mm):");
42
+    SERIAL_PROTOCOLLN(filament_width_nominal);
43
+  }
44
+}
45
+
23
 /**
46
 /**
24
  * M405: Turn on filament sensor for control
47
  * M405: Turn on filament sensor for control
25
  */
48
  */
26
-void gcode_M405() {
49
+void GcodeSuite::M405() {
27
   // This is technically a linear measurement, but since it's quantized to centimeters and is a different
50
   // This is technically a linear measurement, but since it's quantized to centimeters and is a different
28
   // unit than everything else, it uses parser.value_byte() instead of parser.value_linear_units().
51
   // unit than everything else, it uses parser.value_byte() instead of parser.value_linear_units().
29
   if (parser.seen('D')) {
52
   if (parser.seen('D')) {
47
   //SERIAL_PROTOCOLPGM("Extrusion ratio(%):");
70
   //SERIAL_PROTOCOLPGM("Extrusion ratio(%):");
48
   //SERIAL_PROTOCOL(planner.flow_percentage[active_extruder]);
71
   //SERIAL_PROTOCOL(planner.flow_percentage[active_extruder]);
49
 }
72
 }
73
+
74
+/**
75
+ * M406: Turn off filament sensor for control
76
+ */
77
+void GcodeSuite::M406() {
78
+  filament_sensor = false;
79
+  calculate_volumetric_multipliers();   // Restore correct 'volumetric_multiplier' value
80
+}
81
+
82
+/**
83
+ * M407: Get measured filament diameter on serial output
84
+ */
85
+void GcodeSuite::M407() {
86
+  SERIAL_PROTOCOLPGM("Filament dia (measured mm):");
87
+  SERIAL_PROTOCOLLN(filament_width_meas);
88
+}
89
+
90
+#endif // FILAMENT_WIDTH_SENSOR

+ 4
- 13
Marlin/src/gcode/gcode.cpp View File

102
 //
102
 //
103
 // Placeholders for non-migrated codes
103
 // Placeholders for non-migrated codes
104
 //
104
 //
105
-extern void gcode_G0_G1(
106
-  #if IS_SCARA
107
-    bool fast_move=false
108
-  #endif
109
-);
110
 extern void gcode_G2_G3(bool clockwise);
105
 extern void gcode_G2_G3(bool clockwise);
111
 extern void gcode_G4();
106
 extern void gcode_G4();
112
 extern void gcode_G5();
107
 extern void gcode_G5();
216
 extern void gcode_M400();
211
 extern void gcode_M400();
217
 extern void gcode_M401();
212
 extern void gcode_M401();
218
 extern void gcode_M402();
213
 extern void gcode_M402();
219
-extern void gcode_M404();
220
-extern void gcode_M405();
221
-extern void gcode_M406();
222
-extern void gcode_M407();
223
 extern void gcode_M410();
214
 extern void gcode_M410();
224
 extern void gcode_M428();
215
 extern void gcode_M428();
225
 extern void gcode_M500();
216
 extern void gcode_M500();
871
 
862
 
872
       #if ENABLED(FILAMENT_WIDTH_SENSOR)
863
       #if ENABLED(FILAMENT_WIDTH_SENSOR)
873
         case 404:  // M404: Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width
864
         case 404:  // M404: Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width
874
-          gcode_M404();
865
+          M404();
875
           break;
866
           break;
876
         case 405:  // M405: Turn on filament sensor for control
867
         case 405:  // M405: Turn on filament sensor for control
877
-          gcode_M405();
868
+          M405();
878
           break;
869
           break;
879
         case 406:  // M406: Turn off filament sensor for control
870
         case 406:  // M406: Turn off filament sensor for control
880
-          gcode_M406();
871
+          M406();
881
           break;
872
           break;
882
         case 407:   // M407: Display measured filament diameter
873
         case 407:   // M407: Display measured filament diameter
883
-          gcode_M407();
874
+          M407();
884
           break;
875
           break;
885
       #endif // FILAMENT_WIDTH_SENSOR
876
       #endif // FILAMENT_WIDTH_SENSOR
886
 
877
 

+ 0
- 29
Marlin/src/gcode/sensor/M407.h View File

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
-/**
24
- * M407: Get measured filament diameter on serial output
25
- */
26
-void gcode_M407() {
27
-  SERIAL_PROTOCOLPGM("Filament dia (measured mm):");
28
-  SERIAL_PROTOCOLLN(filament_width_meas);
29
-}

+ 0
- 4
Marlin/src/lcd/ultralcd.cpp View File

47
   #include "../feature/filwidth.h"
47
   #include "../feature/filwidth.h"
48
 #endif
48
 #endif
49
 
49
 
50
-#if HAS_BED_PROBE
51
-  #include "../module/probe.h"
52
-#endif
53
-
54
 #if ENABLED(BLTOUCH)
50
 #if ENABLED(BLTOUCH)
55
   #include "../module/endstops.h"
51
   #include "../module/endstops.h"
56
 #endif
52
 #endif

+ 4
- 0
Marlin/src/module/planner.cpp View File

72
   #include "../feature/bedlevel/bedlevel.h"
72
   #include "../feature/bedlevel/bedlevel.h"
73
 #endif
73
 #endif
74
 
74
 
75
+#if ENABLED(FILAMENT_WIDTH_SENSOR)
76
+  #include "../feature/filwidth.h"
77
+#endif
78
+
75
 Planner planner;
79
 Planner planner;
76
 
80
 
77
   // public:
81
   // public:

+ 4
- 0
Marlin/src/module/temperature.cpp View File

45
 
45
 
46
 #include "printcounter.h"
46
 #include "printcounter.h"
47
 
47
 
48
+#if ENABLED(FILAMENT_WIDTH_SENSOR)
49
+  #include "../feature/filwidth.h"
50
+#endif
51
+
48
 #ifdef K1 // Defined in Configuration.h in the PID settings
52
 #ifdef K1 // Defined in Configuration.h in the PID settings
49
   #define K2 (1.0-K1)
53
   #define K2 (1.0-K1)
50
 #endif
54
 #endif

Loading…
Cancel
Save