diff --git a/printer_data/config/CUSTOM/set_material.cfg b/printer_data/config/CUSTOM/set_material.cfg index 8e25c0c..1e11df1 100644 --- a/printer_data/config/CUSTOM/set_material.cfg +++ b/printer_data/config/CUSTOM/set_material.cfg @@ -492,80 +492,6 @@ variable_pa: 0.04 # MAX_FLOW : Max hotend flow in mm³/s (default: 15) # SMOOTH : Optional smoothing (default: 0.045) -[gcode_macro SET_PA] -description: Set Pressure Advance with fully dynamic scaling based on nozzle and flow -variable_pa: 0.04 - -# === OVERVIEW === -# Fully dynamic Pressure Advance tuning: -# - Uses nozzle diameter from printer.cfg -# - Scales PA by nozzle and flow ratio -# - Automatically sets EXP (flow exponent) as 2x nozzle -# - Dynamically sets SMOOTH_TIME unless overridden -# -# === HOW TO USE === -# SET_PA PA= [FLOW=] [MAX_FLOW=] [SMOOTH=] [EXP=] -# -# Example: -# SET_PA PA=0.05 FLOW=30 MAX_FLOW=70 -# SET_PA PA=0.05 ; uses defaults (FLOW=10, MAX_FLOW=15) - -gcode: - {% set base_pa = params.PA|float %} - {% set flow = params.FLOW|default(10.0)|float %} - {% set max_flow = params.MAX_FLOW|default(15.0)|float %} - {% set nozzle = printer.extruder.nozzle_diameter|float %} - - # === Scale PA based on nozzle diameter === - {% if nozzle <= 0.2 %} - {% set nozzle_scale = 1.8 %} - {% elif nozzle <= 0.3 %} - {% set nozzle_scale = 1.4 %} - {% elif nozzle <= 0.4 %} - {% set nozzle_scale = 1.0 %} - {% elif nozzle <= 0.6 %} - {% set nozzle_scale = 0.75 %} - {% elif nozzle <= 0.8 %} - {% set nozzle_scale = 0.5 %} - {% else %} - {% set nozzle_scale = 0.4 %} - {% endif %} - {% set scaled_pa = base_pa * nozzle_scale %} - - # === Calculate exponent from nozzle size unless overridden === - {% set exp = params.EXP|default(2.0 * nozzle)|float %} - - # === Flow ratio and flow scale === - {% set flow_ratio = flow / max_flow %} - {% set flow_scale = flow_ratio ** exp %} - {% set adjusted_pa = scaled_pa * flow_scale %} - - # === Dynamic smoothing time unless overridden === - {% if 'SMOOTH' in params %} - {% set smooth = params.SMOOTH|float %} - {% set smooth_source = "manual" %} - {% else %} - {% if nozzle <= 0.3 %} - {% set smooth = 0.03 %} - {% elif nozzle <= 0.4 %} - {% set smooth = 0.04 %} - {% elif nozzle <= 0.6 %} - {% set smooth = 0.045 %} - {% elif nozzle <= 0.8 %} - {% set smooth = 0.055 %} - {% else %} - {% set smooth = 0.065 %} - {% endif %} - {% set smooth_source = "dynamic" %} - {% endif %} - - # === Set and store final values === - SET_PRESSURE_ADVANCE ADVANCE={adjusted_pa} SMOOTH_TIME={smooth} - SET_GCODE_VARIABLE MACRO=SET_PA VARIABLE=pa VALUE={adjusted_pa} - - # === Logging === - {% set msg = "📐 PA scaled | Nozzle: " ~ nozzle|string ~ "mm | Base: " ~ base_pa|string ~ " ➜ x" ~ nozzle_scale|string ~ " ➜ x" ~ flow_scale|string ~ " (flow^" ~ exp|string ~ ") = " ~ adjusted_pa|string ~ " | Smooth: " ~ smooth|string ~ " (" ~ smooth_source ~ ")" %} - RESPOND MSG="{msg}" diff --git a/printer_data/config/CUSTOM/set_pa.cfg b/printer_data/config/CUSTOM/set_pa.cfg index e69de29..9b7e4d3 100644 --- a/printer_data/config/CUSTOM/set_pa.cfg +++ b/printer_data/config/CUSTOM/set_pa.cfg @@ -0,0 +1,74 @@ +[gcode_macro SET_PA] +description: Set Pressure Advance with fully dynamic scaling based on nozzle and flow +variable_pa: 0.04 + +# === OVERVIEW === +# Fully dynamic Pressure Advance tuning: +# - Uses nozzle diameter from printer.cfg +# - Scales PA by nozzle and flow ratio +# - Automatically sets EXP (flow exponent) as 2x nozzle +# - Dynamically sets SMOOTH_TIME unless overridden +# +# === HOW TO USE === +# SET_PA PA= [FLOW=] [MAX_FLOW=] [SMOOTH=] [EXP=] +# +# Example: +# SET_PA PA=0.05 FLOW=30 MAX_FLOW=70 +# SET_PA PA=0.05 ; uses defaults (FLOW=10, MAX_FLOW=15) + +gcode: + {% set base_pa = params.PA|float %} + {% set flow = params.FLOW|default(10.0)|float %} + {% set max_flow = params.MAX_FLOW|default(15.0)|float %} + {% set nozzle = printer.extruder.nozzle_diameter|float %} + + # === Scale PA based on nozzle diameter === + {% if nozzle <= 0.2 %} + {% set nozzle_scale = 1.8 %} + {% elif nozzle <= 0.3 %} + {% set nozzle_scale = 1.4 %} + {% elif nozzle <= 0.4 %} + {% set nozzle_scale = 1.0 %} + {% elif nozzle <= 0.6 %} + {% set nozzle_scale = 0.75 %} + {% elif nozzle <= 0.8 %} + {% set nozzle_scale = 0.5 %} + {% else %} + {% set nozzle_scale = 0.4 %} + {% endif %} + {% set scaled_pa = base_pa * nozzle_scale %} + + # === Calculate exponent from nozzle size unless overridden === + {% set exp = params.EXP|default(2.0 * nozzle)|float %} + + # === Flow ratio and flow scale === + {% set flow_ratio = flow / max_flow %} + {% set flow_scale = flow_ratio ** exp %} + {% set adjusted_pa = scaled_pa * flow_scale %} + + # === Dynamic smoothing time unless overridden === + {% if 'SMOOTH' in params %} + {% set smooth = params.SMOOTH|float %} + {% set smooth_source = "manual" %} + {% else %} + {% if nozzle <= 0.3 %} + {% set smooth = 0.03 %} + {% elif nozzle <= 0.4 %} + {% set smooth = 0.04 %} + {% elif nozzle <= 0.6 %} + {% set smooth = 0.045 %} + {% elif nozzle <= 0.8 %} + {% set smooth = 0.055 %} + {% else %} + {% set smooth = 0.065 %} + {% endif %} + {% set smooth_source = "dynamic" %} + {% endif %} + + # === Set and store final values === + SET_PRESSURE_ADVANCE ADVANCE={adjusted_pa} SMOOTH_TIME={smooth} + SET_GCODE_VARIABLE MACRO=SET_PA VARIABLE=pa VALUE={adjusted_pa} + + # === Logging === + {% set msg = "📐 PA scaled | Nozzle: " ~ nozzle|string ~ "mm | Base: " ~ base_pa|string ~ " ➜ x" ~ nozzle_scale|string ~ " ➜ x" ~ flow_scale|string ~ " (flow^" ~ exp|string ~ ") = " ~ adjusted_pa|string ~ " | Smooth: " ~ smooth|string ~ " (" ~ smooth_source ~ ")" %} + RESPOND MSG="{msg}"