G-code for cooling down X1C after print ends

Custom G-code for cooling down X1C post-print. Only runs if chamber temperature is set over 40ºC.
4
9
0
199
updated March 11, 2025

Description

PDF

I have written custom G-code to add a conditional post-print cooldown for high temperature print jobs. The code speeds up cooling by using both auxiliary and exhaust fans until bed and chamber reach 40ºC. 

Cooldown is conditional on chamber temperature being set to at least 40ºC. In OrcaSlicer, you can set your target chamber temperature under Material Settings. Set below 40ºC to disable cooldown. 

The included .3mf file is an otherwise stock profile (OrcaSlicer 2.3.0-rc) with the cooldown procedure added to the “Machine End G-code.” You can find that same modified machine end gcode in the txt file. 

Developed for use with X1C and OrcaSlicer but should be able to work for P1S without modification. 

 

Implementation 

Replace the following two lines in the original “Machine End G-code” with the code block. They should be the last two lines. 

M17 X0.8 Y0.8 Z0.5 ; lower motor current to 45% power
M960 S5 P0 ; turn off logo lamp

 

Code

 

;===== cooldown start =================
;===== V2 - 03-08-2025 ================

; For high temperature prints
{if chamber_temperature[0] >= 40}

; Stage 1 - Cool bed using auxiliary fan to reduce bed vs chamber temperature differential
M1002 gcode_claim_action : 5; LCD Message = "M400 Pause"
M106 P2 S255; Turn on auxiliary fan 
M190 R{chamber_temperature[0]}; Set bed temperature to chamber temperature and wait for bed to reach temperature
M190 S0; Set bed temperature to 0 but do not wait

; Stage 2 - Cool chamber 
M1002 gcode_claim_action : 16; LCD Message = "Paused by the user" 
M106 P3 S255; Turn on exhaust fan at 100%
M191 S40; wait for chamber temperature to reach 40ºC


{endif}

; Shutdown Machine
M106 P2 S0; Turn off auxiliary fan 
M106 P3 S0; Turn off exhaust fan
M17 X0.8 Y0.8 Z0.5 ; lower motor current to 45% power
M1002 gcode_claim_action : 0; Clear LCD screen of messages
M960 S5 P0; Turn off logo lamp
;===== end - cooldown =================

 

 

Background

I designed a two stage cooldown to prevent the chamber from cooling too fast before the bed. In theory, a large temperature difference between bed and chamber may cause warping if top and bottom of print cool at different rates. 

The first stage uses the auxiliary fan to help cool down the bed. When bed and chamber temperature equalize, the second stage then activates both auxiliary and exhaust fans to further cool the chamber to 40ºC. 

Additionally, I added commands to update of print status to indicate when cooling is being performed and when it ends. Stage 1 is indicated by the display message "M400 Pause" and Stage 2 by “Paused by the user.” LCD is cleared of messages after print ends.

 

References 

  1. Bambu Lab specific gcode implementation → https://forum.bambulab.com/t/bambu-lab-x1-specific-g-code/666
  2. More gcode commands → https://github.com/jphannifan/x1plus-testing/blob/main/Gcode.md
  3. How to access values set in the slicer when writing gcode → https://wiki.bambulab.com/en/software/bambu-studio/placeholder-list
  4. OrcaSlicer chamber temperature implementation → https://github.com/SoftFever/OrcaSlicer/wiki/chamber-temperature
  5. Marlin documentation for chamber temperature gcode → https://marlinfw.org/docs/gcode/M191.html  

Tags



Model origin

The author marked this model as their own original creation.

License