BBL P1S organized start and end gcode

Hello everyone~

I have been trying to understand how the printer works with its BBL specific gocde and I did some cleaning / optimization on the stock profile start and end gcodes:

I am still trying to get a list of the commands from BBL, but until then, I think this should help.

Enjoy!

; ========== machine: P1S ==========
; ========== date: 20231130 ==========
; ========== start gcode modified by mmoraes80 ==========

; ========== BBL P1S Auto Control for Machine Control Board Fan ==========
M710 A1 S255; MCB fan will turn on automatically if hot end temp >=50C

; ========== reset machine status ==========
M290 X40 Y40 Z2.666666 6
G91; use relative coordinates
M17 Z0.4; lower the z-motor current
G380 S2 Z30 F300
G380 S2 Z-25 F300
G1 Z5 F300
G90; use absolute coordinates
M17 X1.2 Y1.2 Z0.75; reset motor current to default
M220 S100; Reset Feedrate
M221 S100; Reset Flowrate
M73.2 R1.0; Reset left time magnitude
M1002 set_gcode_claim_speed_level : 5
M221 X0 Y0 Z0; turn off soft endstop to prevent potential logic problem
G29.1 Z{+0.0}; clear z-trim value first
M204 S10000; ste starting acceleration to 10m/s^2

; ========== filament runout detection ==========
M412 S1; Enable (and reset) filament runout detection

; ========== preheat tool head ==========
; Display meesage “Heating hotend” on Bambu Handy App & Slicer plugin
M1002 gcode_claim_action : 7
M104 S75; set extruder temp to 75C to turn MC board fan on

; ========== preheat build plate ==========
; Display meesage “Heatbed preheating” on Bambu Handy App & Slicer plugin
M1002 gcode_claim_action : 2
M140 S[bed_temperature_initial_layer_single]; set bed temp
M190 S[bed_temperature_initial_layer_single]; wait for bed temp

; ========== prepare printer ==========
M104 S[nozzle_temperature_initial_layer]; set extruder to printing temp
G91; use relative coordinates
G0 Z10 F1200
G90; use absolute coordinates
G28 X
M975 S1; turn on vibration suppression
G1 X60 F12000
G1 Y245
G1 Y265 F3000

; ========== switch material if AMS exists ==========
M620 M
M620 S[initial_extruder]A
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]}

; ========== purge nozzle and remove poop ==========
; Display meesage “Heating hotend” on Bambu Handy App & Slicer plugin
M1002 gcode_claim_action : 7
M109 S[nozzle_temperature_initial_layer]
M400
M104 S[nozzle_temperature_initial_layer]
M106 P1 S0
G92 E0
G1 E20 F200; purge 20mm of filament (useful for different previous color)
M400
G92 E0
G1 E10 F200; purge 10mm of filament
M400
M106 P1 S255; ; turn part cooling fan on to cool extruded filament
G92 E0
G1 E5 F300
M109 S{nozzle_temperature_initial_layer[initial_extruder]-20}; drop nozzle temp by 20C
G92 E0
G1 E-1.0 F300; retract 1mm of filament to reduce oozing
G1 X70 F9000
G1 X76 F15000
G1 X65 F15000
G1 X76 F15000
G1 X65 F15000
G1 X80 F6000
G1 X95 F15000
G1 X80 F15000
G1 X165 F15000
M400
M106 P1 S0; turn part cooling fan off

; ========== wipe nozzle tip ==========
; Display meesage “Cleaning nozzle tip” on Bambu Handy App & Slicer plugin
M1002 gcode_claim_action : 14
M975 S1; turn on vibration suppression
M106 P1 S255

G1 X65 Y230 F18000
G1 Y264 F6000

M109 S{nozzle_temperature_initial_layer[initial_extruder]-20}

G1 X100 F18000
G0 X135 Y253 F20000

G28 Z P0 T300; home z with low precision, allow 300C nozzle temperature
G29.2 S0; turn off ABL

G0 Z5 F20000
G1 X60 Y265
G92 E0
G1 E-0.5 F300
G1 X100 F5000
G1 X70 F15000
G1 X100 F5000
G1 X70 F15000
G1 X100 F5000
G1 X70 F15000
G1 X100 F5000
G1 X70 F15000
G1 X90 F5000

G0 X128 Y261 Z-1.5 F20000 ; move to exposed steel surface and stop the nozzle

M104 S140; set build plate temp down to 140C for probing
M106 P1 S255; turn on fan (G28 turned fan off)

M221 S; push soft endstop status
M221 Z0; turn off Z axis endstop
G0 Z0.5 F20000
G0 X125 Y259.5 Z-1.01
G0 X131 F211
G0 X124
G0 Z0.5 F20000
G0 X125 Y262.5
G0 Z-1.01
G0 X131 F211
G0 X124
G0 Z0.5 F20000
G0 X125 Y260.0
G0 Z-1.01
G0 X131 F211
G0 X124
G0 Z0.5 F20000
G0 X125 Y262.0
G0 Z-1.01
G0 X131 F211
G0 X124
G0 Z0.5 F20000
G0 X125 Y260.5
G0 Z-1.01
G0 X131 F211
G0 X124
G0 Z0.5 F20000
G0 X125 Y261.5
G0 Z-1.01
G0 X131 F211
G0 X124
G0 Z0.5 F20000
G0 X125 Y261.0
G0 Z-1.01
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

M109 S140
G2 I0.5 J0 F3000
G2 I0.5 J0 F3000
G2 I0.5 J0 F3000
G2 I0.5 J0 F3000

M221 R; pop softend status
G1 Z10 F1200
M400
G1 Z10
G1 F30000
G1 X230 Y15
G29.2 S1; turn on ABL
M106 P1 S0; turn off fan

; ========== bed leveling ==========
M1002 judge_flag g29_before_print_flag
M622 J1
; Display meesage “Auto bed leveling” on Bambu Handy App & Slicer plugin
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 calibration data
M623

; Clear meesage on Bambu Handy App & Slicer plugin
M1002 gcode_claim_action : 0

; ========== home tool head after wiping nozzle ==========
M1002 judge_flag g29_before_print_flag
M622 J0
; Display meesage “Homing toolhead” on Bambu Handy App & Slicer plugin
M1002 gcode_claim_action : 13
G28
M623
M975 S1; turn on vibration suppression

; ========== turn on fans to prevent loaded PLA heat creep ==========
{if filament_type[initial_extruder]==“PLA”}
{if (bed_temperature[initial_extruder] >45)||(bed_temperature_initial_layer[initial_extruder] >45)}
M106 P2 S100; turn on AUX fan ,to cool down toolhead
M106 P3 S180
{elsif (bed_temperature[initial_extruder] >60)||(bed_temperature_initial_layer[initial_extruder] >60)}
M106 P2 S100; turn on AUX fan ,to cool down toolhead
M106 P3 S255
{endif}
{endif}

M104 S{nozzle_temperature_initial_layer[initial_extruder]}; set extrude temp earlier, to reduce wait time

; ========== mech mode fast check ==========
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

M975 S1
G1 F30000
G1 X230 Y15

; Display meesage “Homing toolhead” on Bambu Handy App & Slicer plugin
M1002 gcode_claim_action : 13
G28 X

; ========== prime noozle before print ==========
M975 S1; turn on vibration suppression
G90
M83
T1000
G1 X18.0 Y1.0 Z0.8 F18000;Move to start position
M109 S{nozzle_temperature_initial_layer[initial_extruder]}
G1 Z0.2
G0 E2 F300
G0 X240 E15 F{outer_wall_volumetric_speed/(0.30.5) * 60}
G0 Y11 E0.700 F{outer_wall_volumetric_speed/(0.3
0.5)/ 4 * 60}
G0 X239.5
G0 E0.2
G0 Y1.5 E0.700
G0 X18 E15 F{outer_wall_volumetric_speed/(0.3*0.5) * 60}
M400

; ========== Textured PEI Plate ==========
;curr_bed_type={curr_bed_type}
{if curr_bed_type==“Textured PEI Plate”}
G29.1 Z{-0.04}; lower the nozzle as it was touching topmost of the texture when homing
{endif}

; ========== turn off fans ==========
; Clear meesage on Bambu Handy App & Slicer plugin
M1002 gcode_claim_action : 0
M106 P1 S0; turn off fan
M106 P2 S0; turn off AUX fan
M106 P3 S0; turn off Chamber fan

M975 S1; turn on vibration suppression

; ========== end of start gcode ==========

; ========== date: 20231129 ==========
; ========== end gcode modified by mmoraes80 ==========

; ========== move toolhead up and back ==========
M400 ; wait for buffer to clear
G92 E0 ; zero the extruder
G1 E-0.8 F1800 ; retract
{if max_layer_z < max_print_height}G1 Z{z_offset+min(max_layer_z+1, max_print_height)} F900 ; Move print head up{endif}
G1 X65 Y245 F12000; park toolhead
G1 Y265 F3000
M140 S0 ; turn off build plate heater
M106 P1 S0 ; turn off part cooling fan
M106 P2 S0 ; turn off AUX cooling fan
M106 P3 S0 ; turn off chamber cooling fan
G1 X100 F12000 ; remove oozed filament

;========== if AMS exists ==========
M620 S255; pull back filament to AMS
G1 X20 Y50 F12000
G1 Y-3
T255

;========== wipe nozzle ==========
G1 X65 F12000
G1 Y265
G1 X100 F12000 ; wipe nozzle
M621 S255
M104 S0 ; turn off hotend

;========== finish timelapse ==========
M622.1 S1 ; for previous firmware, default is ON
M1002 judge_flag timelapse_record_flag
M622 J1
M400; wait all motion done
M991 S0 P-1 ;end smooth timelapse at safe pos
M400 S3 ;wait for last picture to be taken
M623; end of “timelapse_record_flag”

;========== lower build plate ==========
M400; wait all motion done
M17 S
M17 Z0.4 ; lower z motor current to reduce impact if there is something in the bottom
{if (max_layer_z + 100.0) < 250}
G1 Z{max_layer_z + 100.0} F600
G1 Z{max_layer_z + 98.0}
{else}
G1 Z250 F600
G1 Z248
{endif}
M400 P100
M17 R ; restore z current

;========== move toolhead to middle back position ==========
G90; use absolute coordinates
G1 X128 Y250 F3600

;========== reset printer parameters ==========
M220 S100; Reset feedrate magnitude
M201.2 K1.0; Reset acc magnitude
M73.2 R1.0; Reset left time magnitude
M1002 set_gcode_claim_speed_level : 0

M17 X0.8 Y0.8 Z0.5 ; lower XY motor current to 45% power

;========== end of end gcode ==========

9 Likes

Did you do it manually?

2 Likes

No… I used the stock BBL profile as a starting point and went through line by line to understand what the printer does before every print.

It seems that the P1S inherited the X1C gcode profile with little to none modifications, as one of the very first commands is “turn logo lamp on” when the P1S does not even have a lit logo on the tool head.

As there are no proper documentation from BBL, some of the gcode commands are assumed to do something based on my own observations during the process. Exact syntaxes and functionalities are still unknown.

The main purpose of this was to help the community to identify specific blocks of code where some optimization can be done (ie. poop reduction or heat creep prevention).

Suggestions are always welcome as I believe we will have to figure this out on our own.

4 Likes

I tried your g-code and it comes up with a couple of errors when I try to slice. Any ideas?

1 Like

Make sure you don’t have any “smart” quotes in there. @mmoraes80, you can edit your original post, select all of your gcode, and click on the “preformatted text” button to essentially mark it as a code block. This will cause the forum software to not transform quotation marks into curved, or smart quotation marks.

2 Likes

I think the issue is created by the Wiki pre-formatted post. I will redo it as suggested.

I tried to upload the actual file but the system does not allow me to do so.

The code is exactly the same as of the one in the stock profile in an organized way.

Try to copy and paste it in plain text editor first and then you copy to your slicer.

Yeah, I imported it into notepad before putting it into the profile. I’ve done a few of them this way and not had a problem.
Seems odd that it only came up with those 2 errors if it is a formatting issue. I look forward to trying it though if you can work out what the cause is.

1 Like

What version of OrcaSlicer are you using? Mine is the 1.8.0.

This is a very weird error because I did not include any gocde to it, I only separated it in blocks of codes for easy reading and understanding.

I contacted Bambu Lab to provide me some sort of instruction manual for the machine specific gcodes and they refused to do so with some BS about IP protection (isn’t it ironic? :rofl:). All I asked was a list of the gcodes and what they do, and if possible, along with the correct syntaxes.

Unfortunately, we will need to rely on the community to dig deeper and learn more about the printer as we go.

By-the-way… I try to spend some time on the revised gocde on a daily basis after observing the printer moves.

One thing is for sure. BBL created a great machine but they were lazy enough to not create a machine specific firmware. You can tell this by some of X1C moves that the P1S does. (ie. slow move of the print head on the lower left corner to read the QR Code on the bed. The problem is that the P1S does not read anything so it is just a waste of time).

Also, I noticed that the printer makes way too many up/down bed moves which seems completely unnecessary to me like here:

; ========== reset machine status ==========
G380 S2 Z30 F300
G380 S2 Z-25 F300
G1 Z5 F300

Original code says G380 is like G38, but Marlin only has G38.X (Probe target | Marlin Firmware) which seems appropriate here but, obviously was modified by BBL.

If that is somewhat related, why the bed goes down 30mm, then up 25mm and down again by 5mm? Honestly I am not really sure.

If anyone has any ideas or more information, that would be great.

Apparently I have reached the max number of editing my original post… (wait, what?!)

I cannot change it anymore.

Yes, the OP of the Bambu X1 Deficiencies thread had to have their post unlocked in order add more edits as the edit window times out.

6 Likes

Revision 1, 20231230
.
.
.
Hey Folks,

I worked a little to make a more logic and fast start code for the P1S Combo and here it is :slight_smile:
Up to now I tested it only with different PLA and only Orca Slicer. There will be a warning, if the max filament temperature in your profile is below 250°C
I needed to prefill the nozzle at the end to have a good first line. Please check if you need this.
There is one unnecessary move in the start (head goes in front and back before purging). This is from the AMS GCODE and I cannot change.

Feel free to use and improve it!

DONE:

  • Logical order
  • Delete X1 commands
  • Complete heat up and homing at first
  • Delete unnecessary moves
  • Switch on fans on a low value
  • no vibration test
  • only one extruder temperature change

OPEN POINT:

  • Check and complete display messages (I don´t care about the messages, I deleted a lot of them for my tests)
Start gcode

;===== machine: P1S =====
;===== date: 20231226 =====
; ===== Rev. 1, 20231230 =====
;===== Start Code by Schmudi =====
;===== !!! Use at your own risk !!! =====
;****************************************
;===== reset machine status =================
G90
M17 X1.2 Y1.2 Z0.75 ; reset motor current to default
M220 S100 ;Reset Feedrate
M221 S100 ;Reset Flowrate
M73.2 R1.0 ;Reset left time magnitude
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 =================
M106 P1 S125 ; Part fan
M106 P2 S50 ; AUX Fan - minimum allowed by Bambu is 20 percent
M106 P3 S125 ; Chamber Fan
M710 A1 S255; MC-board fan automatic

;===== preheat and homing ====================
M140 S[bed_temperature_initial_layer_single] ;set bed temp
M104 S[nozzle_temperature_initial_layer] ;set extruder temp
M190 S[bed_temperature_initial_layer_single] ;wait bed temp
G28 P0 T300; home with low precision, permit 300deg temperature

;===== prepare purging ==========
M109 S250; set purge temp
G91
G0 Z10 F1200
G90
M975 S1 ; turn on mech mode supression
G1 X67 F12000
G1 Y240
G1 Y265 F3000

;===== prepare AMS ==========
M620 M
M620 S[initial_extruder]A ; switch material if AMS exist
G1 X120 F12000
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]}

;===== purge extruder ==========
M412 S1 ;turn on filament runout detection
M104 S250 ;set nozzle to common flush temp
M106 P1 S0 ; Part fan off
G92 E0
G1 E40 F200; purge one
M400
M104 S[nozzle_temperature_initial_layer]
G92 E0
G1 E40 F200; purge two
M400
M106 P1 S255 ; Part fan full
M400 S3
G92 E0
G1 E-1.1 F300
M106 P1 S125
G1 X70 F9000
G1 X76 F15000
G1 X65 F15000
G1 X76 F15000
G1 X65 F15000; shake to put down garbage
G1 X80 F6000
G1 X95 F15000
G1 X80 F15000
G1 X165 F15000; wipe
M400
M106 P1 S125
G92 E0

;===== wipe nozzle ===============================
M1002 gcode_claim_action : 14
M975 S1
G1 X65 Y230 F18000
G1 Y264 F6000
G1 X100 F18000; first wipe
G29.2 S0 ; turn off ABL
G0 Z5 F20000
G1 X60 Y265
G1 X100 F5000; second wipeG1 X70 F15000
G1 X100 F5000
G1 X70 F15000
G1 X100 F5000
G1 X70 F15000
G1 X100 F5000
G1 X70 F15000
G1 X90 F5000
M400
G1 Z10
G29.2 S1 ; turn on ABL
M975 S1 ; turn on vibration supression

;===== for Textured PEI Plate , lower the nozzle as the nozzle was touching topmost of the texture when homing ==
;curr_bed_type={curr_bed_type}
{if curr_bed_type==“Textured PEI Plate”}
G29.1 Z{-0.04} ; for Textured PEI Plate
{endif}
;======== wait extrude temperature and prefill nozzle =============
M1002 gcode_claim_action : 0
G29.2 S1
M190 S[bed_temperature_initial_layer_single] ;set and wait bed temp
M109 S[nozzle_temperature_initial_layer] ;set and wait extruder temp
M975 S1 ; turn on mech mode supression
G92 E0
G1 E0.2 F300; pre-fill nozzle CHECK if you need this
G92 E0

4 Likes

UPDATE

  • Updated the fan section with the MC-board cooling fan (switch on the fan as soon as a stepper is activated)
  • some other small changes

Switch off the fan in the end gcode by adding this line if you like:
M710 S0; MC-board fan off

UPDATE to V4
I had some trouble with melted Filament inside the extruder. It looks like there is little to much and/or to fast retract especially at the End G-Code.
So I reduced both values a little.
Raise the bed for textured plate a little more (Z-0.05) to be nearer to the nozzle.

UPDATE to V3
I had some time, so I finished Start and End G-Code.

  • Display Messages added
  • End G-Code adapted:
    – nozzle wipe included
    – added comments
    – put a 60 second cooling in (all 3 fans running high), please delete if you are printing a cooling sensitive filament (or if you just don´t like it :wink:). I did this also on my other printers to have an initial fast cool down especially for the nozzle/print head.
Start G-Code V4

;===== machine: P1S =====
;===== date: 20240101 =====
;===== Version 4 =====
;===== start G-Code by Schmudi =====
;===== !!! use at your own risk !!! =====
;===== P1S firmware: 1.04.02.00 =====
;===== AMS firmware: 00.00.06.40 =====
;===================================================
;===== reset machine status =================
G90
M17 X1.2 Y1.2 Z0.75 ; set motor current to default
M220 S100 ;Reset Feedrate
M221 S100 ;Reset Flowrate
M73.2 R1.0 ;Reset left time magnitude
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 =================
M106 P1 S125 ; Part fan
M106 P2 S50 ; AUX Fan
M106 P3 S200 ; Chamber Fan
M710 A1 S216; MC-board fan automatic

;===== heatbed preheat and home ====================
M1002 gcode_claim_action : 2
M140 S[bed_temperature_initial_layer_single] ;set bed temp
M104 S[nozzle_temperature_initial_layer] ;set extruder temp
M190 S[bed_temperature_initial_layer_single] ;wait bed temp
M1002 gcode_claim_action : 13
G28 P0 T300; home with low precision,permit 300deg temperature

;===== prepare print temperature and material ==========
M1002 gcode_claim_action : 7
M109 S250; set purge temp
G91
G0 Z10 F1200
G90
M975 S1 ; turn on mech mode supression
G1 X67 F12000
G1 Y240
G1 Y265 F3000

;===== prepare AMS ==========
M1002 gcode_claim_action : 4
M620 M
M620 S[initial_extruder]A ; switch material if AMS exist
G1 X120 F12000
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]}

;===== purge extruder and nozzle ==========
M1002 gcode_claim_action : 14
M412 S1 ;turn on filament runout detection
M104 S250 ;set nozzle to common flush temp
M106 P1 S0 ; Part fan off
G92 E0
G1 E40 F200
M400
M104 S[nozzle_temperature_initial_layer]
G92 E0
G1 E40 F200
M400
M106 P1 S255 ; Part fan full
M400 S4
G92 E0
G1 E-0.8 F300
M106 P1 S125
G1 X70 F9000
G1 X76 F15000
G1 X65 F15000
G1 X76 F15000
G1 X65 F15000; shake to put down garbage
G1 X80 F6000
G1 X95 F15000
G1 X80 F15000
G1 X165 F15000
M400
M106 P1 S125
G92 E0

;===== wipe nozzle ===============================
M1002 gcode_claim_action : 14
M975 S1
M106 S255
G1 X65 Y230 F18000
G1 Y264 F6000
G1 X100 F18000 ; first wipe mouth
G29.2 S0 ; turn off ABL
G0 Z5 F12000
G1 X60 Y265
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
M400
G1 Z10
G29.2 S1 ; turn on ABL
M975 S1 ; turn on vibration supression
M106 P1 S125 ; Part fan on
M1002 gcode_claim_action : 0

;===== for Textured PEI Plate , lower the nozzle as the nozzle was touching topmost of the texture when homing ==
;curr_bed_type={curr_bed_type}
{if curr_bed_type==“Textured PEI Plate”}
G29.1 Z{-0.05} ; for Textured PEI Plate
{endif}

;======== wait extrude temperature and prefill =============
M106 P3 S220 ; Chamber Fan
M1002 gcode_claim_action : 0
G29.2 S1
M1002 gcode_claim_action : 2
M190 S[bed_temperature_initial_layer_single] ;set bed temp
M1002 gcode_claim_action : 7
M109 S[nozzle_temperature_initial_layer] ;set extruder temp
M1002 gcode_claim_action : 0
M975 S1 ; turn on mech mode supression
G92 E0
G1 E0.2 F300; pre-fill nozzle
G92 E0

End G-Code V3

;===== machine: P1S =====
;===== date: 20240101 =====
;===== Version 3 =====
;===== End G-Code by Schmudi =====
;===== !!! Use at your own risk !!! =====
;===================================================
;===== Preparation =====
M1002 gcode_claim_action : 0
M400 ; wait for buffer to clear
M1002 set_gcode_claim_speed_level : 5
;===== Retract filament =====
G92 E0 ; zero the extruder
G1 E-0.4 F300 ; retract
G1 Z{max_layer_z + 5} F900 ; lower z a little
G1 X65 Y255 F12000 ; move to safe pos
M400 S3; wait
G1 E-0.8 F300 ; retract
M400 S3; wait
G92 E0 ; zero the extruder
;===== 1st Wipe =====
G1 Y265 F3000
M140 S0 ; turn off bed
G1 X100 F12000 ; wipe
M1002 gcode_claim_action : 4
M620 S255; pull back filament to AMS

;====== cut filament =======
G1 X20 Y50 F12000
G1 Y-3
T255
G1 X65 F12000
G1 Y265

;===== wipe =======
M1002 gcode_claim_action : 14
G1 X100 F18000 ; first wipe
G29.2 S0 ; turn off ABL
G1 X60 Y265
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
M400
G29.2 S1 ; turn on ABL
M975 S1 ; turn on vibration supression
M400
M1002 gcode_claim_action : 0
;===== AMS =====
M621 S255; something for AMS
M104 S0 ; turn off hotend
M622.1 S1 ; for prev firmware, default turned on
;===== timelapse (camera) =====
M1002 judge_flag timelapse_record_flag
M622 J1
M400 ; wait all motion done
M991 S0 P-1 ;end smooth timelapse at safe pos
M400 S3 ;wait for last picture to be taken
M623; end of “timelapse_record_flag”
;===== Move Z down =====
M400
M17 S
M17 Z0.4 ; lower z motor current to reduce impact if there is something in the bottom
{if (max_layer_z + 100.0) < 250}
G1 Z{max_layer_z + 100.0} F600
G1 Z{max_layer_z +98.0}
{else}
G1 Z249 F600
G1 Z247
{endif}
M400 P100
;===== Move to park position and reset printer=====
G90
G1 X128 Y250 F3600
M220 S100 ; Reset feedrate magnitude
M201.2 K1.0 ; Reset acc magnitude
M73.2 R1.0 ;Reset left time magnitude
M1002 set_gcode_claim_speed_level : 0

;===== fast cool down ==========
M106 P1 S200; part cooling fan
M106 P2 S200; Aux fan
M106 P3 S256; Chamber fan
M400 S60; 60 seconds fast cool down time
M106 P1 S0; part cooling fan off
M106 P2 S0; Aux fan off
M106 P3 S0; Chamber fan off
M710 S0; MC-board fan off

M17 X0.8 Y0.8 Z0.5 ; lower motor current

Any comments are very welcome
Have fun!!!

I would also like to point out that the filament change code is also in progress. Thx @DzzD for this :+1:

3 Likes

interesting code. i am going to give it a try and see how it works. seems alot faster to start printing already. is the bed leveling gone? thanks

Thx and yes, bed leveling is gone. You can do it manualy if needed.

Startcode UPDATE to V5

  • Added setting for Noctua exhaust (Chamber) fan. If you build in a Noctua fan, you cannot change the speed because the RPM is different from the Bambu fan. But you can put in 10% to have at least something in your display. Still don´t found a solution for this.
  • Purge temperature change: Now it is 5°C more than the maximum of the filament (find it in filament settings)
  • Purge procedure changed to 2 x 40mm
  • Retract now 2 times a liitle with some cool and leaking time in between
  • Offset for smooth PEI plate added. You can write an offset in the gcode for your smooth plate if you need, actually it is set to Z-0.02
  • No more prefill at the end of start code
  • First homing in high precission. I faced some problems with inadequate hight. Looks like the fast himing is sometimes not exact enough.

Endcode UPDATE to V4

  • Added setting for Noctua exhaust fan
  • Cool down time split into to ranges: First 30 seconds with high fans, then 120 seconds with medium fans
  • better nozzle wipe

Endcode UPDATE to V4.1

  • made a little fault, so AMS is not unloading. Repaired it with in 4.1.
Start G-Code V5

;===== machine: P1S =====
;===== date: 20240112 =====
;===== Version 5 =====
;===== start G-Code by Schmudi =====
;===== !!! use at your own risk !!! =====
;===== P1S firmware: 1.05.01.00 =====
;===== AMS firmware: 00.00.06.40 =====
;===================================================
;===== reset machine status =================
G90
M17 X1.2 Y1.2 Z0.75 ; set motor current to default
M220 S100 ;Reset Feedrate
M221 S100 ;Reset Flowrate
M73.2 R1.0 ;Reset left time magnitude
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
M204 S10000 ; init ACC set to 10m/s^2

;=============turn on fans =================
M106 P1 S125 ; Part fan
M106 P2 S50 ; AUX Fan
M106 P3 S25; Chamber fan NOCTUA
; M106 P3 S125; Chamber fan BAMBU
M710 A1 S255; MC-board fan automatic

;===== heatbed preheat and home ====================
M1002 gcode_claim_action : 2
M140 S[bed_temperature_initial_layer_single] ;set bed temp
M104 S{nozzle_temperature_range_high[initial_extruder]} ;set extruder temp
M190 S[bed_temperature_initial_layer_single] ;wait bed temp
M1002 gcode_claim_action : 13
G28 T300; home XY first - permit 300deg temperature

;===== prepare print temperature and material ==========
M1002 gcode_claim_action : 7
; M109 S250; set purge temp - only use if different type of filament in use (ABS/PLA/ASA/…)
M104 S{nozzle_temperature_range_high[initial_extruder]} ;set extruder temp
G91
G0 Z10 F1200
G90
M975 S1 ; turn on mech mode supression
G1 X67 F12000
G1 Y240
G1 Y265 F3000

;===== bed leveling ====================
;M1002 gcode_claim_action : 7
;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

;===== prepare AMS ==========
M1002 gcode_claim_action : 4
M620 M
M620 S[initial_extruder]A ; switch material if AMS exist
G1 X120 F12000
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]}

;===== purge extruder and nozzle ==========
M1002 gcode_claim_action : 14
M412 S1 ;turn on filament runout detection
; M104 S250 ;set nozzle to common flush temp - only for different materials
M109 S{nozzle_temperature_range_high[initial_extruder]}+5 ;set extruder temp+5
M106 P1 S0 ; Part fan off
G92 E0
G1 E40 F200 ; clean 40mm
M400
M104 S[nozzle_temperature_initial_layer]
G92 E0
G1 E40 F200 ; clean 50mm
M400
M106 P1 S255 ; Part fan full
M400 S4
G92 E0
G1 E-0.5 F300
M106 P1 S200
M400 S2
G92 E0
G1 E-0.3 F300
G92 E0
M400 S2
G1 X70 F9000
G1 X76 F15000
G1 X65 F15000
G1 X76 F15000
G1 X65 F15000; shake to put down garbage
G1 X80 F6000
G1 X95 F15000
G1 X80 F15000
G1 X165 F15000
M400
M106 P1 S255
G92 E0

;===== wipe nozzle ===============================
M1002 gcode_claim_action : 14
M975 S1
M106 P1 S255
G1 X65 Y230 F18000
G1 Y264 F6000
G1 X100 F18000 ; first wipe mouth
G29.2 S0 ; turn off ABL
G0 Z5 F12000
G1 X60 Y265
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
M400
G1 Z10
G29.2 S1 ; turn on ABL
M975 S1 ; turn on vibration supression
M106 P1 S125 ; Part fan on
M1002 gcode_claim_action : 0

;===== for Textured PEI Plate , lower the nozzle as the nozzle was touching topmost of the texture when homing ==
curr_bed_type={curr_bed_type}
{if curr_bed_type==“Textured PEI Plate”}
G29.1 Z{-0.05} ; for Textured PEI Plate; personal PEI plate - corrct value to your own plate
{endif}
{if curr_bed_type==“High Temp Plate”}
G29.1 Z{-0.02} ; for smooth PEI-plate
{endif}

;======== wait extrude temperature and prefill =============
;M106 P3 S220 ; Chamber Fan BAMBU
M106 P3 S25 ; Chamber Fan NOCTUA
G29.2 S1
M1002 gcode_claim_action : 2
M190 S[bed_temperature_initial_layer_single] ;set bed temp
M1002 gcode_claim_action : 7
M109 S[nozzle_temperature_initial_layer] ;set extruder temp
M1002 gcode_claim_action : 0
M975 S1 ; turn on mech mode supression
G92 E0

End G-Code V4.1

;===== machine: P1S =====
;===== date: 20240117 =====
;===== Version 4.1 =====
;===== End G-Code by Schmudi =====
;===== !!! Use at your own risk !!! =====
;===================================================
M400 ; wait for buffer to clear
M17 X1.2 Y1.2 Z0.75 ; set motor current to default
M204 S10000 ; init ACC set to 10m/s^2
M1002 set_gcode_claim_speed_level : 5
G92 E0 ; zero the extruder
G1 E-0.2 F200 ; retract, 0,8mm retract is done automatically by Slicer
G1 Z{max_layer_z + 5} F900 ; lower z a little
G1 X65 Y255 F12000 ; move to safe pos
M400 S8; wait
G92 E0 ; zero the extruder
G1 Y265 F3000
M140 S0 ; turn off bed
G1 X100 F12000 ; wipe
M1002 gcode_claim_action : 4

;====== cut filament =======
M620 S255
G1 X20 Y50 F12000
G1 Y-3
T255
G1 X65 F12000
G1 Y265
M621 S255; pull back filament to AMS

;===== wipe nozzle =======
M1002 gcode_claim_action : 14
G1 X100 F18000 ; first wipe
G29.2 S0 ; turn off ABL
G1 X60 Y265
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
M400
G29.2 S1 ; turn on ABL
M975 S1 ; turn on vibration supression
M400
M1002 gcode_claim_action : 0
M621 S255; AMS
M104 S0 ; turn off hotend

;===== stop camera =======
M622.1 S1 ; for prev firmware, default turned on
M1002 judge_flag timelapse_record_flag
M622 J1
M400 ; wait all motion done
M991 S0 P-1 ;end smooth timelapse at safe pos
M400 S3 ;wait for last picture to be taken
M623; end of “timelapse_record_flag”
M400

;===== lower heatbed =======
M17 S
M17 Z0.4 ; lower z motor current to reduce impact if there is something in the bottom
{if (max_layer_z + 100.0) < 250}
G1 Z{max_layer_z + 100.0} F600
G1 Z{max_layer_z +98.0}
{else}
G1 Z249 F600
G1 Z247
{endif}
M400 P100
G90
G1 X128 Y250 F3600

;===== reset printer =======
M220 S100 ; Reset feedrate magnitude
M201.2 K1.0 ; Reset acc magnitude
M73.2 R1.0 ;Reset left time magnitude
M1002 set_gcode_claim_speed_level : 0

;===== fast cool down chamber ==========
M106 P1 S200; part cooling fan
; M106 P3 S25; Chamber fan NOCTUA
M106 P3 S125; Chamber fan BAMBU
M400 S30; 30 seconds fast cool down time

;===== second cool down ==========
M106 P1 S50; part cooling fan
M106 P2 S100; Aux fan
; M106 P3 S25; Chamber fan NOCTUA
M106 P3 S125; Chamber fan BAMBU
M400 S120; 120 second cool down time

;===== switch off machine ==========
M106 P1 S0; part cooling fan off
M106 P2 S0; Aux fan off
M106 P3 S0; Chamber fan off
M710 S0; MC-board fan off
M17 X0.8 Y0.8 Z0.5 ; lower motor current

One notice for the “Improve filament gcode change speed (x2)”. Please check the gcode as well. There is a high retract inside (G1 E-20 or something like this). I needed to reduce it (its also commented) to avoid extruder blockage. It`s only a short distance between hard and melted filament in the hotend.

Any comments are very welcome
Have fun!!!

4 Likes

Working great so far, thanks!

1 Like

Hello everybody,

after small adjustments the Start- and Endcodes are running now a while, so here´s the final version :partying_face:
It is tested with actual firmware, without noise reduction mode and only with Orca-Slicer (05.03.24: tested only with 0.4mm nozzle)
The Bed Mesh will only be done, if its tagged.

image

At end of print the toolhead will move to the cutter position and wait there. Don’t be surprised, that’s exactly what I want.
During this time the filament is moved back and the toolhead is waiting to be safe the filament is depressured and cooled down.

STARTCODE V6 - FINAL
;===== machine: P1S =====
;===== date: 20240229 =====
;===== Version 6 - FINAL =====
;===== start G-Code by Schmudi =====
;===== !!! use at your own risk !!! =====
;===== P1S firmware: 1.05.02 =====
;===== AMS firmware: 00.00.06.40 =====
;===================================================
;===== reset machine status =================
G90
M17 X1.2 Y1.2 Z0.75 ; set motor current to default
M290 X40 Y40 Z2.6666666; Use Babystepping
M220 S100 ;Reset Feedrate
M221 S100 ;Reset Flowrate
M73.2   R1.0 ;Reset left time magnitude
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
M204 S10000 ; init ACC set to 10m/s^2

;=============turn on fans  =================
M106 P1 S125 ; Part fan
M106 P2 S50 ; AUX Fan
; M106 P3 S25; Chamber fan NOCTUA
M106 P3 S125; Chamber fan BAMBU
M710 A1 S255; MC-board fan automatic

;===== heatbed preheat and home ====================
M1002 gcode_claim_action : 2
M140 S[bed_temperature_initial_layer_single] ;set bed temp
M104 S100 ; set extruder temp - low value to avoid blobs while homing
M190 S[bed_temperature_initial_layer_single] ;wait bed temp
M1002 gcode_claim_action : 13
; G28 P0 T300; fast Homing - permit 300deg temperature
G28 T300; Homing - permit 300deg temperature
M400 ; wait for finish homing

;===== prepare print temperature and material ==========
M1002 gcode_claim_action : 7
; M109 S250; set purge temp - only use if different type of filament in use (ABS/PLA/ASA/...)
M104 S{nozzle_temperature_range_high[initial_extruder]} ;wait extruder temp
G91
G1 Z10 F1200
G90
M975 S1 ; turn on mech mode supression
G1 X67 F12000
G1 Y240
G1 Y265 F3000

;===== bed leveling ====================
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

;===== prepare AMS ==========
M1002 gcode_claim_action : 4
M620 M
M620 S[initial_extruder]A   ; switch material if AMS exist
    G1 X120 F12000
    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]}

;===== purge extruder and nozzle ==========
M1002 gcode_claim_action : 14
M412 S1 ;turn on filament runout detection
; M104 S250 ;set nozzle to common flush temp - only for different materials
M109 S{nozzle_temperature_range_high[initial_extruder]}+5 ;set extruder temp+5
M106 P1 S0 ; Part fan off
G92 E0
G1 E40 F200 ; clean 40mm
M400
G92 E0
G1 E-1.5 F300 ; retract
M104 S[nozzle_temperature_initial_layer]
G92 E0
G1 E50 F400 ; clean 50mm
M400
M106 P1 S255 ; Part fan full
M400 S4
G92 E0
G1 E-0.5 F300
M106 P1 S200
M400 S2
G92 E0
G1 E-0.3 F300
G92 E0
M400 S2
G1 X70 F9000
G1 X76 F15000
G1 X65 F15000
G1 X76 F15000
G1 X65 F15000; shake to put down garbage
G1 X80 F6000
G1 X95 F15000
G1 X80 F15000
G1 X165 F15000
M400
M106 P1 S255
G92 E0

;===== wipe nozzle ===============================
M1002 gcode_claim_action : 14
M975 S1
M106 P1 S255
G1 X65 Y230 F18000
G1 Y264 F6000
G1 X100 F18000 ; first wipe
G29.2 S0 ; turn off ABL
G0 Z5 F12000
G1 X60 Y265
G1 X100 F5000; second wipe
G1 X70 F15000
G1 X100 F5000
G1 X70 F15000
G1 X100 F5000
G1 X70 F15000
G1 X100 F5000
G1 X70 F15000
G1 X90 F5000
M400
G1 Z10
G29.2 S1 ; turn on ABL
M975 S1 ; turn on vibration supression
M106 P1 S125 ; Part fan on

;===== for Textured PEI Plate , lower the nozzle as the nozzle was touching topmost of the texture when homing ==
curr_bed_type={curr_bed_type}
{if curr_bed_type=="Textured PEI Plate"}
G29.1 Z{-0.05} ; for Textured PEI Plate; personal PEI plate - corrct value to your own plate
{endif}
{if curr_bed_type=="High Temp Plate"}
G29.1 Z{-0.00} ; for smooth PEI-plate
{endif}

;======== wait extrude temperature and prefill =============
M106 P3 S220 ; Chamber Fan BAMBU
; M106 P3 S25 ; Chamber Fan NOCTUA
G29.2 S1
M1002 gcode_claim_action : 2
M190 S[bed_temperature_initial_layer_single] ;set bed temp
M1002 gcode_claim_action : 7
M109 S[nozzle_temperature_initial_layer] ;set extruder temp
M1002 gcode_claim_action : 0
M975 S1 ; turn on mech mode supression
G92 E0
G92 E0.2 F200
G92 E0
ENDCODE V6 - FINAL
;===== machine: P1S =====
;===== date: 20240229 =====
;===== Version 6.0 - FINAL =====
;===== End G-Code by Schmudi =====
;===== !!! Use at your own risk !!! =====
;===================================================
M400 ; wait for buffer to clear
M17 X1.2 Y1.2 Z0.75 ; set motor current to default
M204 S10000 ; init ACC set to 10m/s^2
M1002 set_gcode_claim_speed_level : 5
G92 E0 ; zero the extruder
G1 E-0.3 F600 ; retract, 0,8mm retract is done automatically by Slicer
M104 S175 ; Lower nozzle temp
G1 Z{max_layer_z + 5} F900 ; lower z a little
G1 X65 Y255 F12000 ; move to safe pos
M400 S5; wait
G92 E0 ; zero the extruder
G1 E-0.3 F700 ; retract
M400 S5; wait
G92 E0 ; zero the extruder
G1 Y265 F3000
M140 S0 ; turn off bed
G1 X100 F12000 ; wipe
M1002 gcode_claim_action : 4

;====== cut filament =======
M620 S255
G1 X20 Y50 F12000
G1 Y-3
T255
G1 X65 F12000
G1 Y265
M621 S255; pull back filament to AMS

;===== wipe nozzle =======
M104 S0 ; turn off hotend
M1002 gcode_claim_action : 14
G1 X100 F18000 ; first wipe
G29.2 S0 ; turn off ABL
G1 X60 Y265
G1 X100 F5000; second wipe
G1 X70 F15000
G1 X100 F5000
G1 X70 F15000
G1 X100 F5000
G1 X70 F15000
G1 X100 F5000
G1 X70 F15000
G1 X90 F5000
M400
G29.2 S1 ; turn on ABL
M975 S1 ; turn on vibration supression
M400
M1002 gcode_claim_action : 0
M621 S255; AMS
M104 S0 ; turn off hotend

;===== stop camera =======
M622.1 S1 ; for prev firmware, default turned on
M1002 judge_flag timelapse_record_flag
M622 J1
M400 ; wait all motion done
M991 S0 P-1 ;end smooth timelapse at safe pos
M400 S3 ;wait for last picture to be taken
M623; end of “timelapse_record_flag”
M400

;===== lower heatbed =======
M17 S
M17 Z0.4 ; lower z motor current to reduce impact if there is something in the bottom
{if (max_layer_z + 100.0) < 250}
G1 Z{max_layer_z + 100.0} F600
G1 Z{max_layer_z +98.0}
{else}
G1 Z249 F600
G1 Z247
{endif}
M400 P100
G90
G1 X128 Y250 F3600

;===== reset printer =======
M220 S100 ; Reset feedrate magnitude
M201.2 K1.0 ; Reset acc magnitude
M73.2 R1.0 ;Reset left time magnitude
M1002 set_gcode_claim_speed_level : 0

;===== fast cool down chamber ==========
M106 P1 S200; part cooling fan
M106 P2 S200; Aux fan
; M106 P3 S25; Chamber fan NOCTUA
M106 P3 S200; Chamber fan BAMBU
M400 S30; 30 seconds fast cool down time

;===== second cool down ==========
M106 P1 S100; part cooling fan
M106 P2 S100; Aux fan
; M106 P3 S25; Chamber fan NOCTUA
M106 P3 S125; Chamber fan BAMBU
M400 S120; 120 second cool down time

;===== switch off machine ==========
M106 P1 S0; part cooling fan off
M106 P2 S0; Aux fan off
M106 P3 S0; Chamber fan off
M710 S0; MC-board fan off
M17 X0.8 Y0.8 Z0.5 ; lower motor current
M1002 gcode_claim_action : 0

Make sure to optimize it to your own need.

Happy Printing

6 Likes