3
$\begingroup$

My printer's hot end heats up way faster than the bed. Still, it takes its sweet time, and Cura's default startup sequence: heat the bed, wait for bed to reach target temperature, heat hot-end, wait to reach hot-end temperature, proceed - takes considerably more that it should.

M140 S{material_bed_temperature_layer_0}      ;Start heating bed
M190 S{material_bed_temperature_layer_0}      ;Wait for bed to reach temp
M104 S{material_print_temperature_layer_0}    ;Start heating extruder 
M109 S{material_print_temperature_layer_0}    ;Wait for extruder to reach temp 

Sure I could start heating both to target temperature simultaneously and then wait for both, but then I'll be baking unmoving filament in the nozzle for much longer than necessary. What I'd like to do is to start heating the nozzle when the bed is about 20 °C short of its target temperature - that causes them to reach their target temperatures nearly simultaneously. Something along the lines of:

M140 S{material_bed_temperature_layer_0}      ;Start heating bed
M190 S{material_bed_temperature_layer_0 - 20} ;Wait for bed to be 20 degrees before target
M104 S{material_print_temperature_layer_0}    ;Start heating extruder 
M190 S{material_bed_temperature_layer_0}      ;Wait for bed to reach temp
M109 S{material_print_temperature_layer_0}    ;Wait for extruder to reach temp 

Except S{material_bed_temperature_layer_0 - 20} isn't recognized as a valid substitution.

How can I achieve the desired effect?

$\endgroup$

3 Answers 3

3
$\begingroup$

You can't do this entirely in start gcode templates, but you can do it by first adding a custom setting to the json file for your printer profile or the base fdmprinter.def.json file most profiles derive from. It would look something like (copied from my copy of fdmprinter.def.json's material_bed_temperature_layer_0 definition:

            "material_bed_temperature_preheat":
            {
                "label": "Build Plate Preheat Temperature",
                "description": "The temperature used for preheating the heated build plate.",
                "unit": "°C",
                "type": "float",
                "resolve": "max(extruderValues('material_bed_temperature_layer_0'))",
                "default_value": 40,
                "value": "resolveOrValue('material_bed_temperature_layer_0 - 20')",
                "minimum_value": "-273.15",
                "minimum_value_warning": "max(build_volume_temperature, max(extruderValues('material_bed_temperature')))",
                "maximum_value_warning": "130",
                "maximum_value": "200",
                "enabled": "machine_heated_bed and machine_gcode_flavor != \"UltiGCode\"",
                "settable_per_mesh": false,
                "settable_per_extruder": false,
                "settable_per_meshgroup": false
            },

Alternatively, you could set enabled for it to false so it won't show up in settings, avoid the nice description and stuff, and name it something like material_bed_temperature_layer_0_minus_20.

In either case you can then use the new setting in your start gcode.

$\endgroup$
1
  • $\begingroup$ Awesome! I had found a forum thread about using these expressions, except it was completely devoid of context, no info what file, where to put the code, some scary restrictions on default_value, and so I hoped there is a way. And there is, thank you! $\endgroup$
    – SF.
    Mar 31 at 16:05
2
$\begingroup$

None of the above examples work, because the settings parser is more complex than that.

So you can achieve preheated temperatures by adding the following modification to the fdmprinter.def.json file:

"material_bed_temperature_pre":
    {
        "label": "Build Plate Preheat Temperature",
        "description": "The temperature used for preheating the heated build plate.",
        "unit": "°C",
        "type": "float",
        "resolve": "material_bed_temperature_pre",
        "default_value": "material_bed_temperature_layer_0 - 8",
        "value": "material_bed_temperature_layer_0 - 8",
        "minimum_value": "0",
        "minimum_value_warning": "max(build_volume_temperature, max(extruderValues('material_bed_temperature')))",
        "maximum_value_warning": "130",
        "maximum_value": "200",
        "enabled": "false",
        "settable_per_mesh": false,
        "settable_per_extruder": false,
        "settable_per_meshgroup": false
    },

A probable reason why the previous suggestions fail is that the code completion will see the inclusion as some sort of conflict/default as it is not listed in the settings ("enabled = false"). When there is conflict, it attempts to resolve it based on the "resolve" field, equating to the layer_0 setting in an incorrect example.

So the value can be something else than what is listed in the "value" category depending on circumstances. With this addition, the value has no other choice than to compute the preheated temperature based on layer_0 temperature.

For nozzle temperatures, I use fixed value which does not yet cause oozing of most materials during the small mismatch of sync period.

The setting in the G-code generator is as follows:

M190 S{material_bed_temperature_pre} ;Initial bed temperature, wait
M140 S{material_bed_temperature} ; start heating the bed
M104 S180 ;Hotend initial target, no wait
G28 ;Home
G1 Z15.0 F1200 ;Move the platform down 15mm
M104 S{material_print_temperature} ;Hotend actual target, no wait
M190 S{material_bed_temperature} ;Target bed temperature, wait
M109 S{material_print_temperature} T0 ; wait for hotend

So first we wait for the bed to reach preheat temperatures, which takes some time. Then, the bed temperature is set to target and the nozzle is to preheat levels, but in the background.

During this, we moved to the home position.

Finally, in sequence ultimate target for the nozzle is no wait, and then we stay until the bed temperature is final. To make sure the nozzle is at the final temperature (if it was not reached during bed heat up), we wait for it until it goes to actual printing.

New contributor
3dprinterman is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$
1
$\begingroup$

Cura doesn't allow math operations in G-code scripts, if you want to do that you should use Slic3r or PrusaSlicer.

See e.g. this question or this question asked on the UltiMaker community.

$\endgroup$
2
  • 1
    $\begingroup$ This isn't entirely true. You can add new virtual settings to the json settings file which are specified as formuals in terms of other settings. I'll elaborate in an answer. $\endgroup$ Mar 31 at 15:47
  • $\begingroup$ @R..GitHubSTOPHELPINGICE Please do, this has been a long awaited missing feature in Cura. Although, virtual settings to the json settings file doesn't sound too user-friendly as in using the arithmetic in your start G-code. $\endgroup$
    – 0scar
    Mar 31 at 16:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .