How do I set the GCODE macros to not raise the printhead so much?
 
Notifications
Clear all

How do I set the GCODE macros to not raise the printhead so much?  

  RSS
pug
 pug
(@pug)
Active Member
How do I set the GCODE macros to not raise the printhead so much?

I apologize if this is a kind of obvious question but my knowledge of GCODE is very limited. I'm using the stock GCODE macros that the slicer was configured with. Ideally I'd have the printhead raised 2mm maximum above whatever the max height was.

Posted : 09/01/2025 11:18 pm
Diem
 Diem
(@diem)
Illustrious Member

If you are writing about travel lift the settings are in: Printer Settings > Extruder (n)

and there are more lift settings that might be useful in: Filament Settings > Filament Overrides

Cheerio,

Posted : 10/01/2025 9:22 am
Neophyl
(@neophyl)
Illustrious Member
RE: How do I set the GCODE macros to not raise the printhead so much?

And if you are talking about at the end of a print that's controlled in the End gcode section of Printers>Custom G-code>End G-Code.  You will need to be in Expert mode to even see those as available.

We would need to know what printer you have installed to advise on what exactly to edit.  

Posted : 10/01/2025 11:09 am
pug
 pug
(@pug)
Active Member
Topic starter answered:
RE: How do I set the GCODE macros to not raise the printhead so much?

Ender 3 pro. Confirmed I am in expert mode (just not an expert in GCODE)

Posted : 10/01/2025 7:49 pm
Neophyl
(@neophyl)
Illustrious Member
RE: How do I set the GCODE macros to not raise the printhead so much?

Ok I installed the default PS profile for the Ender 3 Pro.  The End G-code block had the following in there

{if max_layer_z < max_print_height}G1 Z{z_offset+min(max_layer_z+2, max_print_height)} F600 ; Move print head up{endif}
G1 X5 Y{print_bed_max[1]*0.85} F{travel_speed*60} ; present print
{if max_layer_z < max_print_height-10}G1 Z{z_offset+min(max_layer_z+70, max_print_height-10)} F600 ; Move print head further up{endif}
{if max_layer_z < max_print_height*0.6}G1 Z{max_print_height*0.6} F600 ; Move print head further up{endif}
M140 S0 ; turn off heatbed
M104 S0 ; turn off temperature
M107 ; turn off fan
M84 X Y E ; disable motors

 

This line 
{if max_layer_z < max_print_height}G1 Z{z_offset+min(max_layer_z+2, max_print_height)} F600 ; Move print head up{endif}
is saying if the current print height is less than the printers configured max height then move up 2mm or move to the maximum if the distance between what you printed and max is less than 2mm.  Thats the max_layer_z+2 part.  The 2 is 2mm.  I wouldn't touch that one.

This line 
{if max_layer_z < max_print_height-10}G1 Z{z_offset+min(max_layer_z+70, max_print_height-10)} F600 ; Move print head further up{endif}
is doing the same but this time moving it up a further 70mm but with a maximum of the max height minus 10.  I think this is there so that if you have a really low print its up far enough that you can easily remove the model.

This one 
{if max_layer_z < max_print_height*0.6}G1 Z{max_print_height*0.6} F600 ; Move print head further up{endif}
This one seems to be a bit superfluous to me.    Its basically saying if the height after the print is less than 60% of the max z height then move to 60% of the max z height.  I'd start with commenting out this line.  Putting a ; before a line makes it a comment.

Be careful editing, make sure you don't accidentally remove line ending as each command should be on a new line.

Posted : 11/01/2025 8:49 am
pug
 pug
(@pug)
Active Member
Topic starter answered:
RE: How do I set the GCODE macros to not raise the printhead so much?

@neophyl thank you, this helped a bit, but the printhead is still being raised by a lot. For example, I did a print that was about 8mm thick and the printhead ended up about 80mm off of the build plate when the print was done.

I'm interested in dialing this in as minimal as possible because I had an optical filament runout sensor mounted near the top, so long continuous movements in the Z direction cause kinking. What would you suggest the next step to be?

Posted : 12/01/2025 7:30 am
Neophyl
(@neophyl)
Illustrious Member
RE: How do I set the GCODE macros to not raise the printhead so much?

It will do, first block moves up 2mm, that second moves it up a further 70mm (max_layer_z+70) before that final one does the 60%.  So with those 2 its always going to end up 72mm higher than your finished part unless that exceeds your printers configured height.

Just tweak the 70 value if you want it to go up less. 

I would say though that if moving up in a straight line is causing your filament sensor issues then that sounds like the problem and I would change that so it doesn't cause a problem.  Are there any alternate designs/mods available for it already ?

Just had a look on printables and there are quite a few.  Just a thought.

Posted : 12/01/2025 10:54 am
pug
 pug
(@pug)
Active Member
Topic starter answered:
RE: How do I set the GCODE macros to not raise the printhead so much?

Dropping down the 70 on that line to a much small number worked perfectly. Thank you! Agreed on replacing the model that's holding the sensor. My hope with switching to Prusa Slicer was to be able to do the minimal with this change of slicer, so if there are more issues with kinking then the sensor will need to be re-positioned.

Posted : 13/01/2025 5:50 am
Share: