Skip to content

Commit

Permalink
LDO Nitehawk MCU template and tachometer proper integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Frix-x authored Feb 26, 2024
1 parent 8508191 commit a2f8671
Show file tree
Hide file tree
Showing 15 changed files with 191 additions and 179 deletions.
14 changes: 14 additions & 0 deletions config/hardware/fans/hotend_fan_tachometer.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[gcode_macro _USER_VARIABLES]
variable_hotend_fan_tach_enabled: True
gcode:

[heater_fan hotend_fan]
pin: E_FAN
max_power: 1.0
kick_start_time: 0.100
heater: extruder
heater_temp: 50.0
tachometer_pin: E_FAN_TACHO

# And we also include the tachometer check macros from here
[include ../../../macros/helpers/tachometer_check.cfg]
12 changes: 12 additions & 0 deletions config/hardware/fans/part_fan_tachometer.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[gcode_macro _USER_VARIABLES]
variable_part_fan_tach_enabled: True
gcode:

[fan]
pin: PART_FAN
kick_start_time: 0.100
cycle_time: 0.010
tachometer_pin: PART_FAN_TACHO

# And we also include the tachometer check macros from here
[include ../../../macros/helpers/tachometer_check.cfg]
2 changes: 2 additions & 0 deletions docs/pinout.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ Here is a list of all the "Frix-x names" available to use in your own board_pins
#### Fans

- `E_FAN`: hotend fan. This fan should stay at 100% whenever the hotend is hot, so a PWM capable pin is not mandatory
- `E_FAN_TACHO`: tachometer of the hotend fan, optional and used to validate that the fan is spinning as a safety feature
- `PART_FAN`: part fan used during the print. This pin should be a PWM capable pin to allow modulation of the fan speed
- `PART_FAN_TACHO`: tachometer of the part fan, optional and used to validate that the fan is spinning as a safety feature
- `EXHAUST_FAN`: for an exhaust filter (such as the Voron basic exhaust). This pin should be a PWM capable pin to allow modulation of the fan speed
- `FILTER_FAN`: for a filter (such as a Nevermore filter). This pin should be a PWM capable pin to allow modulation of the fan speed
- `CONTROLLER_FAN`: to cool down your MCUs or electronic bay
Expand Down
5 changes: 5 additions & 0 deletions macros/base/cancel_print.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ gcode:
{% set bed_mesh_enabled = printer["gcode_macro _USER_VARIABLES"].bed_mesh_enabled %}
{% set filament_sensor_enabled = printer["gcode_macro _USER_VARIABLES"].filament_sensor_enabled %}
{% set filter_default_time = printer["gcode_macro _USER_VARIABLES"].filter_default_time_on_end_print|default(600)|int %}
{% set hotend_fan_tach_enabled = printer["gcode_macro _USER_VARIABLES"].hotend_fan_tach_enabled %}

PARK

Expand All @@ -33,6 +34,10 @@ gcode:
SET_HEATER_TEMPERATURE HEATER=extruder TARGET={safe_extruder_temp}
{% endif %}

{% if hotend_fan_tach_enabled %}
UPDATE_DELAYED_GCODE ID=_BACKGROUND_HOTEND_TACHO_CHECK DURATION=0
{% endif %}

M107
M400

Expand Down
5 changes: 5 additions & 0 deletions macros/base/end_print.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ gcode:
{% set bed_mesh_enabled = printer["gcode_macro _USER_VARIABLES"].bed_mesh_enabled %}
{% set filter_default_time = printer["gcode_macro _USER_VARIABLES"].filter_default_time_on_end_print|default(600)|int %}
{% set filament_sensor_enabled = printer["gcode_macro _USER_VARIABLES"].filament_sensor_enabled %}
{% set hotend_fan_tach_enabled = printer["gcode_macro _USER_VARIABLES"].hotend_fan_tach_enabled %}

PARK

Expand All @@ -33,6 +34,10 @@ gcode:
SET_HEATER_TEMPERATURE HEATER=extruder TARGET={safe_extruder_temp}
{% endif %}

{% if hotend_fan_tach_enabled %}
UPDATE_DELAYED_GCODE ID=_BACKGROUND_HOTEND_TACHO_CHECK DURATION=0
{% endif %}

M107
M400

