Hi guys, for years I'm trying to make my own CNC router so I can make PCB easier.

What I'm trying to make is a G code interpreter who can sends signals to an arduino board. So the arduino board can control a simple CNC router to draw a circuit over a PCB.

I hope this project inspirer some peoples to support, improve, and make this things gonna real.

Any suggestions, comments, bug, improvement, please send to me.

Step 1: The Processing Code.

The code is real simple. I generate an G file in Eagle Layout editor. Read this file in processing. And I move, or Draw, the lines.

On the next step I will shoe how to generate the G file, and use my code to draw the PCB on screen.

The file named as 12.txt is a G file to use as example.

The file named as "motor shield" is a example already routed on the eagle. You just need to generate the G-file.

The file named as "teste" is simple example already routed on the eagle. You just need to generate the G-file too.

Step 2: Generating the G File.

Open any project that you already made, or just download the example above.

Open the *.brd file.

Click on the CAM Processor icon, the one that looks like a movie film.

On the layer windows deselected all, and select only the Top OR Bottom layer. Make sure you deselected all other layer or my program will won't recognize the code.

Make sure that on the Style tab this check-box are checked. Mirror, Upside Down, pos. Coord.

Click on file button and save the file inside of your sketch folder. Something like this: C:/Users/Otavio/Documents/Processing/cnc/data/12.txt

Change my name for yours.

Then click on the "process job" button.

A warning message will appear, ignore it. Just click on OK.

Nice, if you do everything right. the file will be create, and locate inside the data folder of your sketch.

If you open the file you will see some codes like this one:


Ok, now on Run your sketch and see the results. It looks amazing, don't?

Step 3: Lets Check the Results.

On the images below you can see and compare both circuits.

I know that the pads aren't draw, but I intend to leave this part to the arduino board handle.

The part that send messages to arduino is not done yet.

Any suggestions are welcome.

