CNC G-Code Interpreter Using Processing

95,115

96

36

Intro: CNC G-Code Interpreter Using Processing

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:

G01*
X000000Y000000D02*
D10*
X005919Y003615D02*
X005842Y003802D01*
X003086Y006558D01*

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.

Share

Recommendations

  • Tiny Home Contest

    Tiny Home Contest
  • Fix It! Contest

    Fix It! Contest
  • Furniture Contest 2018

    Furniture Contest 2018

36 Discussions

0
None
wombat99

1 year ago

Hi all.

I know this is an old Instructable, but I'm hoping that someone is still watching this and can help me out.

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 <Run> 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.

Any idea why some of the lines are not being displayed? Any idea on how to remedy this?

Thank you for your time.

CNC G-Code Interpreter - 001.jpgCNC G-Code Interpreter - 002.jpgCNC G-Code Interpreter - 003.jpg
0
None
mmebra

2 years ago

hay bros , lovely work 'bravo )

can you gives me the basics of your project !

like :

how you can progrm the GUI and what did you used to make the arduino sketch :)

thank you in avnc :)

2 replies
0
None
otaviouspmmebra

Reply 2 years ago

Hey,

Thank you for the feedback.

About the GUI I used the Processing IDE. Is much like the Arduino IDE.

About the Arduino Sketch, i did not understand your question.

Sorry my bad English.

0
None
shashank318

2 years ago

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.

0
None
pmagalhães

4 years ago on Introduction

Oi Otavio tudo bem ?

Sou de Belo Horizonte e estou como bolsista em um programa da faculade em que colaboro na construção de uma fresadora. Estamos tentando desenvolver sua terceira versão e uma das demandas é 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áquina, mas estou tento problemas na geração do código. Gostaria de saber como você tem se saido nas tentativas de criar uma forma direta de exportar o g-code para o Arduino sem intermédio de softwares controladores. Se for conveniente podemos conversar por Facebook. Meu nome Pedro Henrique Figueiredo Magalhaes.

Um abs !

1 reply
0
None
otaviousppmagalhães

Reply 4 years ago on Introduction

Beleza Pedro,

Faz tempo que nao volto para esta area, mas deve ter evoluido bastante.

Tem uma versao que se nao me engano é a Mendel http://reprap.org/wiki/Mendel, o gcode é salco em cartao SD e um arduino le o gcode e executa o comando.

Abraço

0
None
omdiferit

5 years ago on Introduction

When i run the program i get an unexpected char 'i' too. How have you fixed nerdling?

0
None
vsbora

6 years ago on Introduction

Hello , i´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 ,
I am trying to arduino understand my GCODE .

1 reply
0
None
mgingerich

6 years ago on Introduction

Nice project! This gives me hope because I plan to write the same sort of thing for the propeller microcontroller.

Hello!! greatproyect!!, i´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´m tryin to do a 3d printer and router :)

1 reply

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 :)


void setup()
{
size(1000,1000);
background(0);


}
int ESCALA = 2;
int offsetx=0,offsety=0;

void draw()
{
String lines[] = loadStrings("12.txt");
for(int i=3;i String[] strx = split(lines[i], 'X');
int[] x=int (split(strx[1],'Y'));
strx = split(strx[1],'Y');
int[] y=int (split(strx[1],'D'));
strx = split(strx[1],'D');
int[] d= int (split(strx[1],'*'));
println(x[0]);
println(y[0]);
println(d[0]);
if(d[0]==2) move((x[0]/100*ESCALA),(y[0]/100*ESCALA));
if(d[0]==1) anda(x[0]/100*ESCALA,y[0]/100*ESCALA);

}
}

void move(int x1,int y1){
println("move");
strokeWeight(5);
stroke(255);
point(x1,y1,0);
offsetx=x1;
offsety=y1;
println(x1);
println(y1);
println("fin move");
}

void anda(int x,int y){
int countx=offsetx,county=offsety;

smooth();
strokeWeight(2.0);
strokeCap(ROUND);
line(countx,county,x,y);
offsetx=x;
offsety=y;
}

0
None
hondaman900

6 years ago on Introduction

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.

1 reply