Universal Template for gCode Start Code

At the beginning of every 3d print, most slicers will include a block of gcode, designed to set up your printer for a successful print. Here is the gcode I use for my Marlin based printers. Please note that if you have an auto bed leveling system (ABL) available you should uncomment the “g29” that will run the ABL before each print.

; DrVax May 2020 Start Code
; Added set temp before printint index line
; Added set bed temp before print
; This first section is for printers with ABL
M104 S200 ; heat up extruder before calibrating bed
M140 S40 ; same for bed
G28 ; Home all axes
; G29 ; Probe the bed with the ABL ; **** uncomment this line if you have a always on ABL *****
G92 E0 ; Reset Extruder
M140 S{material_bed_temperature_layer_0}
M190 S{material_bed_temperature_layer_0}
M104 S{material_print_temperature_layer_0}
M109 S{material_print_temperature_layer_0} ; Wait for extruder to get back up to temperature
G1 Z2.0 F3000 ; Move Z Axis up little to prevent scratching of Heat Bed
G1 X0.1 Y20 Z0.3 F5000.0 ; Move to start position
G1 X0.1 Y200.0 Z0.3 F1500.0 E15 ; Draw the first line
G1 X0.4 Y200.0 Z0.3 F5000.0 ; Move to side a little
G1 X0.4 Y20 Z0.3 F1500.0 E30 ; Draw the second line
G92 E0 ; Reset Extruder
G1 Z2.0 F3000 ; Move Z Axis up little to prevent scratching of Heat Bed
; DrVax a number of viewers have mentioned that the following M140,190,104,109 commands are redundant.
; They maybe but if your printer is already at the correct temperature they will execute immediately
M140 S{material_bed_temperature_layer_0}
M190 S{material_bed_temperature_layer_0}
M104 S{material_print_temperature_layer_0}
M109 S{material_print_temperature_layer_0} ; Wait for extruder to get back up to temperature
; End of custom start GCode

curious about the Z0.3 for drawing your purge line every time I have mine any higher than 0.15 it gets drug over to the model printing area and screws with my prints
Mind you I am having issues currently with my prints with or with out my purge line.
My last print which I just stopped because I noting some things wrong with it only 6 hours into the print, which brought me to you lol sorry if I use you as a crutch
Judging by the actual print that was already printed I am guessing that the underlying issue is with my x axis gantry not being level, as I have already leveled the bed and some where around layer 45 and 60 I noticed the print had a side step to it but not exactly a full side step more like one side has a shelf effect and almost a complete angled edge along the Z axis of one side and the other side was fairly straight I have pictures of the partial failed print if you or some one want to see what I am talking about
I have it sliced at 0.1 layer thickness with a 0.12 initial layer thickness if this helps any.

A z height of 0.3 is quite high. Consider that people often print the first layer at .20mm, I used .3mm since I am extruding a significant amount of filament. If you have to print the purge line at .15 then your bed might be too low which would also explain your difficulties with prints sticking. When you check your bed height with a piece of paper, or as I prefer a post-it note, the note should have significant resistance when you try and move it. If it moves freely your bed may be too low.

Ok I was under the impression that the paper test should feel like it is barely touching it like it moves freely but can feel a slight gritty feel to it as the paper moves past the tip.
So I need to feel it tug it when it moves past the tip?

Sorry for the rookie question but is there a similar template available for the end code?

Often the standard end code works fine. The end code is really not critical for print success, if done well it just moves the hot end (print head) out of the way to make it easy to get the print off the printer.

This end code, which ships in Cura 4.6.1 does a good job. Basically it retracts a bit of filament to reduce blobs on top of the print, moves the hot end away from the print to a safe area, then moves the print head to the top of the Z range, turns everything off except for the Z motor. The Z motor is left on so the print head will not crash back down into the print.

G91 ;Relative positioning
G1 E-2 F2700 ;Retract a bit
G1 E-2 Z0.2 F2400 ;Retract and raise Z
G1 X5 Y5 F3000 ;Wipe out
G1 Z10 ;Raise Z more
G90 ;Absolute positionning

G1 X0 Y{machine_depth} ;Present print
M106 S0 ;Turn-off fan
M104 S0 ;Turn-off hotend
M140 S0 ;Turn-off bed

M84 X Y E ;Disable all steppers but Z

Hello Irv
At the end of a print, my Artillery Genius returns the nozzle to the home position, so sending the print to the rear of the machine. I then have to manually pull the bed forward to access the model. How would I change the gcode to reverse this manoeuvre, so the bed ends up at the front? Sorry for the noob question, but I’ve never touched a line of code in my life. Thanks.

Move the bed and extruder to the position to where you want it to position itself at by using the move axis method in the controls “NOT BY MOVING THE BED BY HAND” take note of the coordinates , then edit the Gcode to those coordinates.
Make sure that the move to that location does not cross the path of any part of your print…

Thanks Buzz, I’ll try your suggestion over the weekend.

