Skip to content

Instantly share code, notes, and snippets.

@aphexddb
Created March 17, 2025 12:57
Show Gist options
  • Save aphexddb/4d8a6380505881d4c0c896d586c53d91 to your computer and use it in GitHub Desktop.
Save aphexddb/4d8a6380505881d4c0c896d586c53d91 to your computer and use it in GitHub Desktop.
Prusa MK3S Start / Stop G-Code
;AFTER_LAYER_CHANGE
;[layer_z]
{if ! spiral_vase}M74 W[extruded_weight_total]{endif}
;BEFORE_LAYER_CHANGE
G92 E0.0
;[layer_z]
M201 X{interpolate_table(extruded_weight_total, (0,4000), (1400,2500), (20000,2500))} Y{interpolate_table(extruded_weight_total, (0,4000), (1400,2500), (20000,2500))}
M600
G1 E0.3 F1500 ; prime after color change
{if layer_z < max_print_height}G1 Z{z_offset+min(max_layer_z+1, max_print_height)} F720 ; Move print head up{endif}
M104 S0 ; turn off temperature
M140 S0 ; turn off heatbed
M107 ; turn off fan
G1 X241 Y201 F3600 ; park
{if layer_z < max_print_height}G1 Z{z_offset+min(max_layer_z+23, max_print_height)} F300 ; Move print head up{endif}
G4 ; wait
M572 S0 ; reset PA
M593 X T2 F0 ; disable IS
M593 Y T2 F0 ; disable IS
M84 X Y E ; disable motors
; max_layer_z = [max_layer_z]
M17 ; enable steppers
M862.1 P[nozzle_diameter] A{(filament_abrasive[0] ? 1 : 0)} F{(nozzle_high_flow[0] ? 1 : 0)} ; nozzle check
M862.3 P "MK3.5" ; printer model check
M862.5 P2 ; g-code level check
M862.6 P"Input shaper" ; FW feature check
M115 U6.2.2+8853
M555 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32)} Y{(max(0, first_layer_print_min[1]) - 4)} W{((min(print_bed_max[0], max(first_layer_print_min[0] + 32, first_layer_print_max[0])))) - ((min(print_bed_max[0], first_layer_print_min[0] + 32) - 32))} H{((first_layer_print_max[1])) - ((max(0, first_layer_print_min[1]) - 4))}
G90 ; use absolute coordinates
M83 ; extruder relative mode
; ---------------------------------------------
; Pinda soaking addon to default Prusa G-Code
; https://forum.prusa3d.com/forum/original-prusa-i3-mk3s-mk3-assembly-and-first-prints-troubleshooting/bed-not-level-after-bed-level-correct/
; ---------------------------------------------
; cool down PINDA
M106 S255 ; turn on fan
M104 S0 ; turn off nozzle heat
M140 S0 ; turn off bed heat
M860 S35 ; wait until PINDA is less than 35C
M106 S0 ; turn off fan
; preheat nozzle to a low temp, get plastic mushy before driving into the bed with G28
M140 S[first_layer_bed_temperature] ; set bed temp
M109 R175 ; wait for extruder temp
M190 R[first_layer_bed_temperature] ; set & wait for bed temp
G28 W ; home all without mesh bed level
; soak PINDA then level
G0 X50 Y50 Z1 F3000; this is a good PINDA heating position
M860 S37.5 ; wait until PINDA is >= 35C in winter, 37.5C spring/fall, 40C summer
G80 N7 R5; mesh bed leveling
; ---------------------------------------------
; default start gcode disabled
; ---------------------------------------------
;M140 S[first_layer_bed_temperature] ; set bed temp
;M104 T0 S170 ; set extruder temp for bed leveling
;M109 T0 R170 ; wait for temp
;M190 S[first_layer_bed_temperature] ; wait for bed temp
;G28 ; home all
; ---------------------------------------------
G29 P1 ; invalidate mbl & probe print area
G29 P1 X23 Y5 W80 H20 C ; probe near purge place
G29 P3.2 ; interpolate mbl probes
G29 P3.13 ; extrapolate mbl outside probe area
G29 A ; activate mbl
; prepare for purge
M104 S{first_layer_temperature[0]}
G0 X0 Y-4 Z15 F4800 ; move away and ready for the purge
M109 S{first_layer_temperature[0]}
; Extrude purge line
G92 E0 ; reset extruder position
G0 E7 X15 Z0.2 F500 ; purge
G0 X25 E4 F500 ; purge
G0 X35 E4 F650 ; purge
G0 X45 E4 F800 ; purge
G0 X48 Z0.05 F8000 ; wipe, move close to the bed
G0 X51 Z0.2 F8000 ; wipe, move quickly away from the bed
G92 E0
M221 S100 ; reset flow to 100%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment