Optimized A1 mini Start G-code (Quick and Quiet version)

After some research and testing, I have made several small changes over the A1 mini default factory start g-code.
It is faster, quiet and makes more sense at some sections. It works great for frequent, small printings.
(Based on start g-code version 20240620, check your current version before using this)

The changes are:

1, Disabled the “xy mech resonance check” on every print.
Explain:
It is not neccesary to check this for every small printing (The machine doesn’t do this check in the middle of a large printing anyway)
People love printing at late-night, it shakes up the whole house (wakes my wife especially)
You should manully do the resonance check like ~once a week, or only when the printing items looks wrong, minimized the machine wearing.
Optional: Restore original checks by removing “;shaking removed” comments

2, Tune down the “sudden 100% fan” noise to 50%.
Explain:
I look into this and found no logic to run noisy 100% fan except checking the fan is working well.

3, Implement non-blocking bed heating all the way till the very last moment, saving lots of time.
Explain:
Not blocking/waiting the nozzle&bed heatup until the actual printing.
The “bed heating” is the main time consuming factor in the initialization. The default g-code pauses & waits for the bed heating too early. My code simultaneously run bed leveling and homing wiping etc. during the heating process, saves lots of time.

4, Accelerated transition between between the “first 1 bar” (nozzle flush) and the actual printing, minimized the initial stringing.
Explain:
The default g-code does some internal jobs (stalls like ~100ms) after printing the “first 1 bar”, often causes a worse initial stringing. I make this move faster (nozzle only leaves the bed after the internal job, jump right to the actual printing), resulted in cleaner, thinner, or eliminated initial stringing.

Tips:
Do NOT need to skip the bed leveling at every job, because the bed leveling now costs no additional time (merged with heating process, you need to wait for the heating anyway)

Mod A1 mini start g-code below:

;===== machine: A1 mini =========================
;===== date: 20240620 =====================
;===== modified by KK v1.1 =====================

;===== start to heat heatbead&hotend==========
M1002 gcode_claim_action : 2
M1002 set_filament_type:{filament_type[initial_no_support_extruder]}
M104 S140
M140 S[bed_temperature_initial_layer_single]
G392 S0 ;turn off clog detect
M9833.2
;=====start printer sound ===================
M17
M400 S1
M1006 S1
M1006 A0 B0 L100 C37 D10 M100 E37 F10 N100
M1006 A0 B0 L100 C41 D10 M100 E41 F10 N100
M1006 A0 B0 L100 C44 D10 M100 E44 F10 N100
M1006 A0 B10 L100 C0 D10 M100 E0 F10 N100
M1006 A43 B10 L100 C39 D10 M100 E46 F10 N100
M1006 A0 B0 L100 C0 D10 M100 E0 F10 N100
M1006 A0 B0 L100 C39 D10 M100 E43 F10 N100
M1006 A0 B0 L100 C0 D10 M100 E0 F10 N100
M1006 A0 B0 L100 C41 D10 M100 E41 F10 N100
M1006 A0 B0 L100 C44 D10 M100 E44 F10 N100
M1006 A0 B0 L100 C49 D10 M100 E49 F10 N100
M1006 A0 B0 L100 C0 D10 M100 E0 F10 N100
M1006 A44 B10 L100 C39 D10 M100 E48 F10 N100
M1006 A0 B0 L100 C0 D10 M100 E0 F10 N100
M1006 A0 B0 L100 C39 D10 M100 E44 F10 N100
M1006 A0 B0 L100 C0 D10 M100 E0 F10 N100
M1006 A43 B10 L100 C39 D10 M100 E46 F10 N100
M1006 W
M18
;=====avoid end stop =================
G91
G380 S2 Z30 F1200
G380 S3 Z-20 F1200
G1 Z5 F1200
G90

;===== reset machine status =================
M204 S6000

M630 S0 P0
G91
M17 Z0.3 ; lower the z-motor current

G90
M17 X0.7 Y0.9 Z0.5 ; reset motor current to default
M960 S5 P1 ; turn on logo lamp
G90
M83
M220 S100 ;Reset Feedrate
M221 S100 ;Reset Flowrate
M73.2   R1.0 ;Reset left time magnitude
;====== cog noise reduction=================
M982.2 S1 ; turn on cog noise reduction

;===== prepare print temperature and material ==========
M400
M18
M109 S80 H170
M104 S140
M400
M17
M400
G28 X

M211 X0 Y0 Z0 ;turn off soft endstop ; turn off soft endstop to prevent protential logic problem

M975 S1 ; turn on

G1 X0.0 F3000
G1 X-13.5 F3000

M620 M ;enable remap
M620 S[initial_no_support_extruder]A   ; switch material if AMS exist
    G392 S0 ;turn on 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} ; drop nozzle temp, make filament shink a bit
    M104 S{nozzle_temperature_initial_layer[initial_no_support_extruder]-40}
    G92 E0
    G1 E-0.5 F300

    G1 X0 F30000
    G1 X-13.5 F3000
    G1 X0 F30000 ;wipe and shake
    G1 X-13.5 F3000
    G1 X0 F12000 ;wipe and shake
    G1 X0 F30000
    G1 X-13.5 F3000
    M109 S{nozzle_temperature_initial_layer[initial_no_support_extruder]-40}
    G392 S0 ;turn off clog detect
M621 S[initial_no_support_extruder]A

M400
M106 P1 S0
;===== prepare print temperature and material end =====


;===== mech mode fast check============================
M1002 gcode_claim_action : 3
G0 X25 Y175 F20000 ; find a soft place to home
;M104 S0
G28 Z P0 T300; home z with low precision,permit 300deg temperature
G29.2 S0 ; turn off ABL
M104 S140

; build plate detect
M1002 judge_flag build_plate_detect_flag
M622 S1
  G39.4
  M400
M623

G1 Z5 F3000
G1 X90 Y-1 F30000
M400 P200
;shaking removed M970.3 Q1 A7 K0 O2
;shaking removed M974 Q1 S2 P0

G1 X90 Y0 Z5 F30000
M400 P200
;shaking removed M970 Q0 A10 B50 C90 H15 K0 M20 O3
;shaking removed M974 Q0 S2 P0

M975 S1
G1 F30000
G1 X-1 Y10
G28 X ; re-home XY

;===== wipe nozzle ===============================
M1002 gcode_claim_action : 14
M975 S1

M104 S140 ; set temp down to heatbed acceptable
M106 S100 ; turn on fan (G28 has turn off fan)
M211 S; push soft endstop status
M211 X0 Y0 Z0 ;turn off Z axis endstop

M83
G1 E-1 F500
G90
M83

M109 S140
M104 S140
G0 X90 Y-4 F30000
G380 S3 Z-5 F1200
G1 Z2 F1200
G1 X91 F10000
G380 S3 Z-5 F1200
G1 Z2 F1200
G1 X92 F10000
G380 S3 Z-5 F1200
G1 Z2 F1200
G1 X93 F10000
G380 S3 Z-5 F1200
G1 Z2 F1200
G1 X94 F10000
G380 S3 Z-5 F1200
G1 Z2 F1200
G1 X95 F10000
G380 S3 Z-5 F1200
G1 Z2 F1200
G1 X96 F10000
G380 S3 Z-5 F1200
G1 Z2 F1200
G1 X97 F10000
G380 S3 Z-5 F1200
G1 Z2 F1200
G1 X98 F10000
G380 S3 Z-5 F1200
G1 Z2 F1200
G1 X99 F10000
G380 S3 Z-5 F1200
G1 Z2 F1200
G1 X99 F10000
G380 S3 Z-5 F1200
G1 Z2 F1200
G1 X99 F10000
G380 S3 Z-5 F1200
G1 Z2 F1200
G1 X99 F10000
G380 S3 Z-5 F1200
G1 Z2 F1200
G1 X99 F10000
G380 S3 Z-5 F1200

G1 Z5 F30000
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
G1 X25 Y175 F30000.1 ;Brush material
G1 Z0.2 F30000.1
G1 Y185
G91
G1 X-30 F30000
G1 Y-2
G1 X27
G1 Y1.5
G1 X-28
G1 Y-2
G1 X30
G1 Y1.5
G1 X-30
G90
M83

G1 Z5 F3000
G0 X50 Y175 F20000 ; find a soft place to home
G28 Z P0 T300; home z with low precision, permit 300deg temperature
G29.2 S0 ; turn off ABL

G0 X85 Y185 F10000 ;move to exposed steel surface and stop the nozzle
G0 Z-1.01 F10000
G91

