From b22a81cd3469bf8621f7467a171e784eea7b706f Mon Sep 17 00:00:00 2001 From: Andy Silverman Date: Sat, 30 Dec 2017 15:43:03 -0800 Subject: heater: Added config for heater PWM cycle time. Added the pwm_cycle_time option for heater config sections. Defaults to previous value of 0.100 seconds, but may be reduced to shorter times at the expense of MCU workload and possible MOSFET heating, depending on controller design. Some printers that need bed PID to be enabled, notably the Felixprinters series, are known to benefit from shorter cycle times, as the default 10hz rate results in excessive voltage supply droop. While this option can be used on extruder heaters as well, there is not expected to be any particular benefit from doing so unless the extruder heater presents a particularly large load. Signed-off-by: Andy Silverman Signed-off-by: Kevin O'Connor --- klippy/heater.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'klippy/heater.py') diff --git a/klippy/heater.py b/klippy/heater.py index 553b208b..83e8cf7c 100644 --- a/klippy/heater.py +++ b/klippy/heater.py @@ -95,7 +95,6 @@ Sensors = { SAMPLE_TIME = 0.001 SAMPLE_COUNT = 8 REPORT_TIME = 0.300 -PWM_CYCLE_TIME = 0.100 MAX_HEAT_TIME = 5.0 AMBIENT_TEMP = 25. PID_PARAM_BASE = 255. @@ -125,7 +124,9 @@ class PrinterHeater: self.mcu_pwm = pins.setup_pin(printer, 'digital_out', heater_pin) else: self.mcu_pwm = pins.setup_pin(printer, 'pwm', heater_pin) - self.mcu_pwm.setup_cycle_time(PWM_CYCLE_TIME) + pwm_cycle_time = config.getfloat( + 'pwm_cycle_time', 0.100, above=0., maxval=REPORT_TIME) + self.mcu_pwm.setup_cycle_time(pwm_cycle_time) self.mcu_pwm.setup_max_duration(MAX_HEAT_TIME) self.mcu_adc = pins.setup_pin(printer, 'adc', config.get('sensor_pin')) adc_range = [self.sensor.calc_adc(self.min_temp), -- cgit v1.2.3-70-g09d2