Custom g-code

Hi everyone. I am looking for someone who knows g-code. I need custom g-code I guess that will tell my printers at the end of every print to raise the bed to a certain height and then force the aux fan on to expedite the cool down of the part. The goal being in a print farm environment to speed up the whole workflow. I will likely be using petg and x1c’s. Is such a thing possible?

1 Like

G1 Z100 ; raise Z to 100mm

M106 P3 S255; set Aux fan to 100% (range from 0-255)

EDIT: you may also add a G90 before G1 to set absolute positioning just in case

G90

EDIT2: You can also use placeholder as values :

G1 Z{max_layer_z}

2 Likes

On a p1p how do I figure out the current bed height? I want to manually raise it to the desired level then see what that is in gcode.

@DzzD

Since the OP neglected to do it, Thanks DzzD for that response.

3 Likes

Bro really? The conversation wasn’t over lol, lay off. And I did actually say thanks, but I deleted the response because my additional question was already answered so the thanks went with it.

1 Like

So thanks DzzD for your help so far.

1 Like

It should be possible. Here is the standard code for the end of a print (I added comments)

{if (max_layer_z + 100.0) < 250} ; Is the print less than 150mm high?
G1 Z{max_layer_z + 100.0} F600 ; If so, drop bed 100mm
G1 Z{max_layer_z +98.0} ; then raise it 2mm
{else}
G1 Z250 F600 ; Drop to 250mm
G1 Z248 ; Raise by 2mm
{endif}
M400 P100 ; Wait for motion to complete

So, let’s say you want the bed to go to the Z=50mm position and turn on the fan. Something like this might work:

M400 P100 ; Wait
G1 Z50
M106 P2 S255

I’d suggest tacking this at the end of the “Machine end G-code” in the printer profile (you need the Advanced toggle on to see this), save as a new profile, and select that when you want this to happen after a print.

Bambu occasionally updates the G-code in the profile, so when you get Studio updates, check the date in the comment at the top of the text.

2 Likes

Thanks. Do you mean the filament profile as that is the only place i saw gcode. Also I want the bed to be basically level with the fan port but how do I measure that distance. Is it to the top of the bed(i assume) or bottom and is it measured from the bottom of the printer?
Nm i found what you mean.

No, I mean the printer profile. You must have the Advanced view turned on to see this.

1 Like

1 Like

Yes I found the machine gcode and have entered it in. i’ll know in 5 hrs what happens.

Good to know…Thanks Guys

  • Uman

hy guys, anyone knows if its possible to add a two extruder printer like sovol sv04 on bambu studio?
thanks

Oook so setting the bed height to Z290 was a flop. It went down instead of up and hit the machine platform and made awful sounds I never want to hear again. Based on how I came to the conclusion to use 290mm my mistake must be in assuming the desk is 0mm and max height is somewhere around 300mm. The only other way to measure this would be a positive and negative integer with the “0” height being in the middle. Does this sound right?

Well the aux fan G-code works!
I added the following code to Printer settings / Machine end G-code:

M106 P2 S100 ; activate aux fan 40%

The aux fan turns-on and spins at 40%, when the print is complete and stays-on until instructed otherwise.

A piece of metal tape attached to the aux fan vent directs the blast on the bed/part.
This feature automatically cools the part down for plate/part removal from printer bed.

cheers,

  • Uman
1 Like

Hi @zanelato3d , welcome to the Forum.

You have made a comment in an ongoing discussion that’s completely off the discussion.

If you have questions they’re quite welcome, but you should always post a new item in the proper section on the Main Page (look on the left for the proper group).

You’ll then get hundreds of eyeballs and not interrupt a different discussion :wink:
Start here:
https://forum.bambulab.com/

Cheers!

Yes i got the fan to work just fine using this line of code
M106 P2 S255
However, how do I get the bed to come to a position that is in line with the fan? I’ve “homed” the machine just now and it looks like the home position of the bed is at the right height where I want it. However the extruder is also “homed” and that would be in the way of the parts. Also I am testing this on a p1p not x1c. So it looks like all I need is the code to send the bed only to home position.

Would this code work- G28 Z ???
FYI am only using this code set in a project that will be repeated with the same height parts every day.

In all printers, Z0 is where the nozzle hits the bed, so on the Bambus and other printers where the bed moves up and down, higher Z values move the bed farther down. Z290 is some 40mm more than the available volume. Don’t go more than Z250.

1 Like

Depends on what you want. It will home Z, raising the bed to what it thinks is Z0. I’d be reluctant to do that after a print as it might drive the nozzle into the bed.

1 Like