M106/M107 G-codes for Laser Inline Control and air assist setting

LightBurn Bug Report: Wrong M106/M107 G-codes for Laser Inline Control and air assist setting

Summary

LightBurn generates fan control G-codes (M106/M107) which are influenced by the air assist setting for laser control instead of proper laser commands (M3/M4) when using the Snapmaker Marlin profile with inline power mode.

Environment

  • LightBurn Version: 1.7.08
  • Device Profile: Snapmaker Marlin
  • Operating System: Linux (also confirmed on Windows)
  • Machine: Snapmaker 2.0

Problem Description

When using the Snapmaker Marlin profile with inline power control, LightBurn generates laser control commands based on the “Air Assist” setting, which is illogical:

  • Air Assist ON: Generates M106
  • Air Assist OFF: Generates M107

The main issues are:

  1. Confusing UI logic: The “Air Assist” setting controls laser commands, not air assist
  2. Inconsistent behavior: Laser control should not depend on an unrelated setting
  3. Better alternative exists: M4 should be used directly for variable power laser control
  4. Misleading configuration: Users expect Air Assist to control air flow, not laser power mode

Expected Behavior

  • M4 should be used directly for variable power laser control (best solution)
  • Laser power control should be independent of the Air Assist setting
  • The Air Assist setting should only control actual air assist functionality

Steps to Reproduce

  1. Create a new project in LightBurn
  2. Configure Snapmaker Marlin device profile
  3. Set up a simple laser job with inline power control
  4. Generate G-code and observe the laser control commands
  5. Notice that M106/M107 are used instead of M3/M4

Actual Results

; Current problematic behavior: Laser control depends on Air Assist setting
; Air Assist ON:
M106 P0 S255    ; Laser control (works but tied to wrong setting)
M05             ; Laser off
G0 X153 Y88 F0
G0 Z0
; Layer C00
G1 Y153F6000 I S255  ; Inline power control

; Air Assist OFF:
M107            ; Laser control (works but tied to wrong setting)
M05             ; Laser off
G0 X153 Y88 F0
G0 Z0
; Layer C00
G1 Y153F6000 I S255  ; Inline power control

Expected Results

; Best solution: Use M4 directly for laser control
M4 S255         ; Variable power laser control (optimal)
M05             ; Laser off
G0 X153 Y88 F0
G0 Z0
; Layer C00
G1 Y153F6000 I S255  ; Inline power control

Impact

  • Severity: Medium
  • Frequency: Always occurs when using Snapmaker Marlin profile with inline power
  • User Confusion: Air Assist setting controls laser power instead of air flow
  • Illogical Dependency: Laser control tied to unrelated UI setting
  • Workaround: Manual G-code editing or custom post-processing required

Additional Context

This issue creates confusion because:

  1. The Air Assist UI setting controls laser behavior, not air assist
  2. M4 would be better for variable power control as it compensates for acceleration/deceleration
  3. Users expect Air Assist to control actual air flow, not laser power

Suggested Fix

  1. Decouple laser control from Air Assist setting
  2. Implement M3/M4 laser control commands for inline
  3. Add separate “Constant Power” toggle (currently missing from Snapmaker Marlin profile)
  4. Use M4 by default for better variable power control
  5. Reserve Air Assist setting for actual air assist functionality

Related Issues

  • Missing “Constant Power” toggle in Snapmaker Marlin profile
  • Inconsistent behavior between different device profiles regarding fan control

@Skreelink can you relate?

What is illogical here? If you turn on AA setting, LB sends the “fan on” command at the start. If AA should be off, it sends “fan off”.
Sounds absolutely correct. For grbl it is M8 and M9.

The issue of dynamic power control might be something different.

Maybe i am wrong, but i thought the M106 should control the laser in marlin and not the air assist.
Take a look at notes:

fan != air assist.

M8 is air assist → Snapmaker 2.0 G-code Commands | Snapmaker Wiki

I don’t think so. M106 is also fan speed on snapmaker. And M3 and M4 exist as well.

Thanks for your answer.
In Laser Mode it only controls the laser, in 3D Printing mode the Fan. It does not control the air assist.

I don’t have any experience with Snapmaker, but the wiki clearly states m3 and m4 and has no note about m106 being used in a different way. But I also didn’t read completely through it :grinning_face:

