I am currently working on the Arduino Uno + CNC Shield V3 + GRBL 1.1h + UGS stack and could not get any love from PWM. My GCODE was using M3 S255. I stripped everything down and just hooked up an LED to pin 11 and ground on the Arduino itself, no shield attached. I was using UGS and was very surprised that not even that worked. I tried CNCjs in desperation, toggled the spindle on - nothing. About to smash everything in front of me, I decided to run Laser Test, since I have a laser working on my original Primo setup using all the same stack. Bam, green light. From reading the console commands - I noticed that it is sending G1F1 before the S1000, that seems to be the secret sauce. Why doesn’t the spindle work until that command is sent?
I’m not an expert, but I believe F is a feed rate command. If it has no feed rate, it can’t move, so intuitively then your PWM does nothing. If you are G20 or G21, that F1 is 1 inch or 1 mm, so the pwm will be different depending on the F value and how it is being interpreted.
You need four instructions for the PWM to fire up. Sometimes you will have already stipulated some of these commands earlier in your gcode but from a cold start you will need all 4.
A G1 instruction this is a move instruction
A Fxxx instruction this is a speed instruction
A Sxxx instruction this is a power instruction
A M3 instruction. this is the on instruction
eg G1S200F128M3 will turn the pwm on
After that you can control the laser intensity by changing the Sxxx value from zero to maximum OR you can turn it off and back on (at the previously set power) with M5 and M3
Your pwm signal is available on pin D11 on the Uno or Z+ on the shield
The ‘magic’ is that with a laser you don’t want the laser on and the carriage to be not moving…it leads to fires - hence in laser mode you need the speed and move commands before the laser will fire. (even though the move command doesn’t tell the carriage where to move to…it is sufficient just to enter the G1)