Custom Start G-code : Is It Worth Changing 

Custom G-code snippet

When you load your Gcode into your printer, it will carry out exactly the commands it is told. Are the default ones the best for your printer…

Why customize the start g-code: Your 3d printer will do exactly what G-codes you tell it to do. So with a bit of careful programming you can optimize your start G-code with no ooze and custom heating.

Why change the start g-code

My 3d printing days go back to the old version of cura, when the version was a lot higher than it is now….(15.xxx)

Once you loaded up a model…set up how you wanted it to print…what you want it printed with…you pressed slice, and it popped out a file that contained the start commands and the stop commands.

Loading this onto an SD card and putting it into your 3d printer, it would happily heat up sensibly, move to the start position sensibly and then start printing.

As slicers have progressed it appears that less thought is put into the start code, almost having it as an afterthought.

Most slicers now place the print nozzle at the printing height before moving onto the bed, or heat both the bed and nozzle up at the same time.

I did try briefly in the past to add custom G-code but it normally just ignored it.

But i revisited it recently after trying out prusaslicer and it trying to crash my machine into one of my bed screws at the start….

What can be done

Once you start looking into what you can change in G-code you will be amazed and perhaps a little afraid to have a go.

But once you start and find that you can control your printer at its lowest level you feel in control.

The start code for most slicers now consists of heat the bed, heat the nozzle, zero the axes, move to the initial layer height, go to the first position and start printing.

Some, as i said above , even switch both bed and nozzle on at the same time, trying to overload your power supply for the length of time they are both on.

The old cura was a lot more gentle with the printer.

Zeroing the axes, moving the printhead up 10mm,heating the bed, heating the nozzle and moving to the start position all in one smooth movement.

This code had the advantage of missing any screwheads in the corners of the bed.

If you looked into it you could sit down manually and write your own g-code for your model using the special strings available and then process it through your favorite slicer.

But why would you- the slicer can do the heavy lifting, you just want to treat your printer with respect at the start and prevent damaging your nozzle as it moves to the start position for printing.

My safe routine

So instead of the standard start G-code trying to break my nozzle off i decided to create a similar routine to the original cura.

But even better, as i got fed up of the ‘snotty nose’ initial ooze and pulling off the filament at startup to reduce the risk of it not sticking i decided to have a look at this as well.

Using the prusaslicer, the startup process i decided on is :

  •  Heat the bed
  • Heat the nozzle to a ‘safe’ temp (160C)
  • Start with no fan
  • Zero the Axes
  • Move z axis up 10mm
  • Move the printhead over the bed
  • Go to the first layer height
  • Heat the nozzle the rest of the way
  • And  start printing.

My first few attempts didn’t end up doing what i wanted, but i persevered and found that using the special placeholders over rode the standard coding.

I used the Marlin g-code command reference to find what i wanted to do.

There are commands to start the heating process and then you can go off and do other things while it is still heating (M104- nozzle heating), or you can start the heating and wait till it is finished to carry on( M109 nozzle heating and wait).

And there is a host of other commands.

My Custom Start G-code

So my list of G-codes for the prusaslicer ended up as :

M190 S[first_layer_bed_temperature]; heat the bed and wait
M109 S160 ; heat the nozzle to a non drip temp
G21; set the system to metric
G90 ; with absolute positioning
M82; set the extruder to absolute
M107; start with the fan off
G28 X0 Y0 ; zero the x and y axes
G28 Z0 ; zero the z axis
G1 Z10.0 F2400.00 ; move the gantry up 10mm to clear any obstructions
G92 E0; zero the extruder
G1 X15.0 Y15.0 ; move the nozzle over the bed
G1 Z[first_layer_height] ; move the nozzle down to the start height
M109 S[first_layer_temperature] ; get the nozzle up to temperature
M117 let's Print…; put on the screen a messageCustom G-code snippet

Did it do what i wanted

The standard heating of the bed first before loading the power supply with anything else did work, i maybe will try starting the bed running and then zero the axes and all the other setup before going back to wait for the bed to finish. – i will update if it seems to work well and not drop the power supply volts on my anet A8 clone.

Setting the nozzle to a safe temp of 160C does get the filament soft but not oozing, this is for pla but may also work for ABS – as yet untried.

Moving the printhead up to miss everything – that worked well.

And again moving the nozzle over the bed – i had to adjust it a bit as the home position is off the bed rather than the corner of the bed.

Moving the nozzle back down shows me whether it will collide with the bed – it shouldn’t if the bed is leveled correctly.

And finishing the heating before printing, again works well with no ooze as the nozzle is so close to the bed.

I did try printing the skirt while heating the nozzle up, but as the filament was not liquid enough to be extruded then it failed while trying to feed the filament…not a good move.

And yes with the two special placeholders it prevented the slicer from putting its code over the top and messing things up.

Will this work with other slicers – yes

You may have to change the placeholder text

Cura has {material_print_temperature_layer_0} as the first layer nozzle temp

And {material_bed_temperature} for the bed temperature.

So those will need changing in the routine above.

But everything else is standard G-code.

In Simplify3d they call it custom scripting – but as i don’t own a copy then….the support area is your best bet i’m afraid.

here is a list of prusa and slic3r placeholders

and the cura ones are here

Advanced start G-code

What else could be added

Bed leveling – once i have my other machine up and running again i will be adding this and seeing if it really does help.

Linear advance – i want to investigate this as it does improve your overall printing.

Within prusaslicer and slic3r there is a section on conditional programming, so you can have your slicer make decisions on your G-code.

So if you always want your second layer temperature to drop a few degrees you can add this to your custom start code rather than setting it up in the slicer.

But be warned that the slic3r and prusaslicer conditional code uses different commands – so once you start getting into that level then it is best to stay with one slicer.

But with the conditional coding you can setup temperature towers for a specific model – changing the nozzle temp at certain heights.

You could run a speed test to see where you start to skip steps in the x and y  axes.

Thee is a host of things you could investigate, but start with the custom G-code to control your machine how you want it to startup and move forward from there.

I hope that this has given you the confidence to have a go at changing your start code – even if it is only changing the message on the lcd (M117)…it just makes the printer yours…..

Most stop codes are ok, they will move the print nozzle up a bit or home the x axis and switch off the heaters. But again you could customize this – but make sure you don’t knock off your model…

Leave a Reply

Your email address will not be published. Required fields are marked *