Prusaslicer: Custom G-code arithmetics don't work as expected.

Created on 28 Jun 2018  Â·  10Comments  Â·  Source: prusa3d/PrusaSlicer

Version

1.40.1-beta (AppImage)

Operating system type + version

Debian Stretch x64

Behavior

I tried to speed up the start of my prints, so I had the idea to first let my hotend and heat bed warm up to a standby temperature parallel. After that they should proceed to working temperature just as expected.

My idea was to do it like this:

; Set standby temps without waiting
M140 S{[first_layer_bed_temperature] - 20} ; bed
M104 S{[first_layer_temperature] - 60} ; hotend

; Now wait for the temps
M190 S[first_layer_bed_temperature] ; bed

; Set Z home
G28 Z0
; Proceed with hotend temperature

M109 S[first_layer_temperature] ; hotend

This attempt makes use of the conditional expression and arithmetic syntax introduced in version 1.38.

I thought, -20 °C for the heat bed and -60 °C for the hotend should be generic enough to fit as standby temperatures for almost every filament.

However, this code doesn't "compile".

I get an error

!!!!! Failed to process the custom G-code template ...

Did I make a mistake or is the arithmetic syntax not working as expected?

_Is this a new feature request?_
No.

awaiting response

Most helpful comment

The bed and extruder temperatures are indexed with extruder number.

M140 S{first_layer_bed_temperature[0] - 20} ; bed
M104 S{first_layer_temperature[0] - 60} ; hotend

Also instead of the index 0, you may use

M140 S{first_layer_bed_temperature[initial_tool] - 20} ; bed
M104 S{first_layer_temperature[initial_tool] - 60} ; hotend

or

M140 S{first_layer_bed_temperature[current_extruder] - 20} ; bed
M104 S{first_layer_temperature[current_extruder] - 60} ; hotend

All 10 comments

The bed and extruder temperatures are indexed with extruder number.

M140 S{first_layer_bed_temperature[0] - 20} ; bed
M104 S{first_layer_temperature[0] - 60} ; hotend

Also instead of the index 0, you may use

M140 S{first_layer_bed_temperature[initial_tool] - 20} ; bed
M104 S{first_layer_temperature[initial_tool] - 60} ; hotend

or

M140 S{first_layer_bed_temperature[current_extruder] - 20} ; bed
M104 S{first_layer_temperature[current_extruder] - 60} ; hotend

Thank you for your help!

That works and significantly decreases the warm up time of my printer.

However, am I mistaken if this solution seems a bit counter intuitive for me? I don't understand (yet) why I have to use an index within curly brackets while I can use the variables without index in other Gcode snippets...

However, am I mistaken if this solution seems a bit counter intuitive for me? I don't understand (yet) why I have to use an index within curly brackets while I can use the variables without index in other Gcode snippets...

We support the old syntax (variables in []), but that should be deprecated. The new syntax for vector addressing is similar to common programming languages, therefore it is preferred.

May we close this issue?

Just a final question: is there any documentation about this feature that I missed? Just to make sure I did not ask stupid questions that I could have answerde myself...

Besides that: yes, you can close the issue!

I hoped the wiki is clear. If not, you are most welcome to add your findings :-)

https://github.com/prusa3d/Slic3r/wiki/Slic3r-Prusa-Edition-Macro-Language

Closing, vector addressing is described in the wiki.

Example:

prusa mk3s tested code:

M140 S[first_layer_bed_temperature] ; set bed temp
M190 S{first_layer_bed_temperature[0] - 5} ; wait for bed temp -5
M104 S[first_layer_temperature] ; set extruder temp
M190 S[first_layer_bed_temperature] ; wait for bed temp
M109 S[first_layer_temperature] ; wait for extruder temp

Just insert it in "Printer tab" -> "Cutom g-code" -> "Start G-code" instead of default sequence

@qqgg231 What's wrong?

@bubnikv
Nothing wrong, I just gave an example for future readers

all right, thanks.

On Mon, Apr 8, 2019 at 1:01 PM qqgg231 notifications@github.com wrote:

@bubnikv https://github.com/bubnikv
Nothing wrong, I just gave an example for future readers

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/prusa3d/Slic3r/issues/1010#issuecomment-480785489,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFj5I5Zw1bbikgj6Nsv3DjaoZPVf15tUks5veyGJgaJpZM4U8GsA
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RossKor picture RossKor  Â·  3Comments

Foxtrek64 picture Foxtrek64  Â·  4Comments

DROBORD picture DROBORD  Â·  3Comments

guestisp picture guestisp  Â·  3Comments

sebastianha picture sebastianha  Â·  4Comments