GRBL and M4 dynamic laser power

Follow-up of my other thread, since the issue is something completely else.
It seems Laserweb uses the Z-axis to control the laser?
I used the GRBL config, and Laserweb won’t fire the laser. I can fiddle around with the gcode settings, and add M3/M4 and M5 gcode to “tool start/stop”. Now Laserweb fires the laser in M3 mode, so it comes to a full stop when turning the laser on or off. And I have to manually edit the laser power settings in the config for every change, so I don’t know how to set the power through the tool menu (laser cut, laser raster, etc.).

I can’t figure out if this is about GRBL that needs to turn on the laser on G1 moves, or Laserweb that needs to be configured to use the M4 mode correctly.

Hardware: arduino uno, CNC shield. Laser PWM going to Z+, which is the PWM pin of the arduino.
Laserweb 4.0.998, grbl 1.1h

Laser PWM and M4 dynamic power work correctly with LaserGRBL.

LaserWeb has nothing to do with the pin that is used for PWM power. It uses typical laser gcode S value for the laser power.

There are two versions of the CNC Shield. The older one (V3.0) has the PWM connected to pin Z+, the newer version 3.1 has corrected the pins so the laser power PWM is going to pin “Spindle Enable/PWM”.

In LaserWeb, you just load the “Generic GRBL machine” profile. This should have “M4 S0” in the gcode start command and “M5” in the gcode end command. Tool on and tool off should be empty.

These settings activate the laser with zero power at the beginning of the file and deactivate it at the end. On each G0 the laser will stay off and on G1, G2, G3 it will fire with the power defined by the S value (relative to feed during accelleration/decelleration). This way you don’t get darker starts & ends of cuts.

Thank you for explaining.
I must have the V3.0 of CNC shield. I have selected “generic GRBL machine” alright.
I see the M3 or M4 at S0 in the beginning of my code alright. The laser doesn’t turn on, however.
Clicking “laser test” doesn’t turn on the laser either (unless I add my own Gcode).
Somehow “pen up” and “pen down” turn the laser on and off alright. Almost like something is going wrong with the $32 parameter?

Pen up/down? Where do you find that command? It’s neither part of GRBL 1.1h nor LaserWeb.
This sounds more like a special pen plotter firmware (like my grbl servo version).

Okay, I removed the folder with user settings. I applied the GRBL profile. Laser test now works, the “pen up” and “pen down” macros are gone. Laser burning works as well, and the output power is variable, but the movement is extremely slow. I still had to set $32 to 1 through LaserGRBL, to enable laser mode, and then it finally worked.

Weird. I think everything is solved now, but at least I understand better what’s going on.


Hi, I had weird and… interesting issues getting the laser to work on a mks dlc32v2 board. For some reason adding M3 S0.01 before burn start fixed it, Laser would not turn on with an initial M3 (or M4) S0.

I’m sure there is something I’m not getting, but works fine as a quick fix - so thought to post it here, in case someone else has the same problem.