top of page

Using a diode laser with grblHAL


Diode lasers are becoming quite popular and recently ones with 30 and 40 watt laser power have been introduced. I expect this trend to continue. A lot of CNCers are adding them to CNC routers along with the spindle. Here's how to connect and use them with grblHAL.


The typical Diode Laser consists of 2 parts - the actual diode and the laser controller. Some have the controller directly mounted on the laser body and other have them separate. Personally, I prefer separate as that moves the two heat generating parts away from each other which makes it easier to cool. It may come with a power supply unit though the one I bought did not. The laser controller not only drives the diode but also manages the power and PWM control input.


Connecting the diode laser

Using one with grbHAL is fairly straight forward though not every laser diode is the same. Basically, you need identify the PWM input of the laser controller and connect that to the PWM terminal of your grblHAL board. On the PicoCNC and T41U5XBB breakout boards they are in the upper left corner of the boards and labeled PWM. And, of course, the laser controller, power supply and breakout board need to have common grounds. Connect the ground terminal near the PWM terminal to the PSU ground terminal and also connect the laser controller to the PSU ground terminal. Do not daisy chain them. You will need to supply the laser controller with the appropriate voltage PSU. Mine takes 12V and I use the same PSU that powers the board. The higher power lasers use 24V. On some laser controllers, the PWM pin may be labeled TTL and have + and - pins. The - pin is ground and the + pin is the PWM input. Note: there is at least one report of the TTL pins being labeled backwards. The + pin is ground and - pin is PWM.


Mounting the laser diode

There are a lot of ways to do this. Some people mount them on one side of the spindle. This allows you to have both the spindle and laser on the machine and ready to be used. The disadvantage of that, especially on smaller CNC machines, is that it reduces your effective work envelope. I 3D printed a spindle mount adaptor that holds the diode and fits in the spindle mount of my machine. The one shown below fits in a 70mm spindle mount and holds the Diode Laser vertically. The square defined by the 4 inside corners is 33.5mm x 33.5mm, just slightly larger than the diode body. The split in front allows the spindle mount, when tightened, to grip the laser diode securely. Note that you will want the laser diode to be fairly well trammed (perpendicular to machine bed) but extreme accuracy is not necessary - machinist square accuracy is fine. If the spindle mount it fits into is trammed, the diode laser will be too. The wires need to be routed through your cable carrier. While not strictly necessary, I recommend shielded wires to avoid EMI.

You may want to add air assist. It is definitely helpful by blowing away the smoke that may block some of the laser energy. That is particularly helpful for lower power lasers.


You may want to test the laser before mounting it. If so, please take precautions to avoid the laser beam. I recommend wearing laser glasses when ever testing and avoid looking directly at the laser beam. Don't damage your eyesight.


Setting up grblHAL to use the laser

I will be using ioSender for this section but any GCode Sender can be used. Specific Grbl settings will be given. Note that "spindle" and "laser" are often used interchangeably but Laser Mode and Spindle Mode are not synonymous. The Laser and Spindle will share much of the same control hardware. The general steps you need to take are:

  1. Enable Laser mode.

  2. Select PWM Spindle Enable and RPM control of spindle.

  3. Invert Spindle Signal (PicoCNC only, it may already be set).

  4. Set Minimum and Maximum Spindle Speed

Enable Laser Mode

Grbl setting $32 - Mode of Operation - is used to turn on Laser Mode. For other GCoder Senders, send $32=1. $32=0 to cancel Laser Mode and return to Normal Mode.



PWM Spindle Enable and RPM control

This setting enables PWM output. While it may not be necessary, it is worth setting because some configurations (such as Modbus VFD control) may prevent PWM. Also, select RPM controls spindle enable. Send $9=3 or use ioSender.


Invert Spindle Signal

This depends on your laser module. Some use +5V to trigger the laser and some use 0V. If a module says it works with the 3018, it will likely be +5V triggered. Otherwise, you may need to experiment. You can use a wire from a +5V source on the breakout board and very briefly touch the PWM pin on the laser controller. If it fires, then it is +5V triggered. If it doesn't, disconnect the wire from +5V, connect it to ground (0V) and touch the PWM pin on the laser controller. If it fires, it is 0V triggered. If +5V triggers the laser and you have the Teensy breakout board (T41U5XBB), you don't need to invert spindle PWM. If you have the PicoCNC, you should make sure that the spindle PWM signal is inverted. (This is a bit convoluted but inverting PWM makes it fire with +5V). If 0V triggers the laser and you have a Teensy, you will need to invert the spindle PWM signal. If you have a PicoCNC, you will not invert the spindle PWM signal.

+5V Triggered

0V Triggered

Teensy (T41U5XBB)

Send $16=0, PWM unchecked

Send $16=4, PWM checked

PicoCNC