Expand Down
15 changes: 15 additions & 0 deletions macros/base/start_print.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ gcode:
{% set firmware_retraction_enabled = printer["gcode_macro _USER_VARIABLES"].firmware_retraction_enabled %}
{% set filter_enabled = printer["gcode_macro _USER_VARIABLES"].filter_enabled %}
{% set filament_sensor_enabled = printer["gcode_macro _USER_VARIABLES"].filament_sensor_enabled %}
{% set part_fan_tach_enabled = printer["gcode_macro _USER_VARIABLES"].part_fan_tach_enabled %}
{% set hotend_fan_tach_enabled = printer["gcode_macro _USER_VARIABLES"].hotend_fan_tach_enabled %}

{% if MATERIAL not in printer["gcode_macro _USER_VARIABLES"].material_parameters %}
RESPOND MSG="Material '{MATERIAL}' is unknown!"
Expand Down Expand Up @@ -96,6 +98,19 @@ gcode:
STOP_FILTER
{% endif %}

# If a tachometer is enabled on one of the fans, we check them:
# - It's done only once for the part fan to be sure nothing block it before starting the print
# - And as a safety feature, we start a monitoring loop for the hotend fan (that is automatically stopped at the end of a print)
{% if part_fan_tach_enabled %}
M106 S255
G4 P2000
_PART_FAN_CHECK
M106 S0
{% endif %}
{% if hotend_fan_tach_enabled %}
UPDATE_DELAYED_GCODE ID=_BACKGROUND_HOTEND_TACHO_CHECK DURATION=1
{% endif %}

SET_GCODE_OFFSET Z=0
M221 S100
M220 S100
Expand Down
25 changes: 0 additions & 25 deletions macros/hardware_functions/tacho_macros.cfg

This file was deleted.

44 changes: 44 additions & 0 deletions macros/helpers/tachometer_check.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
## This config file contains macros that are used in conjuction with tacho-enabled hotend and part fans

# Monitoring loop for hotend fan safety check
[delayed_gcode _BACKGROUND_HOTEND_TACHO_CHECK]
gcode:
_HOTEND_FAN_CHECK
UPDATE_DELAYED_GCODE ID=_BACKGROUND_HOTEND_TACHO_CHECK DURATION=3

[gcode_macro _HOTEND_FAN_CHECK]
description: Check the hotend fan tachometer to verify that it is running effectively
variable_he_stop_count: 0
gcode:
{% set min_rpm = 1000|float %} # This is a relatively low value adapted to all fans to check that they are effectively running
{% 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}
RESPOND MSG="Hotend fan stoppage detected for {(he_stop_count+1)*3}sec (max {max_consecutive_stops*3}sec allowed)"
M400
{% if printer["gcode_macro _HOTEND_FAN_CHECK"].he_stop_count|int >= max_consecutive_stops-1 %}
CANCEL_PRINT
{% endif %}
{% else %}
SET_GCODE_VARIABLE MACRO=_HOTEND_FAN_CHECK VARIABLE=he_stop_count VALUE=0
{% endif %}


[gcode_macro _PART_FAN_CHECK]
description: Check the part fan tachometer to verify that it is running effectively
gcode:
{% if printer.fan.rpm is not none %}
{% if printer.fan.rpm > 1000 %} # This is a relatively low value adapted to all fans to check that they are effectively running
{action_respond_info("Part fan OK!")}
{% else %}
M400
CANCEL_PRINT
{action_raise_error("Hotend fan stoppage detected, print was canceled!")}
{% endif %}
{% endif %}
1 change: 1 addition & 0 deletions user_templates/mcu_defaults/main/BTT_SKR_3.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#-------------------------------------#
#### BTT SKR3 definition ####
#-------------------------------------#
Expand Down
1 change: 1 addition & 0 deletions user_templates/mcu_defaults/main/BTT_SKR_Pro_V1.2.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#----------------------------------------#
#### BTT SKR Pro v1.2 definition ########
#----------------------------------------#
Expand Down
4 changes: 3 additions & 1 deletion user_templates/mcu_defaults/main/MY-OWN-CUSTOM-TEMPLATE.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ aliases:
E_HEATER= , E_TEMPERATURE= ,
BED_HEATER= , BED_TEMPERATURE= ,

PART_FAN= , E_FAN= ,
PART_FAN= , E_FAN= ,
PART_FAN_TACHO , E_FAN_TACHO ,

CONTROLLER_FAN= ,
EXHAUST_FAN= ,
FILTER_FAN= ,
Expand Down
152 changes: 0 additions & 152 deletions user_templates/mcu_defaults/toolhead/LDO_Nighthawk-SB_v1.0.cfg

This file was deleted.

Loading

0 comments on commit a2f8671

Please sign in to comment.