3dSynth

Tutorials / Custom G-code

Open in the interactive tutorials reader

---
title: Tutorial 9 Fan Control
description: Managing part cooling for bridges and overhangs.
---

Tutorial 9 Fan Control

1. Lesson Header

2. Concept Introduction

The Need for Speed.

When molten plastic leaves the nozzle, it's sticky and fluid.
- Layer Adhesion: Requires heat (Fan OFF).
- Detail / Overhangs: Requires cooling (Fan ON).

If you blow too much air, the layers won't stick together (delamination).
If you blow too little, the plastic will sag (drooping).

The Part Cooling Fan (M106) is separate from the Heatsink Fan (which is always on).

3. Machine State Explanation

PWM (Pulse Width Modulation)
The fan speed is not just ON or OFF. It's a value from 0 to 255.
- 0: Off (0%)
- 127: Half Speed (50%)
- 255: Full Speed (100%)

4. Command Breakdown

Set Fan Speed (M106 S...)

- Syntax: M106 S255 - Use: Turn on cooling.

Turn Fan Off (M107)

- Syntax: M107 - Equivalent: M106 S0

5. Minimal Working Example

; Start with Fan OFF for First Layer Adhesion
M107
G28

; Print Layer 1 (Slow, Hot)
G1 Z0.3
G1 X10 Y10 E1

; Turn Fan ON for Layer 2
M106 S128 ; 50% Speed
G1 Z0.5   ; Move Up
G1 X20 Y20 E1

; Turn Fan FULL for Bridge
M106 S255 ; 100% Speed
G1 X50 Y50 E1

6. Visual Representation

Interactive preview is available in the interactive reader.

7. Build Exercise

Task: Write a script that:
1. Moves to Z=10.
2. Turns the fan on 25% (S64).
3. Waits 2 seconds (G4 P2000).
4. Turns the fan on 50% (S128).
5. Waits 2 seconds.
6. Turns the fan on 100% (S255).
7. Turns the fan off.

...

Solution:

G28
G0 Z10

M106 S64
G4 P2000

M106 S128
G4 P2000

M106 S255
G4 P2000

M107

8. Deep Insight Section

Bridging
When printing in mid-air (between two pillars), the plastic must be cooled instantly so it freezes into a solid line before gravity pulls it down.
This is called "Bridging."
Slicers detect bridges and automatically insert M106 S255 right before the bridge starts, and turn it down after it lands.

9. Common Failure Modes

  1. First Layer Peeling: If you turn the fan on too early (Layer 1), the plastic cools too fast and curls up off the bed. Always keep the fan OFF for the first few layers.
  2. Thermal Runaway: If your fan blows directly on the heater block (instead of the nozzle tip), the heater has to work extra hard to stay hot. The firmware might think the sensor is broken and shut down for safety.

10. Real-World Application

Material Differences
- PLA: Needs 100% Fan.
- PETG: Needs 30-50% Fan.
- ABS: Needs 0% Fan (or very low). ABS shrinks when cooled, causing cracks.

11. Final Clean Version

Save this as lesson9.gcode.

; Lesson 9 - The Fan Ramp
; Setup
G21
G90
M83
G28

; Heat Nozzle (Manual)

; --- Layer 1 (Fan Off) ---
M107           ; Ensure Fan Off
G0 Z0.3
G0 X20 Y20     ; Start
G1 X120 Y20 E5 ; Base Line

; --- Layer 2 (Fan 50%) ---
M106 S128      ; Fan On Half
G0 Z0.6        ; Move Up
G1 X120 Y30 E1 ; Shift Over
G1 X20 Y30 E5  ; Draw Back

; --- Layer 3 (Fan 100%) ---
M106 S255      ; Fan Full Blast
G0 Z0.9        ; Move Up
G1 X20 Y40 E1  ; Shift Over
G1 X120 Y40 E5 ; Draw Forward

; Finish
M107           ; Fan Off
G0 Z10
G0 X0 Y200

12. Stretch Challenge

Challenge: Simulate a "Pulsing Fan."
Write a loop (manually unrolled) that ramps the fan up and down while moving the X axis, to see if it affects the surface finish.

Answer Key:

G1 X10 M106 S50
G1 X20 M106 S100
G1 X30 M106 S150
G1 X40 M106 S200
G1 X50 M106 S255
G1 X60 M106 S200
; ... etc