fan: add enable_pin option (#5732)
Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
This commit is contained in:
parent
6ba0242900
commit
9f8f3cd77d
|
@ -2520,6 +2520,12 @@ pin:
|
||||||
# enough for fans below 10000 RPM at 2 PPR. This must be smaller than
|
# enough for fans below 10000 RPM at 2 PPR. This must be smaller than
|
||||||
# 30/(tachometer_ppr*rpm), with some margin, where rpm is the
|
# 30/(tachometer_ppr*rpm), with some margin, where rpm is the
|
||||||
# maximum speed (in RPM) of the fan.
|
# maximum speed (in RPM) of the fan.
|
||||||
|
#enable_pin:
|
||||||
|
# Optional pin to enable power to the fan. This can be useful for fans
|
||||||
|
# with dedicated PWM inputs. Some of these fans stay on even at 0% PWM
|
||||||
|
# input. In such a case, the PWM pin can be used normally, and e.g. a
|
||||||
|
# ground-switched FET(standard fan pin) can be used to control power to
|
||||||
|
# the fan.
|
||||||
```
|
```
|
||||||
|
|
||||||
### [heater_fan]
|
### [heater_fan]
|
||||||
|
@ -2541,6 +2547,7 @@ a shutdown_speed equal to max_power.
|
||||||
#tachometer_pin:
|
#tachometer_pin:
|
||||||
#tachometer_ppr:
|
#tachometer_ppr:
|
||||||
#tachometer_poll_interval:
|
#tachometer_poll_interval:
|
||||||
|
#enable_pin:
|
||||||
# See the "fan" section for a description of the above parameters.
|
# See the "fan" section for a description of the above parameters.
|
||||||
#heater: extruder
|
#heater: extruder
|
||||||
# Name of the config section defining the heater that this fan is
|
# Name of the config section defining the heater that this fan is
|
||||||
|
@ -2577,6 +2584,7 @@ watched component.
|
||||||
#tachometer_pin:
|
#tachometer_pin:
|
||||||
#tachometer_ppr:
|
#tachometer_ppr:
|
||||||
#tachometer_poll_interval:
|
#tachometer_poll_interval:
|
||||||
|
#enable_pin:
|
||||||
# See the "fan" section for a description of the above parameters.
|
# See the "fan" section for a description of the above parameters.
|
||||||
#fan_speed: 1.0
|
#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
|
||||||
|
@ -2622,6 +2630,7 @@ information.
|
||||||
#tachometer_pin:
|
#tachometer_pin:
|
||||||
#tachometer_ppr:
|
#tachometer_ppr:
|
||||||
#tachometer_poll_interval:
|
#tachometer_poll_interval:
|
||||||
|
#enable_pin:
|
||||||
# See the "fan" section for a description of the above parameters.
|
# See the "fan" section for a description of the above parameters.
|
||||||
#sensor_type:
|
#sensor_type:
|
||||||
#sensor_pin:
|
#sensor_pin:
|
||||||
|
@ -2679,6 +2688,7 @@ with the SET_FAN_SPEED [gcode command](G-Codes.md#fan_generic).
|
||||||
#tachometer_pin:
|
#tachometer_pin:
|
||||||
#tachometer_ppr:
|
#tachometer_ppr:
|
||||||
#tachometer_poll_interval:
|
#tachometer_poll_interval:
|
||||||
|
#enable_pin:
|
||||||
# See the "fan" section for a description of the above parameters.
|
# See the "fan" section for a description of the above parameters.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,12 @@ class Fan:
|
||||||
shutdown_power = max(0., min(self.max_power, shutdown_speed))
|
shutdown_power = max(0., min(self.max_power, shutdown_speed))
|
||||||
self.mcu_fan.setup_start_value(0., shutdown_power)
|
self.mcu_fan.setup_start_value(0., shutdown_power)
|
||||||
|
|
||||||
|
self.enable_pin = None
|
||||||
|
enable_pin = config.get('enable_pin', None)
|
||||||
|
if enable_pin is not None:
|
||||||
|
self.enable_pin = ppins.setup_pin('digital_out', enable_pin)
|
||||||
|
self.enable_pin.setup_max_duration(0.)
|
||||||
|
|
||||||
# Setup tachometer
|
# Setup tachometer
|
||||||
self.tachometer = FanTachometer(config)
|
self.tachometer = FanTachometer(config)
|
||||||
|
|
||||||
|
@ -46,6 +52,11 @@ class Fan:
|
||||||
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)
|
||||||
|
if self.enable_pin:
|
||||||
|
if value > 0 and self.last_fan_value == 0:
|
||||||
|
self.enable_pin.set_digital(print_time, 1)
|
||||||
|
elif value == 0 and self.last_fan_value > 0:
|
||||||
|
self.enable_pin.set_digital(print_time, 0)
|
||||||
if (value and value < self.max_power and self.kick_start_time
|
if (value and value < self.max_power and self.kick_start_time
|
||||||
and (not self.last_fan_value or value - self.last_fan_value > .5)):
|
and (not self.last_fan_value or value - self.last_fan_value > .5)):
|
||||||
# Run fan at full speed for specified kick_start_time
|
# Run fan at full speed for specified kick_start_time
|
||||||
|
|
Loading…
Reference in New Issue