- Split the macro files into folders by topic (print, heating, afc, pressure_advance, spoolman, leds, sensors); klipper-macros.cfg is the one file printer.cfg includes. Macros moved unchanged; the effective config is identical apart from the paths of the PA shell scripts. - Add the modified Blobifier (Turtleblobifier for AFC) and define [save_variables] once in save_variables.cfg instead of in both blobifier.cfg and the PA macros (same file, bd_pa_variables.cfg). - PRINT_WARMUP: heat to the loaded lane's temperature before the first tool change. AFC skips heating when the loaded lane's tool number is not in the print file's temperature list, and the unload then failed below min_extrude_temp. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
303 lines
14 KiB
INI
303 lines
14 KiB
INI
# Filament drying on the heated bed: START_DRYING, STOP_DRYING, STATUS_DRYING
|
|
|
|
###########################################################
|
|
# Filament Drying #
|
|
###########################################################
|
|
# #
|
|
# Macro Settings #
|
|
# Z-axis bed movement - value in mm #
|
|
# Chamber with chamber heater - value in degrees Celsius #
|
|
# Bed - value in degrees Celsius #
|
|
# Drying duration - value in minutes #
|
|
# Recirculation fan - value in % #
|
|
# Recirculation runtime - value in minutes #
|
|
# Recirculation wait time - value in minutes #
|
|
# Exhaust fan - value in % #
|
|
# Exhaust runtime - value in minutes #
|
|
# Exhaust wait time - value in minutes #
|
|
# Setting run and wait times to "0" will keep #
|
|
# the corresponding fan running continuously #
|
|
# #
|
|
###########################################################
|
|
[gcode_macro START_DRYING]
|
|
description: Start the filament dryer for the heated bed.
|
|
gcode:
|
|
# Drying parameters
|
|
{% set MaxChamberTemperature = 60.0 %}
|
|
{% set MaxBedTemperature = 100.0 %}
|
|
|
|
BEDFANSFAST
|
|
|
|
# Check the chamber and bed temperatures
|
|
{% set Chamber = params.CHAMBER|default(25.0)|float %}
|
|
{% set Bed = params.BED|default(45.0)|float %}
|
|
|
|
{% if Chamber < 0 %}
|
|
M118 Error: Chamber temperature cannot be negative.
|
|
M117 Error: Chamber temperature negative.
|
|
{% set SkipRemainingCommands = True %}
|
|
{% elif Chamber > MaxChamberTemperature %}
|
|
M118 Warning: Chamber temperature exceeds the maximum value of { MaxChamberTemperature }°C. Drying will be stopped.
|
|
M117 Warning: Chamber temperature exceeds the maximum value of { MaxChamberTemperature }°C. Drying will be stopped.
|
|
{% set SkipRemainingCommands = True %}
|
|
{% else %}
|
|
{% set SkipRemainingCommands = False %}
|
|
{% endif %}
|
|
|
|
{% if not SkipRemainingCommands %}
|
|
{% if Bed < 0 %}
|
|
M118 Error: Bed temperature cannot be negative.
|
|
M117 Error: Bed temperature negative.
|
|
{% set SkipRemainingCommands = True %}
|
|
{% elif Bed == 0 %}
|
|
M118 Error: Bed temperature is 0 degrees. How will drying be achieved?
|
|
M117 Error: Bed temperature is 0 degrees. How will drying be achieved?
|
|
{% set SkipRemainingCommands = True %}
|
|
{% elif Bed > MaxBedTemperature %}
|
|
M118 Warning: Bed temperature exceeds the maximum value of { MaxBedTemperature }°C. Drying will be stopped.
|
|
M117 Warning: Bed temperature exceeds the maximum value of { MaxBedTemperature }°C. Drying will be stopped.
|
|
{% set SkipRemainingCommands = True %}
|
|
{% else %}
|
|
{% set SkipRemainingCommands = False %}
|
|
{% endif %}
|
|
{% endif %}
|
|
|
|
|
|
# Check exhaust and recirculation fan values
|
|
{% set Exhaust = params.EXHAUST|default(100)|int %}
|
|
{% set Recirculation = params.RECIRCULATION|default(100)|int %}
|
|
|
|
{% if Exhaust < 0 %}
|
|
M118 Error: Exhaust value cannot be negative.
|
|
M117 Error: Exhaust value negative.
|
|
{% set SkipRemainingCommands = True %}
|
|
{% elif Recirculation < 0 %}
|
|
M118 Error: Recirculation value cannot be negative.
|
|
M117 Error: Recirculation value negative.
|
|
{% set SkipRemainingCommands = True %}
|
|
{% elif Exhaust > 100 %}
|
|
M118 Warning: Exhaust value exceeds the maximum value of 100%. Value will be limited to 100%.
|
|
M117 Warning: Exhaust value exceeds the maximum value of 100%. Value will be limited to 100%.
|
|
{% set Exhaust = 100 %}
|
|
{% elif Recirculation > 100 %}
|
|
M118 Warning: Recirculation value exceeds the maximum value of 100%. Value will be limited to 100%.
|
|
M117 Warning: Recirculation value exceeds the maximum value of 100%. Value will be limited to 100%.
|
|
{% set Recirculation = 100 %}
|
|
{% endif %}
|
|
|
|
{% if not SkipRemainingCommands %}
|
|
; Enter drying duration in minutes, limited to a maximum of 12 hours (720 minutes)
|
|
{% set DryingDurationMinutes = params.DRYING_DURATION|default(240)|int %}
|
|
{% if DryingDurationMinutes > 720 %}
|
|
{% set DryingDurationMinutes = 720 %}
|
|
M118 Warning: Drying duration exceeds 12 hours. Duration limited to 12 hours.
|
|
M117 Warning: Drying duration exceeds 12 hours. Duration limited to 12 hours.
|
|
{% endif %}
|
|
{% set DryingDuration = DryingDurationMinutes * 60 %}
|
|
|
|
# Recirculation and exhaust fan settings
|
|
{% set WaitTime_ExhaustMinutes = params.WAIT_TIME_EXHAUST|default(60)|int %}
|
|
{% set Runtime_ExhaustMinutes = params.RUNTIME_EXHAUST|default(30)|int %}
|
|
{% set WaitTime_RecirculationMinutes = params.WAIT_TIME_RECIRCULATION|default(60)|int %}
|
|
{% set Runtime_RecirculationMinutes = params.RUNTIME_RECIRCULATION|default(30)|int %}
|
|
|
|
# Check wait and runtime settings
|
|
{% if WaitTime_ExhaustMinutes < 0 or Runtime_ExhaustMinutes < 0 or WaitTime_RecirculationMinutes < 0 or Runtime_RecirculationMinutes < 0 %}
|
|
M118 Error: Wait and runtime settings cannot be negative.
|
|
M117 Error: One or more wait or runtime settings are negative.
|
|
{% set SkipRemainingCommands = True %}
|
|
{% endif %}
|
|
|
|
{% if not SkipRemainingCommands %}
|
|
# Convert wait and runtime to seconds
|
|
{% set WaitTime_Exhaust = WaitTime_ExhaustMinutes * 60 %}
|
|
{% set Runtime_Exhaust = Runtime_ExhaustMinutes * 60 %}
|
|
{% set WaitTime_Recirculation = WaitTime_RecirculationMinutes * 60 %}
|
|
{% set Runtime_Recirculation = Runtime_RecirculationMinutes * 60 %}
|
|
|
|
# Convert percentage to PWM value (0-255)
|
|
{% set ExhaustPWM = (Exhaust * 255 / 100)|int %}
|
|
{% set RecirculationPWM = (Recirculation * 255 / 100)|int %}
|
|
|
|
# Ensure PWM values are within the range (0-255)
|
|
{% if ExhaustPWM > 255 %}
|
|
{% set ExhaustPWM = 255 %}
|
|
{% elif ExhaustPWM < 0 %}
|
|
{% set ExhaustPWM = 0 %}
|
|
{% endif %}
|
|
|
|
{% if RecirculationPWM > 255 %}
|
|
{% set RecirculationPWM = 255 %}
|
|
{% elif RecirculationPWM < 0 %}
|
|
{% set RecirculationPWM = 0 %}
|
|
{% endif %}
|
|
|
|
# Issue fan speed warnings if speed is 0
|
|
{% if Exhaust == 0 and (WaitTime_Exhaust > 0 or Runtime_Exhaust > 0) %}
|
|
M118 Warning: Exhaust fan speed is 0, but wait time or runtime specified.
|
|
M117 Warning: Exhaust fan speed is 0, but wait time or runtime specified.
|
|
{% endif %}
|
|
|
|
{% if Recirculation == 0 and (WaitTime_Recirculation > 0 or Runtime_Recirculation > 0) %}
|
|
M118 Warning: Recirculation fan speed is 0, but wait time or runtime specified.
|
|
M117 Warning: Recirculation fan speed is 0, but wait time or runtime specified.
|
|
{% endif %}
|
|
|
|
# Check if fans should run continuously
|
|
{% set ExhaustPermanent = (WaitTime_Exhaust == 0 and Runtime_Exhaust == 0) %}
|
|
{% set RecirculationPermanent = (WaitTime_Recirculation == 0 and Runtime_Recirculation == 0) %}
|
|
|
|
# Check homing status of the toolhead
|
|
{% if printer.toolhead.homed_axes|default("") != "xyz" %}
|
|
M118 Printer is homing!
|
|
M117 Printer is homing!
|
|
G28 ; Home all axes
|
|
M118 Homing completed
|
|
M117 Homing completed
|
|
{% else %}
|
|
M118 Homing already completed!
|
|
M117 Homing already completed!
|
|
{% endif %}
|
|
|
|
G1 X175 Y175 F3000 ; Move the toolhead quickly to X=1, Y=1
|
|
|
|
# Z-axis bed movement
|
|
{% set Z_movement = params.Z_MOVEMENT|default(250.0)|float %}
|
|
{% if Z_movement > 0 %}
|
|
G1 Z+{Z_movement} F1500 ; Move the bed up in the Z-axis at the specified speed
|
|
G1 X175 Y350 Z+{Z_movement} F1500
|
|
M118 Bed moved by Z={Z_movement}
|
|
M117 Bed moved by Z={Z_movement}
|
|
{% endif %}
|
|
|
|
# Wait until the Z-displacement is complete
|
|
M118 Wait for completion of Z-displacement...
|
|
M117 Wait for completion of Z-displacement...
|
|
|
|
# Repeat M114 to ensure that the Z position is reached
|
|
M114 # Query the current position
|
|
G4 P1000 # Short pause to query the Z position
|
|
|
|
# When Z-movement is complete, start countdown
|
|
M118 Z-displacement completed.
|
|
M117 Z-displacement completed.
|
|
# Wait 30 seconds
|
|
M118 Please insert filament and close the door! Drying starts in 30 seconds.
|
|
M117 Please insert filament and close the door! Drying starts in 30 seconds.
|
|
G4 P5000 # Wait 5 seconds
|
|
# Loop for the countdown from 25 seconds to 5 seconds
|
|
{% for i in range(1, 6) %}
|
|
M118 Drying in {25 - 5 * (i - 1)} seconds!
|
|
M117 Drying in {25 - 5 * (i - 1)} seconds!
|
|
G4 P5000 # wait 5 seconds
|
|
{% endfor %}
|
|
|
|
# Turn on heating elements
|
|
M140 S{ Bed } ; Set bed temperature without waiting.
|
|
M141 S{ Chamber } ; [OPTIONAL] Set chamber temperature.
|
|
|
|
# Set dryer status and start timer
|
|
SET_GCODE_VARIABLE MACRO=STATUS_DRYING VARIABLE=time_remaining VALUE={ DryingDuration }
|
|
SET_GCODE_VARIABLE MACRO=STATUS_DRYING VARIABLE=bed_temperature VALUE={ Bed }
|
|
SET_GCODE_VARIABLE MACRO=STATUS_DRYING VARIABLE=chamber_temperature VALUE={ Chamber }
|
|
SET_GCODE_VARIABLE MACRO=STATUS_DRYING VARIABLE=exhaust VALUE={ Exhaust }
|
|
SET_GCODE_VARIABLE MACRO=STATUS_DRYING VARIABLE=exhaust_pwm VALUE={ ExhaustPWM }
|
|
SET_GCODE_VARIABLE MACRO=STATUS_DRYING VARIABLE=recirculation VALUE={ Recirculation }
|
|
SET_GCODE_VARIABLE MACRO=STATUS_DRYING VARIABLE=recirculation_pwm VALUE={ RecirculationPWM }
|
|
SET_GCODE_VARIABLE MACRO=STATUS_DRYING VARIABLE=waittime_exhaust VALUE={ WaitTime_Exhaust }
|
|
SET_GCODE_VARIABLE MACRO=STATUS_DRYING VARIABLE=runtime_exhaust VALUE={ Runtime_Exhaust }
|
|
SET_GCODE_VARIABLE MACRO=STATUS_DRYING VARIABLE=waittime_recirculation VALUE={ WaitTime_Recirculation }
|
|
SET_GCODE_VARIABLE MACRO=STATUS_DRYING VARIABLE=runtime_recirculation VALUE={ Runtime_Recirculation }
|
|
SET_GCODE_VARIABLE MACRO=STATUS_DRYING VARIABLE=exhaust_permanent VALUE={ ExhaustPermanent }
|
|
SET_GCODE_VARIABLE MACRO=STATUS_DRYING VARIABLE=recirculation_permanent VALUE={ RecirculationPermanent }
|
|
|
|
# Start the delayed gcode for timer
|
|
UPDATE_DELAYED_GCODE ID=DRYING_TIMER DURATION=1
|
|
|
|
M118 Drying in progress...
|
|
M117 Drying in progress...
|
|
{% endif %}
|
|
{% endif %}
|
|
|
|
[gcode_macro STOP_DRYING]
|
|
description: Stops the filament drying process
|
|
gcode:
|
|
# Turn off heating elements and fans
|
|
M140 S0 ; Turn off heating element
|
|
M141 S0 ; [OPTIONAL] Turn off chamber heater/fan
|
|
M106 P2 S0 ; Turn off recirculation fan
|
|
M106 P3 S0 ; Turn off exhaust fan
|
|
|
|
# Stop timer and update status
|
|
SET_GCODE_VARIABLE MACRO=STATUS_DRYING VARIABLE=time_remaining VALUE=0
|
|
UPDATE_DELAYED_GCODE ID=DRYING_TIMER DURATION=0
|
|
M117 Drying stopped! Please remove filament.
|
|
M118 Drying stopped! Please remove filament.
|
|
|
|
# Query print bed temperature
|
|
{% if printer.heater_bed.temperature > 40 %}
|
|
M117 Attention: Print bed above 40°C! Take care when removing the filament roll.
|
|
M118 Attention: Print bed above 40°C! Caution when removing the filament roll.
|
|
{% else %}
|
|
M117 Print bed temperature OK.
|
|
M118 Print bed temperature OK.
|
|
{% endif %}
|
|
|
|
# Send Telegram notification
|
|
#RESPOND PREFIX=tgnotify MSG="Filament drying has been stopped. Please remove the filament."
|
|
|
|
[gcode_macro STATUS_DRYING]
|
|
variable_time_remaining: 0
|
|
variable_bed_temperature: 0
|
|
variable_chamber_temperature: 0
|
|
variable_exhaust: 100
|
|
variable_exhaust_pwm: 255
|
|
variable_recirculation: 100
|
|
variable_recirculation_pwm: 255
|
|
variable_waittime_exhaust: 60
|
|
variable_runtime_exhaust: 30
|
|
variable_waittime_recirculation: 60
|
|
variable_runtime_recirculation: 30
|
|
variable_exhaust_permanent: False
|
|
variable_recirculation_permanent: False
|
|
gcode:
|
|
{% set cycle_time_exhaust = waittime_exhaust + runtime_exhaust %}
|
|
{% set cycle_time_recirculation = waittime_recirculation + runtime_recirculation %}
|
|
{% if time_remaining > 0 %}
|
|
{% set current_time = time_remaining - 1 %}
|
|
|
|
{% set hours = (current_time // 3600) %}
|
|
{% set minutes = (current_time % 3600) // 60 %}
|
|
{% set seconds = (current_time % 3600) % 60 %}
|
|
|
|
{% set time_display = "%02d:%02d:%02d" % (hours, minutes, seconds) %}
|
|
|
|
# Update fan states based on the current cycle
|
|
{% if exhaust_permanent or (current_time % cycle_time_exhaust) < runtime_exhaust %}
|
|
; Exhaust fan running
|
|
M106 P3 S{ exhaust_pwm }
|
|
{% else %}
|
|
; Exhaust fan off
|
|
M106 P3 S0
|
|
{% endif %}
|
|
|
|
{% if recirculation_permanent or (current_time % cycle_time_recirculation) < runtime_recirculation %}
|
|
# Recirculation fan running
|
|
M106 P2 S{ recirculation_pwm }
|
|
{% else %}
|
|
# Recirculation fan off
|
|
M106 P2 S0
|
|
{% endif %}
|
|
|
|
M117 Remaining time: { time_display }
|
|
SET_GCODE_VARIABLE MACRO=STATUS_DRYING VARIABLE=time_remaining VALUE={ current_time }
|
|
{% else %}
|
|
# Stop drying when time runs out
|
|
STOP_DRYING
|
|
{% endif %}
|
|
|
|
[delayed_gcode DRYING_TIMER]
|
|
gcode:
|
|
UPDATE_DELAYED_GCODE ID=DRYING_TIMER DURATION=1
|
|
STATUS_DRYING
|