aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/example-extras.cfg30
-rw-r--r--docs/HallFilamentWidthSensor.md13
-rw-r--r--klippy/extras/hall_filament_width_sensor.py16
3 files changed, 53 insertions, 6 deletions
diff --git a/config/example-extras.cfg b/config/example-extras.cfg
index 4c5d0d8c..d7410ece 100644
--- a/config/example-extras.cfg
+++ b/config/example-extras.cfg
@@ -1891,7 +1891,35 @@
#measurement_interval: 10
# The approximate distance (in mm) between sensor readings. The
# default is 10mm.
-
+#Virtual filament_switch_sensor support. Create sensor named hall_filament_width_sensor.
+#min_diameter:1.0
+#Minimal diameter for trigger virtual filament_switch_sensor.
+#Values from filament_switch_sensor.
+#See [filament_switch_sensor] for a description of these parameters.
+#pause_on_runout: True
+# When set to True, a PAUSE will execute immediately after a runout
+# is detected. Note that if pause_on_runout is False and the
+# runout_gcode is omitted then runout detection is disabled. Default
+# is True.
+#runout_gcode:
+# A list of G-Code commands to execute after a filament runout is
+# detected. See docs/Command_Templates.md for G-Code format. If
+# pause_on_runout is set to True this G-Code will run after the
+# PAUSE is complete. The default is not to run any G-Code commands.
+#insert_gcode:
+# A list of G-Code commands to execute after a filament insert is
+# detected. See docs/Command_Templates.md for G-Code format. The
+# default is not to run any G-Code commands, which disables insert
+# detection.
+#event_delay: 3.0
+# The minimum amount of time in seconds to delay between events.
+# Events triggered during this time period will be silently
+# ignored. The default is 3 seconds.
+#pause_delay: 0.5
+# The amount of time to delay, in seconds, between the pause command
+# dispatch and execution of the runout_gcode. It may be useful to
+# increase this delay if Octoprint exhibits strange pause behavior.
+# Default is 0.5 seconds.
######################################################################
# Board specific hardware support
diff --git a/docs/HallFilamentWidthSensor.md b/docs/HallFilamentWidthSensor.md
index 7dba78cb..17a263ad 100644
--- a/docs/HallFilamentWidthSensor.md
+++ b/docs/HallFilamentWidthSensor.md
@@ -48,6 +48,19 @@ Sensor generates two analog output based on calculated filament width. Sum of ou
# measurement_interval:10
# Sensor readings done with 10 mm intervals by default. If necessary you are free to change this setting
+ #Virtual filament_switch_sensor suppurt. Create sensor named hall_filament_width_sensor.
+ #
+ #min_diameter:1.0
+ #Minimal diameter for trigger virtual filament_switch_sensor.
+ #
+ #Values from filament_switch_sensor. See the "filament_switch_sensor" section for information on these parameters.
+ #
+ #pause_on_runout: True
+ #runout_gcode:
+ #insert_gcode:
+ #event_delay: 3.0
+ #pause_delay: 0.5
+
## Commands
**QUERY_FILAMENT_WIDTH** - Return the current measured filament width as result
diff --git a/klippy/extras/hall_filament_width_sensor.py b/klippy/extras/hall_filament_width_sensor.py
index fc3ca6f6..860ec2ca 100644
--- a/klippy/extras/hall_filament_width_sensor.py
+++ b/klippy/extras/hall_filament_width_sensor.py
@@ -3,6 +3,7 @@
# Copyright (C) 2019 Mustafa YILDIZ <mydiz@hotmail.com>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
+import filament_switch_sensor
ADC_REPORT_TIME = 0.500
ADC_SAMPLE_TIME = 0.001
@@ -29,6 +30,7 @@ class HallFilamentWidthSensor:
- self.measurement_max_difference)
self.diameter =self.nominal_filament_dia
self.is_active =config.getboolean('enable', False)
+ self.runout_dia=config.getfloat('min_diameter', 1.0)
# filament array [position, filamentWidth]
self.filament_array = []
self.lastFilamentWidthReading = 0
@@ -57,6 +59,7 @@ class HallFilamentWidthSensor:
self.cmd_M405)
self.gcode.register_command('QUERY_RAW_FILAMENT_WIDTH',
self.cmd_Get_Raw_Values)
+ self.runout_helper = filament_switch_sensor.RunoutHelper(config)
# Initialization
def handle_ready(self):
# Load printer objects
@@ -73,17 +76,17 @@ class HallFilamentWidthSensor:
def adc2_callback(self, read_time, read_value):
# read sensor value
self.lastFilamentWidthReading2 = round(read_value * 10000)
+ # calculate diameter
+ self.diameter = round((self.dia2 - self.dia1)/
+ (self.rawdia2-self.rawdia1)*
+ ((self.lastFilamentWidthReading+self.lastFilamentWidthReading2)
+ -self.rawdia1)+self.dia1,2)
def update_filament_array(self, last_epos):
# Fill array
if len(self.filament_array) > 0:
# Get last reading position in array & calculate next
# reading position
-
- self.diameter = round((self.dia2 - self.dia1)/
- (self.rawdia2-self.rawdia1)*
- ((self.lastFilamentWidthReading+self.lastFilamentWidthReading2)
- -self.rawdia1)+self.dia1,2)
next_reading_position = (self.filament_array[-1][0] +
self.MEASUREMENT_INTERVAL_MM)
if next_reading_position <= (last_epos + self.measurement_delay):
@@ -100,6 +103,9 @@ class HallFilamentWidthSensor:
last_epos = pos[3]
# Update filament array for lastFilamentWidthReading
self.update_filament_array(last_epos)
+ # Check runout
+ self.runout_helper.note_filament_present(
+ self.diameter > self.runout_dia)
# Does filament exists
if self.lastFilamentWidthReading > 0.5:
if len(self.filament_array) > 0: