mirror of https://github.com/Desuuuu/klipper.git
adc_temperature: Add builtin definition for PT1000 sensors
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
8d10379ad8
commit
a074af7c87
|
@ -874,6 +874,19 @@
|
||||||
#voltage_offset: 0
|
#voltage_offset: 0
|
||||||
# The ADC voltage offset (in Volts). The default is 0.
|
# The ADC voltage offset (in Volts). The default is 0.
|
||||||
|
|
||||||
|
# Directly connected PT1000 sensor. The following parameters are
|
||||||
|
# available in heater sections that use one of these sensors.
|
||||||
|
#[extruder]
|
||||||
|
# See the "extruder" section in example.cfg for a description of
|
||||||
|
# heater parameters. The parameters below describe sensor parameters.
|
||||||
|
#sensor_type: PT1000
|
||||||
|
#sensor_pin:
|
||||||
|
# Analog input pin connected to the sensor. This parameter must be
|
||||||
|
# provided.
|
||||||
|
#pullup_resistor: 4700
|
||||||
|
# The resistance (in ohms) of the pullup attached to the sensor. The
|
||||||
|
# default is 4700 ohms.
|
||||||
|
|
||||||
# Custom thermistors (one may define any number of sections with a
|
# Custom thermistors (one may define any number of sections with a
|
||||||
# "thermistor" prefix). A custom thermistor may be used in the
|
# "thermistor" prefix). A custom thermistor may be used in the
|
||||||
# sensor_type field of a heater config section. (For example, if one
|
# sensor_type field of a heater config section. (For example, if one
|
||||||
|
|
|
@ -132,7 +132,7 @@ class LinearResistance:
|
||||||
def __init__(self, config, samples):
|
def __init__(self, config, samples):
|
||||||
self.pullup = config.getfloat('pullup_resistor', 4700., above=0.)
|
self.pullup = config.getfloat('pullup_resistor', 4700., above=0.)
|
||||||
try:
|
try:
|
||||||
self.li = LinearInterpolate(samples)
|
self.li = LinearInterpolate([(r, t) for t, r in samples])
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
raise config.error("adc_temperature %s in heater %s" % (
|
raise config.error("adc_temperature %s in heater %s" % (
|
||||||
str(e), config.get_name()))
|
str(e), config.get_name()))
|
||||||
|
@ -156,7 +156,7 @@ class CustomLinearResistance:
|
||||||
if t is None:
|
if t is None:
|
||||||
break
|
break
|
||||||
r = config.getfloat("resistance%d" % (i,))
|
r = config.getfloat("resistance%d" % (i,))
|
||||||
self.samples.append((r, t))
|
self.samples.append((t, r))
|
||||||
def create(self, config):
|
def create(self, config):
|
||||||
lr = LinearResistance(config, self.samples)
|
lr = LinearResistance(config, self.samples)
|
||||||
return PrinterADCtoTemperature(config, lr)
|
return PrinterADCtoTemperature(config, lr)
|
||||||
|
@ -266,6 +266,11 @@ PT100 = [
|
||||||
(1000, 4.48), (1100, 4.73)
|
(1000, 4.48), (1100, 4.73)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
PT1000 = [
|
||||||
|
(0., 1000.), (100., 1385.1), (200., 1758.6), (300., 2120.5),
|
||||||
|
(400., 2470.9), (500., 2809.8),
|
||||||
|
]
|
||||||
|
|
||||||
def load_config(config):
|
def load_config(config):
|
||||||
# Register default sensors
|
# Register default sensors
|
||||||
pheater = config.get_printer().lookup_object("heater")
|
pheater = config.get_printer().lookup_object("heater")
|
||||||
|
@ -278,6 +283,11 @@ def load_config(config):
|
||||||
func = (lambda config, params=params:
|
func = (lambda config, params=params:
|
||||||
PrinterADCtoTemperature(config, LinearVoltage(config, params)))
|
PrinterADCtoTemperature(config, LinearVoltage(config, params)))
|
||||||
pheater.add_sensor_factory(sensor_type, func)
|
pheater.add_sensor_factory(sensor_type, func)
|
||||||
|
for sensor_type, params in [("PT1000", PT1000)]:
|
||||||
|
func = (lambda config, params=params:
|
||||||
|
PrinterADCtoTemperature(config,
|
||||||
|
LinearResistance(config, params)))
|
||||||
|
pheater.add_sensor_factory(sensor_type, func)
|
||||||
|
|
||||||
def load_config_prefix(config):
|
def load_config_prefix(config):
|
||||||
if config.get("resistance1", None) is None:
|
if config.get("resistance1", None) is None:
|
||||||
|
|
|
@ -129,6 +129,10 @@ resistance3: 3000
|
||||||
sensor_type: my_custom_resistance_adc
|
sensor_type: my_custom_resistance_adc
|
||||||
sensor_pin: analog5
|
sensor_pin: analog5
|
||||||
|
|
||||||
|
[temperature_sensor test_PT1000]
|
||||||
|
sensor_type: PT1000
|
||||||
|
sensor_pin: analog9
|
||||||
|
|
||||||
[controller_fan test_controller_fan]
|
[controller_fan test_controller_fan]
|
||||||
pin: ar17
|
pin: ar17
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue