heater: Only create a soft PWM object for PID heaters

The "watermark" style heater only needs a digital_out pin - not a
software PWM pin.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2017-01-10 18:36:43 -05:00
parent 8378b7345b
commit 4ea091339e
1 changed files with 9 additions and 3 deletions

View File

@ -39,17 +39,23 @@ class PrinterHeater:
self.next_pwm_time = 0. self.next_pwm_time = 0.
self.last_pwm_value = 0 self.last_pwm_value = 0
def build_config(self): def build_config(self):
algos = {'watermark': ControlBangBang, 'pid': ControlPID}
algo = self.config.getchoice('control', algos)
heater_pin = self.config.get('heater_pin') heater_pin = self.config.get('heater_pin')
thermistor_pin = self.config.get('thermistor_pin') thermistor_pin = self.config.get('thermistor_pin')
self.mcu_pwm = self.printer.mcu.create_pwm(heater_pin, 0, MAX_HEAT_TIME) if algo is ControlBangBang:
self.mcu_pwm = self.printer.mcu.create_digital_out(
heater_pin, MAX_HEAT_TIME)
else:
self.mcu_pwm = self.printer.mcu.create_pwm(
heater_pin, 0, MAX_HEAT_TIME)
self.mcu_adc = self.printer.mcu.create_adc(thermistor_pin) self.mcu_adc = self.printer.mcu.create_adc(thermistor_pin)
min_adc = self.calc_adc(self.config.getfloat('max_temp')) min_adc = self.calc_adc(self.config.getfloat('max_temp'))
max_adc = self.calc_adc(self.config.getfloat('min_temp')) max_adc = self.calc_adc(self.config.getfloat('min_temp'))
self.mcu_adc.set_minmax( self.mcu_adc.set_minmax(
SAMPLE_TIME, SAMPLE_COUNT, minval=min_adc, maxval=max_adc) SAMPLE_TIME, SAMPLE_COUNT, minval=min_adc, maxval=max_adc)
self.mcu_adc.set_adc_callback(REPORT_TIME, self.adc_callback) self.mcu_adc.set_adc_callback(REPORT_TIME, self.adc_callback)
algos = {'watermark': ControlBangBang, 'pid': ControlPID} self.control = algo(self, self.config)
self.control = self.config.getchoice('control', algos)(self, self.config)
if self.printer.mcu.is_fileoutput(): if self.printer.mcu.is_fileoutput():
self.can_extrude = True self.can_extrude = True
def set_pwm(self, read_time, value): def set_pwm(self, read_time, value):