Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Klipper3d/klipper.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordalegaard <dalegaard@users.noreply.github.com>2022-09-03 19:23:55 +0300
committerGitHub <noreply@github.com>2022-09-03 19:23:55 +0300
commit9f8f3cd77d97339bd825053b064ae4d08d5d6902 (patch)
tree472679e93f591a379447ed761830cca9324ec630
parent6ba02429009df34ba348abe80023ce3a3530bc58 (diff)
fan: add enable_pin option (#5732)
Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
-rw-r--r--docs/Config_Reference.md10
-rw-r--r--klippy/extras/fan.py11
2 files changed, 21 insertions, 0 deletions
diff --git a/docs/Config_Reference.md b/docs/Config_Reference.md
index 833e14570..90bf1770f 100644
--- a/docs/Config_Reference.md
+++ b/docs/Config_Reference.md
@@ -2520,6 +2520,12 @@ pin:
# 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
# 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]
@@ -2541,6 +2547,7 @@ a shutdown_speed equal to max_power.
#tachometer_pin:
#tachometer_ppr:
#tachometer_poll_interval:
+#enable_pin:
# See the "fan" section for a description of the above parameters.
#heater: extruder
# Name of the config section defining the heater that this fan is
@@ -2577,6 +2584,7 @@ watched component.
#tachometer_pin:
#tachometer_ppr:
#tachometer_poll_interval:
+#enable_pin:
# See the "fan" section for a description of the above parameters.
#fan_speed: 1.0
# The fan speed (expressed as a value from 0.0 to 1.0) that the fan
@@ -2622,6 +2630,7 @@ information.
#tachometer_pin:
#tachometer_ppr:
#tachometer_poll_interval:
+#enable_pin:
# See the "fan" section for a description of the above parameters.
#sensor_type:
#sensor_pin:
@@ -2679,6 +2688,7 @@ with the SET_FAN_SPEED [gcode command](G-Codes.md#fan_generic).
#tachometer_pin:
#tachometer_ppr:
#tachometer_poll_interval:
+#enable_pin:
# See the "fan" section for a description of the above parameters.
```
diff --git a/klippy/extras/fan.py b/klippy/extras/fan.py
index 77fdef8a3..d6e687218 100644
--- a/klippy/extras/fan.py
+++ b/klippy/extras/fan.py
@@ -30,6 +30,12 @@ class Fan:
shutdown_power = max(0., min(self.max_power, shutdown_speed))
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
self.tachometer = FanTachometer(config)
@@ -46,6 +52,11 @@ class Fan:
if value == self.last_fan_value:
return
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
and (not self.last_fan_value or value - self.last_fan_value > .5)):
# Run fan at full speed for specified kick_start_time