-
Notifications
You must be signed in to change notification settings - Fork 0
/
fan_tach.cfg
49 lines (45 loc) · 2.25 KB
/
fan_tach.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Author: alch3my#9819
# Requires a 3-wire fan with tachometer_pin defined. https://www.klipper3d.org/Config_Reference.html#heater_fan
# The tach wire can be connected to a spare endstop pin.
# Don't forget a pullup (^) on the tach pin (example: tachometer_pin: ^P1.29)
# Monitoring loop. Begins at Klipper start.
[delayed_gcode CHECK_ALL_FANS]
initial_duration: 1
gcode:
HOTEND_FAN_CHECK
UPDATE_DELAYED_GCODE ID=CHECK_ALL_FANS DURATION=3
# Change min_rpm and max_consecutive_stops to your desired values.
[gcode_macro HOTEND_FAN_CHECK]
variable_he_stop_count: 0
gcode:
{% set min_rpm = 8000|float %}
{% set max_consecutive_stops = 3 %}
{% set rpm = printer['heater_fan hotend_fan'].rpm|float %}
{% set he_target = printer[printer.toolhead.extruder].target|float %}
{% set he_temp = printer[printer.toolhead.extruder].temperature|float %}
{% set fan_on_temp = printer.configfile.settings['heater_fan hotend_fan'].heater_temp|float %}
{% set he_stop_count = printer["gcode_macro HOTEND_FAN_CHECK"].he_stop_count|int %}
{% if (he_target >= fan_on_temp) and (rpm < min_rpm) and (he_temp >= fan_on_temp) %}
SET_GCODE_VARIABLE MACRO=HOTEND_FAN_CHECK VARIABLE=he_stop_count VALUE={he_stop_count + 1}
M118 WARNING: Fan stoppage detected ({he_stop_count+1}/{max_consecutive_stops}).
M400
{% if printer["gcode_macro HOTEND_FAN_CHECK"].he_stop_count|int >= max_consecutive_stops-1 %}
FAN_STOPPAGE_ROUTINE
{% endif %}
{% else %}
SET_GCODE_VARIABLE MACRO=HOTEND_FAN_CHECK VARIABLE=he_stop_count VALUE=0
{% endif %}
# Insert the gcode that you want to run when a fan stoppage is detected.
# This runs every ~3 seconds until the stop conditions are cleared.
[gcode_macro FAN_STOPPAGE_ROUTINE]
gcode:
# If not already paused
{% if printer['pause_resume'].is_paused|int == 0 %}
M117 !!FAN STOPPAGE!!
PAUSE
# Turn off the hotend.
# !! Don't forget to turn your hotend back on before resume. !!
# -- If using this guide's pause/resume macros (in useful_macros.html), the hotend will automatically reheat on resume
# -- (as long as the hotend is not turned off BEFORE pause is called)
SET_HEATER_TEMPERATURE HEATER=extruder TARGET=0
{% endif %}