m106_adjust.cfg modified - 18/04/25 - 09:39:30

This commit is contained in:
pi committed 2025-04-18 09:39:33 +01:00
1 parent 1784795e75
commit 8ca3232b8c
1 file changed
+53
@@ -0,0 +1,53 @@
[gcode_macro M106]
rename_existing: G106
description: Compresses fan speeds into 10–30% range if bed temp ≥ 70°C
# === OVERVIEW ===
# This macro overrides the default M106 behavior to apply a thermal-aware fan speed limiter.
# When the bed temperature is at or above 70°C, it compresses the part cooling fan speed range
# into a safer 10–30% range (i.e., 26–76 PWM) to reduce warping or delamination in high-temp materials.
#
# === WHY USE THIS ===
# - Prevents excessive part cooling when printing materials like ABS, ASA, or PC.
# - Helps maintain stable chamber temperatures and reduce thermal shock.
# - Minimizes curling or layer splitting due to sudden cooling on hot beds.
#
# === HOW TO USE ===
# Simply use M106 S<value> as usual in your G-code or slicer.
# The macro will automatically adjust the fan speed if needed based on bed temperature.
#
# === NOTES ===
# - This logic only applies when the bed temperature is 70°C or higher.
# - Below 70°C, full-range fan control is allowed.
# - You can customize the input/output compression range if needed.
# === PARAMETERS ===
# S: Standard fan speed in 0–255 (required by M106)
# Internal constants:
# min_input = 26 (10% of 255)
# max_input = 255 (100%)
# min_output = 26 (10%)
# max_output = 76 (30%)
gcode:
{% set fan_speed = params.S|default(0)|int %}
{% set bed_temp = printer["heater_bed"].temperature %}
{% set min_input = 26 %}
{% set max_input = 255 %}
{% set min_output = 26 %}
{% set max_output = 76 %}
{% if bed_temp >= 70 %}
# If below threshold, limit fan to the lower compressed range (10–30%)
{% if fan_speed < min_input %}
{% set compressed_speed = min_output %}
{% else %}
{% set compressed_speed = (min_output + ((fan_speed - min_input) * (max_output - min_output) / (max_input - min_input)))|int %}
{% endif %}
G106 S{compressed_speed}
{% else %}
# Below threshold, allow full fan speed as requested
G106 S{fan_speed}
{% endif %}