# G Code Tutorial

• posted

I'm looking for a decent G-Code tutorial. Preferably one for Mach 3. There are a couple projects I want to do that I think it would just be easier to write the raw g-code than to draw the picture in a CAD program, run it through the CAM stuff I can afford and then go back and tweak it so it will work. I was just going to write it line by line, but then I ran across a reference to routines or subroutines that seemed to indicate you could do reiterative work with Mach 3 compatible g-code.

I do not mind buying a book. I'm not looking for a freebie or a handout.

Specifically it seems to wasteful and confusing to repeat the same code over and over to cut a pocket. It seems it would be a lot easier to increment Z and go back to the same code instead.

• posted

CNC Programming Handbook, 2nd Edition by Peter Smid

Wes

• posted

You're talking about parametric programming. Pretty useful stuff. Look for info on Fanuc Macro B. Here's one that cuts the teeth for a three jaw chuck jaws:

%LAPPER = 0 %ZDEPTH = 0.5000

%START: %COUNTER = 0 %ZDEPTH = %ZDEPTH + 0.025 *;DEPTH OF CUT FOR EACH PASS %LAPPER = %LAPPER + 1

G92 X 0.00 Y 0.00 Z %ZDEPTH G90 G00 X 0.000 Y -0.250 Z 0.00

%LOOP: %COUNTER = %COUNTER + 1

G42 T 02 G01 X 0.008 Y 0.000 F 3.0 G01 X 0.122 Y 0.000 G03 X 0.096 Y 0.750 I -1.304 J 0.330 G01 X 0.000 Y 0.750 G02 X 0.008 Y 0.000 I -3.986 J -0.420 G01 X 0.008 Y -0.125 G01 G 40 X 0.2857 Y -0.25 G92 X 0.000 Y -0.25 Z 0.00

IF (%COUNTER LE 9) GOTO %LOOP

G54 G00 X 0.00 Y 0.00 Z 0.00

IF (%LAPPER LE 5) GOTO %START *;DO ALL TEETH 5 TIMES

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.