Send $16=4, PWM checked

Send $16=0, PWM unchecked

To invert, send $16=4. To not invert (to vert?) send $16=0. Or use ioSender.


Note: on the PicoCNC, if $16 is zero and you have a +5V PMW laser, the laser will fire at full power. In addition, when you press the Pico Reset button, the laser will fire regardless of the $16 setting. We recommend you have a switch that allows you to turn off the power to your laser when not in use.


Set minimum and maximum spindle speed.

This may be optional depending on what GCode Sender you use. A Laser specific GCode Sender like Lightburn may work with any settings of min and max. Grbl often defaults to specific min and max speeds and we need to make sure yours are not different. Basically, minimum speed should be 0 and maximum should be 1000. Send $30=1000 and $31=0 or use ioSender. The above screen shot shows $30 and $31 set to 1000 and 0, respectively. Note that this means when you tell grblHAL to use a specific spindle speed (i.e. laser power) you are doing it in tenths of a percent. So a command to turn on the laser and set it to 27.5% power looks like this

M3 S275

M3 is the command to turn on the spindle/laser and S275 sets the speed/power to 27.5%.


Testing it out

We are now ready to test to see if it works. Caution - lasers can start fires, damage things and injure your skin and eyes. Use laser glasses and confine the beam to a sacrificial target. Have a fire extinguisher handy. Note that some laser controllers have a PWM enable switch that will need to be set. Consult the manual or vendor's literature.


Once you are powered up and ready (glasses on!), in your GCode sender console send (via the MDI box in ioSender or your favorite GCode Sender).

M3 S100

to grblHAL. This will turn on the laser to 10% power. To turn it off, it send the stop spindle command.

M5

You should see the laser fire and then stop after the M5 command.


Switching between laser and spindle

If you plan on keeping both the spindle and laser mounted on the machine, you will need a way to switch between them and prevent them both from running at the same time. This is dependent on what signals you use to control the spindle. If you use 0-10V and spindle enable, you can leave your PWM controlled laser connected but you will need a way to switch the laser off when using the spindle and the spindle off when using the laser. One approach is a multiple pole relay used to switch control to the spindle or laser and turn on/off power to the laser. The relay could be controlled by a single pole switch.


Here is an example circuit that uses a common DPDT relay. The laser power is switched by one pole and the spindle enable signal by the other. One example relay is a TE Relay Products K10P-11DT5-12. But, there are many that would work for this application. Note that the pin numbers on the relay symbol are for the Omron G2L PCB mount form factor. Amazon also shows a number of automotive style 12V relays that would work - one example is a Potter & Brumfield T92P11D22-12 which use crimp connectors. There are DIN rail mount relays available. This one from Amazon is pretty nice. The SPST switch can be any that is capable of 250 mA or higher. The indicator LEDs are optional but make for positive visual feed back of your selection. I would use 2 different color LEDs to make the selection totally obvious. The 2K resistors will very likely work perfectly but the value could depend on your selection of LEDs.

You will also need to switch $32 between normal and laser modes. In ioSender, macros can change settings. So, in a macro,

$32=1

will set the machine into Laser mode. If you use a macro for setting the laser's Z height for correct focus, you could add this to set the machine into laser mode. Also,

$32=0

will set the machine into normal mode.


Note: we are looking for a better way to switch between Laser and Normal mode in grblHAL. The idea is to allow using an external switch to also change $32. Check back for updates.


Using Lightburn

If you have Lightburn, discovery may not work so you will need to add your board by hand. Press the Devices button and press Find My Laser. If it does not find your board,

  1. Press the Create Manually button.

  2. Scroll through the list to find and select Grbl. Press the Next button.

  3. Highlight Serial/USB and press Next.

  4. Name your device (I entered My Laser), set the dimensions of your work area and press Next.

  5. Set the origin of your machine - usually it is front left. Homing is set by default but if you do not have homing enabled, uncheck the option.

  6. Press Next and then Finish.


In the laser section, select My Laser (or what ever you named it) and the com port it uses. Look for any errors in the console and correct them. For example if you do not have homing enabled in your machine but left it checked when you set up the device, it will display an error. Go back and edit the device to uncheck homing.


Using LaserGrbl

Connecting to LaserGrbl is straight forward. Set the com port that your board is connected to and the baud rate to 115200. Then click on the connect button.


Many thanks to Tracy Ranson for his kind review of this posting and suggestions for improvement.


About Me.

I'm Phil Barrett, a long time CNC enthusiast. I run a small company, Brookwood Design, that makes several breakout boards for grblHAL and love to help people get the most out of their CNC machines.


















Comentarios


Featured Posts
Recent Posts
Search By Tags
No tags yet.
Follow Us
  • Facebook Classic
  • Twitter Classic
  • Google Classic
bottom of page