Notifications
Clear all

Bed preheat using Slic3r PE macros  

  RSS
francesco.s
(@francesco-s)
Eminent Member
Bed preheat using Slic3r PE macros

Hi forum!

I find it a better practice, in general, to start preheating the bed before the extruder, because it takes so much longer, and we don't want a idle hot hotend. So I came up with a neat command that you can add to your start GCode (only for Slic3r PE!), which uses the new macro functionalities and preheats the bed to target temp minus 20°C before heating the extruder.

The line is the following:
{if first_layer_bed_temperature[0] > 20}M190 S{first_layer_bed_temperature[0] - 20}{endif}

you should insert it in the start GCode before the M104 code.

I struggled a bit to come up with this mostly because I could not find proper documentation for the macro language. Does it exist at all? The caveat here is that the first_layer_bed_temperature is not a scalar but a vector!

HTH,

Francesco

Posted : 16/02/2018 11:24 am
Vojtěch Bubník
(@vojtech-bubnik)
Member Admin
Re: Bed preheat using Slic3r PE macros

> I struggled a bit to come up with this mostly because I could not find proper documentation for the macro language. Does it exist at all? The caveat here is that the first_layer_bed_temperature is not a scalar but a vector!

Hi Francesco.

I am happy people are finding good use of the new macro functionality. As of now there is no documentation. In general, you may reference any variable you will find in the config file. The extruder dependent values are vectors because Slic3r supports multiple extruders. Currently the macro language supports the {if condition}{elsif condition}{else}{endif} syntax, where the condition is an expression in a syntax derived from the C language, with the addition of a Perl language like regex expression.

The macro processor also supports {expression}, which simply evaluates and places the result of an expression into the G-code. You may again use the usual C expression syntax including the ternary operator.

You will find the grammar definition as part of the source code, starting with line 880:
https://github.com/prusa3d/Slic3r/blob/ac904b273182506892f57cc9a08312550e24d80c/xs/src/libslic3r/PlaceholderParser.cpp#L880
up to line 1043, so it is not really complex.

You are most welcome to contribute your findings and use cases to the Slic3r PE wiki 🙂
https://github.com/prusa3d/slic3r/wiki

Vojtech

Posted : 16/02/2018 5:41 pm
MareIngenii
(@mareingenii)
Active Member
Re: Bed preheat using Slic3r PE macros

This is cool. I'm going to try this! I had been preheating the bed 1st but waiting for it to get to full temp before heating the nozzle but that takes a "long" time. Now I can dial in the -20 to a temperature that gets the nozzle and the bed at full heat right about the same time.

Posted : 18/02/2018 6:38 pm
francesco.s
(@francesco-s)
Eminent Member
Topic starter answered:
Re: Bed preheat using Slic3r PE macros


> I struggled a bit to come up with this mostly because I could not find proper documentation for the macro language. Does it exist at all? The caveat here is that the first_layer_bed_temperature is not a scalar but a vector!

You are most welcome to contribute your findings and use cases to the Slic3r PE wiki 🙂
https://github.com/prusa3d/slic3r/wiki

Vojtech

Hi Vojtech,

As you suggested, I started writing up some minimal documentation on the Wiki: https://github.com/prusa3d/Slic3r/wiki/Slic3r-Prusa-Edition-Macro-Language

It's an exciting feature of Slic3r PE (even though, I have to admit, I would have implemented it differently 🙂 ) and I hope it will be useful to others!

I see you are also working on linear advance. Keep up the good work! I'm looking forward to seeing the fruit of your labor!

Francesco

Posted : 21/02/2018 4:01 pm
Vojtěch Bubník
(@vojtech-bubnik)
Member Admin
Re: Bed preheat using Slic3r PE macros

Hi Francesco.

Thanks a lot for your effort, it is greatly appreciated!

I based the macro processor language loosely on the legacy macro processor language and on the efforts at the upstream Slic3r.

Please go ahead, if you have any comments on missing constructs. We will not break backward compatibility though.

Vojtech

Posted : 26/02/2018 5:27 pm
Share: