diff --git a/config/example.cfg b/config/example.cfg index 74ec1224..a7d6fd3d 100644 --- a/config/example.cfg +++ b/config/example.cfg @@ -203,6 +203,11 @@ pid_Kd: 114 #pid_integral_max: # The maximum "windup" the integral term may accumulate. The default # is to use the same value as max_power. +#pwm_cycle_time: 0.100 +# Time in seconds for each software PWM cycle of the heater. It is +# not recommended to set this unless there is an electrical +# requirement to switch the heater faster than 10 times a second. +# The default is 0.100 seconds. #min_extrude_temp: 170 # The minimum temperature (in Celsius) at which extruder move # commands may be issued. The default is 170 Celsius. 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),