Skip to main content

X1C Specific G-Code

Bambu Labs has partially implemented Marlin G-Code commands and have added their own custom G-Code commands to perform functions that are not implemented in Marlin. It is also important to note that the X1C runs their own G-Code engine and does not use the open-source Marlin Firmware on their MC Board.

Hardware Control

Printer

Code Description Example
G29.1

Set Z-trim value to # 

Use 0 to clear Z-trim

Squish for Textured PEI

G29.1 Z-0.04
G29.2  Bed leveling compensation (ABL)

Disable ABL

G29.2 S0

Enable ABL

G29.2 S1
 G29.4  High frequency z compensation

 Turn off high frequency z compensation

G29.4 S0

Turn on high frequency z compensation

G29.4 S1

 

M205 

Sets the jerk limits in mm/sec for the X Y Z and E motions

 

If you are not chainging an jerk limit axis you do not need to explicity list it

M205 X0.5 Y1.01 Z2.02 E3.03

M17 X/Y/Z#.#

Set X/Y/Z Stepper Motor Current

Be EXTREMELY careful using this command as it is VERY EASY to cause hardware damage with it should you set it too high!!!

set Z stepper current to 0.4 Amps

 

M17 Z0.4
M106 P1 S0-255 Part cooling fan off-full***

Sets the part fan on at 70%

M106 P1 S180

Sets the Aux fan on at 100%

M106 P2 S255

Sets the chamber fan on at 0%

M106 P3 S0

Sets the part fan on at 70%

M106 A1 S180
M142 Chamber Fan Temp Control

Set chamber fan to min start rpm @35° and ramp to full speed at 40°

M142 P1 R35 S40
M400 Pause 

Pause until all movement completes

M400

Pause for 10 seconds

M400 S10

 Pause for User Interaction

M400 U1

 Pause for 500 miliseconds

M400 P500
M220

Set feed rate to percent of normal. 

Default Speed is 100

Set print rate to Ludicrous Speed.
M220 S166
M221 
Set Flow rate

disable the X endstop and enable them on Y and Z)

M221 S100

Disable endstop

If you are not chainging an endstop you do not need to explicity list it

disable the X endstop and enable them on Y and Z)

M221 X0 Y1 Z1



M622 

Conditional code block and execute if selected flag is True, otherwise skip to the end of the code block 

Used with M1002

Execute if false

M622 J0

Execute if true

M622 J1
M623

End of the conditional code block

 

M623

M710 A1 S0-255

Motor Control (MC) Board fan off-full

Be EXTREMELY careful using this command as it is VERY EASY to cause hardware damage with it should you set it too high!!!

Sets the part fan on at 70%

M106 A1 S180

 

M900 Set Pressure Advance, also known as Bambu Labs call this the K-value. 
M900 K0.023
M960 S0 P0 Toolhead Lighting and Lazers

Turn off all Leds

M960 S0 P0

Turn on all Leds

M960 S0 P1

Horizontal Laser Off

M960 S1 P0

Horizontal Laser On

M960 S1 P1

Vertical Laser Off

M960 S2 P0

Vertical Laser On

M960 S2 P1

 Toolhead Light Off (micro-lidar)

M960 S4 P0

Toohead Light On

M960 S4 P1

 Toolhead Logo Light Off

M960 S5 P0

Toolhead Logo Light On

M960 S5 P1
M970.3

Play mech mode test vibrations

M970.3 Q0 A7 B30 C90 Q0 H15 K0
M970.3 Q1 A7 B30 C80  H15 K0
M971 Internal Camera Control

Take photo

M971 S11 C10 O0

 

M972 Calibrate Micro-Lidar

Move Lidar to calibration sticker

M972 S5 P0
M973

Toolhead Camera

 

Enable  Auto Exposure

M973 S1

 Camera Off

M973 S3

Camera On

M973 S3

Turn off Micro-Lidar

M973 S4

Set Auto Exposure for Horizontal :Laser

M973 S6 P0

Set Auto Exposure for Vertical Laser

M973 S6 P1
M974 Set Mech Mode Suppression Values
M974 Q0 S2 P0
M974 Q1 S2 P0
M975 Mech Mode Supression

turn off mech mode supression

M975 S0

turn on mech mode supression

 

M975 S1
M976
M976 S3 P2

Scan Heatbead before printing

M976 S2 P1

First Layer Scan

M976 S1 P1
M977 first layer scanning

Enable first layer scanning

M971 S11 C10 O0
M971 S11 C10 O0
M981 Spaghetti detector

Spaghetti detector off

M981 S0 P20000

Spagetti detector on

M981 S1 P20000


M982.2 Motor Noise Cancelation

Turn off motor noise cancelation

M982.2 C0

Turn on motor noise cancelation

M982.2 C1

 

M991 Layer Change

Notify Printer of Layer Change where # is the current layer number

M991 S0	P#

Finish Smooth timelapse

M991 S0 P-1
M620 C# calibrate AMS by AMS index
M620 R# refresh AMS by tray index
M620 P# select AMS tray by tray index
M620 S# select AMS by tray index

Pull Filament back into AMS

M620 S255
M621 S# load filament in AMS by tray index  
M1002
Select flag for conditional commands from slicer

Check to see if extrusion calibration was set in the slicer

“M1002 judge_flag extrude_cali_flag”
Update Printer Status on Slicer / LCD

Clear (Set to printing)

M1002 gcode_claim_action: 0

Auto bed levelling

M1002 gcode_claim_action: 1

Heatbed preheating

M1002 gcode_claim_action: 2

Sweeping XY mech mode

M1002 gcode_claim_action: 3

Changing filament

M1002 gcode_claim_action: 4

Pause (M400)

M1002 gcode_claim_action: 5

Paused due to filament runout

M1002 gcode_claim_action: 6

Heating hotend

M1002 gcode_claim_action: 7

Calibrating extrusion

M1002 gcode_claim_action: 8

Scanning bed surface

M1002 gcode_claim_action: 9

Inspecting first layer

M1002 gcode_claim_action: 10

Identifying build plate type

M1002 gcode_claim_action: 11

Calibrating Micro Lidar

M1002 gcode_claim_action: 12

Homing Toolhead

M1002 gcode_claim_action: 13

Cleaning Nozzle Tip

M1002 gcode_claim_action: 14

Checking Extruder Temperature

M1002 gcode_claim_action: 15

Paused by the user

M1002 gcode_claim_action: 16

Paused due to toolhead cover falling off

M1002 gcode_claim_action: 17

Calibrating the micor lidar

M1002 gcode_claim_action: 18

Calibrating the extruder flow

M1002 gcode_claim_action: 19

Paused due to nozzle temperature malfunction

M1002 gcode_claim_action: 20

Paused due to heat bed temperature malfunction

M1002 gcode_claim_action: 21

 

M1003 Power loss recovery

Disable power loss recovery

M1003 S0

Enable power loss recovery

M1003 S1
M1004 External Camera Shutter Control

Actuate External Camera Shutter

M1004 S5 P1
M1005 set skew correction

Set skew correction

M1005 X##.#Y##.# ; input values from printed calibration stl
M500 ; save the values

Add the above Gcode to the last line of the “Machine start Gcode” and only run it once as the compensation will compound each time it is run. 

 

Set skew correction in radians

M1005 I500
M500

Unlike the first example this is not iterative, and will overwrite any skew value set

 

Reset skew correction

M1005 I0 ; reset the compensation value
M500 ; save the value
M1006 Play Sound Through Speaker

Enable Speaker?

M1006 S1

Set note to play

M1006 A0 B10 L100 C37 D10 M60 E37 F10 N60

Play supplied notes

M1006 W
T1000 Set toolhead to extruder
T1000


T1100 Set toolhead to Micro-Lidar
T1100

Software Control


Code Description Example
     
     
     
     
     
     
     
     

References:
  1. https://forum.bambulab.com/t/bambu-lab-x1-specific-g-code/666
  2. https://github.com/Doridian/OpenBambuAPI/blob/main/gcode.md
  3. https://github.com/jphannifan/x1plus-testing/blob/main/Gcode.md