Skip to content

Instantly share code, notes, and snippets.

@maniq2
Last active December 16, 2025 19:05
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 with Orca Slicer. Public release.
;===== Optimized Bambu A1mini start gcode. No sound.
;===== MN v3 ===== Date: 20251216
;===== 3.0 Modify logic and sequences
;===== warm-up
M1002 gcode_claim_action : 2 ; heating
M1002 set_filament_type:{filament_type[initial_no_support_extruder]}
M18 ; disable all motors
M104 S140 ; safe nozzle preheat
M140 S50 ; safe bed preheat
G392 S0 ; disable clog detect
M9833.2 ; set noise parameters
;===== initialize parameters
G90 ; absolute positioning
M83 ; relative extrusion
M211 S1 ; enable soft endstops
M630 S0 P0 ; 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 ; reset time left magnitude
;===== home and ready
M1002 gcode_claim_action : 13 ; homing
M17 Z0.3 ; lower 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 ; clearance
;===== manage AMS (flagged)
M620 M ; enable remap
M620 S[initial_no_support_extruder]A
G392 S1 ; enable clog detect
M1002 gcode_claim_action : 4 ; changing filament
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 E30 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 E30 F{filament_max_volumetric_speed[initial_no_support_extruder]/2.4053*60}
M106 P1 S180
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 F500
G0 X0 F20000 ; wipe
G0 X-13.5 F3000
G0 X0 F20000
G0 X-13.5 F3000
G0 X0 F12000
G0 X-13.5 F3000
M104 S140 ; safe nozzle preheat
G392 S0 ; disable clog detect
M621 S[initial_no_support_extruder]A
M106 P1 S0 ; disable fan
;===== clean nozzle
M1002 gcode_claim_action : 14 ; cleaning
M975 S1 ; enable vibration suppression
M106 P1 S180 ; moderate fan
M400 P800
M106 P1 S0 ; disable fan
G0 X90 Y-4 Z5 F10000 ; move to the prime area
G380 S3 Z-2 F1200 ; tap 1
G1 Z2 F2000
G0 X91 F3000
G380 S3 Z-2 F1200 ; tap 2
G1 Z2 F2000
G0 X35 Y186 F20000 ; move to rubber cleaning surface
G1 Z0.2 F2000
G91
G0 X-30 F20000 ; brush 1
G0 Y-2
G0 X28 ; brush 2
G90
G1 Z5 F2000
G0 X86 Y184 F10000 ; move to steel cleaning surface
G1 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
G90
G1 Z5 F2000
G0 X35 Y187 F20000 ; move to rubber cleaning surface
G1 Z0.2 F2000
G91
G0 X-30 F20000 ; brush 3
G0 Y-2
G0 X30 ; brush 4
G90 ; absolute positioning
M83 ; relative extrusion
G1 Z5 F2000
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
;===== build plate detection (flagged)
M1002 judge_flag build_plate_detect_flag
M622 S1
G39.4 ; build plate detection
M400
M623
{if curr_bed_type=="Textured PEI Plate"}
G29.1 Z{-0.015}
{endif}
;===== mech mode and bed leveling (flagged)
M1002 judge_flag g29_before_print_flag
M622 J1 ; bed leveling IS enabled
G29.2 S0 ; disable ABL
M1002 gcode_claim_action : 3 ; sweeping XY mech mode
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
M1002 gcode_claim_action : 1 ; 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
M623
;===== purge or flow calibration (flagged)
M1002 gcode_claim_action : 2 ; heating
M104 S{nozzle_temperature_initial_layer[initial_extruder]} ; set nozzle to final temperature
M140 S[bed_temperature_initial_layer_single] ; set bed to final temperature
M211 X0 Y0 Z0 ; disable soft endstop
M975 S1 ; enable motion gating
T1000 ; select local tool
G1 Z5 F2000 ; add clearance before move
G0 X0 F10000 ; move to service area
G0 X-13.5 F3000 ; move into wiper
G92 E0 ; reset extruded amount
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
M400 S2 ; stabilize sensor
M109 S{nozzle_temperature_initial_layer[initial_extruder]} ; wait nozzle to final temperature
M1002 judge_flag extrude_cali_flag
M622 J0 ; flow dynamic NOT enabled : purge
G1 E10 F500 ; purge
M623
M622 J1 ; flow dynamic IS enabled : calibration
M1002 set_filament_type:{filament_type[initial_no_support_extruder]}
M1002 gcode_claim_action : 8 ; calibrating extrusion
M900 K0.0 L1000.0 M1.0 ; pressure advance baseline
G0 X68 Y-4 F10000 ; move near start position
G1 Z0.3 F2000 ; move to start position
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 Y0 Z0 F20000
M400
G0 X-13.5 Y0 Z10 F10000 ; move to service area
M400
G1 E10 F{outer_wall_volumetric_speed/2.4*60} ; first dynamic extrusion compensation
M983 F{outer_wall_volumetric_speed/2.4} A0.3 H[nozzle_diameter]
M106 P1 S180 ; moderate fan to neck strand
M400 S5 ; settle
G0 X0 F20000 ; wipe
G0 X-13.5 F3000
G0 X0 F20000
G0 X-13.5 F3000
M106 P1 S0 ; disable fan
M1002 judge_last_extrude_cali_success ; second extrusion compensation, if required
M622 J0 ; if failed
M983 F{outer_wall_volumetric_speed/2.4} A0.3 H[nozzle_diameter]
M106 P1 S180
M400 S5 ; settle
G0 X0 F20000 ; wipe
G0 X-13.5 F3000
G0 X0 F20000
G0 X-13.5 F3000
M106 P1 S0 ; disable fan
M623
M984 A0.1 E1 S1 F{outer_wall_volumetric_speed/2.4} H[nozzle_diameter] ; final corrections
M623
;===== prime line
M211 R ; restore soft endstops
M190 S[bed_temperature_initial_layer_single] ; wait bed to final temperature
M106 P1 S180 ; moderate fan
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 ; disable fan
G1 Z5 F3000
G0 X68 Y-2.5 F20000 ; move to the prime area
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
;===== final stage
M1002 gcode_claim_action : 0 ; printing
M106 P1 S0 ; disable part fan
M106 P2 S0 ; disable auxiliary fan
M106 P3 S0 ; disable chamber fan
M960 S1 P0 ; disable led ch1
M960 S2 P0 ; disable led ch2
M960 S5 P0 ; disable toolhead led
G392 S1 ; enable clog detect
G29.2 S1 ; enable ABL
M975 S1 ; enable vibration suppression
G90
T1000
M211 R ; restore endstop status
M1007 S1 ; 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