In my experiences; M106 P0 S255 has always been placed at the beginning by Luban (I do not know if it still does, this was observed back when I first got the machine and have used Lightburn ever since). So I’ve always had that line in the start gcode line in Lightburn.

My theory is with the laser head attached, M106 enables power to the toolhead fan or the fan that’s blowing across the heatsink in the laser unit iself. However, it does not fully control it. As there’s a timer after the laser turns off and the fan powers down. So it may be ENTIRELY USELESS.

The actual laser power is controlled by M3/M4, whereas M3 is constant power, and M4 is trapezoidal power like other lasers.

Worthy sidenote: There’s an issue with the 2W 1064nm IR module. The minimum power they use is high enough to interfere with M4 control, and you have to manually lower the range.
That particular fix can be found here.

Now to the actual Air Assist, the Snapmaker control uses M8 and M9 JUST LIKE GRBL.

Infact, I’ve used the GRBL-M3 profile in Lightburn ever since the days of having to compile inline support by hand from the github. If I want to use M4, I replace it by hand, as I had a bug using the normal GRBL profile. Those weirdnesses were documented here.

Overall it seems (to me) the Snapmaker profile should.

1: Generate GRBL-M3 style code.
2: Use M8 and M9 for Air Assist.
3: Enable the option for Constant/Variable M3/M4
4: Use Marlin background for the movement buttons/framing/etc.

#4 is mostly because using the GRBL-M3 profile breaks the button controls, movement gets doubled, and framing is wrong, however, for the actual project, the code is leaner, faster and works perfectly fine.

1 Like

Hey Skreelink - when you use snapmaker marlin inline mode in lightburn, it is/was used to activate the laser.
Luban does not use it at all, in my actual version (4.15.1)

I’ll do a gcode test tomorrow. Just to make sure.

TL;DR I did some testing to see what it does, Lightburn likely puts in the M106 line because Snapmaker/Luban did. It’s still useless. My reasoning for this conclusion is as follows.
(Also sorry if my reply seems rough, work has been really beating me up so brain is mushy)

The Marlin profile doesn’t put M3 either, but it also doesn’t use an M106. Because Marlin turns the laser on and sets power when it sees “I”

Both are from Lightburn version 2.0.00.
From vanilla Marlin.

; Image @ 500 mm/min, 100% power
M8
M05
G0 X159.864 Y175.01 F8999
G0 Z0
; Layer C00
G91
G1 X0.208 F500 I S0
G1 X0.12 I S255
G1 X0.06 I S0

And from Snapmaker Marln

; Image @ 500 mm/min, 100% power
M106 P0 S255
M05
G0 X159.864 Y175.01 F8999
G0 Z0
; Layer C00
G91
G1 X0.208 F500 I S0
G1 X0.12 I S255
G1 X0.06 I S0

Only difference is the M106 P0 S255, so likely because of Luban. Which, it apparently doesn’t do anymore. I just generated a test, and it didn’t put in an M106, however, I do have an old file.

;Header End
; Laser multi-pass, pass 1 with Z = 0
; G-code for laser engraving
; Generated by Snapmaker Luban
; G-code START <<<
G90
G21
M106 P0 S0
G91
G0 F3000

The above was an old 1.6W file, though I note it’s an S0.

Also a code snippit from 2020 has it as S255. But also has an M3.

G90
G21
; G-code START <<<
M106 P0 S255
G0 F1500
G1 F500
G0 X-42.35 Y-29.56
M3 P100 S255
G1 X-42.06 Y-29.56
M5
G0 X-41.78 Y-29.56
M3

So my conclusion; it’s been there forever from Luban, so Lightburn added it, Luban dropped it, so now it’s confusing people. :upside_down_face: It’s time for Lightburn to drop it.

It’s a useless line that shouldn’t be there. Again, my guess is in the early days, it might have turned on the 1.6W toolhead fan, and now it’s not needed with newer firmware.

Great finding. Thank you.
My assumption was that I controls the laser, too because I read some machines used the fan pins for the laser, time ago. And that could have interfered with the laser power.

So the conclusion is:
M106/107 yis obsolete.
We need dynamic and constant power switch and air assist option needs to do M8.

I really would love to see a last 1.7 version with this fix, because I am a Linux user.

You’re welcome, asking and bringing up points helps everyone learn and move forward. I think this helped stamp out some info for the Lightburn team if they roll through as well.

Just to make sure:
Its the air assist setting in the layer window

image