Warning: This project uses a laser. It will hurt you if you are not careful. Please take care when handling the laser. Do not look at the beam, do not point it at yourself or anyone else. Remember that an IR Laser can damage the eye just as easily as a visible light one.
I have built a Laser CNC machine out of a couple of old DVD-RW drives, an Arduino UNO with Grbl v0.8 installed, two EasyDriver Stepper Motor Controllers and bits of wood I have around the home. The laser came from one of the DVD-RW drives.
My Engraver is vaguely based upon the Pocket Laser Engraver by Groover, except I have used an Arduino UNO and have added limit switches. G-Code is a industry standard, of sorts, used to control CNC (Computer Numerical Control) Machines, such as lathes, routers, and in this case Laser Engravers.
Here I will be providing additional information about the electronics and Grbl configuration I discovered while building the Laser CNC. I have used the following software:
- Grbl “An open source, embedded, high performance g-code-parser and CNC milling controller written in optimized C that will run on a straight Arduino”: https://github.com/grbl/grbl
- As we’re not using the Z Axis, the Grbl home command needs to be set to ignore this, modifying the Grbl Code is detailed in the MicroSlice project a modified grbl.hex file is also available on the same page.
- Inkscape, vector graphics editor: http://www.inkscape.org/en/
- Laser Engraver extension for Inkscape: http://www.slackersdelight.com/instructables/laserengraver.zip to generate the G-Code files from within Inkscape
- Universal G-Code Sender, to send your G-Code to the Arduino: https://github.com/winder/Universal-G-Code-Sender
There are four electronic parts to this setup. The 5v power supply, a relay circuit to control the laser driver, the Laser Driver to control power to the laser, and the limit switch circuit used by Grbl to provide a stop indication on the axes.
The Power supply is a nothing glamorous, its a basic 7805 design giving a 5v output.
I use a 2A Switched Mode Power Supply plugged into the mains, similar to this 17W Switched Mode AC/DC Multi Voltage Power Supply from Maplins. Using 7.5v as the input is enough to keep the 7805 running without it having to convert too many volts into heat.
To control the laser from the Arduino, I have added a relay circuit. The 5v relay is powered by the power supply above, on one side of the normally open switches is a 5v fan to blow the smoke away, and on the other the Laser Driver, remember to switch the laser driver circuit rather than the laser diode.
The Laser driver using a LM317 Adjustable Regulator is a little more involved, as calculations have to be made to establish the output power. You want enough power to scorch or cut card, but not so much as to burn the laser diode out.
The power output of the Laser Driver is set by the resistors R1 and R2. This video tutorial gives some explanation. Going above 500mA with a red laser will definitely cause it to blow, I have limited the power on my laser to 330mA as I only have a limited supply. I used this page for calculating resistors in parallel. Here are some milliamp output values using a couple of standard resistors.
|Resistors||volts / ohm||mA|
|2 x 10R||1.25v / 5R||250mA|
|2 x 9R1||1.25v / 4R5||270mA|
|2 x 8R2||1.25v / 4R1||300mA|
|2 x 7R5||1.25v / 3R7||330mA|
The final circuit is for the limit switches, and is based upon one found here:
The switches need to be very sensitive, I found using that the motors were not strong enough to push button switches. I used those found in the one of the drives, and a couple from an old cassette deck. Check that you have connected up the switches correctly, X to X, Y to Y, confusion arises when they are the wrong way round and Grbl doesn’t say which switch has made contact.
In Grbl set $16=0 (hard limits, bool) if your image is larger than the allowed size then will just make your drawing look wrong, setting it to 1 (true) will cause the G-Code program to be aborted. $17=1 (homing cycle, bool) will cause Grbl to expect an $H (home) command when started, $H will cause your axes to move to their start positions.
The only real issue with setting up Grbl, was getting the X and Y axes operating in the expected direction. There are two problems, getting the right start point, and having them go in the correct direction. You will be wanting the image in Inkscape to appear correctly. There are two settings within grbl v0.8 that need to be configured so that it works: $6 (step port invert mask) and $18 (homing dir invert mask). Having spent a while trying out various settings, I wrote a little mask calculator to assist me with this, to find your mask, click the checkboxes, or you can enter the current mask number and click set to find the binary code.
The documentation says that the first two bits are not used for inversion, but have found that there is a change in the direction of the motors.
Test with your favorite terminal program, on this Linux box I used: minicom -b 9600 -D /dev/ttyAMA0, turn local echo on with Ctrl-A E. Make the table go forward 1cm with X10, or in reverse X-10, Same for the Y axis, Y10, Y-10 further experimentation may be needed when you first start etching, I had a images and text appearing mirrored at first.
Now it is a case of loading your line-art into Inkscape, thin lines work best, creating the G-Code file using the laserengraver option in the extensions menu. Then sending the file to the Arduino with the Universal G-Code Sender. A Guide
My Grbl settings:
$0=53.333 (x, step/mm)
$1=53.333 (y, step/mm)
$2=250.000 (z, step/mm)
$3=10 (step pulse, usec)
$4=250.000 (default feed, mm/min)
$5=500.000 (default seek, mm/min)
$6=64 (step port invert mask, int:01000000)
$7=25 (step idle delay, msec)
$8=100.000 (acceleration, mm/sec^2)
$9=0.050 (junction deviation, mm)
$10=0.100 (arc, mm/segment)
$11=25 (n-arc correction, int)
$12=3 (n-decimals, int)
$13=0 (report inches, bool)
$14=1 (auto start, bool)
$15=1 (invert step enable, bool)
$16=0 (hard limits, bool)
$17=1 (homing cycle, bool)
$18=101 (homing dir invert mask, int:01100101)
$19=25.000 (homing feed, mm/min)
$20=250.000 (homing seek, mm/min)
$21=100 (homing debounce, msec)
$22=0.400 (homing pull-off, mm)