I come from Marlin, and I’m missing M81x, M301, M851, and M500.
Until now, I had as many printers defined in Cura than I have print heads (indexed quick change tools, DIY until recently, now Stealthburner) ; in the start gcode, I was calling user gcode macros (M810-M817 for eight heads), and these gcode macros were setting PID parameters and nozzle Z-offsets. It’s been working great for years.
I now want to do something similar with Klpper. But these gcodes don’t exist ! And I don’t want to calibrate the machine everytime I swap the tools !
I defined a START_PRINT macro with 3 parameters (1st layer tool temperature, 1st layer bed temperature, and nozzle diameter) ; these parameters are from this list Settings and replacement patterns . Works fine for temperatures (preheat).
In Cura, {machine_nozzle_size} can be altered easily with the “Printer Setttings” plugin by fieldOfView (easier than the printer configuration dialogs)
On the printer side, I’m not sure how to alter the tool PID, probe z_offset, and nozzle diameter.
Found and used a macro (“SEARCH_VARS”), and got interesting variables ;
This is what I plan to add to my start gcode (there will be more later, this is just for one toolhead only).
Is this code correct ?
...
{% set nozzle_diam = params.NOZZLE_DIAM|float %} # Cura {machine_nozzle_size}
...
...
{% if params.nozzle_diam == 0.4 %}
printer.configfile.settings.extruder.nozzle_diameter = 0.4
printer.configfile.config.extruder.nozzle_diameter = 0.400
printer.configfile.settings.extruder.pid_kp = 15.625
printer.configfile.settings.extruder.pid_ki = 0.628
printer.configfile.settings.extruder.pid_kd = 15.625
printer.configfile.settings.bltouch.z_offset = 2.150
{% endif %}
...
The PID parameters are those computed by Klipper, not Marlin.
[EDIT] I’m not familiar with jinja. But I suspect I forgot some "
{% set ... %}
Is this better ?
{% if params.nozzle_diam == 0.4 %}
{% set extruder.nozzle_diameter = 0.4 %}
{% set extruder.nozzle_diameter = 0.400 %}
{% set extruder.pid_kp = 15.625 %}
{% set extruder.pid_ki = 15.625 %}
{% set extruder.pid_kd = 15.625 %}
{% set bltouch.z_offset = 2.150 %}
{% endif %}