Issues getting laser configured properly

I have a 8 watt output laser that I can successfully turn on and off with the TFT35 Spindle interface, but it does nothing in the laser interface (replaced fan interface). Below are the changes I made in Marlin compiling for a BTT SKR 1.4 Turbo. M106 Sxxx (ive tried different number 0-255) does nothing. What am I missing? +12v and GND are connected to Fan 0 and the PWM pin is connected to P1.24 of the neopixel connector.

in Configuration_adv.h
#define SPINDLE_LASER_ACTIVE_HIGH true // Set to “true” if the on/off function is active HIGH
#define SPINDLE_LASER_ENA_PIN P2_03 // Fan 0 pin for +12v amd GND for power and enable/disable
#define SPINDLE_LASER_PWM true // Set to “true” if your controller supports setting the speed/power
#define SPINDLE_LASER_PWM_PIN P1_24 // Neopixel data pin for +5v PWM
#define SPINDLE_LASER_PWM_INVERT false // Set to “true” if the speed/power goes up when you want it to go slower
#define SPINDLE_LASER_POWERUP_DELAY 1000 // (ms) Delay to allow the spindle/laser to come up to speed/power
#define SPINDLE_LASER_POWERDOWN_DELAY 1000 // (ms) Delay to allow the spindle to stop

in pins_BTT_SKR_common.h
#ifndef FAN_PIN
#define FAN_PIN P2_05 // move fan 0 pin P2_03 to bed bin

in pins_BTT_SKR_V1_4.h
#define NEOPIXEL_PIN P2_05 // move neopixel pin P1_24 to bed pin

Update: M3 and M5 work, but the Sxxx feature doesn’t change the intensity.

Alright. I think I finally got it for my case, But I dont like it.
M106 P1 // turns on laser module in GCODE
M106 S25 // Sets laser to 10%

Completely disable the laser feature in Marlin (in Configuration_adv.h) and make some modifications to pins_BTT_SKR_common.h
#define FAN_PIN P1_24 // Fan 0 for Laser PWM M106 Sxxx (0-255)
#define FAN1_PIN P2_03 // Fan 1 for Laser Enable

Modifications from above in pins_BTT_SKR_V1_4.h stay:
#define NEOPIXEL_PIN P2_05 // move neopixel pin P1_24 to bed pin

Ultimately, I may just move the laser power to board power so the laser module is on when the unit is on or just modify my GCODE to start with M106 P1 to turn on the laser module and M107 P1 to turn it off at the end of the GCODE.

I don’t have a laser, but I keep up on the laser topics on the forum, and I’ve been able to help several people get their laser working. I’ve seen several times where fan commands were initially used to get thing up and running, but long term, there was quality issues with the running the laser using a fan pin. They eventually made firmware changes so that inline laser commands can be used, and werer happy. That is an ‘S’ parameter of the G0/G1/G2/G3 commands is used to specify laser output.

The last time I checked, of the firmware that V1 maintains, only the Rambo boards and the SKR Pro boards had firmware with the inline laser enabled. If you elect to try and get inline laser commands running for your SKR 1.4 Turbo, I suggest you download the source for either the Rambo firmware or the SKR Pro firmware and run a ‘diff’ program using configuration.h and configuration_Adv.h between your source and source with lasers enabled. I don’t know how many are really necessary, but there were a fair number of changes (some of them not obvious), between V1 maintain firmware with and without laser support enabled when I ran this diff.

Lately I’ve been using Meld as my diff tool. The first post in this topic contains a test file with inline commands.


I will definitely look into inline S commands within the move commands with the laser. Ultimately grayscale raster images are what I’m after.

1 Like

You can process greyscale images two ways, you can either use a constant laser power and ‘dither’ your image to produce a picture of dots that the laser can use or you can scan the laser across your output material and vary the laser power to produce various levels of ‘burn’.

Marilyn dithered using M3

some sample gcode for dithering -

G0 X0 Y0 F1000
M3 S0
G0 X8.667 Y0 S0
G1 X9 S1000
G0 X21.333 Y0 S0
G1 X21.667 S1000
G0 X22.333 Y0 S0
G1 X23 S1000
G0 X23.667 Y0 S0
G1 X24 S1000
G0 X24.333 Y0 S0
G1 X24.667 S1000
G0 X25.333 Y0 S0
G1 X25.667 S1000
G0 X26.333 Y0 S0
G1 X26.667 S1000
G0 X27.333 Y0 S0
G1 X27.667 S1000
G0 X28.333 Y0 S0
G1 X29 S1000

You notice how the power is either S0 or S1000, (full power on my machine).

Alternatively, Marilyn ‘scanned’ with M4 to vary the output power

Sample gcode for scanning with M4

G0 X0 Y0 F1000
M4 S0
G1 X0.333 S113
X0.667 S109
X2.333 S105
X3 S101
X3.333 S70
X3.667 S98
X4 S105
X4.333 S101
X4.667 S90
X5.333 S86
X6.333 S94
X6.667 S98
X7 S90
X7.333 S86
X8 S98
X8.333 S94
X9.333 S86

This time the laser intensity is modulated using PWM.

Both processes have their settings to obtain the best results according to your materials and desired effects.

I don’t use Marlin for laser work, I find it is not the best choice for the reasons you are experiencing so cannot help with your configuration I’m afraid but I can advise you not to pulse the 12V on and off to control your laser if it has the PWM feature as you are pulsing not only the laser diode but the PWM control circuitry and any fitted cooling fan as well and they wont thank you for that, you should use the PWM function.
I would however suggest you comment out the delays you have enabled, they are not needed. Can you post the gcode you used when you say M3 and M5 work but Sxxx doesn’t.


M106 Sxxx is working since my last update.
I have in my begin HEADER “M106 P1” (FAN1_PIN) (Physical Fan 0 connector, supplies 12v) to turn on the laser module at full power.
I use M106 Sxxx (FAN_PIN) (physical Neopixel pin) as this is how I had originally plugged everything up.
Custom settings in my PP:
M106 S0 for “retract”
in my begin Footer
M107 P1 to turn off the module at the end of a file
and G00 to go home in case I need to run it again (for cuts that may not have gone deep enough)

Of course all this will likely change with the firmware I compiled lastnight. My older firmware didn’t have LASER_MOVE_POWER feature yet which may have been some of my original problem?

TLDR; I’ve gotten a better understanding hopefully.

1 Like

I’ve built off lastnight’ss 2.0.8 bugfix branch and have a working LR2 (x/y/z and endstops all go in their proper direction) laser changes PWM on G1 moves. Sometimes G0 doesn’t work to turn off the laser PWM even though it is enabled in the config (does G0 expect an x/y/z move as well not just G0 S0?). M5 also sometimes doesn’t work to turn off the laser module. This is just through manual GCODE input to get an idea of how to configure my post processor now. I haven’t tried M4 S0 as you stated above (I would use this for retracts maybe?).

On a side note, I now have noise in my stepper motors which seems to be a common issue that has cropped up with the NEMA17 steppers driven by TMC2209 drivers since I compiled on IIRC?
Edit: found my answer

Anywho, this is the build I have M106 controlling the laser.
This is what I am currently working with that just seems to have the issues with stepper noise.

Update: tested with Ryan’s Test gcode. Turned up this.

Update 2: more more things tweaked.

Update 3: Almost there!