Skip to content

How P1S GCODE Works

Justagwas edited this page Jul 18, 2026 · 1 revision

How P1S-GCODE Works

The short explanation

P1S-GCODE replaces the machine preparation and shutdown sections generated by the slicer.

Before the model begins, the selected start profile initializes the printer, begins heating, homes the axes, prepares filament, purges and wipes the nozzle, handles adaptive probing where applicable, and primes near the front of the build plate.

After the model finishes, the selected end profile retracts and clears the print, cleans the nozzle, handles filament unloading, turns off the heaters, lowers the bed, parks the toolhead, and completes the final ventilation stage.

The model toolpath remains controlled by the slicer.

What this means for you

  • Choose S, L-Lite, L, or XL according to which you prefer.
  • Use L as the balanced everyday profile.
  • Keep Bed Leveling enabled for L-Lite, L, and XL.
  • Use the same profile files with an AMS or the external spool.
  • Continue selecting print, filament, and quality settings normally in the slicer.
  • Slice the model again whenever the machine profile changes.

The complete path

Start sequence

  1. Initialize: set positioning, extrusion, motor-current, feed, and flow state.
  2. Enable: activate filament runout detection and resonance compensation.
  3. Heat: begin bed and nozzle heating.
  4. Home: establish the printer’s machine position.
  5. Prepare filament: enter the Bambu material-system sequence.
  6. Purge: establish filament flow at the rear purge area.
  7. Wipe: clean the nozzle using the profile-specific movement sequence.
  8. Probe: L-Lite, L, and XL can probe the first-layer print area.
  9. Compensate: enable bed-level compensation.
  10. Prime: prepare flow near the front of the plate.
  11. Print: hand control to the slicer-generated model toolpath.

End sequence

  1. Finish: allow the remaining model moves to complete.
  2. Clear: retract and raise above the printed model.
  3. Clean: move to the purge area and run the selected cleaning sequence.
  4. Unload: complete AMS unloading when an AMS is present.
  5. Switch off: set nozzle and bed heater targets to zero.
  6. Wipe: complete the final nozzle-cleaning movement.
  7. Restore: re-enable bed compensation and resonance control.
  8. Park: lower the bed and move the toolhead to its final position.
  9. Ventilate: run the profile-specific fan stage.
  10. Idle: turn off the profile-controlled fans and reduce holding current.

Profile comparison

Start profiles

Property S L-Lite L XL
Adaptive probing block No Conditional Conditional Conditional
Rear purge Minimal Reduced Moderate Extended
Wiping Short Moderate Moderate Extended
Front priming Stationary Short segment Full line Full staged line
Relative sequence Shortest Shorter Balanced Longest

End profiles

Property S L XL
Cleaning Short purge and minimal wiping Retraction and moderate wiping Extended purge and wiping
Bed lowering Up to 80 mm Up to 100 mm Up to 100 mm
Final ventilation 10 seconds 30 seconds 60 seconds
Relative sequence Shortest Balanced Longest

Slicer-provided values

The profiles use values supplied by the active slicer configuration.

Examples include:

[bed_temperature_initial_layer]
[nozzle_temperature_initial_layer]
[initial_extruder]

The slicer replaces these expressions when the model is generated.

The scripts also use information derived from the model:

{first_layer_print_min[0]}
{first_layer_print_size[1]}
{max_layer_z + 2}

This allows the probing area and final clearance move to follow the current print.

Initial machine state

The start profiles begin with commands such as:

G90
M83
M17 X1.2 Y1.2 Z0.75
M220 S100
M221 S100

These establish absolute XYZ positioning, relative extrusion, the profile motor-current state, and normal feed and flow multipliers.

Runout detection and resonance compensation are then enabled before heating and homing begin.

Heating strategy

The custom profiles start bed and nozzle heating early:

M140 S[bed_temperature_initial_layer]
M104 S[nozzle_temperature_initial_layer]

This allows heating to continue while the printer completes the remaining preparation stages.

The nozzle is later brought to its required target with M109 before extrusion.

The stock reference sequence uses an explicit M190 bed wait. The custom profiles use a different preparation order in which bed heating overlaps with the rest of the start routine.

AMS and external-spool behavior

The profiles use the same Bambu material-system block structure found in the stock P1S machine G-code:

M620 ...
...
M621 ...

With an AMS, the printer uses these blocks for material selection, loading, cutting, and unloading.

With the external spool, the AMS-specific operation is not performed. The surrounding start and end sequence remains unchanged.

Adaptive probing

L-Lite, L, and XL contain:

M1002 judge_flag g29_before_print_flag
M622 J1
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]}
M500
M623
G29.2 S1

The g29_before_print_flag controls entry into the probing block. When the block runs, G29 A probes the first-layer print area, and G29.2 S1 enables compensation afterward.

S omits the probing block and enables compensation directly.

The two video examples in the README show these two observed paths: the conditional block being skipped and the block being entered. The custom script does not contain a separate mesh-scoring algorithm.

Start-profile details

S-START

S uses a 2 mm initial prime, an 8 mm rear purge, a short wipe sequence, and a 4 mm front prime. It does not draw a full purge line.

L-START-LITE

L-Lite uses a reduced rear purge, a moderate wipe sequence, adaptive probing support, and a short front purge segment.

Its purpose is to reduce startup material use relative to standard L. A strong material or color transition may remain more visible at the beginning of the print.

L-START

L uses a 4 mm initial prime, a 36 mm rear purge, moderate wiping, adaptive probing support, and a full front purge line.

This is the balanced profile.

XL-START

XL adds staged temperatures, additional purge, an extended wipe sequence, adaptive probing support, and a full staged front purge line.

This is the most extensive start profile.

End-profile details

S-END

S uses a short purge and minimal wipe sequence, lowers the bed by up to 80 mm, and finishes with 10 seconds of ventilation.

L-END

L uses retraction and moderate wiping. Its positive extrusion inside the material-system block positions filament during cutting and unloading rather than acting as a separate nozzle purge.

It lowers the bed by up to 100 mm and finishes with 30 seconds of ventilation.

XL-END

XL uses the longest purge, wipe, unloading, and ventilation sequence.

It lowers the bed by up to 100 mm and finishes with 60 seconds of ventilation.

Final machine state

All end profiles set the nozzle and bed targets to zero:

M104 S0
M140 S0

They temporarily disable bed compensation for part of the final wipe and then restore it.

All profiles turn off the part, auxiliary, and chamber fans after ventilation. S and XL also issue M710 S0; the equivalent line is commented in L, leaving that controller-fan state to the firmware.

Source reference map

Area Project file
Short start profile S-START G-code
Reduced-purge start profile L-START-LITE G-code
Balanced start profile L-START G-code
Extended start profile XL-START G-code
Short end profile S-END G-code
Balanced end profile L-END G-code
Extended end profile XL-END G-code
Stock comparison STOCK-START and STOCK-END

Related pages