Laser not turning off between layers

When I tried the laser spindle before it would only turn the laser on at 100% on the layers set to cut at 100%, anything less and the laser doesn’t fire (no PWM) and I had to plug it into pin 2, laser would not fire plugged into pin 0. With PWM I am plugged into pin 0.

Are you using M4 mode? M3 mode is 100% or nothing. M4 is full PWM.

@Tylas is using 26 and I’m using 27. I’m on jackpot 1 if it matters. I thought that 0 is a magic one

GPIO 0 is used at boot. That can mess up bootimg if you multi-purpose it. It also glitches at boot which could cause dangerous results with your laser.

Don’t use GPIO 0

I’m pretty sure that M3 support S parameter as well. M4 is a dynamic laser mode so it adjusts the power based on speed / acceleration to make even engraving when the head is accelerating

A laser is considered a spindle because gcode does not have laser specific codes. It uses the RPM value as a power level. Lasers also have special requirements.

They always operate like the advanced laser mode of Grbl

They will only operate in G1, G2, or G3 motion modes. They will not operate during G0, Jog, Homing etc. If you need it to operate in those modes, use a PWM spindle.

They turn off when idle or doing a rapid move.

M3 is constant power and M4 is dynamic power mode (scales linearly with speed during accel/decel)

I agree with everyone above, to sum up:

First, get off GPIO 0 - it can give issues, been there. Use 2, 26, 27, make sure you use the 5V rail.

Direction_pin - unnecessary, either delete, omit (#), or explicitly state NO_PIN.

On the console, type $32=1. Lightburn should put this in the beginning of a code file, but you can explicitly enable. You say you can’t change this to 1 in your first post, why? What error do you see?

GRBL reuses spindle directions for lasers: M3 - CW on spindle, constant burn setting on laser. M4 - CCW on spindle, PWM signal for laser. You want $32=1 for M4 to enable instant change and motion, $32=0 GRBL will stop to adjust Sxxx before moving again. Light does not need time to spool up.

Share the gcode you are trying to cut, many on here can diagnose if there are settings issues on the Lightburn side.

I changed from gpio.0 to gpio.2. I was using PWM, and no matter what I changed the laser would not turn off between layers, and when I tried to change $32=1 in LB, I received a 162 message, read only. So I switched to using the Laser in the config file and now$32 is =1 in LB, I have no messages/alarms. I can fire the laser with the test fire button, but it will not fire when running a program, unless I have constant power mode turned on. When I go to the device settings for Grbl page, there’s no options for which m code to use to fire the laser.

In Lightburn, when you are setting up your cuts you choose your mode.

Line - Constant Power = M3

Fill - Variable Power = M4

If you have the right GRBL machine profile set up in Lightburn it should create the right gcode. Are you copying the gcode file to the SD card or are you using Lightburn directly?

Which laser are you using? We use different lasers so there might be a quirk with yours.

Also if you share your gcode so we can make sure it is set up correctly.

How’s it going @Soaringhigher - get it working yet?

Sorry for not responding sooner, been a busy week. I did get everything working, thank you everyone for your help along the way. I have a 34 watt Jtech laser and am using lightburn to directly control the Mpcnc and laser. I have experimented and figured out how to use line vs fill.

thank you again everyone.

Well done!