The M104 and M140 are “set temp and continue” codes. The M109 and M190 are “set temp and wait” codes. So M140, M190, M104, M109 means, “Bed set-go, Bed set-wait, Hotend set-go, Hotend set-wait”. In other words, after the first G92 E0, you just need M190 and M109. The temperature calls after the second G92 E0 (and G1 Z2.0 F…), don’t do anything at all, because they are the same as the previous calls.

I noticed that this start code has the bed heat to full temperature before commencing to heat up the extruder with this setup on my Anet ET4. How do you get it to heat both at the same time to save a bit of time before the print can begin?

Thanks… Hal

Thanks for the reply…

The nozzle remains at room temp until the bed is fully up to temp. As a work around, I’ve started preheat before sending it to print. Preheat allows both to heat at the same time so apparently the ET4 is capable. Do you know how to get this to happen by modifying Irv’s start code?

Irv’s start code, as shown above, should preheat the hot end to 200, the bed to 40, and home the axes, all at the same time. It would also start the bed leveling, if that is enabled.

Can you post the first section (everything before ;layer 0) of the gcode that your slicer is generating?

I’ve been tweaking Irv’s start code based specifically for my Anet ET4. It’s working great for me now.

See what you think…

; based on Dr Vax May 2020 start code modified for the Anet ET4
M140 S{material_bed_temperature_layer_0}
; heat up bed
M104 S{material_print_temperature_layer_0}
; heat up extruder
; without an auto level system all G29 associated commands have been deleted
G28
; home all axes
M109 S{material_print_temperature_layer_0}
; wait for extruder to heat up
M190 S{material_bed_temperature_layer_0}
; wait for the bed to heat up
G1 Z2.0 F3000
; move Z-axis up to prevent scratching bed
G1 X0.2 Y20 Z0.3 F5000.0
; move to start position
G1 X0.2 Y200.0 Z0.3 F1000.0 E15
; draw first line
G1 X0.4 Y200.0 Z0.3 F5000.0
; move to right a little
G1 X0.4 Y20 Z0.3 F1500.0 E30
; draw second line
G1 Z2.0 F3000
; move z-axis up to prevent scratching bed
; end of custom start code

Thanks for the response. I see your points. I don’t run production, just personal pleasure use. As I said. this start code is only for an Anet ET4.

With the Anet ET4, there is not a heated bed requirement for bed level because the manufacturer didn’t see fit to provide the capability. I have no need for 200/40 degree preheat. The preparation menu on this printer does have a preheat option which carries the bed to 60 degrees and 220 degrees and does them both at the same time. My logic is why not send g-code to bringing the extruder and bed to the temperatures that you intend to print with, regardless of material.

The heating happens while the printer homes (G28), which on this printer is up at Z250 which does take some time. It pauses until the temperatures come up then prints the 2 purge lines. As far as bed temp goes, I have not had one bed adhesion failure since Irv put me on to Magigoo. I was just trying to adapt a start g-code to this printer and pass the information along to other ET4 users.

Are you saying that you’ve never had a single bed adhesion problem for the entire day that you’ve been testing this code? That’s terrific!
In post #11.1, I asked you if your hot end paused at 200, or stayed at room temperature. The purpose of that question was to see if you were actually running Irv’s code or not, and if you knew it or not. Your reply was that it stayed at room temperature, which means that it wasn’t running that code, and you didn’t know it. If your code works, then his would’ve too. There are reasons why it may not have changed, which is why I asked you to post all of the slicer generated first section.
As far as your solution, just about every newbie that wants to shave time off of the start code does it that way, yet very few people with experience publish “universal start code” that does. Why do you suppose that is?

I made a post stating (see #18) that I was wrong about the heat sequence. I realized that I was not using the modified CR-3 profile that Irv created for the Anet ET4, but was actually using the ET4 profile provided by CURA. I was mistaken. My modified start g-code suits my purposes for my printer now. I couldn’t have gotten there as easily without Irv leading the way.

I do 3D printer for fun. I base my methods on what research I have done but more so from valuable and constructive advice, such as what I have received from Irv and from others. And yes… I have gone 6 completely full bed prints in one day without a single problem with adhesion after figuring out how to properly level the bed, and thanks to Irv’s advice about using Magigoo. I have posted a good bed leveling procedure in the forum for the Anet ET4 specifically.

I had stated that I was tweaking Irv’s “Universal (being the key word here) Start G-code” to get my printer, an Anet ET4, to work better. It has been said by many users of this printer that due to it’s proprietary software, hardware, and firmware… that little can be done to perform normal programming functions afforded by other printers. Things such as adjusting PID settings are not allowed. After connecting my printer with Google Chrome and the G-code Sender app, most of my queries only return “OK” instead of values capable of edit. With this printer, small victories are all that are possible.

As I have heard from others, do 3D printer for fun and enjoy the times you figure out something, either with help or on your own.

I have done an edit on this post to try to be constructive and to be more positive. ?

I had stated that my bed heated to temp first before the nozzle began to heat using Irv’s g-code. I was wrong… that happened using the Anet ET4 printer selection in CURA rather than the modified CR-3 Irv has supplied. Sorry for my mistake.