G2 I1 J0 X2 Y0 F2000.1
G2 I-0.75 J0 X-1.5
G2 I1 J0 X2
G2 I-0.75 J0 X-1.5
G2 I1 J0 X2
G2 I-0.75 J0 X-1.5
G2 I1 J0 X2
G2 I-0.75 J0 X-1.5
G2 I1 J0 X2
G2 I-0.75 J0 X-1.5
G2 I1 J0 X2
G2 I-0.75 J0 X-1.5
G2 I1 J0 X2
G2 I-0.75 J0 X-1.5
G2 I1 J0 X2
G2 I-0.75 J0 X-1.5
G2 I1 J0 X2
G2 I-0.75 J0 X-1.5
G2 I1 J0 X2
G2 I-0.75 J0 X-1.5

G90
G1 Z5 F30000
G1 X25 Y175 F30000.1 ;Brush material
G1 Z0.2 F30000.1
G1 Y185
G91
G1 X-30 F30000
G1 Y-2
G1 X27
G1 Y1.5
G1 X-28
G1 Y-2
G1 X30
G1 Y1.5
G1 X-30
G90
M83

G1 Z5
G0 X55 Y175 F20000 ; find a soft place to home
G28 Z P0 T300; home z with low precision, permit 300deg temperature
G29.2 S0 ; turn off ABL

G1 Z10
G1 X85 Y185
G1 Z-1.01
G1 X95
G1 X90

M211 R; pop softend status

M106 S0 ; turn off fan , too noisy
;===== wipe nozzle end ================================






;===== wait heatbed  ====================
M1002 gcode_claim_action : 2
M104 S140
M140 S[bed_temperature_initial_layer_single];set bed temp


G1 Z5 F3000
G29.2 S1
G1 X10 Y10 F20000

;===== bed leveling ==================================
;M1002 set_flag g29_before_print_flag=1
M1002 judge_flag g29_before_print_flag
M622 J1
    M1002 gcode_claim_action : 1
    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 cali data
M623
;===== bed leveling end ================================

;===== home after wipe mouth============================
M1002 judge_flag g29_before_print_flag
M622 J0

    M1002 gcode_claim_action : 13
    G28 T145

M623

;===== home after wipe mouth end =======================

M975 S1 ; turn on vibration supression
;===== nozzle load line ===============================

M975 S1
G90
M83
T1000

G1 X-13.5 Y0 Z10 F10000
G1 E1.2 F500
M400
M1002 set_filament_type:UNKNOWN

;force temperature
M109 S{nozzle_temperature[initial_extruder]}
M400

M412 S1 ;    ===turn on  filament runout detection===
M400 P10

G392 S0 ;turn on clog detect

M620.3 W1; === turn on filament tangle detection===
M400 S2

M1002 set_filament_type:{filament_type[initial_no_support_extruder]}
;M1002 set_flag extrude_cali_flag=1
M1002 judge_flag extrude_cali_flag
M622 J1
    M1002 gcode_claim_action : 8
    
    M400
    M900 K0.0 L1000.0 M1.0
    G90
    M83
	
	;force temperature
	M190 S[bed_temperature_initial_layer_single];set bed temp
	M400
	
    G0 X68 Y-4 F30000
    G0 Z0.3 F18000 ;Move to start position
    M400
    G0 X88 E10  F{outer_wall_volumetric_speed/(24/20)    * 60}
    G0 X93 E.3742  F{outer_wall_volumetric_speed/(0.3*0.5)/4     * 60}
    G0 X98 E.3742  F{outer_wall_volumetric_speed/(0.3*0.5)     * 60}
    G0 X103 E.3742  F{outer_wall_volumetric_speed/(0.3*0.5)/4     * 60}
    G0 X108 E.3742  F{outer_wall_volumetric_speed/(0.3*0.5)     * 60}
    G0 X113 E.3742  F{outer_wall_volumetric_speed/(0.3*0.5)/4     * 60}
    G0 Y0 Z0 F20000
    M400
    
    G1 X-13.5 Y0 Z10 F10000
    M400
    
    G1 E10 F{outer_wall_volumetric_speed/2.4*60}
    M983 F{outer_wall_volumetric_speed/2.4} A0.3 H[nozzle_diameter]; cali dynamic extrusion compensation
    M106 P1 S178
    M400 S7
    G1 X0 F18000
    G1 X-13.5 F3000
    G1 X0 F18000 ;wipe and shake
    G1 X-13.5 F3000
    G1 X0 F12000 ;wipe and shake
    G1 X-13.5 F3000
    M400
    M106 P1 S0

    M1002 judge_last_extrude_cali_success
    M622 J0
        M983 F{outer_wall_volumetric_speed/2.4} A0.3 H[nozzle_diameter]; cali dynamic extrusion compensation
        M106 P1 S178
        M400 S7
        G1 X0 F18000
        G1 X-13.5 F3000
        G1 X0 F18000 ;wipe and shake
        G1 X-13.5 F3000
        G1 X0 F12000 ;wipe and shake
        M400
        M106 P1 S0
    M623
    
    G1 X-13.5 F3000
    M400
    M984 A0.1 E1 S1 F{outer_wall_volumetric_speed/2.4} H[nozzle_diameter]
    M106 P1 S178
    M400 S7
    G1 X0 F18000
    G1 X-13.5 F3000
    G1 X0 F18000 ;wipe and shake
    G1 X-13.5 F3000
    G1 X0 F12000 ;wipe and shake
    G1 X-13.5 F3000
    M400
    M106 P1 S0

M623 ; end of "draw extrinsic para cali paint"

;===== extrude cali test ===============================
M104 S{nozzle_temperature_initial_layer[initial_extruder]}
G90
M83

;force temperature
M190 S[bed_temperature_initial_layer_single];set bed temp
M400

G0 X68 Y-2.5 F30000
G0 Z0.3 F18000 ;Move to start position
G0 X88 E10  F{outer_wall_volumetric_speed/(24/20)    * 60}
G0 X93 E.3742  F{outer_wall_volumetric_speed/(0.3*0.5)/4     * 60}
G0 X98 E.3742  F{outer_wall_volumetric_speed/(0.3*0.5)     * 60}
G0 X103 E.3742  F{outer_wall_volumetric_speed/(0.3*0.5)/4     * 60}
G0 X108 E.3742  F{outer_wall_volumetric_speed/(0.3*0.5)     * 60}
G0 X113 E.3742  F{outer_wall_volumetric_speed/(0.3*0.5)/4     * 60}
G0 X115 Z0 F20000


M400

;========turn off light and wait extrude temperature =============
M1002 gcode_claim_action : 0

M400 ; wait all motion done before implement the emprical L parameters

;===== 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.02} ; for Textured PEI Plate
{endif}

M960 S1 P0 ; turn off laser
M960 S2 P0 ; turn off laser
M106 S0 ; turn off fan
M106 P2 S0 ; turn off big fan
M106 P3 S0 ; turn off chamber fan

M975 S1 ; turn on mech mode supression
G90
M83
T1000

M211 X0 Y0 Z0 ;turn off soft endstop
M1007 S1

G0 Z4



5 Likes

Sure, what could go wrong?

Nothing too much. The bed temperature limit is set to the printing material target and the nozzle temperature is set to be the “safe for bed 140” till the last moment. So nothing too bad could happen.

The only difference is (the default vs my g-code):

  • The factory default commands the printer to pause&wait for the bed heating up BEFORE the bed levelling stage.
  • My g-code make them run simultaneously, so the printer continue doing levelling/calib/wiping while the bed use this precious time to heating up.

Would a “cooler bed” affects the bed levelling? I doubt it would.

I did mess up many times during my testing. But eventually, I slowly understand the logical reasons behind every movement of the printing initialisation.

FYI, I can feel the reason for the factory g-code inefficiency is: each section of that g-code is written by a different person in the company. Everyone wants to be on the safe side, turning things on&off in his/her own section, without a global optimisation.

Things tend to expand when getting hotter, so yes, it matters. How much the A1 bed stack differs in height from cold to hot I do not know, but with a 0.2mm layer height a fraction of a mm could make a difference. So yes, they might be on the safe side, but there is reasoning

Okay Einstein, let’s dive into the thermal expansion calculation!

The bed plate material is likely stainless steel magnetic 410, with a thickness of approximately 1mm. During bed levelling (using my g-code), the temperature is typically 10-20 degrees below the target – let’s use 20 degrees for our analysis.

Given:

  • ΔT = 20°C
  • CTE (α) = 9.9 × 10^-6 /°C
  • Calculated thermal expansion (ΔL) = 0.000198mm

This minuscule expansion is less than 1/1000 of what the printer would even notice…

2 Likes

Oh hi there Lord Kelvin, nice to meet a peer!

That’s why I said bed stack instead of just the thin plate, everything get’s hot. But I’m not sure linear expansion is the one to worry about most, it gets wider as well. And if the stack is made up of different materials it can bow like a bimetal strip. Especially if the top is hotter than the bottom of the assembly (which I presume it is). It might not matter much indeed, but again, this might be the reasoning. I have had issues with this in the past.

Apart from that, good work on the gCode. I have not yet tinkered with this with my A1 but there are some annoyances in daily use (like the standard retraction of AMS at the end, and thus the complete prime cycle at the start) that might be solvable with custom gCode.

1 Like

Why is an A1 user in the A1 mini section of the forum?

:smile: :smile: :smile:

I dig into the g-code because my wife said, if your bloody 3d printer makes the buzz noise in the mid-night again, I throw it away.

Yaa, even if the whole bed stack is 10x thicker than plate (about that), and made with materials 10x the CTE(not likely), it still doesn’t matter, sits right within the margin of error of the bed levelling.

BTW, the A1 series margin of error is not small. I manually use the g-code did some controlling and testing. After the bed levelling, the right side of my plate is still closer to the nozzle comparing to the left side…estimate 0.02 mm.

Bambu g-code is mixed with 90% standard g-code and 10% of the proprietary command. I wish they publish a documentary listing all their firmware g-code.
My guess the AMS control codes are mostly the proprietary ones…good luck

Wow, nice job! Would those be safe for A1 as well (after adapting to A1)?

I feel like most of your changes should be included in the slicer g-code generator and some turned into firmware-based trackers:

  1. xy resonance could very well be tracked by firmware to see when it was performed last and be suggested to user same as there’s maintenance suggestions on the screen. The check in g-code should be then optional within the slicer (same as timelapse option)
  2. full agree on fan speed
  3. should be an option in the slicer (in the advanced setting). Could be off by default in case the 0.005mm possible change on leveling is “a problem” and “it’s better to be safe than fast”
  4. This one I think should be the default behaviour!

I wonder whether it’d be good idea to do a PR with the gcode change to BambuSlicer and/or OrcaSlicer ith their respective github repos. If it would get merged in Orca it’d get much more testing and we’d get practical response to “what could go wrong” with point 3 :slight_smile:

1 Like

Just as a question: My printer runs at 100% - I calibrated my filament flow, so 144 and 167% will lead to bad results.

But under 100% there is only 50% as setting, not 75% or something as a compromise between speed and quality.

Is there a factor in start G-Code which I may use to devide all speeds in the file by 40% so that 167% would be my 100%?

(Doing this with all measures in Bambu would be possible, but is messy).

I quickly list the change I made here, so you can try it on your A1.

(Below are the A1 mini commands, could be the same for A1 but I am not 100% sure)

1, Resonance check, are the M970 and M974 commands

2, Fan speed is the M106 commands

3,
M104 nozzle heating no wait,
M109 nozzle heating wait till temperature reached.
M140 bed heating no wait,
M190 bed heating wait till temperature reached.

4, Find the codes that draw the nozzle flush bar, the last 2 lines should be pushing the nozzle to the bed (Z0) and quickly lift (to maybe Z5)
You should move the quick lift code (the line could be G0 Z5) to the very end of the whole g-code. So it lifts → jumps to actual printing is faster…The filament keeps leaking out once it is lifted, so the faster the process is, the better for the initial stringing.

2 Likes

To my understanding, once the project is sent to the printer, that’s the full g-code commands that the printer will follow.
The speed that could be changed during the printing is not a “g-code command”, that must be a fixed function built-in the printer.

Manually change the all the speed settings in the bambu studio is the easiest way currently.

Thanks for this, I’ll give it a try.

Been printing with this today 4-5 prints, seems to work well with no issues, no calibrations done between prints, both bed leveling and filament running on same calibrations as before.
Silent and speedy.
Will continue to test it out but do not see a reason why this would fail, i do bigger calibration now and then anyway.
Thanks!

The DK is strong in this one.

Yep the g-code I publish here is the “safe version”, slightly touch up only, keeping every movement original. Good for public use.

I myself is running a “dangerous version” on my own machine, which bypass all the safety checking/homing etc. It wipes nozzle and start the actual printing in 30 seconds if the bed is already warm

2 Likes

Thanks for this Gcod. It really helped

Do you know wich codes I need to change to have this on normal A1 ?

Have been using this for a few days now. Works GREAT !!! There are always the Negative Nates who usually do not know what they are talking about. AKA “HUP’s” (Head Up A**)

Thanks for posting this and putting all the work into it.

1 Like

I listed the codes that I changed on a few replies above.

I’m not sure if this is a place to ask or not, but is there a way the amount of discharge the startup sequence? I get two seperate purges in my A1 mini and both of them seem to be a little excessive. I have not modified that G-Code just yet. Looking for suggestions.