Skip to content

Instantly share code, notes, and snippets.

@maniq2
Last active November 25, 2025 00:24
Show Gist options
  • Select an option

  • Save maniq2/a302c6d1217f1926fa1d631e36709c9e to your computer and use it in GitHub Desktop.

Select an option

Save maniq2/a302c6d1217f1926fa1d631e36709c9e to your computer and use it in GitHub Desktop.
Optimized Bambu A1mini start gcode. No sound. Tested. Public release.
;===== Optimized Bambu A1mini start gcode. No sound.
;===== maniq v2.1 ===== Date: 20251107
;===== 2.1 Remove first E small retract
;===== 2.0 organize vibration test, cleaning, softstops, temp and moves sequences
;===== start warm-up sequence
M1002 gcode_claim_action : 2 ; status: heating
M1002 set_filament_type:{filament_type[initial_no_support_extruder]}
M18 ; Disable all motors
M140 S50 ; safe bed preheat
M104 S140
G392 S0 ; disable clog detect
M9833.2 ; bambu: set noise/mech params
;===== initialize machine status
G90 ; absolute positioning
M83 ; relative extrusion
M211 S1 ; enable soft endstops
M630 S0 P0 ; Bambu: reset internal state
M204 S6000 ; set default acceleration
M960 S5 P1 ; enable toolhead lamp
M220 S100 ; feedrate to 100%
M221 S100 ; flowrate to 100%
M982.2 S1 ; enable cog noise reduction
M975 S1 ; enable motion gating
M106 P1 S0 ; disable fan while heating
M73.2 R1.0 ; Bambu: reset time left magnitude
;===== home and stage printer
M1002 gcode_claim_action : 13 ; status: homing
M17 Z0.3 ; lower the z-motor current
G1 Z2 F1200 ; safe clearance before homing
M17 X0.7 Y0.9 Z0.5 ; default motor current
G28 X ; home X Y
G0 X90 Y90 F10000 ; move to center
G28 Z P0 T300 ; home Z
M400 ; finish movements
M211 S ; push soft endstop status
M211 X0 Y0 Z0 ; disable soft endstop
G1 Z5 F2000 ; add clearance before move
G0 X0 F10000 ; move to service area
G0 X-13.5 F3000 ; move into wiper
M400
;===== switch material in AMS (flagged)
M620 M ; enable remap
M620 S[initial_no_support_extruder]A
G392 S1 ; enable clog detect
M1002 gcode_claim_action : 4
M400
M1002 set_filament_type:UNKNOWN
M109 S[nozzle_temperature_initial_layer]
M104 S250
M400
T[initial_no_support_extruder]
G1 X-13.5 F3000
M400
M620.1 E F{filament_max_volumetric_speed[initial_no_support_extruder]/2.4053*60} T{nozzle_temperature_range_high[initial_no_support_extruder]}
M109 S250 ; set nozzle to common flush temp
M106 P1 S0
G92 E0
G1 E50 F200
M400
M1002 set_filament_type:{filament_type[initial_no_support_extruder]}
M104 S{nozzle_temperature_range_high[initial_no_support_extruder]}
G92 E0
G1 E50 F{filament_max_volumetric_speed[initial_no_support_extruder]/2.4053*60}
M400
M106 P1 S178
G92 E0
G1 E5 F{filament_max_volumetric_speed[initial_no_support_extruder]/2.4053*60}
M109 S{nozzle_temperature_initial_layer[initial_no_support_extruder]-20}
M104 S{nozzle_temperature_initial_layer[initial_no_support_extruder]-40}
G92 E0
G1 E-0.5 F300
G0 X0 F20000
G0 X-13.5 F3000
G0 X0 F20000
G0 X-13.5 F3000
G0 X0 F12000
G0 X-13.5 F3000
M104 S170 ; reset nozzle to expected temperature
G392 S0 ; disable clog detect
M621 S[initial_no_support_extruder]A
M400
M106 P1 S0
; ===== sweeping XY mech mode
M1002 gcode_claim_action : 3
G0 X25 Y175 F20000 ; short distance
G28 Z P0 T300 ; quick home z
G29.2 S0 ; turn off ABL
M104 S170 ; safe nozzle temp
;===== build plate detection (flagged)
M1002 judge_flag build_plate_detect_flag
M622 S1
G39.4 ; Bambu: quick build plate detection
M400
M623
;===== mech-mode resonance test (bed leveling flagged)
M1002 judge_flag g29_before_print_flag
M622 J1
G1 Z5 F2000
G0 X90 Y-1 F20000
M400 P200
M970.3 Q1 A7 K0 O2
M974 Q1 S2 P0
G0 X90 Y0 Z5 F20000
M400 P200
M970 Q0 A10 B50 C90 H15 K0 M20 O3
M974 Q0 S2 P0
M623
;===== clean nozzle
M1002 gcode_claim_action : 14 ; status: cleaning
M975 S1 ; Re-enable vibration suppression
G90 ; explicit
M83 ; explicit
M106 P1 S255 ; short blast to neck any strands
M400 P800
M106 P1 S0 ; keep fan off while heating
G1 Z5 F2000 ; clearance
G0 X90 Y-4 F10000 ; move to the purge area
G380 S3 Z-2 F1200 ; tap 1
G1 Z2 F2000
G1 X91 F3000
G380 S3 Z-2 F1200 ; tap 2
G1 Z2 F2000
G1 X92 F3000
; brush material on rubber - first pass
G0 X25 Y176 F20000
G1 Z0.2 F2000
G1 Y186
G91
G0 X-30 F20000 ; brush 1
G0 Y-2
G0 X27 ; brush 2
G0 Y1.5
G0 X-28 ; brush 3
G90
G1 Z5 F2000
; brush material on steel
G0 X86 Y184 F10000 ; move to cleaning steel surface
G0 Z-1.01 F2000
G91
G2 I1 J0 X2 Y0 F2000 ; loop 1
G2 I-0.7 J0 X-1.4
G2 I1 J0 X2 ; loop 2
G2 I-0.7 J0 X-1.4
G3 I1 J0 X2 ; loop 3
G3 I-0.7 J0 X-1.4
G3 I1 J0 X2 ; loop 4
G3 I-0.7 J0 X-1.4
G90
G1 Z5 F2000
; brush material on rubber - second pass
G0 X25 Y177 F20000
G1 Z0.2 F2000
G0 Y187
G91
G0 X-30 F20000 ; brush 4
G1 Y-2
G0 X30 ; brush 5
G90
G1 Z5 F2000
; restore protections and establish raw Z reference
M211 R ; restore soft endstrop
G29.2 S0 ; disable ABL for raw Z
G0 X90 Y90 F10000 ; move to center
G28 Z P0 T300 ; final home Z after cleaning
G29.2 S1 ; enable ABL
;===== bed leveling (flagged)
M1002 judge_flag g29_before_print_flag
M622 J1
G29.2 S0 ; disable ABL for probing
M1002 gcode_claim_action : 1 ; status: auto bed leveling
G29 A1 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 mesh
G29.2 S1 ; enable ABL with fresh mesh
M623
;===== nozzle load line
M975 S1 ; enable motion gating
G90 ; re-assert positioning
M83
T1000 ; select local tool
M211 X0 Y0 Z0 ; disable soft endstop
G1 Z5 F2000 ; add clearance before move
G0 X0 F10000 ; move to service area
G0 X-13.5 F3000 ; move into wiper
M1002 gcode_claim_action : 2 ; status: heating
M140 S[bed_temperature_initial_layer_single] ; bed to final temperature
M109 S{nozzle_temperature_initial_layer[initial_extruder]} ; wait nozzle to final temperature
; main purge with fan to solidify strand
G92 E0 ; reset extruded amount
G1 E10 F200 ; slow purge of 10mm
M400
M106 P1 S180 ; moderate fan to neck the strand
G1 E-0.5 F500 ; small retract to control oozing
M400 S2 ; Wait 2s
; wipe to remove strand
G0 X0 F20000
G0 X-13.5 F3000 ; wipe
G0 X0 F20000
G0 X-13.5 F3000
M400
M106 P1 S0 ; fan off
;===== prepare sensors for calibration
M1002 set_filament_type:UNKNOWN ; prepare filament for calibration
M412 S1 ; enable filament runout detect
M400
M620.3 W1 ; enable filament tangle detect
G392 S0 ; disable clog detect during calibration
M400 S2 ; Wait 2s
;===== flow dynamics calibration (flagged)
M1002 set_filament_type:{filament_type[initial_no_support_extruder]}
M1002 judge_flag extrude_cali_flag
M622 J1
M1002 gcode_claim_action : 8 ; status: calibrating extrusion
M900 K0.0 L1000.0 M1.0 ; pressure advance baseline
G90
M83 ; re-assert positioning (explicit)
G1 Z5 F3000 ; safe lift
G0 X68 Y-4 F10000 ; move near start position
G1 Z0.3 F2000 ; move to start position
M400
G1 X88 E10 F{outer_wall_volumetric_speed/(24/20)*60}
G1 X93 E.3742 F{outer_wall_volumetric_speed/(0.3*0.5)/4*60}
G1 X98 E.3742 F{outer_wall_volumetric_speed/(0.3*0.5)*60}
G1 X103 E.3742 F{outer_wall_volumetric_speed/(0.3*0.5)/4*60}
G1 X108 E.3742 F{outer_wall_volumetric_speed/(0.3*0.5)*60}
G1 X113 E.3742 F{outer_wall_volumetric_speed/(0.3*0.5)/4*60}
G0 Y0 Z0 F20000 ; finish the patterned sweep
M400
G1 X-13.5 Y0 Z10 F10000 ; park in service area
M400
; primary dynamic extrusion compensation
G1 E10 F{outer_wall_volumetric_speed/2.4*60}
M983 F{outer_wall_volumetric_speed/2.4} A0.3 H[nozzle_diameter]
M106 P1 S180 ; enable fan to neck strand
M400 S7 ; settle
G0 X0 F20000 ; wipe
G0 X-13.5 F3000
G0 X0 F20000
G0 X-13.5 F3000
M400
M106 P1 S0 ; disable fan
; retry if needed
M1002 judge_last_extrude_cali_success
M622 J0 ; If failed J0
M983 F{outer_wall_volumetric_speed/2.4} A0.3 H[nozzle_diameter]
M106 P1 S180
M400 S7
G0 X0 F20000 ; wipe
G0 X-13.5 F3000
G0 X0 F20000
G0 X-13.5 F3000
M400
M106 P1 S0
M623
; final corrections and cleanup
M984 A0.1 E1 S1 F{outer_wall_volumetric_speed/2.4} H[nozzle_diameter]
M106 P1 S180
M400 S7
G0 X0 F20000 ; wipe
G0 X-13.5 F3000
G0 X0 F20000
G0 X-13.5 F3000
M400
M106 P1 S0
M623 ; end flow dynamics calibration
M211 R ; restore soft endstops
;===== extrude calibration
M190 S{bed_temperature_initial_layer_single} ; wait for bed to reach final temperature
G90
M83
; clear any ooze before extruding
M106 P1 S180 ; moderate fan for PLA and PETG
M400 S2
G1 E-0.05 F1500
G0 X0 F20000 ; wipe
G0 X-13.5 F3000
G0 X0 F12000
G0 X-13.5 F3000
M106 P1 S0
M400
; draw short stabilization line
G1 Z5 F3000
G0 X68 Y-2.5 F20000
G1 Z0.3 F3000
G1 X88 E10 F{outer_wall_volumetric_speed/(24/20)*60}
G1 X93 E0.3742 F{outer_wall_volumetric_speed/(0.3*0.5)/4*60}
G1 X98 E0.3742 F{outer_wall_volumetric_speed/(0.3*0.5)*60}
G1 X103 E0.3742 F{outer_wall_volumetric_speed/(0.3*0.5)/4*60}
G1 X108 E0.3742 F{outer_wall_volumetric_speed/(0.3*0.5)*60}
G1 X113 E0.3742 F{outer_wall_volumetric_speed/(0.3*0.5)/4*60}
G0 X115 Z0 F20000
G1 Z5 F3000
;===== for textured pei plate
{if curr_bed_type=="Textured PEI Plate"}
G29.1 Z{-0.02}
{endif}
;===== normalize lights/fans & re-enable protections
M960 S1 P0 ; light/laser ch1 off
M960 S2 P0 ; light/laser ch2 off
M960 S5 P0 ; toolhead lamp off
M106 P1 S0 ; part fan off
M106 P2 S0 ; aux fan off
M106 P3 S0 ; chamber fan off
G392 S1 ; re-enable clog detect
G29.2 S1 ; enable ABL for print
;===== final staging
M1002 gcode_claim_action : 0 ; status: printing
M975 S1 ; vibration suppression on
G90
M83
T1000
M211 R ; restore endstop status
M211 X0 Y0 Z0 ; disable soft endstops
M1007 S1 ; Bambu: keep enabled
; ===== hand-off to slicer
; Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
; The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
; THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment