Monday, July 14, 2014

38mm x 38mm Laser Engraver build using CD-ROM/Writer on ATmega328p

A laser engraving machine, is a tool that uses lasers to engrave an object.


To build this tool I've used two old CD-ROM writer that lays around in my garage.
The X/Y positioning system it is build using the CD-ROM motor assembly. For the engraving laser i use the CD-ROM writer laser.
With this hardware the engraving area are will be almost 38mm x 38mm.


I know, there is nothing new in the project i posted here, this is just my implementation of a pretty usefull tool.

Warning! Laser diodes drive are emitting visible and invisible laser radiation and they are extremely dangerous! Their light can permanently damage the eyes. You must never look into the working diode even without the lens or point it on a reflective surface. Laser beam can cause burns or fire. This is usually a Class IIIb laser. Everything you do at your own risk.

The laser used is a red laser diode, taken apart from the DVD-ROM writer optics. It should be 100mA.
In CD-ROM and DVD-ROM you could also find IR driver, DVD laser writer diode will be a little more powerfull than the CD one.
Laser diode usually has three pins, one is the common ground, laser and photodiode cathode (-), one the laser diode anode (+), the other is the monitor photodiode anode(+).
If the diode you are using has no mark, and you do not know the diode pinout, you have to find the laser cathode and anode. One simple method I use is to power up the diode with a 1.8 to 2.2v current, just for a little amount of time, let's say 1s, if it sucks current, that wiring is the laser diode pinout.


Laser diode has to be drive with a proper driver, to run mine, i've used a small and cheap LM358 based adjustable driver, capable of 10mA to 400mA, it also comes with a TTL input pin to enable or disable the laser. You could also use a LM317 to build a simple laser driver, there are many schematics around here, that exaplains how to build one.
A standard 80mm x 80mm pc brushless fan fan is installed to clear the smoke, this prevents the laser optics lens to be clouded.


The two motors are small stepper, to drive the motors, two EasyDriver stepper driver are used. EasyDriver is a Allegro A3967 based driver board. Motors are powered at 5 volts.
Once again, if you do not know the motors wiring, you have just have to pay attention to pair each coil and then connect to the EasyDriver motor output. If direction is inverted, invert the coil wiring, or just setup grbl to invert the axis direction.


The microcontroller used here is an ATmega328p running at 16Mhz. I've used an Arduino Mini board, even if the software does not use the Arduino framework. The software used is grbl, available at http://github.com/grbl/grbl, which is a powerfull yet opensource g-code parser.
I'm using grbl version grbl v0.8c (ATmega328p, 16mhz, 9600).
You just have to upload the firmware using your favorite uploader, the grbl wiki page drive you on how to do this step.
On the grbl wiki page you could also find any other information about command and software setup.

Commands to the engraving machine are sent through UART.

When you assembly your harware, pay attention to build it making X normal to the Y axis. The two direction has to be perpendicular, or your engraving will has distorsion.

Below you should find the schematics i'm using.


One you have connect and upload the grbl firmware to your microcontroller, you could use terminal software, or a grbl controller to setup your board. I'm using Grbl Controller to setup and send command to grbl, but you can also use a simple terminal.
Below you can find the grbl configuration parameters i changed, basically what i've changed here is:

Set step/mm to setup the correct motor distance to run (a common step/mm value for CD-ROM motor should 53.333):
$0=53.333 (x, step/mm)
$1=53.333 (y, step/mm)
Set the accelleration value to 100:
$8=100.000 (acceleration, mm/sec^2)
Enabled the homing cycle:
$17=1 (homing cycle, bool)

If you need to invert axis direction, "Step port invert mask, int:binary" is the paramenter you have to touch. Those are the most common inversion, but if you need other inversion, look at the grlb wiki for this parameter:
$6=32 (invert x axis)
$6=64 (invert y axis)
$6=96 (invert x and y axis)

To test it, just send the
X10 Y10
command, or use the Grbl Controller rows, you should see a 10mm movement on each ax is.

Also check the "spindle on" command power your laser on and off.

Now you could be able to send g-code drawing to your engraver.


There are a lot of software you could use to build g-code draw, the one I use the InkScape.
The working are for this plotter is 38mm x 38mm, so setup your project area to this dimension.
Once you have you path, then you could select the path you want to engrave, and transform it using the InkScape laser engraver extension.
Just copy the extension on your extension inkscape folder, restart inkscape, and use that to build your g-code file.
Once you have your g-code file, you could send it to grbl using Grbl Controller, or other software like Universal-G-Code-Sender.