hall_filament_width_sensor: Increasing measure stability (#2836)

Signed-off-by: Denis Ignatenko <deniss979@gmail.com>
This commit is contained in:
Denis Ignatenko 2020-05-19 00:14:24 +03:00 committed by GitHub
parent c9daefd97f
commit 1d2746f167
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -6,8 +6,8 @@
import filament_switch_sensor import filament_switch_sensor
ADC_REPORT_TIME = 0.500 ADC_REPORT_TIME = 0.500
ADC_SAMPLE_TIME = 0.001 ADC_SAMPLE_TIME = 0.01
ADC_SAMPLE_COUNT = 5 ADC_SAMPLE_COUNT = 49
class HallFilamentWidthSensor: class HallFilamentWidthSensor:
def __init__(self, config): def __init__(self, config):
@ -77,10 +77,11 @@ class HallFilamentWidthSensor:
# read sensor value # read sensor value
self.lastFilamentWidthReading2 = round(read_value * 10000) self.lastFilamentWidthReading2 = round(read_value * 10000)
# calculate diameter # calculate diameter
self.diameter = round((self.dia2 - self.dia1)/ diameter_new = round((self.dia2 - self.dia1)/
(self.rawdia2-self.rawdia1)* (self.rawdia2-self.rawdia1)*
((self.lastFilamentWidthReading+self.lastFilamentWidthReading2) ((self.lastFilamentWidthReading+self.lastFilamentWidthReading2)
-self.rawdia1)+self.dia1,2) -self.rawdia1)+self.dia1,2)
self.diameter=(5.0 * self.diameter + diameter_new)/6
def update_filament_array(self, last_epos): def update_filament_array(self, last_epos):
# Fill array # Fill array