diff options
author | Denis Ignatenko <60291791+test3210-d@users.noreply.github.com> | 2020-03-02 05:05:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-01 22:05:12 -0500 |
commit | f84542cd20dba6b3ffffd1da1b6363bcbd31b279 (patch) | |
tree | 50d2fe77b674966a4fc2e34f5d13dde5dbfc3992 /klippy | |
parent | 26523d77bab09948412ff9695c13209ad2395256 (diff) | |
download | kutter-f84542cd20dba6b3ffffd1da1b6363bcbd31b279.tar.gz kutter-f84542cd20dba6b3ffffd1da1b6363bcbd31b279.tar.xz kutter-f84542cd20dba6b3ffffd1da1b6363bcbd31b279.zip |
hall_filament_width_sensor: Added virtual runout sensor (#2535)
Signed-off-by: Denis Ignatenko deniss979@gmail.com
Diffstat (limited to 'klippy')
-rw-r--r-- | klippy/extras/hall_filament_width_sensor.py | 16 |
1 files changed, 11 insertions, 5 deletions
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: |