If you own or plan to build a Shapeoko 2 CNC Milling Machine, this Instructable will walk you through the steps necessary to be able to add a 2 watt laser capable of printing grey-scale images on many surfaces. You will also find details on how to engrave at full power.
I will take you through all of the steps necessary to build your laser, to control it from the Shapeoko 2's GRBL CNC controller, including modifications needed to the controller's software to enable gray-scale output by varying the laser intensity. I will walk you through the software for photo engraving as well as engraving of more traditional Shapeoko / MakerCAM / Inkscape images.
Though I would personally love to own an Epilog Laser, this Instructable will guide you through building a tool that can do many of the same things albeit at a slower speed. It is a great tool for any Maker and you will find hundreds of uses!
If you follow the instructions in this Instructable, it is absolutely necessary to obtain AND use proper eye protection. A 2 watt laser can blind you instantly! It can also start a fire and quickly ruin anything it is focused on! DO NOT ATTEMPT THIS PROJECT WITHOUT TAKING ALL NECESSARY SAFETY PRECAUTIONS AND WITHOUT FULLY UNDERSTANDING THE RISKS ASSOCIATED WITH USING A HIGH POWER LASER AND CNC MACHINERY. YOU ONLY HAVE ONE SET OF EYES, DON'T RUIN THEM!
Step 1: Supply List and the Shapeoko 2
The Shapeoko 2 is an Open Hardware desktop CNC mill. Complete kits may be purchased online or you can acquire the parts and build a customized version of the Shapeoko 2 to fit your needs. Details of the Shapeoko 2 can be found at http://www.shapeoko.com/.
When I built my Shapeoko 2 from the full kit offered by Inventables.com, I ordered several of the upgrades. For this project you will not need most of them. In particular, if you plan to follow the instructions in this project that allow for gray-scale image printing by varying laser intensity, don't install the limit switches. Limit switches may be added but it will require additional changes to the GRBL controller so that they can be sensed on a different Arduino pin. (More to follow in additional steps.)
The upgraded wasteboard is helpful. I purchased the Drag Chain upgrade but found no use for it. You will notice in my photos that I've run most of the cables through a small piece of PVC pipe attached with cable ties. This has worked very well.
In my opinion, the GShield Enclosure and fan are very useful upgrades.
If you don't already have an operational Shapeoko 2, this is your first step. Assemble it according to the directions on the Shapeoko website. Run the "marker" test. You don't need the spindle for this project, but having it will make your Shapeoko 2 more valuable. After following the instructions in this Instructable, the laser can be easily removed when you want to do CNC milling with the spindle.
One final note on the Shapeoko 2: The instructions provide methods of wiring the machine that do not require soldering. I chose to solder and then heat-shrink all of the wires that were connected, to provide for a longer lasting solution.
In addition to a functional Shapeoko 2, you will need the following supplies:
Step 2: Understanding the Laser Mount and Heat Sink
Mounting the laser to the Shapeoko 2 could be done in many different ways. What really matters are the following:
The mounts which I will show you require a lathe to machine aluminum. If this is not available to you, find another solution that accomplishes the same purposes. If you search the Internet you will find others that have modified CPU coolers like the one I am modifying in this Instructable, so that the laser module fits tightly inside -- or is secured in some way similar to what I will show but without requiring the use of a metal lathe. Experiment a bit and you will find a satisfactory solution! You might also check out the following websites for laser module housings which you can purchase and then modify if necessary to be mounted on the Shapeoko 2 -- or to be held in the spindle holder:
There are at least two ideal places to mount your laser on the Shapeoko 2. The most obvious is on the spindle mount. If your module is attached to the spindle mount -- even using the spindle brackets, you will be able to raise and lower it using Z axis commands. This could even be used for focusing the laser. Just keep in mind that if you want to be able to control the laser intensity, using the technique that I will show, you need to be able to turn Z axis commands into a PWM (Pulse Width Modulation) signal to the laser diode. You can't control the Z axis at the same time that you control laser intensity. This however should not be a problem. In the modified GShield code which I have provided, the Z-axis can be placed in laser-mode and switched back and forth at will.
The other ideal place that I recommend is just under the spindle mount. You will see this in the photos that follow. In this location, the distance to the waste board is fixed, and you must focus the laser based on the thickness of the material you are burning. Nevertheless it is relatively easy to access and allows the laser to be removed when milling operations are done with the spindle, and the spindle can remain on the Shapeoko 2 at the same time that the laser is mounted. (Though, I would highly recommend removing the laser before using the spindle to stir up dust!
Step 3: The Laser Mount Support Bracket - bottom side
Take a piece of 1" Aluminum angle and cut it to the length of the CPU Cooler on the side you wish to have mounted to the Shapeoko 2. You can cut it with a hacksaw (as I did because I didn't yet have a metal cutting band saw), or you can use a metal cutting band saw and get a slightly straighter cut.
Mark the aluminum angle for 2 mounting screw holes on each side. A #29 hole will be drilled and then tapped with an 8-32 tap for the mounting bolts to pass through into the CPU Cooler. Tapping the holes can be done after using the aluminum angle as a guide for drilling holes into the CPU Cooler. Both the CPU Cooler and the aluminum angle can be tapped in one pass.
Mark the center of the aluminum angle. Drill a 27/64" hole for the laser holder in that center spot.
Using a couple of pieces of double-sided duct tape, attach the angle aluminum to the base of the CPU Cooler. Using the drill press and the previously drilled holes as a guide, drill through the aluminum angle into the CPU Cooler. With the tape still holding the aluminum angle in place, tap the holes using an 8-32 tap. Then secure the angle aluminum to the cooler using two 8-32 screws. This will keep it from moving while drilling the larger hole. (Not shown in the photos, but it would be the better way.)
With the angle aluminum secured to the CPU Cooler base, drill a 27/64" hole in the center of the angle aluminum. Then thread this hole at least 1/2" down with a 1/2"-13 tap. Use tapping fluid carefully to avoid getting in the fan, or temporarily remove the fan will drilling and tapping.
Step 4: The Laser Mount Support Bracket - mounting side...
Hold the CPU Cooler and aluminum angle against the X-axis gantry carriage of the Shapeoko 2 and use a marker to mark where the slot aligns on the aluminum angle.
Near the edges of the slot, drill #25 holes through the aluminum angle and into the CPU Cooler side, about 1/2" deep. Next thread these holes using a 10-24 tap. Be careful to space the holes so that you don't run into the screws holding the aluminum angle to the CPU Cooler.
The laser will mount to the Shapeoko 2 by threading two 10-24 cap screws into these holes after passing them through the slot in the X-axis gantry carriage as seen in the photos for this step.
Drill a hole near the top of the CPU Cooler aligned with the 1/2" hole in the base and penetrating this hole. We will run the wires from the laser module through the side using this new hole. A 5/16" bit should suffice. The wires should be protected with heat shrink tubing.
Step 5: Make the Laser Module Holder...
Start with a 1" round bar of 6061-T6 aluminum that is about 1 to 1.5" long. Place it a metal lathe and face each side. Then turn just enough off of about 3/8 to 1/2" on one side to make a nice finish.
Then turn along approximately 3/4" of the bar until it is ready to be threaded with a 1/2"-13 die. Using the die, carefully thread that 3/4" as close as possible to the base without bending the aluminum. If you are skilled at cutting threads with your lathe you may wish to do it that way instead of using the die.
Next cut the piece off about 1/2" above the threads. I used a parting tool do this, but a band saw would work fine, as would simply facing a piece until it was about the right length. Once it cut, flip it around in the lathe chuck so that the threaded end is inside the jaws but not being held by the jaws. Use a center drill to make a pilot hole, then drill a 15/32" hole (just over 12mm to allow the laser diode to fit inside) about 1/2" deep. (See photo.) This is where the laser module will be held.
Drill a 7/32" (or thereabouts) hole all the way through holder. The wires from the laser module will extend all the way through the threaded end.
After cleaning up the piece on the lathe, and chamfering any sharp edges, remove the piece from the lathe and place it into a vice. Using a drill press, drill a #29 hole through the thick part of the holder, all the way into the 15/32" hole in the center.
Next thread that hole with an 8-32 tap and insert an 8-32 screw. This will be used to push the laser module against the holder firmly.
Step 6: Laser Mount Final Assembly...
To assembly the laser mount, first apply thermal grease/compound to the aluminum angle and CPU Cooler where they will touch. Then install the screws that hold the angle to the base of the CPU Cooler.
Slip a piece of heat shrink tubing over the wire that will go into the laser diode. I used a power cable with a barrel adapter on the end. Make sure to have a matching barrel jack -- this will connect to your FlexMod P3 laser diode driver.
Run the now protected power cable through the side of the CPU Cooler and out the 1/2" threaded hole in the base. Then run it through the threaded end of the laser holder.
Now attach the holder to the threaded hole in the base of the CPU Cooler, after liberally applying thermal compound to the threads and base of the holder.
Next solder the wires to the laser diode. Be certain to keep track of the polarity! (Know which wire and goes to negative, which to positive, and how that maps to the barrel adapter.) If you have not already done so, shrink the heat shrink tubing making certain now bare wires are exposed.
NOTE in this setup only the top half of the laser module (with the diode) is used. This gives more space between the laser and the materials being engraved/printed.
Apply thermal compound to the base of the laser module and insert it into the holder. Be careful not to get the thermal grease on the lens! Finally, tighten the screw on the side of the laser holder to secure it in place.
Step 7: Attach the laser to the Shapeoko 2...
As previously described, mount the laser to the x-axis gantry carriage of the Shapeoko 2 using the 10-24 cap screws, after cleaning up any excess thermal compound. Run the power wire between the gantry carriage and the CPU Cooler and up to where it will not interfere with operation of the gantry.
See the photos for details.
Step 8: Setup the Laser Driver (FlexMod P3)...
It is important that you follow the direction that come with the FlexMod P3 driver. The input power to the driver should be approximately 6 volts. A little more is fine but keep it under 8 volts. The power supply should be capable of supplying at least 2 Amps.
The FlexMod P3 needs to be calibrated so that a 0 PWM (or ground value) on the modulation input just barely turns the laser diode on making it visible. A full 255-value or 5 volts on the modulation input should produce no more than 1.8 Amps! Test this with a multimeter using the directions supplied with the FlexMod P3 driver!
With the FlexMod P3 calibrated it's time to wire everything up and put in a box. I used 22 gauge stranded wire from radio shack along with heat shrink tubing and good solder. Pick a small project box that comfortably hold the FlexMod P3, 2 barrel jacks - one for power and one to connect to the laser diode. It should also have another outlet for the two wires that will go to the Arduino/GShield.
Drill holes in the project box for the power jacks, and a separate hole for whatever type of wire or connector you will run to the Arduino/GShield. I suggest putting the laser output on the opposite side of the box of the power input. Label or mark the jacks clearly. You will see from the photos that I lazily used the soldering iron to burn the words "Power" or "Laser Output" near the jacks. Next solder the wires to the jacks being careful of polarity. Push the wires into the project box and pull the barrel jacks into position. Use the nuts that come with the power jacks to secure them to the box. Then solder the wires to the FlexMod P3.
The power positive wire goes to the FlexMod P3's V+ connection. The power ground wire should go to the G(nd) connection on the FlexMod P3. You will need another ground connection to the Arduino / GShield. I spliced into the ground wire and ran the extra wire as needed for the Arduino.
On the Laser Diode output +/- side of the FlexMod P3 solder the wires that lead to the laser power output jack. Keep the polarity correct all the way to the laser diode!
Another set of wires needs to leave the box. You can use another jack, or some other type of connector. I chose to just heat shrink wrap the wires and take them out a hole in the side of the box. The other end of these wires can be connected to a 2 position interlocking connector, or can be soldered directly to the Arduino/GShield. The Ground wire connects to any of the Ground solder points on the GShield. The signal wire that is soldered to the M(od) connector on the FlexMod P3 will be soldered to a connection point on the GShield that goes to Pin 11 on the Arduino. (See photos for details.)
Connect a suitable heat sink to the transistor on the FlexMod P3, using thermal compound between the two. Attach the heat sink to the project box if so desired. Seal all of this up in the project box and attach it near your Shapeoko 2.
Step 9: Optional Relay Control
Though this part is optional, I also have another project box with a DC relay control that is connected to the GShield so that the Spindle On (M3) and Spindle Off (M5) commands sent to the GShield will turn the laser power on and off.
This is optional because you can simply turn the power to the laser on and off from the power supply when it use. You should never leave the laser on without constantly checking on it's work anyway. If, as sometimes happens, the software sending signals to the GShield freezes up, or the gantry stops moving, and the laser remains on, it will quickly begin to burn your work piece.
The Spindle On/Off commands can be added to the beginning and end of files sent to the GShield to ensure the laser is turned on before starting and shut off when the job is done, but that is not a good substitute for carefully watching the job.
If you wish to use relay control, there are many ways to do it. I bought a Seeed Relay Shield, placed in its own project box, and then ran wires from the GShield to the Relay Shield to control one of the relays. (The Relay shield is designed to plug into an Arduino, but a single signal is needed for one relay.) The box also has a power input jack and a power output jack. The ground between the two jacks is connected, and the positive supply line runs through the relay.
I've built a similar box for controlling my AC spindle, using an 8 amp solid state relay.
Step 10: Connecting everything to the Shapeoko 2 GShield...
For this step, you will be following directions from the previous steps. The photo however will explain where things get soldered to the GShield. You will notice that I have a piece of duct tape on my GShield. No, it is not broken. It is there just to make it easier to remove and reattach the GShield to the Arduino without removing all of it from the GShield box attached to the Shapeoko 2.
In the course of getting this to work, I had to try many things and I had to reprogram my Arduino many times. You hopefully will only have to do this once.
NOTE: If you have upgraded your Shapeoko 2 to use the TinyG or another controller, you will have to use the product documentation, and possibly reprogram the controller to allow for laser intensity control. Many of the boards, like the TinyG allow for Spindle Speed control using PWM output. This *should* work. My original attempt was to use Spindle Speed control commands to control laser intensity from the GShield. I found however that the Spindle Speed control was not synchronized with x, y, and z axis movement. Therefore I reprogrammed that Arduino to allow for a "Laser Mode" which causes z-axis values from 0 to 255 to translate to PWM output on Pin 11 to control laser intensity. In LaserMode, the Z axis does NOT move. The next step will provide greater details.
Step 11: Reprogramming your Arduino Uno...
The Arduino Uno that shipped with my Shapeoko 2 kit came with grbl firmware version 0.8c. This version of the firmware allows for M3/M5 commands to enable or disable the signal on Pin 12 of the Arduino. It also provides support for Spindle Direction control. It does not however provide Spindle Speed control or any other type of signal we can use to control laser intensity.
For this reason, I have modified the GRBL source code to allow the GShield to be put in "Laser Mode." When the shield receives a $L1 command, the Z-axis motor is disengaged, and POSITIVE Z values from 0 to 255 set the laser intensity. A Z0 value sets the laser at it's lowest current setting determined by calibration of the FlexMod P3 driver. A Z255 value will set the laser at it's fullest current setting which should not exceed 1.8 Amps if the FlexMod P3 was properly calibrated. From Z1 to Z254 the power should gradually increase.
To disable Laser Mode, and reengage the Z-axis motor, send the $L0 command to the GShield. This allows a "GRBL" program to enable and disable laser-mode as needed.
If you are so inclined, you can access my source code changes to the GRBL firmware in github at the following link:
https://github.com/alsliahona/grbl/tree/LaserMode. Be sure to select the LaserMode branch once you have cloned the tree.
If you want to start with a pre-compiled file (recommended) you can download the attached grbl.hex file. Once installed on the Arduino it should display version 0.8laser.
There are many documented ways of installing the .hex file onto the Arduino Uno. I *highly recommend* that you purchase a new Arduino Uno to use with your Shapeoko 2. Leave the old one as a backup in case you have serious problems reprogramming the Uno with the new GRBL code. It should be possible to reprogram the Arduino Uno using it's own USB port. I was unsuccessful in my attempt to do this from a Windows 8.1 PC however. The software froze up on me and left the Arduino in an unusable state. To fix this, I simply reprogrammed the Arduino using a USBtinyISP programmer from Adafruit. If you do much work with Arduino's or AVR microcontrollers this is a must have tool! You can also try using other USB based AVR programmers, from the one Sparkfun sells to the more expensive (non-hobby) versions sold by ATMEL. You can go for pre-built programmers as well, such as this one from Hobby King that is only $3.99.
After downloading the grbl.hex file, simply connect the ISP programmer to the Arduino Uno, and follow instructions on the programmer to upload the grbl.hex file. See the attached photos for details on how I did this with the USBtinyISP programmer. To follow my process you will need to install the Arduino development software on your Windows PC. Don't worry, if you don't program you can take it off after we are done with this step. If there is enough demand, I could probably make a few pre-programmed Uno's available for purchase on eBay though I currently do not have plans to do this.
From a cmd.exe prompt, locate the folder that contains the grbl.hex file. Then run the following commands. If necessary adjust directories to point to the proper locations for your computer:avrdude -C "C:\Program Files (x86)\Arduino\hardware\tools\avr\etc\avrdude.conf" -c usbtiny -p m328p -e -U flash:w:grbl.hex
You can also use the burn.bat file attached to this step.
Once you get the confirmation message "avrdude done. Thank You", you can detach the ISP programmer and directly attach the Arduino Uno to your USB port. Then use your favorite GRBL controller software to connect to the Arduino. In the attached photos I am using a brand new Beta copy of Pic Sender. It was made by the author of PicLaser Lite from http://www.picengrave.com. We will use PicLaser Lite to send photos to the Shapeoko 2 to print (or really burn) grayscale images on various material.
If you get to this before PicSender is officially released you can use GRBL Controller 3.6.1 (which was used for some of the images shown on the Intro step.) You can also use the "Universal GCode Sender." I will however warn you that the Universal GCode Sender should NOT be used with large GCode files, over about 150,000 lines! Because it is a Java program -- and all Java programs are unfortunate, it has little control over how memory is used. After sending about 150,000 lines to the GShield, the Universal GCode Sender will slow down, causing the laser to burn your target material after the image has been printing for an hour or more. Hopefully fixes for this software will be available, though I am confident that the worst of the problems stem from the choice of language.
Step 12: Using your new CNC Laser with PicLaser Lite
PicLaser Lite is an inexpensive program available from http://www.picengrave.com. It allows you to load a bitmap file and from it generate G-code for the Shapeoko 2 with Z-axis values set to produce a gray scale image.
First pick a photo that you think will look good in gray scale. You may need to resize it using Microsoft Paint or another tool to get the output size you want from the Shapeoko 2. The output size is largely determined by the pixel size setting. See the photos for details on the settings that I recommend.
Once you are happy with the settings click on Load File. Then click on Make GCode.
Now click on Save Gcode and give a filename that you will remember.
If you added the $L1 to the machine setup codes, edit the output file and put the $L1 on a line by itself. See the photos for details.
The file is now ready to be sent to the Shapeoko 2. Though I fear the feed rate may be a little slow, I'm going to send this image to a piece of inexpensive (purchased at Walmart) artists canvas on cardboard.
Step 13: Sending the PicLaser Lite file to the Shapeoko 2
There are a variety of GCode sender programs we could use to send the file to the GShield on the Shapeoko 2. Since I promised the owner of PicLaser Lite that I would test out his sender program we will use this one for this example. Most of the programs are the same. Grbl Controller 3 and PicSender may be amongst your best options. Both are feature loaded, and neither use Java and have problems when they reach 180,000 lines.
First open the sender program. Select the COM port that is connected to your GShield -- often there is only one choice. Make sure the baud rate is set to 115,200. Then click Open.
Next put the controller in Laser Mode by entering the $L1 command. You get a message back confirming laser mode.
PUT ON YOUR LASER SAFETY GLASSES!
After the controller is in laser mode and your safety glasses are on, turn the laser on. If you are not using a relay to control it, turn the power supply on to the laser. With the laser on, you can focus the beam to the smallest clear dot possible on the target material.
Now click Load and select the file you created from PicLaser Lite. The contents of the file will show in PicSender on the left. With the laser carriage positioned at the home position, and the target material secured in place you can now click the Send button and watch the laser print your picture.
The small approximately 4x6" image will take more than an hour with a .0075 pixel size and a feed rate of 60.
Step 14: Using your new CNC Laser with Inkscape and MakerCAM...
You can also use Inkscape and MakerCAM to produce gcode for the Shapeoko 2. You will need to modify the MakerCAM output in order to put your GShield into Laser-Mode and to set the Z value to control laser intensity. This is best for line-art, like signs with text, etc. Typically you will set the Z value close to full power. You can use M3/M5 commands to shut off the laser during non-cutting/burning moves if you have a relay to control it, or you can modify the gcode by hand to set the laser output to Z0.
MakerCAM produces gcode that is in no way optimal. When producing an 8x10 sign with text, you will see it draw one letter on the middle-right, move all the way to the bottom left and draw another, and then move somewhere entirely different to draw another letter. This is painful to watch and substantially slows down the process of producing anything. To help remedy this, I have produce a command-line program that can optimize gcode produced by MakerCAM. It also has a laser-mode that adds M3/M5 commands to enable and disable the laser during non-burning moves. With Grbl 0.8laser you will still need to modify the output from the optimize to first turn the laser on to full power with Z255, and then if you don't have relay control to change the M3 commands to Z255 and the M5 commands to Z0. This software was originally written before I learned that I could control the laser intensity. Perhaps when time permits I will update it for use with the Grbl 0.8laser. The source code for this software is available here: https://github.com/alsliahona/gcode-optimizer
A Windows compatible version of the software is attached to this step and called gcodelaseropt.exe. Run it without any arguments to see the details on how it may be used. Be sure to examine the file it produces to make sure it did what was expected. You should become familar with the basic gcode commands such as:
More details can be found on the gcode Wiki page.
The important thing to remember is that you must modify gcode to work with our setup as follows:
If you have not already used Inkscape to make SVG files that are fed into MakerCAM (http://www.makercam.com), you should try this at least once to draw text with a marker in your spindle holder, or using the spindle. You then will have no troubles using it with the laser as long as you follow the steps outlined above. Instructions for using Inkscape and MakerCAM with the Shapeoko 2 are available in abundance on the Internet. The primary difference for laser burning is in how you set the CAM settings.
Since the laser doesn't need to move up and down, you can set the Safety Height to 0. The will also produce G0 Z0 codes to prevent the laser from burning will moving between unaffected areas. You can set the Tool Diameter as low as 0.007, though you should be warned that for Pocket Operations this will produce very large files and the laser will sometimes overlap and could burn more than is desired. You might experiment with values between 0.007 and 0.02. The Target Depth should be -255, and the Step Down should be 255 to match. We will fix these later. Stock Surface can remain 0. You will need to experiment with the Feed Rate on different materials. Too slow and you will overly burn the material. Too quick and the burn will be too light.
In the attached image you will see a very simple example of a MakerCAM generated gcode and MakerCAM settings that produced it. On the far right, highlighted in yellow are the only changes that need to be made to the file to make it compatible with our CNC laser. By changing the Z-255 to Z255 we set the laser to maximum intensity. Adding the $L1 to the top of the file will put the controller in laser mode and keep the Z-axis from moving to an impossible (255 inch) height. Because this is a very simple file, no other changes are needed. If we were to add another path, or pocket operation, we would need to make sure to change all of the Z-255's to Z255 and ensure that between operations there was a G0 Z0 line.
A more complex operation could benefit from the gcode optimizer.
Step 15: Materials you can engrave or print on...
Just about anything that can be burned, charred, or melted with the laser can be printed on in some form. Reflective metals should not be used and the laser is not strong enough to burn them. Below is a partial list of things I've tested.
You may also be interested in also trying many other new things. It would be interesting for example to write someones name on a sandwich using the laser, or to melt through a layer of chocolate on a strawberry or a candy bar.
Please post comments on your experience. Let everyone know what looks good and works well!