set_material.cfg modified - 18/04/25 - 08:54:44

This commit is contained in:
pi committed 2025-04-18 08:54:47 +01:00
1 parent 776f43b3f4
commit 1126c53702
1 file changed
+49 -16
+49 -16
View File
@@ -492,14 +492,31 @@ 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=<base_value> [FLOW=<actual_mm3/s>] [MAX_FLOW=<max_mm3/s>] [SMOOTH=<value>] [EXP=<value>]
#
# 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 smooth = params.SMOOTH|default(0.045)|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 %}
{% set flow = params.FLOW|default(30.0)|float %}
{% set max_flow = params.MAX_FLOW|default(70.0)|float %}
# === Nozzle-based scaling ===
# === Scale PA based on nozzle diameter ===
{% if nozzle <= 0.2 %}
{% set nozzle_scale = 1.8 %}
{% elif nozzle <= 0.3 %}
@@ -513,29 +530,45 @@ gcode:
{% else %}
{% set nozzle_scale = 0.4 %}
{% endif %}
{% set scaled_pa = base_pa * nozzle_scale %}
# === Flow-based scaling (square root of flow ratio) ===
{% if max_flow > 0 %}
{% set flow_ratio = flow / max_flow %}
{% set flow_scale = flow_ratio ** 0.5 %}
{% set adjusted_pa = scaled_pa * flow_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 %}
{% set adjusted_pa = scaled_pa %}
{% 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 PA and store variable ===
# === 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}
# === Output status ===
{% set msg = "📐 PA scaled for nozzle " ~ nozzle|string ~ "mm | Base: " ~ base_pa|string ~
" ➜ x" ~ nozzle_scale|string ~ " (nozzle) ➜ x" ~ flow_scale|string ~ " (flow) = " ~ adjusted_pa|string ~
" | Smooth: " ~ smooth|string %}
# === 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}"
[gcode_macro SET_CHAMBER_HEAT]
description: Modular chamber heating logic with active/passive support, includes safety checks and debug output