;=========================================================== ;===== XL-End G-code for Bambu Lab P1S WITH AMS ============ ;===== Author: Justagwas =================================== ;===== Date: 2026-05-22 ==================================== ;=========================================================== ; This end script is the "XL" profile for the Bambu Lab P1S. ; It retracts filament, performs a spiral lift, and moves to the purge area. ; The nozzle is primed, purged, cooled in stages, and wiped multiple times. ; Filament is unloaded via the AMS, then the nozzle and bed heaters are turned off. ; The nozzle is wiped again with bed leveling disabled, then leveling is re-enabled. ; Timelapse recording is stopped if it was enabled. ; The bed is moved to a safe height, the toolhead is parked, and motion settings are reset. ; Fans run in a ventilation/cooldown stage, then all fans are turned off and motor currents are reduced. ;===== Ensure motion buffer is clear ======================= M400 ; Wait for all moves to finish M83 ; Relative extrusion mode ;===== Reset motor currents and acceleration =============== M17 X1.2 Y1.2 Z0.75 ; Restore default motor currents M204 S10000 ; Reset acceleration M1002 set_gcode_claim_speed_level :5 ; Internal speed mode reset ;===== Initial retraction and purge ======================== G92 E0 ; Zero extruder position G1 E-0.5 F300 ; Retract 0.5mm to relieve pressure ;===== Spiral lift and retreat ============================= G91 ; Switch to relative positioning G1 Z1 X5 Y5 F3000 ; Lift Z +1mm and move G1 X-10 Y5 F3000 G1 X5 Y-10 F3000 G1 Z2 X5 Y5 F3000 G90 ; Back to absolute positioning G1 Z{max_layer_z + 2} F900 ; Clear tallest print before XY travel G1 E-1.5 F200 ; Retract 1.5mm further ;===== Move to safe park position ========================== G1 X65 Y265 F12000 ; Move head to purge/park area M400 S3 ; Wait for moves to complete ;===== Fan to max ========================================== M106 P1 S255 ; Part cooling fan full speed G92 E0 ; Reset extruder G1 E2 F200 ; Small 2mm prime G4 S6 ; Dwell 6 seconds ;===== Purge =============================================== G92 E0 ; Reset extruder G1 E3 F200 ; Extrude 3mm at 200mm/min M400 ; Wait M104 S200 ; Cool nozzle to 200C (non-blocking) G92 E0 ; Reset extruder G1 E-2 F200 ; Retract 2mm M400 ; Wait ;===== Lower purge temperature ============================= M104 S180 ; Cool to 180C (non-blocking) G92 E0 ; Reset extruder G1 E6 F100 ; Final ooze M400 ; Wait ;===== Wiping movements ==================================== ; Initial wipe pattern to remove residue G1 E-3 F200 ; Retract 3mm G1 X70 F9000 ; Wipe to X70 G1 X95 F12000 ; Wipe to X95 G1 X70 F9000 ; Back to X70 G1 X165 F12000 ; Long wipe to X165 G1 X70 F9000 ; Back to X70 G1 X95 F12000 ; Wipe to X95 G1 X70 F9000 ; Back to X70 G1 E-1 F200 ; Retract again G1 X70 F9000 G1 X95 F12000 G1 X70 F9000 G1 X95 F12000 G1 X70 F9000 G1 X95 F12000 G1 X70 F9000 G1 X95 F12000 ;===== Lower fan =========================================== G1 X88 F9000 ; Move near wipe area G1 X89 F500 ; Precise positioning M106 P1 S150 ; Lower part fan to ~59% G4 S2 ; Dwell 2 seconds ;===== Cool to <=180 before AMS ============================ G1 E-1 F200 ; Retract 1mm M109 S180 ; Wait until 180C G1 X70 F9000 ; Wipe G1 X95 F12000 ; Wipe G1 X70 F9000 ; Back G1 X95 F12000 ; Wipe G1 X70 F9000 ; Back G1 X140 F9000 ; Move to X140 ;===== AMS unload sequence with push/retract =============== M109 S175 ; Wait until 175C M620 S255 ; Begin AMS unload G1 E-1 F200 ; Retract before cut G1 X20 Y50 F12000 ; Move to cut area G1 Y-3 ; Lower T255 ; Select cut tool G1 E2 F200 ; Push to clear inlet G1 X65 F12000 ; Move away G1 Y265 ; Move to retract position M621 S255 ; Complete AMS unload ;===== Cool nozzle/bed down fully ========================== M104 S0 ; Turn off nozzle heater M140 S0 ; Turn off bed heater ;===== Wipe nozzle with ABL off ============================ M1002 gcode_claim_action :14 ; Declare wipe action G29.2 S0 ; Disable ABL G1 X65 Y265 F8000 ; Wipe pattern start G1 X100 F5000 G1 X70 F15000 G1 X100 F5000 G1 X70 F15000 G1 X100 F5000 G1 X70 F15000 G1 X100 F5000 M400 ; Wait for completion ;===== Re-enable ABL and vibration suppression ============= G29.2 S1 ; Re-enable ABL M975 S1 ; Enable resonance compensation M1002 gcode_claim_action :0 ; Clear action state ;===== Stop timelapse recording safely ===================== M622.1 S1 ; End timelapse block M1002 judge_flag timelapse_record_flag ; Check if timelapse enabled M622 J1 ; If true: M400 ; Wait M991 S0 P-1 ; Stop timelapse M400 S3 ; Wait M623 ; End conditional M400 ; Final wait ;===== Lower heatbed safely ================================ M17 S ; Reset motors M17 Z0.4 ; Lower Z motor current {if (max_layer_z + 100.0) < 248} G1 Z{max_layer_z + 100.0} F600; Lower Z 100mm if safe {else} G1 Z248 F600 ; Otherwise lower near max {endif} M400 P100 ; Wait G90 ; Absolute positioning G1 X128 Y250 F3600 ; Park head ;===== Reset motion settings =============================== M220 S100 ; Reset feedrate M201.2 K1.0 ; Reset tuning M73.2 R1.0 ; Reset print time calc M1002 set_gcode_claim_speed_level :0 ; Clear speed claim ;===== Fast cooldown (all fans high) ======================= M106 P1 S200 ; Part fan ~78% M106 P2 S200 ; Aux fan ~78% M106 P3 S200 ; Chamber fan ~78% M400 S30 ; Run for 30s ;===== Second cooldown (medium) ============================ M106 P1 S100 ; Part fan ~39% M106 P2 S100 ; Aux fan ~39% M106 P3 S125 ; Chamber fan ~49% M400 S30 ; Run for 30s ;===== Turn off all fans =================================== M106 P1 S0 ; Part fan off M106 P2 S0 ; Aux fan off M106 P3 S0 ; Chamber fan off M710 S0 ; MC board fan off ;===== Lower motor currents ================================ M17 X0.8 Y0.8 Z0.5 ; Reduce holding current for idle ;===== Final state ========================================= M1002 gcode_claim_action :0 ; Clear any remaining action state ; END