Skip to content

Instantly share code, notes, and snippets.

@coltography
Last active February 13, 2025 01:23
Show Gist options
  • Save coltography/506843297ca3c4f94c2fa8f64a58e17f to your computer and use it in GitHub Desktop.
Save coltography/506843297ca3c4f94c2fa8f64a58e17f to your computer and use it in GitHub Desktop.
Bambu Lab P1S/P1P Optimized Startup GCode

Optimized startup GCode for Bambu Lab P series. Keeps all the original startup actions but changes the order in which they happen, and proceed with the startup instead of waiting for the bed to heat up. It's usually almost always ready to print by the time it's finished, unless you're printing with a bed temp above 60C it might pause before proceeding.

This changes the purge line to be similiar to the KAMP purge line.

Not tested on units with AMS.

Use at your own risk!

;______Machine: Bambu Labs P1 Series______
;______Date: FEB/2025______
;______FW Version: 01.07.00.00______
;______Modified by: https://github.com/coltography
;This modified Startup g-code optimizes the process a little to cut the print start time in half (or more!)
;Doesn't sacrifice any quality settings or remove any safeties, but use at your own risk regardless.
;Comments are messy and still a work in progress.
; _____PREHEAT NOZZLE, BED, TURN ON NOZZLE FAN, MOTHERBOARD FAN_____
M104 S140 ; Preheat nozzle to bed leveling temperature; turns on nozzle fan
M140 S[bed_temperature_initial_layer_single] ; Set bed temperature
M710 A1 S255 ; Turn on motherboard fan (P1S)
;_____RESET MACHINE STATUS______
M290 X40 Y40 Z2.6666666
G91
M17 Z0.4 ; Lowers z-axis motor current to prevent damage if it collides with print head
G380 S2 Z30 F800 ; G380 is same as G38; lower the hotbed , to prevent the nozzle is below the hotbed
G380 S2 Z-25 F800 ; default F300
G1 Z5 F800 ; default F300
G90 ; absolute positioning mode
M17 X1.2 Y1.2 Z0.75 ; Reset motor current to default
G90 ; absolute positioning mode
M220 S100 ; Reset Feed rate
M221 S100 ; Reset Flow rate
M73.2 R1.0 ; Reset print time remaining
M1002 set_gcode_claim_speed_level : 5
M221 X0 Y0 Z0 ; turn off soft endstop to prevent protential logic problem
G29.1 Z{+0.0} ; clear z-trim value first
M204 S10000 ; init ACC set to 10m/s^2
; _______TURN ON FANS TO PREVENT PLA JAMMING IF NOZZLE GETS HOT FROM PRINT BED______
; ________ ONLY ACTIVATES IF BED TEMP IS ABOVE 45C WHEN PRINT STARTS AND FILAMENT IS PLA ________
{if filament_type[initial_extruder]=="PLA"}
{if (bed_temperature[initial_extruder] >45)||(bed_temperature_initial_layer[initial_extruder] >45)}
M106 P3 S180
{endif} ; Prevent PLA from jamming
{endif}
M106 P2 S100 ; turn on auxillary part cooling fan to cool down nozzle quicker
; ______PREPARE PRINT TEMPERATURE AND AMS_______
G91 ; Sets relative positioning mode
G0 Z10 F1200 ; Moves print bed 10mm
G90 ; Sets back to absolute positioning mode
G28 X ; Homes the print head to X axis only
M975 S1 ; Turns on vibration compensation (?) Whatever that does
G1 X60 F12000
G1 Y245 ; Moves print head to Y245 (Back near garbage)
G1 Y265 F3000 ; Moves print head to Y265 slower (back near garbage)
M620 M ; Enables AMS(?)
M620 S[initial_extruder]A ; switch material if AMS exist
M109 S[nozzle_temperature_initial_layer]
G1 X120 F12000
G1 X20 Y50 F12000
G1 Y-3
T[initial_extruder]
G1 X54 F12000
G1 Y265
M400
M621 S[initial_extruder]A
M620.1 E F{filament_max_volumetric_speed[initial_extruder]/2.4053*60} T{nozzle_temperature_range_high[initial_extruder]}
M412 S1 ; Enables filament run-out detection
; ______PREPARE NOZZLE TO WIPE ON BED_______
M975 S1 ; Turns on vibration compensation (?) Whatever that does
G0 X135 Y253 F20000 ; Move to exposed steel surface edge / bed wiping area
; BED WOBBLES BEFORE NEXT STEP
G28 Z P0 T300; Home Z axis with low precision, allowing 300C temperature
G29.2 S0 ; Disable bed leveling compensation
G0 Z5 F20000 ; Moves Z axis 5mm quickly
; _____HARD WIPE NOZZLE ON AND TURN ON FAN______
G1 X60 Y265
G92 E0
; G1 E-0.5 F300 ; retrack more ; DEFAULT THIS IS ON
G1 X100 F5000; second wipe mouth
G1 X70 F15000
G1 X100 F5000
G1 X70 F15000
G1 X100 F5000
G1 X70 F15000
G1 X100 F5000
G1 X70 F15000
G1 X90 F5000 ; Wipes 4 times
G0 X128 Y261 Z-1.5 F20000 ; Move to exposed steel surface and stop the nozzle
M104 S140 ; set temp down to heatbed acceptable
M106 S255 ; turn on fan (G28 has turn off fan)
; _____WIPE NOZZLE ON BED TO PREPARE FOR BED LEVELING______
M221 S; push soft endstop status
M221 Z0 ;turn off Z axis endstop
G0 Z0.5 F20000
G0 X125 Y259.5 Z-1.01 ; bed hops down/up
G0 X131 F211
G0 X124
G0 Z0.5 F20000
G0 X125 Y262.5
G0 Z-1.01 ; bed hops down/up
G0 X131 F211
G0 X124
G0 Z0.5 F20000
G0 X125 Y260.0
G0 Z-1.01 ; bed hops down/up
;G0 X131 F211
;G0 X124
;G0 Z0.5 F20000
;G0 X125 Y262.0
;G0 Z-1.01 ; bed hops down/up
;G0 X131 F211
;G0 X124
;G0 Z0.5 F20000
;G0 X125 Y260.5
;G0 Z-1.01 ; bed hops down/up
;G0 X131 F211
;G0 X124
;G0 Z0.5 F20000
;G0 X125 Y261.5
;G0 Z-1.01 ; bed hops down/up
;G0 X131 F211
;G0 X124
;G0 Z0.5 F20000
;G0 X125 Y261.0
;G0 Z-1.01 ; bed hops down/up ; disabled some hops because 7 is unnecessary ; will keep testing
G0 X131 F211
G0 X124
G0 X128
G2 I0.5 J0 F300
G2 I0.5 J0 F300
G2 I0.5 J0 F300
G2 I0.5 J0 F300 ; 1st circular motion wipe
;
G2 I0.5 J0 F3000
G2 I0.5 J0 F3000
G2 I0.5 J0 F3000
G2 I0.5 J0 F3000 ; Completes quick 2nd circular motion wipe for final nozzle on flat surface (preparing for precise bed leveling)
;_____BED LEVEL AND HOME Z AXIS_____
M221 R; pop softend status ; disables end stop? ; Resets extrusion settings? reset progress bar on LCD?
; Any extruder temperatures are reset here to complete homing of z-axis without filament ooze, can't be overridden
G1 Z10 F1200
M400
G1 Z10
G1 F30000 ; Sets feedrate to 30000 mm/min
G1 X230 Y15 ; Moves print head to front right of glass cover
G29.2 S1 ; Enable Bed Leveling Compensation
; G28 ; home again after hard wipe mouth ; DISABLED BY DEFAULT
M106 S0 ; Turns off chamber fan
; ______ bed leveling start ; optional toggle which appears before starting print(?) ___________
M1002 judge_flag g29_before_print_flag
M622 J1
M1002 gcode_claim_action : 1
G29 A X{first_layer_print_min[0]} Y{first_layer_print_min[1]} I{first_layer_print_size[0]} J{first_layer_print_size[1]}
M400
M500 ; save cali data
M623 ; Sets extrusion multiplier (?)
; ______ bed leveling end________
; _______HOME ALL AXIS________
M1002 judge_flag g29_before_print_flag
M622 J0
M1002 gcode_claim_action : 13
G28 ; Homes all axis
M623 ; Sets extrusion multiplier (?)
M975 S1 ; Turns on vibration compensation (?) Whatever that does
;_________TURN ON FANS TO PREVENT PLA JAMMING FROM HEAT CREEP__________
; Same as command at start of gcode, may be redundant?
{if filament_type[initial_extruder]=="PLA"}
{if (bed_temperature[initial_extruder] >45)||(bed_temperature_initial_layer[initial_extruder] >45)}
M106 P3 S180
{endif};Prevent PLA from jamming
{endif}
M106 P2 S100 ; turn on big fan, to cool down toolhead
; _____INPUT SHAPING VIBRATION CHECK, SET NOZZLE TEMPERATURE_________
M104 S{nozzle_temperature_initial_layer[initial_extruder]} ; Set nozzle temperature early as possible
G1 X128 Y128 Z10 F20000
M400 P200
M970.3 Q1 A7 B30 C80 H15 K0
M974 Q1 S2 P0
G1 X128 Y128 Z10 F20000
M400 P200
M970.3 Q0 A7 B30 C90 Q0 H15 K0
M974 Q0 S2 P0
; ______HOME PRINT HEAD X AXIS_______
M975 S1 ; Turns on vibration compensation (?) Whatever that does
G1 F30000
G1 X230 Y15 ; Move print head towards home position
G28 X ; Home X axis
; ______POSITION PRINT HEAD OVER GARBAGE______
M975 S1 ; Turns on vibration compensation (?) Whatever that does
G1 X65 Y230 F18000 ; Moves print head outward
G1 Y264 F6000 ; Moves print head back to garbage
; G1 X100 F18000 ; Wipes nozzle again
; G1 X65 F18000 ;
; ______INITIAL NOZZLE PURGE AND WIPE_________
M109 S[nozzle_temperature_initial_layer] ; Wait for nozzle to reach printing temp
G92 E0 ; Reset Extruder
M106 P1 S0 ; Turn off part cooling fan
G1 E20 F200 ; Extrude some filament
M400
M106 P1 S255 ; Turns on part cooling fan to 100 percent
M400 S2 ; Waits for filament to cool a little before shake
; ______SHAKE AND WIPE_________
G1 X70 F9000
G1 X76 F15000
G1 X65 F15000
G1 X76 F15000
G1 X65 F15000
G1 X76 F15000
G1 X65 F15000
G1 X76 F15000
G1 X65 F15000
G1 X76 F15000
G1 X65 F15000
G1 X76 F15000
G1 X65 F15000 ; Shake print head to detach melted filament, tripled for extra shake
G1 X80 F6000
G1 X95 F15000
G1 X80 F15000
G1 X165 F15000; Hard wipe end
G1 X65 Y230 F18000 ; Moves print head outward
G1 Y264 F6000 ; Moves print head back to garbage to wait for bed to reach temp
; ______WAIT FOR NOZZLE AND BED TEMP BEFORE PROCEEDING_______
M190 S[bed_temperature_initial_layer_single] ; Wait for bed to reach temperature if it hasn't reached it yet
; M109 R{nozzle_temperature_initial_layer[initial_extruder]-60} ; Wait until nozzle is at least 50 degrees below printing temp ; continues if above
M104 S{nozzle_temperature_initial_layer[initial_extruder]} ; Set final extruder temperature so it continues to rise during purge
G1 X165 F15000 ; final wipe
; ____SET Z-OFFSET FOR TEXTURED PEI PLATE_____
;curr_bed_type={curr_bed_type}
{if curr_bed_type=="Textured PEI Plate"}
G29.1 Z{-0.04} ; for Textured PEI Plate
{endif}
; _____TURN OFF FANS_____
M1002 gcode_claim_action : 0
M106 S0 ; turn off part fan
M106 P2 S0 ; turn off aux fan
M106 P3 S0 ; turn off chamber fan
M975 S1 ; Turns on vibration compensation (?) Whatever that does
; ______ START PURGE LINE______
G92 E0.0; reset extruder
G1 X{first_layer_print_min[0]-10} Y{first_layer_print_min[1]} Z0.8 F6000.0; position 10mm left from the lower left of the first layer
G1 X{first_layer_print_min[0]-10} Y{first_layer_print_min[1]+30} E35 F360.0; extrude 35mm of filament in the Y direction
G92 E0.0; reset extruder
G1 E-0.5 F2100; small retraction
G1 Y{first_layer_print_min[1]+40} f6000.0; move an aditional 10mm without extruding
G92 E0.0; reset extruder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment