fan: Default to using software PWM
Not all hardware has PWM support and there is no compelling reason to use hardware PWM for fans. Change the default to use software PWM. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
37bac916e7
commit
bcaf818c0e
|
@ -65,7 +65,6 @@ max_temp: 110
|
||||||
|
|
||||||
[fan]
|
[fan]
|
||||||
pin: ar14
|
pin: ar14
|
||||||
hard_pwm: 1
|
|
||||||
|
|
||||||
[mcu]
|
[mcu]
|
||||||
serial: /tmp/pseudoserial
|
serial: /tmp/pseudoserial
|
||||||
|
|
|
@ -67,7 +67,6 @@ max_temp: 130
|
||||||
# Extruder print fan (omit section if fan not present)
|
# Extruder print fan (omit section if fan not present)
|
||||||
#[fan]
|
#[fan]
|
||||||
#pin: ar9
|
#pin: ar9
|
||||||
#hard_pwm: 1
|
|
||||||
|
|
||||||
[mcu]
|
[mcu]
|
||||||
serial: /dev/ttyACM0
|
serial: /dev/ttyACM0
|
||||||
|
|
|
@ -219,11 +219,12 @@ max_temp: 110
|
||||||
pin: ar14
|
pin: ar14
|
||||||
# PWM output pin controlling the fan. This parameter must be
|
# PWM output pin controlling the fan. This parameter must be
|
||||||
# provided.
|
# provided.
|
||||||
hard_pwm: 1
|
#hard_pwm: 0
|
||||||
# Set this value to force hardware PWM instead of software PWM. Set
|
# Set this value to force hardware PWM instead of software PWM. Set
|
||||||
# to 1 to force a hardware PWM at the fastest rate; set to a higher
|
# to 1 to force a hardware PWM at the fastest rate; set to a higher
|
||||||
# number (eg, 1024) to force hardware PWM with the given cycle time
|
# number to force hardware PWM with the given cycle time in clock
|
||||||
# in clock ticks. The default is 128 clock ticks.
|
# ticks. The default is 0 which enables software PWM with a cycle
|
||||||
|
# time of 10ms.
|
||||||
#kick_start_time: 0.100
|
#kick_start_time: 0.100
|
||||||
# Time (in seconds) to run the fan at full speed when first enabling
|
# Time (in seconds) to run the fan at full speed when first enabling
|
||||||
# it (helps get the fan spinning). The default is 0.100 seconds.
|
# it (helps get the fan spinning). The default is 0.100 seconds.
|
||||||
|
|
|
@ -71,7 +71,6 @@ max_temp: 100
|
||||||
|
|
||||||
[fan]
|
[fan]
|
||||||
pin: PH5
|
pin: PH5
|
||||||
hard_pwm: 1
|
|
||||||
|
|
||||||
[mcu]
|
[mcu]
|
||||||
serial: /dev/ttyACM0
|
serial: /dev/ttyACM0
|
||||||
|
|
|
@ -5,6 +5,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.
|
||||||
|
|
||||||
FAN_MIN_TIME = 0.1
|
FAN_MIN_TIME = 0.1
|
||||||
|
PWM_CYCLE_TIME = 0.010
|
||||||
|
|
||||||
class PrinterFan:
|
class PrinterFan:
|
||||||
def __init__(self, printer, config):
|
def __init__(self, printer, config):
|
||||||
|
@ -16,8 +17,9 @@ class PrinterFan:
|
||||||
self.kick_start_time = config.getfloat('kick_start_time', 0.1)
|
self.kick_start_time = config.getfloat('kick_start_time', 0.1)
|
||||||
def build_config(self):
|
def build_config(self):
|
||||||
pin = self.config.get('pin')
|
pin = self.config.get('pin')
|
||||||
hard_pwm = self.config.getint('hard_pwm', 128)
|
hard_pwm = self.config.getint('hard_pwm', 0)
|
||||||
self.mcu_fan = self.printer.mcu.create_pwm(pin, hard_pwm, 0)
|
self.mcu_fan = self.printer.mcu.create_pwm(
|
||||||
|
pin, PWM_CYCLE_TIME, hard_pwm, 0.)
|
||||||
# External commands
|
# External commands
|
||||||
def set_speed(self, print_time, value):
|
def set_speed(self, print_time, value):
|
||||||
value = max(0., min(1., value))
|
value = max(0., min(1., value))
|
||||||
|
|
|
@ -16,6 +16,7 @@ Thermistors = {
|
||||||
SAMPLE_TIME = 0.001
|
SAMPLE_TIME = 0.001
|
||||||
SAMPLE_COUNT = 8
|
SAMPLE_COUNT = 8
|
||||||
REPORT_TIME = 0.300
|
REPORT_TIME = 0.300
|
||||||
|
PWM_CYCLE_TIME = 0.100
|
||||||
KELVIN_TO_CELCIUS = -273.15
|
KELVIN_TO_CELCIUS = -273.15
|
||||||
MAX_HEAT_TIME = 5.0
|
MAX_HEAT_TIME = 5.0
|
||||||
AMBIENT_TEMP = 25.
|
AMBIENT_TEMP = 25.
|
||||||
|
@ -55,7 +56,7 @@ class PrinterHeater:
|
||||||
heater_pin, MAX_HEAT_TIME)
|
heater_pin, MAX_HEAT_TIME)
|
||||||
else:
|
else:
|
||||||
self.mcu_pwm = self.printer.mcu.create_pwm(
|
self.mcu_pwm = self.printer.mcu.create_pwm(
|
||||||
heater_pin, 0, MAX_HEAT_TIME)
|
heater_pin, PWM_CYCLE_TIME, 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.max_temp)
|
min_adc = self.calc_adc(self.max_temp)
|
||||||
max_adc = self.calc_adc(self.min_temp)
|
max_adc = self.calc_adc(self.min_temp)
|
||||||
|
|
|
@ -251,7 +251,7 @@ class MCU_digital_out:
|
||||||
|
|
||||||
class MCU_pwm:
|
class MCU_pwm:
|
||||||
PWM_MAX = 255.
|
PWM_MAX = 255.
|
||||||
def __init__(self, mcu, pin, cycle_ticks, max_duration, hard_pwm=True):
|
def __init__(self, mcu, pin, cycle_ticks, max_duration, hard_pwm=False):
|
||||||
self._mcu = mcu
|
self._mcu = mcu
|
||||||
self._oid = mcu.create_oid()
|
self._oid = mcu.create_oid()
|
||||||
self._last_clock = 0
|
self._last_clock = 0
|
||||||
|
@ -510,14 +510,14 @@ class MCU:
|
||||||
def create_digital_out(self, pin, max_duration=2.):
|
def create_digital_out(self, pin, max_duration=2.):
|
||||||
max_duration = int(max_duration * self._mcu_freq)
|
max_duration = int(max_duration * self._mcu_freq)
|
||||||
return MCU_digital_out(self, pin, max_duration)
|
return MCU_digital_out(self, pin, max_duration)
|
||||||
def create_pwm(self, pin, hard_cycle_ticks, max_duration=2.):
|
def create_pwm(self, pin, cycle_time, hard_cycle_ticks=0, max_duration=2.):
|
||||||
max_duration = int(max_duration * self._mcu_freq)
|
max_duration = int(max_duration * self._mcu_freq)
|
||||||
if hard_cycle_ticks:
|
if hard_cycle_ticks:
|
||||||
return MCU_pwm(self, pin, hard_cycle_ticks, max_duration)
|
return MCU_pwm(self, pin, hard_cycle_ticks, max_duration, True)
|
||||||
if hard_cycle_ticks < 0:
|
if hard_cycle_ticks < 0:
|
||||||
return MCU_digital_out(self, pin, max_duration)
|
return MCU_digital_out(self, pin, max_duration)
|
||||||
cycle_ticks = int(self._mcu_freq / 10.)
|
cycle_ticks = int(cycle_time * self._mcu_freq)
|
||||||
return MCU_pwm(self, pin, cycle_ticks, max_duration, hard_pwm=False)
|
return MCU_pwm(self, pin, cycle_ticks, max_duration, False)
|
||||||
def create_adc(self, pin):
|
def create_adc(self, pin):
|
||||||
return MCU_adc(self, pin)
|
return MCU_adc(self, pin)
|
||||||
# Clock syncing
|
# Clock syncing
|
||||||
|
|
Loading…
Reference in New Issue