Merge pull request #1242 from john--/pr_generic_heater
Generic Heater Support
This commit is contained in:
commit
c6d1d1bd8c
|
@ -1227,6 +1227,33 @@
|
||||||
# Directly sets the default prefix. If present, this value will override
|
# Directly sets the default prefix. If present, this value will override
|
||||||
# the "default_type".
|
# the "default_type".
|
||||||
|
|
||||||
|
# The heater_generic section is used to describe a custom/generic heater.
|
||||||
|
# These behave the same as typical heaters (extruders, heated beds) and
|
||||||
|
# can be configured as similarly.
|
||||||
|
# However, a gcode_id must be supplied which is used for temperature reporting.
|
||||||
|
# See notes on the SET_HEATER_TEMPERATURE command for setting the temperature.
|
||||||
|
#[heater_generic my_generic_heater]
|
||||||
|
#gcode_id: C
|
||||||
|
# A mandatory parameter that is required for reporting the temperature
|
||||||
|
# through the M105 command.
|
||||||
|
#heater_pin:
|
||||||
|
#max_power:
|
||||||
|
#sensor_type:
|
||||||
|
#sensor_pin:
|
||||||
|
#pullup_resistor:
|
||||||
|
#adc_voltage:
|
||||||
|
#smooth_time:
|
||||||
|
#control:
|
||||||
|
#pid_Kp:
|
||||||
|
#pid_Ki:
|
||||||
|
#pid_Kd:
|
||||||
|
#pid_integral_max:
|
||||||
|
#pwm_cycle_time:
|
||||||
|
#min_extrude_temp:
|
||||||
|
#min_temp:
|
||||||
|
#max_temp:
|
||||||
|
# See the example.cfg for the definition of the above parameters.
|
||||||
|
|
||||||
# Pause/Resume functionality with support of position capture and restore
|
# Pause/Resume functionality with support of position capture and restore
|
||||||
#[pause_resume]
|
#[pause_resume]
|
||||||
#recover_velocity: 50.
|
#recover_velocity: 50.
|
||||||
|
|
|
@ -111,6 +111,9 @@ The following standard commands are supported:
|
||||||
[ACCEL_TO_DECEL=<value>] [SQUARE_CORNER_VELOCITY=<value>]`: Modify
|
[ACCEL_TO_DECEL=<value>] [SQUARE_CORNER_VELOCITY=<value>]`: Modify
|
||||||
the printer's velocity limits. Note that one may only set values
|
the printer's velocity limits. Note that one may only set values
|
||||||
less than or equal to the limits specified in the config file.
|
less than or equal to the limits specified in the config file.
|
||||||
|
- `SET_HEATER_TEMPERATURE HEATER=<heater_name> [TARGET=<target_temperature>]`:
|
||||||
|
Sets the target temperature for a heater. If a target temperature is
|
||||||
|
not supplied, the target is 0.
|
||||||
- `SET_PRESSURE_ADVANCE [EXTRUDER=<config_name>] [ADVANCE=<pressure_advance>]
|
- `SET_PRESSURE_ADVANCE [EXTRUDER=<config_name>] [ADVANCE=<pressure_advance>]
|
||||||
[ADVANCE_LOOKAHEAD_TIME=<pressure_advance_lookahead_time>]`:
|
[ADVANCE_LOOKAHEAD_TIME=<pressure_advance_lookahead_time>]`:
|
||||||
Set pressure advance parameters. If EXTRUDER is not specified, it
|
Set pressure advance parameters. If EXTRUDER is not specified, it
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Support for a generic heater
|
||||||
|
#
|
||||||
|
# Copyright (C) 2019 John Jardine <john@gprime.net>
|
||||||
|
#
|
||||||
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
class PrinterHeaterGeneric:
|
||||||
|
def __init__(self, config):
|
||||||
|
self.printer = config.get_printer()
|
||||||
|
gcode_id = config.get("gcode_id")
|
||||||
|
self.heater = self.printer.lookup_object('heater').setup_heater(config, gcode_id)
|
||||||
|
|
||||||
|
def load_config_prefix(config):
|
||||||
|
return PrinterHeaterGeneric(config)
|
|
@ -21,8 +21,9 @@ class error(Exception):
|
||||||
class Heater:
|
class Heater:
|
||||||
error = error
|
error = error
|
||||||
def __init__(self, config, sensor, gcode_id):
|
def __init__(self, config, sensor, gcode_id):
|
||||||
printer = config.get_printer()
|
self.printer = config.get_printer()
|
||||||
self.name = config.get_name()
|
self.gcode = self.printer.lookup_object("gcode")
|
||||||
|
self.name = config.get_name().split()[-1]
|
||||||
self.gcode_id = gcode_id
|
self.gcode_id = gcode_id
|
||||||
# Setup sensor
|
# Setup sensor
|
||||||
self.sensor = sensor
|
self.sensor = sensor
|
||||||
|
@ -34,7 +35,7 @@ class Heater:
|
||||||
# Setup temperature checks
|
# Setup temperature checks
|
||||||
self.min_extrude_temp = config.getfloat(
|
self.min_extrude_temp = config.getfloat(
|
||||||
'min_extrude_temp', 170., minval=self.min_temp, maxval=self.max_temp)
|
'min_extrude_temp', 170., minval=self.min_temp, maxval=self.max_temp)
|
||||||
is_fileoutput = printer.get_start_args().get('debugoutput') is not None
|
is_fileoutput = self.printer.get_start_args().get('debugoutput') is not None
|
||||||
self.can_extrude = self.min_extrude_temp <= 0. or is_fileoutput
|
self.can_extrude = self.min_extrude_temp <= 0. or is_fileoutput
|
||||||
self.max_power = config.getfloat('max_power', 1., above=0., maxval=1.)
|
self.max_power = config.getfloat('max_power', 1., above=0., maxval=1.)
|
||||||
self.smooth_time = config.getfloat('smooth_time', 2., above=0.)
|
self.smooth_time = config.getfloat('smooth_time', 2., above=0.)
|
||||||
|
@ -51,7 +52,7 @@ class Heater:
|
||||||
self.control = algo(self, config)
|
self.control = algo(self, config)
|
||||||
# Setup output heater pin
|
# Setup output heater pin
|
||||||
heater_pin = config.get('heater_pin')
|
heater_pin = config.get('heater_pin')
|
||||||
ppins = printer.lookup_object('pins')
|
ppins = self.printer.lookup_object('pins')
|
||||||
if algo is ControlBangBang and self.max_power == 1.:
|
if algo is ControlBangBang and self.max_power == 1.:
|
||||||
self.mcu_pwm = ppins.setup_pin('digital_out', heater_pin)
|
self.mcu_pwm = ppins.setup_pin('digital_out', heater_pin)
|
||||||
else:
|
else:
|
||||||
|
@ -61,8 +62,11 @@ class Heater:
|
||||||
self.mcu_pwm.setup_cycle_time(pwm_cycle_time)
|
self.mcu_pwm.setup_cycle_time(pwm_cycle_time)
|
||||||
self.mcu_pwm.setup_max_duration(MAX_HEAT_TIME)
|
self.mcu_pwm.setup_max_duration(MAX_HEAT_TIME)
|
||||||
# Load additional modules
|
# Load additional modules
|
||||||
printer.try_load_module(config, "verify_heater %s" % (self.name,))
|
self.printer.try_load_module(config, "verify_heater %s" % (self.name,))
|
||||||
printer.try_load_module(config, "pid_calibrate")
|
self.printer.try_load_module(config, "pid_calibrate")
|
||||||
|
self.gcode.register_mux_command("SET_HEATER_TEMPERATURE", "HEATER", self.name,
|
||||||
|
self.cmd_SET_HEATER_TEMPERATURE,
|
||||||
|
desc=self.cmd_SET_HEATER_TEMPERATURE_help)
|
||||||
def set_pwm(self, read_time, value):
|
def set_pwm(self, read_time, value):
|
||||||
if self.target_temp <= 0.:
|
if self.target_temp <= 0.:
|
||||||
value = 0.
|
value = 0.
|
||||||
|
@ -134,6 +138,11 @@ class Heater:
|
||||||
target_temp = self.target_temp
|
target_temp = self.target_temp
|
||||||
smoothed_temp = self.smoothed_temp
|
smoothed_temp = self.smoothed_temp
|
||||||
return {'temperature': smoothed_temp, 'target': target_temp}
|
return {'temperature': smoothed_temp, 'target': target_temp}
|
||||||
|
cmd_SET_HEATER_TEMPERATURE_help = "Sets a heater temperature"
|
||||||
|
def cmd_SET_HEATER_TEMPERATURE(self, params):
|
||||||
|
print_time = self.printer.lookup_object('toolhead').get_last_move_time()
|
||||||
|
temp = self.gcode.get_float('TARGET', params, 0.)
|
||||||
|
self.set_temp(print_time, temp)
|
||||||
|
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
@ -229,7 +238,7 @@ class PrinterHeaters:
|
||||||
def add_sensor(self, sensor_type, sensor_factory):
|
def add_sensor(self, sensor_type, sensor_factory):
|
||||||
self.sensors[sensor_type] = sensor_factory
|
self.sensors[sensor_type] = sensor_factory
|
||||||
def setup_heater(self, config, gcode_id):
|
def setup_heater(self, config, gcode_id):
|
||||||
heater_name = config.get_name()
|
heater_name = config.get_name().split()[-1]
|
||||||
if heater_name == 'extruder':
|
if heater_name == 'extruder':
|
||||||
heater_name = 'extruder0'
|
heater_name = 'extruder0'
|
||||||
if heater_name in self.heaters:
|
if heater_name in self.heaters:
|
||||||
|
|
Loading…
Reference in New Issue