fan: Scale fan speed requests between 0 and max_power
If the fan's max power is limited by the config, then scale speed requests between 0 and max_power. This makes more sense for typical g-code fan speeds. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
48e9fa04e7
commit
85e6cd865c
|
@ -205,10 +205,10 @@
|
||||||
#heater_temp: 50.0
|
#heater_temp: 50.0
|
||||||
# A temperature (in Celsius) that the heater must drop below before
|
# A temperature (in Celsius) that the heater must drop below before
|
||||||
# the fan is disabled. The default is 50 Celsius.
|
# the fan is disabled. The default is 50 Celsius.
|
||||||
#fan_speed:
|
#fan_speed: 1.0
|
||||||
# The fan speed (expressed as a value from 0.0 to 1.0) that the fan
|
# The fan speed (expressed as a value from 0.0 to 1.0) that the fan
|
||||||
# will be set to when its associated heater is enabled. The default
|
# will be set to when its associated heater is enabled. The default
|
||||||
# is max_power.
|
# is 1.0
|
||||||
|
|
||||||
|
|
||||||
# Additional micro-controllers (one may define any number of sections
|
# Additional micro-controllers (one may define any number of sections
|
||||||
|
|
|
@ -224,7 +224,10 @@ pin: ar9
|
||||||
# enabled for extended periods, while a value of 0.5 would allow the
|
# enabled for extended periods, while a value of 0.5 would allow the
|
||||||
# pin to be enabled for no more than half the time. This setting may
|
# pin to be enabled for no more than half the time. This setting may
|
||||||
# be used to limit the total power output (over extended periods) to
|
# be used to limit the total power output (over extended periods) to
|
||||||
# the fan. The default is 1.0.
|
# the fan. If this value is less than 1.0 then fan speed requests
|
||||||
|
# will be scaled between zero and max_power (for example, if
|
||||||
|
# max_power is .9 and a fan speed of 80% is requested then the fan
|
||||||
|
# power will be set to 72%). The default is 1.0.
|
||||||
#cycle_time: 0.010
|
#cycle_time: 0.010
|
||||||
# The amount of time (in seconds) for each PWM power cycle to the
|
# The amount of time (in seconds) for each PWM power cycle to the
|
||||||
# fan. It is recommended this be 10 milliseconds or greater when
|
# fan. It is recommended this be 10 milliseconds or greater when
|
||||||
|
|
|
@ -19,7 +19,7 @@ class PrinterFan:
|
||||||
hardware_pwm = config.getboolean('hardware_pwm', False)
|
hardware_pwm = config.getboolean('hardware_pwm', False)
|
||||||
self.mcu_fan.setup_cycle_time(cycle_time, hardware_pwm)
|
self.mcu_fan.setup_cycle_time(cycle_time, hardware_pwm)
|
||||||
def set_speed(self, print_time, value):
|
def set_speed(self, print_time, value):
|
||||||
value = max(0., min(self.max_power, value))
|
value = max(0., min(self.max_power, value * self.max_power))
|
||||||
if value == self.last_fan_value:
|
if value == self.last_fan_value:
|
||||||
return
|
return
|
||||||
print_time = max(self.last_fan_time + FAN_MIN_TIME, print_time)
|
print_time = max(self.last_fan_time + FAN_MIN_TIME, print_time)
|
||||||
|
|
|
@ -14,10 +14,8 @@ class PrinterHeaterFan:
|
||||||
self.heater_temp = config.getfloat("heater_temp", 50.0)
|
self.heater_temp = config.getfloat("heater_temp", 50.0)
|
||||||
self.fan = fan.PrinterFan(config)
|
self.fan = fan.PrinterFan(config)
|
||||||
self.mcu = self.fan.mcu_fan.get_mcu()
|
self.mcu = self.fan.mcu_fan.get_mcu()
|
||||||
max_power = self.fan.max_power
|
self.fan_speed = config.getfloat("fan_speed", 1., minval=0., maxval=1.)
|
||||||
self.fan_speed = config.getfloat(
|
self.fan.mcu_fan.setup_start_value(0., self.fan.max_power)
|
||||||
"fan_speed", max_power, minval=0., maxval=max_power)
|
|
||||||
self.fan.mcu_fan.setup_start_value(0., max_power)
|
|
||||||
def printer_state(self, state):
|
def printer_state(self, state):
|
||||||
if state == 'ready':
|
if state == 'ready':
|
||||||
pheater = self.printer.lookup_object('heater')
|
pheater = self.printer.lookup_object('heater')
|
||||||
|
|
Loading…
Reference in New Issue