Tuesday, December 1, 2015

A DIY A4 Laser Engraver made from a scanner and a printer on ATmega328


This "Get Ready For Win98" Laser Engraving Machine it's built using an old scanner, and an old printer.
A laser engraving machine is a tool that uses lasers to engrave an object.


I've an old broken scanner and an old printer lying around. Inspired by this instructables project:
http://www.instructables.com/id/Frankenstein-Laser-Engraver/
I decide to build a bigger version of my small CD-ROM based laser engraver, you can find here:
http://davidegironi.blogspot.it/2014/07/38mm-x-38mm-laser-engraver-build-using.html
That way, the engraving area are will be almost 212mm x 274mm.
Note that some part of this post is taken from the above blog post link.

Before starting up, read my blog disclaimer and the one below:

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 Y-axis it is build using the scanner assembly, the X-axis using the printer one.
As you can see by the Get Ready For Win98 sticker, the scanner is pretty old, and this sticker was so vintage that i've decided to leave it on.


The base of this machine is the scanner itself.
The scanner was completely disassebled, all except the motor and the movement mechanism is removed. The same applies for the printer.
Assembling the hardware, pay attention to build it making X normal to the Y axis. The two direction has to be perpendicular, or your engraving will have distortions.
The printer mechanism it is connected to the Y-axis scanner assembly, that way, the laser moves over the part to be engraved.

My engraver it is powered by a 12V 2A power supply, though the total current absorbed it's 700mA.


The brain of this project is an ATmega328p running at 16Mhz. loaded with grbl firmware http://github.com/grbl/grbl, which is a powerfull yet opensource g-code parser.
I've used an Arduino Mini board, even if the software does not use the Arduino framework.
A 7805 voltage regulator it is used as power supply for the ATmega.
Grbl 0.9 it is build for 3 axis router, to make it works on 2 axis systems like this, with hard limit and homing enabled, a custom version of the firmware it is needed. The only change to apply to version 0.9g are on config.h file.
lines
#define HOMING_CYCLE_0 (1<<Z_AXIS) 
#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS)) 
was commented out and changed to:
#define HOMING_CYCLE_0 ((1<<X_AXIS)|(1<<Y_AXIS))
//#define HOMING_CYCLE_0 (1<<Z_AXIS) 
//#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS)) 
Then the new grbl firmware can be compiled and used, preventing grbl 0.9 homing problem on 2 axis machines.


My custom version of grbl v0.9g compiler for ATmega328p @16Mhz, with a baudrate of 115200, can be download below.
CP2102 it is used as USB to UART board.
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.


The motor driver I've use to move the X and Y motor stepper are Polulu A4988 Stepper Motor Driver Carrier, based on Allegro A4988.
My scanner has an unipolar 5-wire stepper motor. That Allegro driver works only with 4-wire bipolar stepper motor. So I've transformed the unipolar motor to a bipolar stepper motor.
To made this modification, I've just cut the common wire between the two main windings. Then I checked that the windings haven't got any connection by using a multimeter. That way i have two coil, like a bipolar motor. Look at the image below for carify:


The printer has a bipolar 4-wire stepper motor.

We can setup how many microstep and how much current Allegro A4988 sends to the motor.
Incrasing microsteps makes the motor more accurate, but it also reduce the motor torque.
You can made some tests to find your best motor power setup.
For mine motors, to allow a smooth and fine motor movement, and a good torque the Allegro A4988 it is setup to 8 microsteps for the Y-motor, and 16-microstep for the X-motor.
Below you can find the basic Polulu board connection wiring.


To make the Polulu board runs at 8 microsteps M1 and M2 has to be connected to logic power supply VDD, if you want to run it at 16 microsteps, connect also M3 to VDD.

Motors supply VMOD is connected straight to 12v.

On each axis a limit and an home microswitch it is placed to prevent axis over-running, and eventually the motor or the motor driver damage.
Because the limit switch are pretty sensible to noise, I've added an high pass 100nF capacitor and an additional pull-up 10k resistor. Also the limit and home wire are indipendent and distant from the motor and laser cable strap.


The laser used is a red laser diode, taken apart from the DVD-ROM writer optics.
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 absorbs current, that wiring is the laser diode pinout.

Laser diode has to be drive with a proper driver, to run mine, i've build a LM317 based laser driver.
This laser driver can drive diode from 12mW to 700mW.
A 9v voltage regulator prevent overvoltage on the laser diode.
Also a NPN it is placed to allow the TTL input that comes from the microcontroller to enable or disable the laser.
We are using LM317 IC as a current regulator.
Input voltage get in the Vin pin of the LM317, from the output Vout to the ADJ pin there is a resistor R connected.
The output current Iout is given by the formula Iout = Vref/R.
Over there resistor there always be Vref voltage. When current decrease, the voltage over R should be lower, but that way the regulator increase his output voltage to adjust his Vref voltage.
Vref is 1.25 for the LM317. R is made using a fixed resistor R1 and a trimmer R2. That resistor and the trimmer sets the current that the laser use.
So laser driver current is given by the formula: I=1.25/(R1+R3).
The power rating of the resistors R1 and R2 is calculated by the forumla P=1.25*I.
Before connecting the laser and testing the driver, check that the resistence is the higher value possible, then connect the laser and measure the absorbed current using an amperometer. Note that if you set too much current to the laser, that will blow.
Below the laser driver circuit.



A standard 60mm x 60mm pc brushless fan is installed to clear the smoke, this prevents the laser optics lens to be clouded.


Commands to the engraving machine are sent through UART at 115200 baud rate.

One you have built the machine, checked and connect all, upload the grbl firmware to your microcontroller, you could use terminal software, or a grbl controller to setup your board. I'm using Universal G-Code Sender to setup and send command to grbl, but you can also use a simple terminal.

The first thing to do is test the motor movement:

To test it, just send the
X10 Y10
command, or use the Universal G-Code Sender movement button.

You should see a motor movement on each axis.

Also check the laser is turned on and off using
M3
and
M5
command.

Now to setup the correct motor distance to run, you have to set each motor step/mm.
The axis motor step/mm calibration method is pretty simple.
Let's try the X axis calibration as example.
We know how many step/mm or steps_per_revolution grbl is actually setup, grbl $100=250.000 (x, step/mm) parameter.
Now, we move your motor for some steps, let's say 100 microsteps, the axis should have move 100mm.
Now we measure the real distance the motor has moved, let's suppose is 181mm.
The new step/mm value for this motor axis should be
steps_per_mm = (steps_per_revolution*microsteps)/mm_per_rev
so
138.121 = (250*100)/181
$100=138.121
Now, if you move the motor 100mm, it should move 100mm.

Because i've installed the limit and home switch, I have alse enabled hard limits
$21=1
I've setup the homing pull-off to 5mm, cause my microswitch have a long lever, and i want the motor to move fare away after the home cycle.
$27=5.000
Also the homing cycle it was enabled:
$22=1
And the homing direction mask it is changed. One may even need to invert axis direction, "dir port invert mask" is the paramenter you have to touch.

Those are the most common grbl setup, for the complete list, look at the grbl wiki page.

Below you can find the grbl configuration parameters i changed:
$21=1 (hard limits, bool)
$22=1 (homing cycle, bool)
$27=5.000 (homing pull-off, mm)
$23=3 (homing dir invert mask:00000011)
$100=37.879 (x, step/mm)
$101=94.246 (y, step/mm)
$110=100.000 (x max rate, mm/min)
$111=100.000 (y max rate, mm/min)
$130=212.500 (x max travel, mm)
$131=274.400 (y max travel, mm)

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 212mm x 274mm, 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 Universal-G-Code-Sender, or other grbl software like Grbl Controller.


Code

Notes
  • read risk disclaimer
  • excuse my bad english

85 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Great work
    David How long is the wood frame or the distance from the work area to the X mechanism?

    ReplyDelete
    Replies
    1. Hello, thank you. It's 5.5cm from working area to laser, and 10cm from working area to the bottom of the printer mechanism. Laser height is adjustable.

      Delete
  3. This comment has been removed by a blog administrator.

    ReplyDelete
  4. Hi,
    You are doing a great job, espacialy with the laser engraver ;)

    Can you tell me what you have changed in your version of grbl?

    ReplyDelete
    Replies
    1. Hello, you can find the compiled grbl hex and the code changes in the download file on this blog post.

      Delete
  5. Hello Davide, awesome project! I want to make my own. Could you give me a list of all the parts you used?

    With kind regards

    ReplyDelete
    Replies
    1. Hello and thank you for your feedback. Because I've used parts from an old scanner and printer, i've to build attachment by my own, I've not any list unluckly.

      Delete
  6. Hi ... Looks great
    Just 1 question .... Would a lightscribe DVD laser be more powerful ? Or have they effectively done the same thing

    ReplyDelete
    Replies
    1. Hello and thank you. As far as i know no, it will be almost the same power. Take a look at this interesting page: http://elabz.com/laser-diode-power-output-based-on-dvd-rrw-specs/

      Delete
  7. i david where i can contact you?
    whatsapp or facebook ?

    ReplyDelete
  8. i want to buy this stuff today , im asking if u have list of items needed ( elecronic stuff) and do u have PCB schematics for print? then i can solder the items easy and faster

    ReplyDelete
    Replies
    1. Hello. You can find the schematics above in the article post. Basically you need a laser and a laser driver. 2 motors and 2 motors driver compatible with the grbl firmare, and a grbl compatible board (an atmega328 one would do the job).

      Delete
  9. hello , is it possible to obtain a full instruction manual on the project ? a step by step detailed manual wood dimensions and more pics of the connections and especially the arduino programming part etc ... i am very interested in it , and is it possible to use a more powerful laser diode ? where can i extracted from what do u advice (krmelie@live.com) your support is highly appreciated

    ReplyDelete
    Replies
    1. a manual that is similar to instructables (Frankenstein engraving thing)

      Delete
    2. Hello, yes, you can find it there. I've linked it above in this post as the inspiration project.

      Delete
    3. i meant a manual of your work that is similar to that project .. i am interested in your project

      Delete
    4. Hello, sorry for that delay. Unluckly not. All the tutorial/manual things I've written for this project are here in this blog post.

      Delete
  10. I dont have pb6 pb7 pinout in my arduino . Im using arduino UNO . Not arduino micro pro
    Any idea ? What pinout i can use?

    ReplyDelete
    Replies
    1. Hello, PB6 and 7 are connecte to crystal on standard Arduino UNO, just like the circuit. That circuit is for a plain ATmega382, but if you have an Arduino the crystal part it's already there. Hope this helps

      Delete
  11. Grbl 0.9 it is build for 3 axis router, to make it works on 2 axis systems like this, with hard limit and homing enabled, a custom version of the firmware it is needed. The only change to apply to version 0.9g are on config.h file.
    lines
    #define HOMING_CYCLE_0 (1<<Z_AXIS)
    #define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))
    was commented out and changed to:
    #define HOMING_CYCLE_0 ((1<<X_AXIS)|(1<<Y_AXIS))
    //#define HOMING_CYCLE_0 (1<<Z_AXIS)
    //#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))
    Then the new grbl firmware can be compiled and used, preventing grbl 0.9 homing problem on 2 axis machines.

    where i can find Config.h file ?

    ReplyDelete
    Replies
    1. Hello. On grbl main source code folder.

      Delete
    2. ok but where and how to upload this src folder to arduino ?

      Delete
    3. what about my second question below ?

      Delete
    4. Hello, you have to compile it using avrgcc, then you can upload the compiled hex to your micro. Take a look here: https://github.com/grbl/grbl/wiki/Compiling-Grbl

      Delete
  12. btw i purshased arduino uni with CNC Shield and a4899 driver
    and laser 500mw blue with driver module
    i have in laser positive negative ( power) and fan power , and TTL
    so ttl must be connected where? to pb4?

    b cz its another laser module
    and one thing i have to connect the laser module to cnc shield no arduino pin , so what pin i have to connect , please help
    almost finish the project , ur amazing

    ReplyDelete
    Replies
    1. Hello, and thank you. The spindle enable pin depends on your grbl version, or how you set in the grbl code. For 0.9 it's usually on PB4. Take a look here: https://github.com/grbl/grbl/wiki/Connecting-Grbl

      Delete
  13. This comment has been removed by the author.

    ReplyDelete
  14. Hello, your scheme unless the driver is wrong it could again be traced ?? I think it should look like this http://imgur.com/a/hvTeI

    ReplyDelete
    Replies
    1. Hello, you are right, i did'n notice ADJ and OUT, swap that and made that error. Check it out now. I should be right.

      Delete
  15. Hello again sir . I received laser 500mw abd driver . Bu the problem this driver ttl on 0v on and on 5v off . How to reverse this please any help or solution ? Please check the laser and description in below link
    500mw 405NM focusing blue purple laser module engraving,with TTL control laser tube diode protective googles
    http://s.aliexpress.com/aa63Ar2U
    (from AliExpress Android)

    ReplyDelete
    Replies
    1. Hello, you can simply use an NPN to reverse the signal logic, something like this should work: https://i.stack.imgur.com/KntFP.jpg

      Delete
  16. Replies
    1. Hello, yes you can use a relay. But to me it's simpler with a NPN, you just have to drive a few mA, a 2n3904 or a 2n2222 would do the job, an NPN it's smaller, and also they swith faster than a relay, and have much longer life, consider that a typical realay can switch almost 100k times. Take a look here: https://www.youtube.com/watch?v=hYN8C769k8A

      Delete
    2. Sir what resistance i have to put on transister emeteur pin ? The laser module how much ttl driver mA ? About 0.200mA or less?

      Delete
    3. This transistor it's used just like a logic inverter, it will just drive a few ampt, the one needed by your laser driver to switch on. You can try with a 1k resistor on E and 47k on B.

      Delete
    4. thx it worked but i wanna say something maybe is new for you , i had another solution , InkScape extension name = Jtech photonics laser tool , i can change for here the command , EXAMP = Laser On command = m5 , Laser Off Command = M3

      Delete
    5. Thank you for your suggestion, it may help other people with the same problem.

      Delete
    6. Welcome bro . Now for home and end position where to wire them ? Im not wiring them directly to arduino . Im wiring them to CNC Hsield V3 so what pin i have to connect home and end and position for x and y

      Delete
    7. I mean home end switch for x and y how to wire them to CNC SHIELD V3 bot to arduino . I tried to research on google badly nothing found

      Delete
    8. Hello, i do not know that board, but i can read END STOPS pin printed on that board, that should be the pins. In generale, check the pins that goes string to Limit Axis pin on the Arduino board for grbl, look here for reference: https://github.com/grbl/grbl/wiki/Connecting-Grbl

      Delete
  17. hello i have really serious problem
    my stepper motor for y axis of scanner have Gears
    so my step MM is so high about 500.000 Not 94.000
    i tried to remove the gears bad luck motor wont have more power to work correct
    do you have gears or you removed

    ReplyDelete
    Replies
    1. Hello. You have to calibrate that motors using the procedure provided above.

      Delete
  18. solved when i type y10 it will travel 1cm
    but the fucking problem is from inkscape wrong dimension
    example i have letter ( A ) dimension H And W 20CM
    its printed about 5 cm

    ReplyDelete
    Replies
    1. Hello, look at the "motor step/mm calibration method" above in the post, it may help you.

      Delete
    2. sir this is my GRBL configuration >>> $$
      $0=10 (step pulse, usec)
      $1=25 (step idle delay, msec)
      $2=0 (step port invert mask:00000000)
      $3=6 (dir port invert mask:00000110)
      $4=0 (step enable invert, bool)
      $5=0 (limit pins invert, bool)
      $6=0 (probe pin invert, bool)
      $10=3 (status report mask:00000011)
      $11=0.020 (junction deviation, mm)
      $12=0.002 (arc tolerance, mm)
      $13=0 (report inches, bool)
      $14=1 (auto start, bool)
      $20=0 (soft limits, bool)
      $21=0 (hard limits, bool)
      $22=0 (homing cycle, bool)
      $23=0 (homing dir invert mask:00000000)
      $24=25.000 (homing feed, mm/min)
      $25=500.000 (homing seek, mm/min)
      $26=128 (homing debounce, msec)
      $27=1.000 (homing pull-off, mm)
      $100=250.000 (x, step/mm)
      $101=3060.000 (y, step/mm)
      $102=250.000 (z, step/mm)
      $110=500.000 (x max rate, mm/min)
      $111=700.000 (y max rate, mm/min)
      $112=500.000 (z max rate, mm/min)
      $120=10.000 (x accel, mm/sec^2)
      $121=10.000 (y accel, mm/sec^2)
      $122=10.000 (z accel, mm/sec^2)
      $130=200.000 (x max travel, mm)
      $131=200.000 (y max travel, mm)
      $132=200.000 (z max travel, mm)
      ok


      ** so when i write Y100 it actualy travel 100mm
      so that true right ?

      but my problem in inkscape dimensions

      Delete
    3. this is my new grbl configuration
      $0=10 (step pulse, usec)
      $1=25 (step idle delay, msec)
      $2=0 (step port invert mask:00000000)
      $3=6 (dir port invert mask:00000110)
      $4=0 (step enable invert, bool)
      $5=0 (limit pins invert, bool)
      $6=0 (probe pin invert, bool)
      $10=3 (status report mask:00000011)
      $11=0.020 (junction deviation, mm)
      $12=0.002 (arc tolerance, mm)
      $13=0 (report inches, bool)
      $14=1 (auto start, bool)
      $20=0 (soft limits, bool)
      $21=0 (hard limits, bool)
      $22=0 (homing cycle, bool)
      $23=0 (homing dir invert mask:00000000)
      $24=25.000 (homing feed, mm/min)
      $25=500.000 (homing seek, mm/min)
      $26=128 (homing debounce, msec)
      $27=1.000 (homing pull-off, mm)
      $100=250.000 (x, step/mm)
      $101=23.810 (y, step/mm)
      $102=250.000 (z, step/mm)
      $110=500.000 (x max rate, mm/min)
      $111=700.000 (y max rate, mm/min)
      $112=500.000 (z max rate, mm/min)
      $120=10.000 (x accel, mm/sec^2)
      $121=10.000 (y accel, mm/sec^2)
      $122=10.000 (z accel, mm/sec^2)
      $130=200.000 (x max travel, mm)
      $131=200.000 (y max travel, mm)
      $132=200.000 (z max travel, mm)
      ok


      i was enabled 16 microstep from A4988 driver
      now disabled
      and when i write Y100 it actually travel 100mm
      but still have problem with inkscape dimension
      example = square H 20cm W 20Cm

      in GRBL file another dimension about 5 cm
      when opening the gcode file

      Delete
    4. Hello. This file here it's a 16x16 square in GCode https://uploadpie.com/pU2f9V. Check you working area dimension in InkScape. You may also take a look at the Shapeoko calibration pattern here http://www.shapeoko.com/wiki/index.php/Calibration_and_Squaring_the_Machine

      Delete
    5. sir we are not understanding each other so i made a video
      check the description below the video on youtube
      inkscape dimension and gcode text another dimension the link : https://youtu.be/pvprHndrh-o

      Delete
    6. I suppose that's the output problem of the GCode inkscape module you are using, the best place you can ask about that is the InkScape forum.

      Delete
    7. what extension u are using ? and u have no problem with

      Delete
    8. Hello, I used the laserengraver extention.
      Please, tell us how you solve this issue. It may be helpfull for other people.

      Delete
    9. Hello, you can just post it here the solution, or find my email on my website.

      Delete
  19. Dear friend,
    Is it possible to send all the details and pictures of the DIY A4 laser engraver using the scanner to my email ivanpaulo1@gmail.com?
    I'd appreciate that very much.
    Tell me, does the LASER cover all the A4 area, or just part of it?
    Best regards,
    Ivan

    ReplyDelete
    Replies
    1. Hello, unluckly all the materials that I have is here in this blog post. I have not made detailed instructions cause one can have different materials then mine, it is difficult that one find the same hardware that I have used. It covers all the A4 area and a little more than that.

      Delete
  20. hello, i'm build this laser engraver too base on your blog (and any other threed too ofcourse). but i'm stuck in the laser driver. i use the laser diode from old DVD-RW. with minimum electronic skill i can't calculation the resistor value for my laser diode.
    what exacly resistor (R1&R2) value for my laser diode???
    it is save to use your driver (including the resistor value on your schematic) for my laser dioda???
    thanks,
    best regard,,,

    ReplyDelete
    Replies
    1. Hello, you can try using a 1.8ohm 1W resistor for R1, and a multiturn pot of 100ohm for R2.
      Hope this helps.

      Delete
    2. thanks before,
      its hard to find 100 ohm pot in my place, yesterday i try to put 4,7 ohm on R1 without R2, but no luck, the laser turn on but wont burn.
      second question :
      what the best OS to run this CNC, linux or windows??
      i have 2 device with different OS. i see u'r using linux, right?

      best regard,,,

      Delete
    3. You may run it on windows and linux. It depends on the software you a re using, as example this one runs on both https://github.com/winder/Universal-G-Code-Sender.
      You may put two 47ohm in series. Week in mind that if you lower too much this resistor you may brurn your laser diode... and also alway remember to wear googles, you have just two eyes! About thw driver

      Delete
    4. thanks a lot, thats really help me.

      best regard,,,

      Delete
  21. This comment has been removed by the author.

    ReplyDelete
  22. This comment has been removed by a blog administrator.

    ReplyDelete
  23. This comment has been removed by a blog administrator.

    ReplyDelete
  24. hola si es muy bueno una duda se puede utilizar un laser playstation 3

    ReplyDelete
  25. This comment has been removed by a blog administrator.

    ReplyDelete
  26. This comment has been removed by the author.

    ReplyDelete
  27. This comment has been removed by a blog administrator.

    ReplyDelete
  28. This comment has been removed by a blog administrator.

    ReplyDelete
  29. Hi i want to buy this machine plz send me the price

    ReplyDelete
    Replies
    1. Hello, I'm sorry but i do not build this machine for selling purpose.

      Delete
  30. Very Interesting, Good job and thanks for sharing such a good information.

    ReplyDelete
  31. Very Interesting, Good job and thanks for sharing such a good information.

    ReplyDelete