2
$\begingroup$

I watched with great interest this video: Temp Tower - Slic3r Gcode Placeholders - How To - Chris's Basement -- Jan 23, 2019 Chris Riley

I found a model I'm happy with: Smart compact temperature calibration tower by gaaZolee, December 24, 2017 Uses Layer 0.20 mm infill: 15 %

I'm testing a stubborn new spool of PLA. Temp range of test 225 °C to 180 °C. That model above came with recommended ifstatements. I verified that with 100 % thickness on first layer, I'm exactly hitting all the Z targets at exactly the correct place for each temperature story on the tower.

I'm using the Slic3r "Printer Settings" tab - to place my if statements in place at "Before Layer Change G-Code".

It's not clear to me on the format required for a G-Code {if} statement. I've tried...

{if layer_z == 7.8}M104 S225{endif};   // fail, this converts to: M104 S225 {endif}    
{if layer_z==1.6}M104 S225             // fail, this converts to: M104 S225    
{if [layer_z]==1.6} M104 S225          // fails, this converts to: (null)    
{if [layer_num]==8} M104 S225          // fails, this converts to: (null)    
{if layer_num==8} M104 S225          // fails, this converts to: M104 S225 

In detail what I'm seeing is the if statements from all ten towers prints as change temp to 225, 220, 215, 210... down to 180 (last entry) and 180 °C is where ALL my prints get printed at. Total Fail.

I'm just not seeing anything in the Gcode output from Slic3r that remotely looks like an if statement. Any ideas here? I've seen this reference, on advanced conditional G-Code but I'm just not understanding what to do here.

I do see from Slic3r Custom G-Code Placeholder Reference, that I'm using the correct terms. [layer_z] - Z height of the active layer, and [layer_num] - Integer number of the active layer. It's not clear if their use in "Before Layer Change G-Code" require the square brackets or not.

Any clues on how to get an if statement into G-Code via Slic3r for a temperature tower print?

$\endgroup$

1 Answer 1

1
$\begingroup$

So I think I figured this one out. I was looking at it a bit wrong. And here's my code:

; Note to self:  layer_z = [layer_z]
; T tower floor 1
{if [layer_z]==1.6} M104 S225 T0
; T tower floor 2
{if [layer_z]==11.6} M104 S220 T0
; T tower floor 3
{if [layer_z]==21.6} M104 S215 T0
; T tower floor 4
{if [layer_z]==31.6} M104 S210 T0
; T tower floor 5
{if [layer_z]==41.6} M104 S205 T0
; T tower floor 6
{if [layer_z]==51.6} M104 S200 T0
; T tower floor 7
{if [layer_z]==61.6} M104 S195 T0
; T tower floor 8
{if [layer_z]==71.6} M104 S190 T0
; T tower floor 9
{if [layer_z]==81.6} M104 S185 T0
; T tower floor 10
{if [layer_z]==91.6} M104 S180 T0

The key to understanding what is going on is the ; Note to self: layer_z = [layer_z] line. The whole block of code above gets repeated for every layer of the print in the G-code, but it gets evaluated. And when I search for "layer z =" and scan thru the code.. I eventually see this...

; Note to self:  layer_z = 1.6
; T tower floor 1
 M104 S225 T0                  <---- Yowza. Nice. 
; T tower floor 2
; T tower floor 3
; T tower floor 4
; T tower floor 5
; T tower floor 6
; T tower floor 7
; T tower floor 8
; T tower floor 9
; T tower floor 10

and then again:

; Note to self:  layer_z = 11.6
; T tower floor 1
; T tower floor 2
 M104 S220 T0           <---- Yes!
; T tower floor 3
...

All good. You have to have {} and [] within the code statements...

Addendum: So it turns out things are not quite perfect. I'm noticing at the upper floors, where things should be cooler, the temperature isn't changing. Its locked at 215C. I see this in the code:

; Note to self:  layer_z = 31.5999999999999      <--- not sure how that happened.  
; T tower floor 1
; T tower floor 2
; T tower floor 3
; T tower floor 4
; T tower floor 5
; T tower floor 6
; T tower floor 7
; T tower floor 8
; T tower floor 9
; T tower floor 10

31.6 would have triggered a temperature change. 31.5999999999999 won't do it. I need to modify the {if... == } to a complex test between two values... Just wanted to share that observation here.

I do see from this reference that

Expressions may be chained for an implicit AND:

{if [layer_num] == 10}{if [temperature_1] != 210}M104 S210

And this seems to fix it:

; Note to self:  layer_z = [layer_z]
; T tower floor 1
{if [layer_z]<=1.65}{if [layer_z]>1.55} M104 S225 T0
; T tower floor 2
{if [layer_z]<=11.65}{if [layer_z]>11.55} M104 S220 T0
; T tower floor 3
{if [layer_z]<=21.65}{if [layer_z]>21.55} M104 S215 T0
; T tower floor 4
{if [layer_z]<=31.65}{if [layer_z]>31.55} M104 S210 T0
; T tower floor 5
{if [layer_z]<=41.65}{if [layer_z]>41.55} M104 S205 T0
; T tower floor 6
{if [layer_z]<=51.65}{if [layer_z]>51.55} M104 S200 T0
; T tower floor 7
{if [layer_z]<=61.65}{if [layer_z]>61.55} M104 S195 T0
; T tower floor 8
{if [layer_z]<=71.65}{if [layer_z]>71.55} M104 S190 T0
; T tower floor 9
{if [layer_z]<=81.65}{if [layer_z]>81.55} M104 S185 T0
; T tower floor 10
{if [layer_z]<=91.65}{if [layer_z]>91.55} M104 S180 T0
$\endgroup$
6
  • $\begingroup$ What firmware are you using that evaluates if statements, please? $\endgroup$
    – Davo
    Commented Apr 17, 2020 at 13:35
  • $\begingroup$ Firmware? I’m not sure I understand the question. I’m creating G-code using Slic3r, then inspecting the code using Atom, a piece of coding software from the folks at Github. And as for temperature problems, I’m watching the temp display as the print proceeds. Obviously something was wrong. $\endgroup$
    – zipzit
    Commented Apr 17, 2020 at 13:45
  • $\begingroup$ I'm asking what firmware, what flavor of processor on your 3d printer, is receiving this code and making these evaluations? When you set your slic3r recipes, what do you select - repetier, marlin, sailboat, windchime, something else? $\endgroup$
    – Davo
    Commented Apr 17, 2020 at 13:48
  • $\begingroup$ Sure, All of those details are contained here. It's a an older MakerBot Replicator clone, actually a Flashforge Creator 1. Firmware upgraded to Sailfish. Start/end gcode settings see link above. Set recipes? not sure I understand what you are asking. Question.. why are you asking? What part of this answer makes you curious? (or is it the odd 31.5999999999999 value?) $\endgroup$
    – zipzit
    Commented Apr 17, 2020 at 13:58
  • 1
    $\begingroup$ Slic3r --> Printer Settings --> General --> Firmware, G-Code Flavor: Sailfish Makerbot . $\endgroup$
    – zipzit
    Commented Apr 17, 2020 at 21:32

You must log in to answer this question.

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