extruder: Support a minimum extrude temperature

Allow the config file to specify the minimum temperature for the
extruder and check for that temperature prior to moving the extruder
motor.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2016-09-30 19:04:24 -04:00
parent 3167e8ddbe
commit 9faa0fbd25
3 changed files with 14 additions and 1 deletions

View File

@ -135,6 +135,9 @@ pid_deriv_time: 2.0
# will be smoothed to reduce the impact of measurement noise # will be smoothed to reduce the impact of measurement noise
pid_integral_max: 255 pid_integral_max: 255
# The maximum "windup" the integral term may accumulate # The maximum "windup" the integral term may accumulate
min_extrude_temp: 170
# The minimum temperature (in Celsius) at which extruder move
# commands may be issued
min_temp: 0 min_temp: 0
# Minimum temperature in Celsius (mcu will shutdown if not met) # Minimum temperature in Celsius (mcu will shutdown if not met)
max_temp: 210 max_temp: 210

View File

@ -4,7 +4,7 @@
# #
# This file may be distributed under the terms of the GNU GPLv3 license. # This file may be distributed under the terms of the GNU GPLv3 license.
import logging import logging
import stepper, heater import stepper, heater, homing
class PrinterExtruder: class PrinterExtruder:
def __init__(self, printer, config): def __init__(self, printer, config):
@ -20,6 +20,8 @@ class PrinterExtruder:
def motor_off(self, move_time): def motor_off(self, move_time):
self.stepper.motor_enable(move_time, 0) self.stepper.motor_enable(move_time, 0)
def check_move(self, move): def check_move(self, move):
if not self.heater.can_extrude:
raise homing.EndstopError(move.pos, "Extrude below minimum temp")
if (not move.do_calc_junction if (not move.do_calc_junction
and not move.axes_d[0] and not move.axes_d[1] and not move.axes_d[0] and not move.axes_d[1]
and not move.axes_d[2]): and not move.axes_d[2]):

View File

@ -28,6 +28,8 @@ class PrinterHeater:
self.mcu_pwm = self.mcu_adc = None self.mcu_pwm = self.mcu_adc = None
self.thermistor_c = Thermistors.get(config.get('thermistor_type')) self.thermistor_c = Thermistors.get(config.get('thermistor_type'))
self.pullup_r = config.getfloat('pullup_resistor', 4700.) self.pullup_r = config.getfloat('pullup_resistor', 4700.)
self.min_extrude_temp = config.getfloat('min_extrude_temp', 170.)
self.can_extrude = False
self.lock = threading.Lock() self.lock = threading.Lock()
self.last_temp = 0. self.last_temp = 0.
self.last_temp_time = 0. self.last_temp_time = 0.
@ -49,6 +51,8 @@ class PrinterHeater:
control_algo = self.config.get('control', 'watermark') control_algo = self.config.get('control', 'watermark')
algos = {'watermark': ControlBangBang, 'pid': ControlPID} algos = {'watermark': ControlBangBang, 'pid': ControlPID}
self.control = algos[control_algo](self, self.config) self.control = algos[control_algo](self, self.config)
if self.printer.mcu.output_file_mode:
self.can_extrude = True
def run(self): def run(self):
self.mcu_adc.query_analog_in(REPORT_TIME) self.mcu_adc.query_analog_in(REPORT_TIME)
def set_pwm(self, read_time, value): def set_pwm(self, read_time, value):
@ -87,12 +91,16 @@ class PrinterHeater:
with self.lock: with self.lock:
self.last_temp = temp self.last_temp = temp
self.last_temp_time = read_time self.last_temp_time = read_time
self.can_extrude = (self.last_temp >= self.min_extrude_temp
and self.target_temp >= self.min_extrude_temp)
self.control.adc_callback(read_time, temp) self.control.adc_callback(read_time, temp)
#logging.debug("temp: %.3f %f = %f" % (read_time, read_value, temp)) #logging.debug("temp: %.3f %f = %f" % (read_time, read_value, temp))
# External commands # External commands
def set_temp(self, print_time, degrees): def set_temp(self, print_time, degrees):
with self.lock: with self.lock:
self.target_temp = degrees self.target_temp = degrees
if self.target_temp < self.min_extrude_temp:
self.can_extrude = False
def get_temp(self): def get_temp(self):
with self.lock: with self.lock:
return self.last_temp, self.target_temp return self.last_temp, self.target_temp