Please guys, if you like it, rate it.
<p>Hi all.</p><p>I know this is an old Instructable, but I'm hoping that someone is still watching this and can help me out.</p><p>I was able to get the Processing script to run (after deleting the first dozen or so lines as mentioned in other comments), however, every time I hit the &lt;Run&gt; button, the resulting image does not contain all of the lines. According to the console window, all of the commands are being processed, but the display simply does not display everything. I've attached some images to show you what's happening.</p><p>Any idea why some of the lines are not being displayed? Any idea on how to remedy this?</p><p>Thank you for your time.</p>
<p>hello friends i have problem in my processing i need a solution please </p>
<p>hay bros , lovely work 'bravo ) </p><p>can you gives me the basics of your project ! </p><p>like : </p><p>how you can progrm the GUI and what did you used to make the arduino sketch :) </p><p>thank you in avnc :) </p>
<p>Hey,</p><p>Thank you for the feedback.</p><p>About the GUI I used the Processing IDE. Is much like the Arduino IDE.</p><p>About the Arduino Sketch, i did not understand your question.</p><p>Sorry my bad English.</p>
<p>Can you send the link of IDE you used. </p>
<p>Can you please tell me which software you are using for processing generated G code. i don't know much about it. Please reply fast.</p>
<p>Oi Otavio tudo bem ? </p><p>Sou de Belo Horizonte e estou como bolsista em um programa da faculade em que colaboro na constru&ccedil;&atilde;o de uma fresadora. Estamos tentando desenvolver sua terceira vers&atilde;o e uma das demandas &eacute; que ela seja controlada diretamente pela interface Rhinoceros 3D + Grasshopper. Usando o plugin Firefly para o Grasshopper consegui mandar o GCode direto para a m&aacute;quina, mas estou tento problemas na gera&ccedil;&atilde;o do c&oacute;digo. Gostaria de saber como voc&ecirc; tem se saido nas tentativas de criar uma forma direta de exportar o g-code para o Arduino sem interm&eacute;dio de softwares controladores. Se for conveniente podemos conversar por Facebook. Meu nome Pedro Henrique Figueiredo Magalhaes.</p><p>Um abs !</p>
Beleza Pedro,<br><br>Faz tempo que nao volto para esta area, mas deve ter evoluido bastante.<br><br>Tem uma versao que se nao me engano &eacute; a Mendel http://reprap.org/wiki/Mendel, o gcode &eacute; salco em cartao SD e um arduino le o gcode e executa o comando.<br><br>Abra&ccedil;o<br>
<p>1- i cant download (other files)FVY088TFZNHOWHW.tmp</p><p>2-your pde doest work</p>
1 rename the file to .pde<br><br>2 what is the error?
When i run the program i get an unexpected char 'i' too. How have you fixed nerdling?
whenever i try your code all i get is unexpected char: 'i' <br>what should i do? <br>
Can you explain better your problem?
never mind i fixed it <br>thanks anyway
Hello , i&Acirc;&acute;m tryimg to download the cnc.pde file but it only downloads a temp file, can anybody helpme? my email is virendrasingh.bora@gmail.com , <br>I am trying to arduino understand my GCODE . <br>
Just try to rename the extension of the file from .tmp to .pde <br> <br>Regards
Nice project! This gives me hope because I plan to write the same sort of thing for the propeller microcontroller.
Hello!! greatproyect!!, i&acute;m tryimg to download the cnc.pde file but it only downloads a temp file, can anybody helpme? my email is aliasthesmileyboybana@hotmail.com i&acute;m tryin to do a 3d printer and router :)
Hello Hello i make some variatios to the Code, and now ir works well, i got some trobles with the original one, there is my version, thank you Octaviusp :)<br><br><br>void setup()<br>{<br> size(1000,1000);<br> background(0);<br><br><br>}<br>int ESCALA = 2;<br>int offsetx=0,offsety=0;<br><br>void draw()<br>{<br> String lines[] = loadStrings(&quot;12.txt&quot;); <br> for(int i=3;i String[] strx = split(lines[i], 'X');<br> int[] x=int (split(strx[1],'Y'));<br> strx = split(strx[1],'Y');<br> int[] y=int (split(strx[1],'D'));<br> strx = split(strx[1],'D');<br> int[] d= int (split(strx[1],'*'));<br> println(x[0]);<br> println(y[0]);<br> println(d[0]);<br> if(d[0]==2) move((x[0]/100*ESCALA),(y[0]/100*ESCALA));<br> if(d[0]==1) anda(x[0]/100*ESCALA,y[0]/100*ESCALA);<br><br> }<br>}<br><br>void move(int x1,int y1){<br> println(&quot;move&quot;);<br> strokeWeight(5);<br> stroke(255);<br> point(x1,y1,0);<br> offsetx=x1;<br> offsety=y1;<br> println(x1);<br> println(y1);<br> println(&quot;fin move&quot;);<br>}<br><br>void anda(int x,int y){<br> int countx=offsetx,county=offsety;<br><br> smooth();<br> strokeWeight(2.0);<br> strokeCap(ROUND);<br> line(countx,county,x,y); <br> offsetx=x;<br> offsety=y;<br>}<br>
Can you post your Processing code? The .PDE file is an Arduino sketch, and not the Processing code. Thanks, or please e-mail to hondaman900@gmail.com.
The file &quot;cnc.pde&quot; is the processing code. There is no Arduino sketch on this example yet.
But the cnc.pde uses non-Processing Arduino statements, and wants to include Stepper.h, which is an Arduino include. Also, #include is an Arduino-only statement. Processing uses &quot;import&quot;. So I'm pretty sure it's not a Processing sketch and would love to see the Processing code.<br><br>Also, did you make further progress with this project since you built the Instructable?<br><br>Thanks in advance
void setup()<br>{<br><br> size(700,700);<br><br>}<br>int ESCALA = 2;<br>int offsetx=0,offsety=0;<br><br>void draw()<br>{<br> String lines[] = loadStrings(&quot;14.txt&quot;);<br><br> for(int i=3;i String[] strx = split(lines[i], 'X');<br> strx = split(strx[1],'Y');<br> String[] stry = split(strx[1],'D');<br> String[] D= split(stry[1],'*');<br><br> if(int(D[0])==2) move(int(strx[0])/100*ESCALA,int(stry[0])/100*ESCALA);<br> if(int(D[0])==1) anda(int(strx[0])/100*ESCALA,int(stry[0])/100*ESCALA);<br><br> }<br><br> while(true){<br> }<br>}<br><br>void move(int x,int y){<br> strokeWeight(5.0);<br> offsetx=x;<br> offsety=y;<br> println(&quot; moveu&quot;);<br> //point(x,y);<br>}<br><br>void anda(int x,int y){<br> int countx=offsetx,county=offsety;<br><br> smooth();<br> strokeWeight(2.0);<br> strokeCap(ROUND);<br> line(countx,county,x,y);<br> <br> offsetx=x;<br> offsety=y;<br>}<br>
Just remove the commented part.
I am currently building a CNC machine and this is really helpful, but when will the arduino sketch be done? and has anyone done something similar? Thanks.
can you send me those files at oshondrom@gmail.com<br>i love your project!
Cool project!<br>Bom ver que &eacute; do brasil!<br>Quando terminar minha CNC, irei testar...<br>Abra&ccedil;o
The CNC.pde code is no such thing it is just the standard Arduino example of follow a pot with a stepping motor code.
Actually my code is based on the Arduino example but with a graphic interface.
Ola parab&eacute;ns pelo teu trabalho, mas download dos arquivos n&atilde;o funciona, se puderes por favor enviar para meu email. marcossilvabrasil@hotmail.com<br /> <br /> abra&ccedil;o e obrigado
file download ain't working<br /> can you send me those files at<br /> jordan2_delta@hotmail.com please<br /> thanks<br />
just try to rename the file you download.<br /> anyway, I will send it t tou,<br /> cya<br />
So, is the goal to draw the circuit using an etch-resist pen on the board, or to run a mill that carves out everything BUT the traces? Just wondering. Someday I'll have a CNC machine of my own, too...
Im think using a PEN the same pen you use to draw the circuit on hand. The milling process is a little different, we have to drill on the edge of the trace. But, it can possible to do with a code modification.
Ah, ok. I'd definitely push for the cnc mill solution in that case...
I've also been toying with CNC for a while and I was thinking of using my *duino as a control board. I'm going to have a play with your code over the week-end. Looks good, nice instructable.
nice, please let me know what you think about the code, and if it is possible to use it.

About This Instructable




More by otaviousp:CNC G-Code Interpreter using Processing How to connect Arduino and RFID Angle measurement using gyro, accelerometer and Arduino 
Add instructable to: