Spindle and Laser Control for CNC Router using Gcode

In this episode we will look at using a dual relay board (amzn.to/1MeJCmN) connected to the GRBL controller to on and off either a spindle or small laser attached to the mill (we will be adding a 2 watt laser in another episode).  This is is current using pin 13 which is set control spindle direction as in stand PWM mode pin 12 for spindle enable does not respond to gcode commands and requires a change in the configuration.f and a recompile with upload.  I got the below table from (www.shapeoko.com/forum/viewtopic.php?f=3&t=5803) and it is a good reference if you want to make changes.


Disabling VARIABLE_SPINDLE will revert Grbl to the old pin layout, where spindle enable is on D12 and direction on D13. With it enabled, spindle enable/PWM is on D11 and direction on D13.

EDIT: Here’s a chart to make it a bit clearer.

D11 = Spindle enable/PWM speed
D12 = Z-limit
D13 = Spindle direction

D11 = Z-limit
D12 = Spindle enable (on/off only)
D13 = Spindle direction

D11 = Spindle PWM speed only
D12 = Z-limit
D13 = Spindle enable (on/off only)