Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LDO Nitehawk MCU template and tachometer management #505

Merged
merged 3 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]
20 changes: 20 additions & 0 deletions config/mcu_definitions/toolhead/LDO_Nitehawk-SB_v1.0.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[board_pins toolhead_manufacturer]
mcu: toolhead
aliases:
MCU_EMOT_EN=gpio25 , MCU_EMOT_STEP=gpio23 , MCU_EMOT_DIR=gpio24 , MCU_EMOT_UART=gpio0 , MCU_EMOT_TX=gpio1 ,

MCU_ENDSTOP_X=gpio13 , MCU_ENDSTOP_Y=gpio12 ,
MCU_HV_ENDSTOP=gpio10 ,

MCU_FAN0=gpio5 , MCU_FAN1=gpio6 ,
MCU_PWM0=gpio16 , MCU_PWM1=gpio17 ,

MCU_TEMP=gpio29 ,

MCU_HEAT=gpio9 , MCU_HEAT_CHAMBER=gpio28 , MCU_NH_TEMP=gpio26 ,

MCU_RGB=gpio17 , MCU_ACTIVITY_LED=gpio8 ,

MCU_ADXL_CS=gpio21 , MCU_ADXL_SCK=gpio18 , MCU_ADXL_MOSI=gpio20 , MCU_ADXL_MISO=gpio19 ,

MCU_FS=gpio3 , MCU_SU=gpio2 , MCU_ST_UART_TX=gpio1 , MCU_ST_UART_RX=gpio0 ,
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
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
84 changes: 84 additions & 0 deletions user_templates/mcu_defaults/toolhead/LDO_Nitehawk-SB_v1.0.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@

#-------------------------------------------------------#
#### LDO Nighthawk SB toolhead v1 MCU definition ########
#-------------------------------------------------------#

[mcu toolhead]
##--------------------------------------------------------------------
serial: /dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0 ##### <--- change-me-to-the-correct-serial hint: ls /dev/serial/by-id/* #
##--------------------------------------------------------------------

# If you want to override the wiring of the LDO Nighthawk, keep in mind that this
# board is defined using the "toolhead" name. So you should use "pin: toolhead:PIN_NAME"
# in your own overrides.cfg files.

[include config/mcu_definitions/toolhead/LDO_Nitehawk-SB_v1.0.cfg] # Do not remove this line
[board_pins nitehawk_mcu]
mcu: toolhead
aliases:
E_STEP=MCU_EMOT_STEP , E_DIR=MCU_EMOT_DIR , E_ENABLE=MCU_EMOT_EN , E_TMCUART=MCU_EMOT_UART ,

X_STOP=MCU_ENDSTOP_X ,
PROBE_INPUT=MCU_HV_ENDSTOP ,

E_HEATER=MCU_HEAT , E_TEMPERATURE=MCU_TEMP , CHAMBER_TEMPERATURE=MCU_HEAT_CHAMBER ,
NH_MCU_TEMP=MCU_NH_TEMP ,

PART_FAN=MCU_FAN1 , E_FAN=MCU_FAN0 ,
PART_FAN_TACHO=MCU_PWM0 , E_FAN_TACHO=MCU_PWM1 ,

STATUS_NEOPIXEL=MCU_RGB , STATUS_BOARD=MCU_ACTIVITY_LED ,

ADXL_CS=MCU_ADXL_CS , ADXL_SCLK=MCU_ADXL_SCK , ADXL_MOSI=MCU_ADXL_MOSI , ADXL_MISO=MCU_ADXL_MISO ,

TX_PIN=MCU_ST_UART_TX ,


#----------------------------------------#
# LDO Nighthawk-SB v1 pins remapping #
#----------------------------------------#

# These pins overrides are automatically added when you select the LDO
# toolhead MCU during the installation process. They should provide a
# good base to work with. Feel free to adapt to your board if needed!

[extruder]
step_pin: toolhead:E_STEP
dir_pin: toolhead:E_DIR
enable_pin: !toolhead:E_ENABLE
heater_pin: toolhead:E_HEATER
sensor_pin: toolhead:E_TEMPERATURE
pullup_resistor: 2200

[tmc2209 extruder]
uart_pin: toolhead:E_TMCUART
tx_pin: toolhead:TX_PIN
sense_resistor: 0.100

[probe]
pin: ^toolhead:PROBE_INPUT

[fan]
pin: toolhead:PART_FAN
#tachometer_pin: toolhead:PART_FAN_TACHO

[heater_fan hotend_fan]
pin: toolhead:E_FAN
# tachometer_pin: toolhead:E_FAN_TACHO

## Uncomment the following line if not using sensorless homing
## and having the X endstop plugged to the toolhead MCU
# [stepper_x]
# endstop_pin: ^toolhead:X_STOP

[neopixel status_leds]
pin: toolhead:STATUS_NEOPIXEL

## Nitehawk PCB temperature sensor
[temperature_sensor nh_temp]
sensor_type: CMFB103F3950FANT
sensor_pin: toolhead:NH_MCU_TEMP
pullup_resistor: 2200
min_temp: 0
max_temp: 100

6 changes: 5 additions & 1 deletion user_templates/printer.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
### --------------------------------------------------------------------------------------
# [include config/hardware/fans/hotend_fan.cfg]
# [include config/hardware/fans/part_fan.cfg]

# [include config/hardware/fans/hotend_fan_tachometer.cfg] # When having a tachometer monitoring hotend fan speed
# [include config/hardware/fans/part_fan_tachometer.cfg] # When having a tachometer monitoring part fan speed

# [include config/hardware/fans/controller_fan.cfg]
# [include config/hardware/fans/rpi_fan.cfg]
# ----------------------------------------------------------------------------------------
Expand Down Expand Up @@ -156,7 +160,7 @@
# [include config/hardware/temperature_sensors/cabinet_temp.cfg]
# [include config/hardware/temperature_sensors/chamber_temp.cfg]
# [include config/hardware/temperature_sensors/chamber_temp_ds18b20.cfg] # Specific for DS18B20 directly connected to the Pi
# [include config/hardware/temperature_sensors/chamber_temp_toolhead.cfg] # This is not recommended as toolhead board temperature sensors are not accurate
# [include config/hardware/temperature_sensors/chamber_temp_toolhead.cfg] # This is to use a toolhead integrated temperature sensor (or an external one as it's done on the LDO Nitehawk)
# ----------------------------------------------------------------------------------------


Expand Down