;=========================================================== ;===== L-Start G-code for Bambu Lab P1S WITH AMS =========== ;===== Author: Justagwas =================================== ;===== Date: 2026-01-24 ==================================== ;=========================================================== ; This start script is the "L" profile for the Bambu Lab P1S. ; It homes the printer, enables runout and resonance compensation, ; and sets default motor currents, feedrate and flow. ; It heats the bed and nozzle, then performs AMS load and tuning. ; The nozzle is primed, purged, and wiped with a reduced wipe sequence, ; followed by a short cooldown and light wipe. ; The printer then conditionally runs adaptive bed leveling on the first-layer area, ; saves the mesh, and enables bed leveling compensation. ; It finishes by priming near the front of the bed and performing a circular wipe, ; then retracts slightly to reduce oozing before printing begins. ;===== DEFAULTING ========================================== G90 ; Absolute positioning mode M83 ; Relative extrusion mode M17 X1.2 Y1.2 Z0.75 ; DEFAULT MOTOR CURRENTS DO NOT CHANGE M290 X40 Y40 Z2.6666666 ; DEFAULTS DO NOT CHANGE M220 S100 ; Feedrate 100% M221 S100 ; Flow rate 100% M73.2 R1.0 ; Reset print time calculation M1002 set_gcode_claim_speed_level :5 ; Internal speed mode M221 X0 Y0 Z0 ; Reset flow modifiers per axis ; G29.1 Z{-0.02} ; Z-offset -0.02mm - negative=closer to bed, positive=farther ; ^ Currently not in use because of ";" ;===== Enable filament runout detection ==================== M412 S1 ; Enable runout sensor (S0=disable) M975 S1 ; Enable resonance compensation (S0=disable) ;===== Turn on fans to safe defaults ======================= M106 P1 S125 ; Part cooling fan 49% (0-255 scale) M106 P2 S50 ; Aux fan 20% (0-255 scale) M106 P3 S125 ; Chamber fan 49% (0-255 scale) M710 A1 S255 ; Controller fan AUTO ;===== Preheat bed and nozzle ============================== M1002 gcode_claim_action :2 ; Declare heating action M140 S[bed_temperature_initial_layer] ; Start bed heating (non-blocking) M104 S[nozzle_temperature_initial_layer] ; Set nozzle temp (non-blocking) ;===== Initial homing ====================================== G28 ; Home all axes (X, Y, Z to endstops) M400 ; Wait for moves to complete ;===== Heat nozzle to purge temperature ==================== M104 S[nozzle_temperature_initial_layer] ; Re-Set nozzle temp (non-blocking) ;===== Prepare AMS (force reload) ========================== M1002 gcode_claim_action :4 ; Declare AMS action M620 M ; AMS: enter manual mode M620 S[initial_extruder]A ; AMS: select extruder slot T[initial_extruder] ; Activate tool M621 S[initial_extruder]A ; AMS: confirm filament loaded M620.1 E F{filament_max_volumetric_speed[initial_extruder]/2.4053*60} T{nozzle_temperature_range_high[initial_extruder]} ;===== Declare purge action ================================ M1002 gcode_claim_action :14 ; Declare wipe/purge action ;===== Move to purge area ================================== G1 X65 Y265 F8000 ; Move to purge position at 8000mm/min M109 S[nozzle_temperature_initial_layer] ; Wait for nozzle temp (blocking) M106 P1 S255 ; Part fan to 100% for cooling purge G92 E0 ; Reset extruder position to zero G1 E4 F240 ; Extrude 4mm at 4 mm/s - 240mm/min (prime nozzle) G4 S1 ; Dwell 1 second ;===== Purge (balanced) ==================================== G92 E0 ; Reset extruder G1 E36 F300 ; Purge 36mm to clear old material M400 ; Wait for purge M104 S160 ; Begin cooling to 160C (non-blocking) G92 E0 ; Reset extruder M400 ; Wait G4 S2 ; Dwell 2 seconds ;===== Wiping movements (reduced) ========================== ; Perform a moderate wipe sequence to clean the nozzle G1 E-3 F400 ; Retract G4 S1 ; Dwell 1 second G1 X70 F9000 ; Wipe to X70 G1 X95 F12000 ; Wipe to X95 G1 X70 F9000 ; Back to X70 G1 X125 F12000 ; Longer wipe to X125 G1 X70 F9000 ; Back to X70 G1 X95 F12000 ; Wipe again G1 X70 F9000 ; Back M400 ; Ensure retract done G1 E-2 F1200 ; Second retract G1 X70 F9000 G1 X95 F12000 G1 X70 F9000 G1 X95 F12000 G1 X70 F9000 M400 ; Ensure retract done G1 E-3 F800 ; Third retract M400 ; Wait for all moves to finish ;===== Cooldown ============================================ G1 X88 F8000 ; Move to X88 G1 X89 F500 ; Precise positioning M400 ; Ensure retract done G4 S4 ; Dwell 4 seconds G1 X70 F9000 ; Light wipe G1 X95 F12000 ; Wipe back G1 X70 F9000 G1 X95 F12000 G1 X70 F9000 M400 ; Ensure moves are done ;===== Reset action and adaptive bed leveling ============= M1002 gcode_claim_action :0 ; Clear action state G1 X110 Y110 F6000 ; Move to centre of bed M400 ; Wait M1002 judge_flag g29_before_print_flag M622 J1 ; If bed leveling enabled then: M106 P1 S150 ; Reduce part fan to ~59% M1002 gcode_claim_action :1 ; Declare mesh action 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 ; Wait for probing to complete M1002 gcode_claim_action :0 ; Clear action state M500 ; Save mesh M623 ; End conditional G29.2 S1 ; Enable bed leveling compensation ;===== Prime and move to print start ======================= M104 S[nozzle_temperature_initial_layer] ; Start heating to print temp G1 X20 Y5 F10000 ; Move to purge line start position G1 Z0.3 F1200 ; Lower to 0.3mm height M109 S[nozzle_temperature_initial_layer] ; Wait until print temperature (blocking) G92 E0 ; Reset extruder G1 E8 F600 ; 8mm (Filament) Purge G92 E0 ; Reset extruder G1 X60 Y5 E12 F600 ; 40mm (Path) slower purge, high extrusion G1 X220 Y5 E24 F1200 ; Remaining purge at normal speed G92 E0 ; Reset extruder G3 X220 Y5 I-2 J0 E1.2 F900 ; CCW half-circle wipe G3 X220 Y5 I2 J0 E1.2 F900 ; CCW second half G1 E-0.5 F120 ; Retract 0.5mm to prevent ooze M400 ; Ensure commands complete ;===== Final state ========================================= ; M106 P1 S0 ; Part cooling fan OFF ; M106 P2 S0 ; Aux / chamber fan OFF M400 ; Wait M975 S1 ; Keep resonance compensation enabled ; END