Bed Preheat settings in config file

Basic Information:

Printer Model: Ender 3 v2
MCU / Printerboard: Creality 4.2.2

Describe your issue:

Hi,

Currently my start-print is as follows:

[gcode_macro START_PRINT]
gcode:
  {% set T_BED = params.T_BED|default(50) %}
  {% set T_EXTRUDER = params.T_EXTRUDER|default(205) %}
  # Use absolute coordinates
  G92
  M109 S0

  #HEAT BED & BUILD MESH
  {% if T_BED > 70 %}
      M190 S70
  {% else %}
      M190 S{T_BED}
  {% endif %}

  G28 ; Home all axes
  BED_MESH_CALIBRATE
  BED_MESH_PROFILE LOAD=default
 
  # Move Nozzle To Heating Posistion
  G0 Z0 X240 Y40
  # Start heating and continue
  M190 S{T_BED}
  M109 S{T_EXTRUDER} 
  # Wipe Nozzle
  NOZZLE_WIPE

  # Prime line
  PRIME_LINE

As can be seen i try to pre-heat the bed to T_BED value, unless it is above 70. In this case i want it to heat at 70 to do the bed leveling sequence. This is because my CR-Touch can’t handle more then 70C.

But my issue is that this is not working. The equation doesn’t work. Am i missing a value indexer of some sort?

How can i make this work?

Thnx

Hello @Wietz !

Sadly you missed to include the first part of the macro between the code braces.

Important is, that everything after the codeword gcode: has to be indented, like here:

[gcode_macro START_PRINT]
gcode:
    {% set BED_TEMP = params.BED_TEMP|default(60)|float %}
    {% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(190)|float %}
    # Start bed heating
    M140 S{BED_TEMP}
    # Use absolute coordinates
    G90
    # Reset the G-Code Z offset (adjust Z offset if needed)
    SET_GCODE_OFFSET Z=0.0
    # Home the printer
    G28
    # Move the nozzle near the bed
    G1 Z5 F3000
    # Move the nozzle very close to the bed
    G1 Z0.15 F300
    # Wait for bed to reach temperature
    M190 S{BED_TEMP}
    # Set and wait for nozzle to reach temperature
    M109 S{EXTRUDER_TEMP}

That can’t be seen in your post.

That is the reason we like to have the klippy.log (as file of course).
Erasing that query from the template does not make this query obsolete.

Thanks for the reply. Klippy.log is not necessary here.

So please do the indents:

https://www.klipper3d.org/Command_Templates.html#formatting-of-g-code-in-the-config