Step 6: Prepare the Arduino.

For the Arduino I started out writing my own software. But while searching for a good way to control movement from the serial port I stumbled upon something called "Grbl ". This is a g-code interpreter with lots of nifty functions. As I already had everything connected to the Arduino I had to ether change my connections or change the software. Luckily it is easy to change control pins in the software. I did however have to download Winavr and then the code from github.com . It is not that hard to do. After downloading and extracting the code you have to change the port numbers in config.h and make sure you get them in the right order. Then all you have to do is start a command window, enter the correct folder and type "make". If all goes to plan you should end up with a .hex file ready for the Arduino.

I have however changed the pin-out since then and here in the instructable I use the default pin-out of Grbl. This will make it a lot simpler to follow and setup. You can just download the prepared hex file from the Grbl download page .

The current version of Grbl (0.6b) has a bug in the queue system. The laser on and off (M3, M5) commands are not put in the queue and the laser will be turned on and off as soon as the Arduino receives the commands. This is resolved in the edge branch. You can download and the source from here , or grab the compiled hex I am using from here . This should resolve the issue until the next version of Grbl.

Any way you choose to do it you will end up with a .hex file that you must get into the Arduino. I have tried a couple of different ways and the one I like the most is by a program called XLoader . The programming is pretty straight forward; select the correct serial port for your Arduino. Select the hex file and type of Arduino and press upload. If you are using the new Arduino Uno the XLoader doesn’t work, you will get an upload error. In that case I recommend using ARP/Arduino Uploader but even this uploader has some issues with the Uno. When programming the Arduino select the com port and microcontroller in the respective dropdown. After that you will have to make a change in the “AVR Dude Params” text. Erase the “-b19200” (without the quotes) part and click on the upload button. In any case, a couple of seconds later you are done and are ready to try it out. Exit the XLoader and get to the next paragraph.

The Arduino needs to be set up for the job. Start your favorite serial terminal and open the port your Arduino is connected to. You should get a welcome message:

Grbl 0.6b
'$' to dump current settings"

If you enter $ followed by return you will get a list of options. Something like this:

$0 = 400.0 (steps/mm x)
$1 = 400.0 (steps/mm y)
$2 = 400.0 (steps/mm z)
$3 = 30 (microseconds step pulse)
$4 = 480.0 (mm/sec default feed rate)
$5 = 480.0 (mm/sec default seek rate)
$6 = 0.100 (mm/arc segment)
$7 = 0 (step port invert mask. binary = 0)
$8 = 25 (acceleration in mm/sec^2)
$9 = 300 (max instant cornering speed change in delta mm/min)
'$x=value' to set parameter or just '$' to dump current settings

You must change the steps/mm for X and Y axis to 53.333 on both. Just enter "$0=53.33" followed by return and then "$1=53.333" followed by return. Z axis can be ignored as it is not used. The acceleration can be ramped up to something like 100 ("$8=100" and return). As we move really slowly with this machine acceleration can be high. Another side effect of low acceleration can be that curves get a lot more burnt than straight lines as the controller constantly tries to accelerate and decelerate but never reach full speed. If you build this like me one of your axis might be mirrored. This is easy to fix. Option $7 lets you change direction on axis. I wanted to change direction on the X axis so I type in "$7=8" as I want to change bit 3 (8 = 00001000 binary) if you want to change direction on Y axis you type in 16 (00010000) or 24 (00011000) to change both. The complete documentation of the invert mask can be found here .

Now you are ready for the computer setup. If you want to try some movement you can type "G91 G28 X0 Y0 [return]" to zero the axis. Followed by "X10 Y10 [enter]". You should see 10mm movement on each of the axis.

<p>Thanks Groover, you've get me going. After a search on the internet your design suits me the best. I've made it mostly like you did but with a few differences.</p><p>First to mention is the laser. I've used a blue laser pulled out of a RGB laser pattern projector. The power lies on approx 250mW, I think (I don't have a LPM). Blue light transfers more energy so there is more burning power. Even on white! paper.</p><p>The programs I used:</p><p>-<strong>GBRL v09.j</strong> (for Arduino Uno library) *</p><p>-<strong>Inkscape 0.91</strong> (for pc)</p><p>-<strong>LaserEngraver</strong> (plugin for <strong>Inkscape</strong>) *</p><p>-<strong>UniversalGcodeSender v1.0.9</strong> (for pc)</p><p><br>Due to version differences of the programs I had to make some adjustments to some of them:</p><p><br><strong>GBRL</strong>, to switch the laser on and off (Gcode M03 and M05) the following has to be done before installation:</p><p><em>1a. Download <strong>GRBL</strong> sourcecode from github ( </em><a href="https://github.com/grbl/grbl" rel="nofollow"><em>https://github.com/grbl/grbl</em></a><em> )<br>2a. Extract zip File<br> 3a. Use Notepad++ and open the file called config.h (Folder: grbl-master\grbl)<br> 4a. Search for a line, that starts with &bdquo;#define VARIABLE_SPINDLE&ldquo;<br>5a. Comment this line out ( Use a double Slash // )<br> 6a. Save the File</em></p><p><br>-<strong>LaserEngraver</strong> plugin for <strong>Inkscape</strong> has a bug, to solve this read the following:</p><p><em>If you&rsquo;ve tried to use the modified Inkscape laser engraver plugin mentioned in this blog post about building an engraver, you may have run into an error trying to do the export. It&rsquo;s something like &ldquo;AttributeError: &lsquo;module&rsquo; object has no attribute &lsquo;unittouu&rsquo;&rdquo; or &ldquo;unittouu not part of inkex module&ldquo;. Here&rsquo;s the fix.</em></p><p><em>The bug is on line 3080 of laserengraver.py and broke due to an Inkscape change. Old line:</em></p><p><em>doc_height = inkex.unittouu(self.document.getroot().get('height'))</em></p><p><br><em>New line:</em></p><p><em>doc_height = self.unittouu(self.document.getroot().xpath('@height', namespaces=inkex.NSS)[0])</em></p><p><br><em>Be sure to have the exact same number of spaces/tabs on this line. In Python, whitespace is important, so you can&rsquo;t mix and match spaces and tabs, and all code blocks must have the same whitespace alignment.</em></p><p><em>Problem solved!</em></p><p>Your Gcode sender does not work so I have downloaded <strong>UniversalGcodeSender</strong>. This works fine and is simple to use.</p><p>I've added some foto's to show some details and a Youtube video where you can see some examples of engraving and cutting I did with it.</p><p>Now I know what to do I wil scale things up and start a new project with two flatbed scanner interiors an my 2W blue laser.</p><p>https://youtu.be/6A7YREqS-w8</p>
<p>THANKS YOU VEY MUCH!!!!</p><p>Your comment has helped me to switch the laser on and off.</p><p> I did the steps (GRBL steps: 1a,2a,3a,4a,5a,6a.) as you had written and now it works !!!!</p><p> It is incredible that a simple detail like a double slash (//) can make you lose a lot of time.</p><p>thanks you again, I was about to give up.</p>
<p>You're welcome!</p>
<p>Hi! And thanks for your instructions. As i stated earlier on other thread i am bit of a novice with electronics, but i have all the components here besides the mosfet. Do you think that if i follow your &quot;schematic&quot; in the last photo in this post i wont run into trouble? do you happen to have that picture in better resolution?</p>
<p>Hey Thanks Venkes,</p><p>This is the very good All-in-1 Solution post you made.</p>
<p>Hello Mr. Groover</p><p>Luckily I have come across this Page I have a few quires:</p><p>1) Can any other Laser also, like the one in pic attached , which has a separate controller card with TTL ( 0V to 5V : 0V = On and 5V- off)</p><p>2) If yes , what would be the setup to trigger TTL on Arduino master card or does it required to be made (or is it available as ready made)</p><p>Please help!</p>
<p>Here is a picture of the one I'm building. I just have to finish up the electronics.</p>
<p>Never mind I figured it out.</p>
<p>Hi I have the mechanacs built and am trying to download the source file and HEX file. Neither of these links work! Can you please fix this so I can get the files. Nice job on your instructable also.</p>
<p>it is necessary to download inkscape 0.48.5 for your plugin to work?latest builds is 0.91</p>
<p>Groover, I'm currently planning to build this. May I know how what is the rating for the external power supply you used?</p>
<p>I am currently building this :) Only difference is that i bought simple step-down module for laser : <a href="https://www.aliexpress.com/item/New-LM317-DC-DC-step-down-DC-converter-circuit-board-power-supply-module-1pcs/32230363619.html?spm=2114.13010608.0.0.Cy1En3" rel="nofollow">https://www.aliexpress.com/item/New-LM317-DC-DC-st...</a> and i am now wondering about the schematics that how i would apply this part to the plan. i am at novice level in electronics - currently studying first year of ICT in UAS.</p><p><br>Thanks for this instructable, it is fantastic!</p>
<p>Thank you!</p><p>The mosfet's only task is to switch the laser on and off. Therefore the mosfet is powering a relais. The relais act like a switch so I think you can easely hook your laser, laser powersupply and step-down module to it if you considder the relais as a simple switch. I hope this wil help you further,</p><p>Succes.</p><p>P.s. Sorry for the late response, I did not get a notification from Instructables</p>
Thanks for the answer. Do you have a better resolution image of those plans?
<p>Hi I'm a total newbie on the electrical part, could i know is LM317 a transistor? or i should use a module? as for module, is it possible for me to just purchase it from ebay which cost around USD 1.29 (eg: http://www.ebay.com/itm/LM317-DC-DC-Converter-Buck-Power-Module-Adjustable-Linear-Regulator-B1-/262486808195?var=&amp;hash=item3d1d6ed683:m:mn3F_kKxDOEXfuPON4JyCQQ)?</p>
<p>Thanks for your post,</p><p>I make follow you, but I use module power 5v 3A to power Easy drive. I dont know why IC A3897 are very hot (I only test for about 1 minute and motor has work).</p><p>Do you help me solve it?</p>
<p>hello, can i use laptop CD drives for this project?</p>
<p>as stated in this instructable, cd drive lasers aren't suitable for use.</p>
<p>how would we give input to the engraver?how would it know what pattern should be engraved?</p>
<p>read the instructions :) it is all there.</p>
<p>what version of inkspace? video looks different than latest version.</p><p>i get errors when creating laser file</p>
<p>Hi! Can I use an Arduino Nano instead of UNO?</p>
<p>if its not too late already you should be able to as it has the same pinouts but be sure to have positive to positive and negative to negative because the nano has no protection from reverse current. you of course need a breadboard then too though.</p>
Hello. I need help with electronic. I bought all but what now?? I am beginners with electronic and i dont understand everything. If somebody can help me with this.... i will be very grateful. ..
<p>Hello. Im writing the G-Code interpreter sketch on the Arduino on my own. I only need to know, how the G-Code Sender knows when to send the next line. What does he expect as a response from the Arduino? </p>
<p>thanks in advance!</p>
<p>Can some one tell me what components are in this Lasershield. Because i can't figure out all of them. I know only one on schematics.</p>
<p>hi there... I was wondering if... I want to use it to engrave several times the same figure: some lines. Is it possible to connect it to the power and put a program in Arduino so I don t have to use the computer? I mean, I connect PC to arduino, upload my little program, and then if I connect the engraver to the power it will work? thank you in advance!</p>
<p>No, Arduino will power on but you will have to use the grbl to control.<br></p>
... thnks :)
<p>No, it won't. Arduino is just like a calculator. You will have to give input in order to receive output.<br>Although you could write a program that will stay on an sdcard and then arduino can repeat that program.</p>
yes, exactly! like this one? : http://www.cetronic.es/sqlcommerce/disenos/plantilla1/seccion/producto/DetalleProducto.jsp?idIdioma=&amp;idTienda=93&amp;codProducto=888304015&amp;cPath=1342&amp;gclid=CjwKEAjw4dm6BRCQhtzl6Z6N4i0SJADFPu1nDCpx0W2rYdx65nX7nO-NEl_Vr1wEsb1NHxrDNYlzqRoCOt3w_wcB<br>how can I do it? ( sd card )... :)))))
<p>Yes with sdcard and lots of coding can do that.<br>Or try searching if someone have that open sourced</p>
<p>Maybe I have not read it pretty well, but I can not find anywhere how much voltage should be marked in the image introduced into the circuit? If you need one at all. The answer Thank you in advance!</p>
<p>That jumper is just an alternative connection for the laser. If you follow the paths you will find they connect to the same as the laser screw terminal. The laser circuit will draw power from the arduino and the Vin pin.</p>
What power supply is should use? How many volt/amp I should supply for whole setup.
<p>How does this work without limit switches? I dont want the motors to run past the length of the rail, causing problems! Also, how do you calibrate the speed of the print, say if you are using a more powerful laser (1.0 W) and you dont want to set stuff on fire... No limit switches are used here so how do you zero the axes and keep the print from going larger than the print area? Also, how do you calibrate the step/mm because with the 53.333 step/mm command given in the project the movements is not properly scaled to the commands. If i put in X10 it will move more than 10mm... Thanks...</p>
Setting of steps depends on what software u r using.<br>If using the given grbl version and controller u jut need to type $ and press enter.<br>That will list all commands that can be set manually. Set first two commands $0 &amp; $1 to 53.33.<br>The author had already described that the inkscape file properties must be st to 38mm*38mm so no limit switch necessary. You can override the stopped manually by using override box in the grbl controller window.
<p>hi, i made the engraver but i am facing a problem, the motion is working fine just needs some calibration but the laser is not burning anything. it is being turned on and off but it just doesn't burn anything what can be the issue</p>
A few things come to mind:<br>1. It is underpowered. How much current are you passing through it?<br>2. It is unfocused. Do you have a focusing lens? Have you tried adjusting the focal length to suit you rig?<br>3. It's not the right laser. Where did you get it? If you got it from a DVD burner, did you pull out the right one?<br>4. It has 'gone LED'... as they say. If you mistreat a laser, it fails and just becomes a nice bright LED.<br><br>There might be other reasons too, that's just what I can think of right now.
4. May be possible because of power fluctuations laser(even with driver) can behave like a working laser but won't burn anything.
Please check if the laser has at least 2.2v and 100mA of power supply.<br>Also check if has focused properly on whatever surface you have setup.<br>Note: It won't engrave shiny metal or glass.
<p>You dont really need to connect MS1 and MS2 on the Easy Driver to 5 Volts.</p><p>The default step setting is 1/8th step.</p><p>From Easy Driver web site:</p><strong>The Easy Driver is able to operate in 1/8th, 1/4, half, and full<br> step (2 phase) modes. These four modes are selected by the logic<br> levels on the MS1 and MS2 input pins. Normally, the pull-up<br> resistors on the Easy Driver hold MS1 and MS2 high, which results in<br> a default setting of 1/8th microstep mode. You can pull either<br> or both to ground to select the other 3 modes if you want.</strong>
<p>So simply leave them as it is(not connected to anywhere) will result in auto stepping? of full, half or 1/8?</p>
<div><div><p>From what I understand, if you leave them unconnected it will be 1/8th step.</p><p>As it says that is the default. I assume if you connect them different ways you will get Full, Half or Quarter step.</p><p>This is the table from the website.</p></div></div>
I'm a newbie to electronics buddy, so don't know this stuff very well. But I found what you said its almost the same as on other site.<br>Quick Specs:<br>Each EasyDriver can drive up to about 750mA per phase of a bi-polar stepper motor. It defaults to 8 step microstepping mode. (So if your motor is 200 full steps per revolution, you would get 1600 steps/rev using EasyDriver.) This setting can be easily overridden by tying the MS1 and/or MS2 pin to ground to set the driver to use 1/8, 1/4 or 1/2 microstep mode (See the datasheet for the table of values). It is a chopper microstepping driver based on the Allegro A3967 driver chip. For the complete specs of the design, read the A3967 datasheet. It has a variable max current from about 150mA/phase to 750mA/phase. It can take a maximum motor drive voltage of around 30V, and includes on-board 5V regulation, so only one supply is necessary. The best part - low cost. The parts cost is easily less than $10, even less if you make the board yourself.<br>http://www.schmalzhaus.com/EasyDriver/
<p>Hi dear, I'm really excited about your project, I have read and searched for information to use GRBL but I can not make move my engines with it, will that use &quot;Adafruit Motor / Stepper / Servo Shield for Arduino Kit - v1.2&quot; if engines run libraries move, but if I do not work for me GRBL.<br><br>Do any of the users has made this project using the shield named?<br><br>Thanks I hope your understanding and prompt reply, thanks.</p>
<p>Use the GRBL of the given version or use from grbl's site and the controller</p>
<p>Hi Groover, nice pocket laser engraver. I would like to know what the work area is as I could find it in your instructions. Thanks</p>
<p>Its written 38mmx38mm</p>

About This Instructable




Bio: I'm just a poor lonesome cowboy... Not really, I am divorced and live in the cold country of Sweden. I am not much of ... More »
More by Groover:Steampunk instant sounds Stamps from craft foam. Pocket laser engraver. 
Add instructable to: