Help - G-Code Circular Motion for CNC Milling

I need a little bit of help with making some CNC parts. I know very basic CNC code and setup, but I have not yet learned how to program to go in a circle. I am only hand coding by the way, no MasterCAM. I want to make some bearing bores (like 1.125" in 1/4" plate). I can send a CAD/Inventor file of the plate if needed. I would like to learn how to do this by using the raw G-Code. Also, if there is an easy way to do text by raw code, I’d like to know that as well. The machine is a HAAS if it makes any difference.

Also, if someone would like to make a CNC program in MasterCAM to make a shifting dog (that I made the Inventor model for) and mating gears, I would be very grateful and perhaps willing to send a shifting dog to the writer of the program once successfully machined.


From what I remember in my CNC class a few years ago, G Codes make circles by defining a center point and a radius. I think…

I’ll see if I can track down my book and give you a better answer.

I know we had to hand type a program to make our first name in block letters and then make a program that included the radii of the letters, which was fairly simple if I recall correctly.

Let’s see …

G02 = circular interpolation (clockwise)
G03 = circular interpolation (counter-clockwise)

Ok … let’s see if I remember this. We’ll start with an arc.

You first have to identify the point at which you want to start your arc. We’ll use (1,4) as our starting point.

The next step is the trickiest - you need to determine what the center point of your circle will be. mapping the whole thing out on graph paper is the easier way to do it, because then you can calculate the radius and you’ll know where the centerpoint is (without a whole lot of trial and error on the actual part)

the coordiantes for your center point are your (I,J) coordinates. The beginning and end points will always be (X,Y) coordinates

Then, you need to identify your end point. We’ll go with a quarter of a circle, which will put us at (6,1)

make sure that there is an equal distance from the center point to your beginning and end points! Otherwise, your mill will hate you and make your part look funny

For example:

N08 G01 X1 Y4 ------ will move your cutter to (1,4)

N09 G02 X4 Y7 I4 J4 ------- (4,4) - your (I,J) coordinates - is your center point. the cutter will move in a clockwise position until it hits (4,7) - your (X,Y) coordinates.

If you want a larger arc, change your (X,Y) coordinates.

For example:

N09 G02 X7 Y4 I4 J4 — will give you half a circle.
N09 G02 X4 Y1 I4 J4 — will give you three quarters of a circle.
N09 G02 X1 Y4 I4 J4 — will give you a full circle.

Of course, you’ll have to tweak this a bit to get the exact size circle you want and such but … I hope this helped! (If you want a drawing, PM me!)

That helps a lot. Now how do I do this while moving downward? I don’t want to take a 1/4" cut all at once of course. I could put like a G01 Z-.03 before the G02 code and then a G01 Z-.06 after and so on and so forth. Or is there a better way to do this? I know with G01 if you put like X1 Y1 Z-.5 it will ramp down until the Z axis reaches final depth of -.5 at X1 Y1. Is there a way to put G01 and G02 in the same line so the circle will like spiral down?

Mainly, I could just move the Z axis down a bit after running in a circle and then repeat but I think doing that would not make for a very nice bearing bore.

Any ideas?

How would could you use a MasterCam program if you don’t have the actual software?

Well, I’d be able to load it into the machine and run my part right?

don’t you have to use mastercam to export it to the machine?

I don’t think so. Can’t you just make an NC file and save it one a floppy. The machine has a floppy drive for importing and exporting files.

Anyway, can we get back to how to bore a bearing hole in 1/4" plate. Katie said how to do the circle, but I need to know how to go down at the same time. Any help?


Any chance you can get your hands on a reamer of the correct size? If so, the initial downward cut shouldn’t make a difference. If not, I suggest that you try dropping the z in increments. You might be surprised at the results if your speeds and feeds are correct and your tool is in good shape.

Also, I would check out the HAAS website for their operator manual. That might have information on what you want. The other website to check (including their Q&A section under “Resources”) is The guy who does most of this site has written several books on CNC programming, including the issue of parametrics.


I think I have finally found what I need. I just realized that the answer probably was in my HAAS Programming manual so I decided to take a look. What I found was a code called G12. It seems to be just what I need but I have one question. Will it ramp downward?

Here’s the sample code the manual gives:

N1 T1 M06
N2 G90 G54 G00 X2.5 Y2.5 (position to X Y center of cirular pocket)
N3 S1900 M03
N4 G43 H01 Z0.1 M08
N5 G01 Z-0.5 F30. (to feed Z axis slower, or faster, than what’s in the G12 line
N6 G12 Z-0.5 I0.5 D01 F11. (1.0 Dia. x .5 deep circular pocket)
N7 G00 Z1. M09
N8 G53 G49 Y0. Z0.
N9 M30

My question is does line 5 run the cutter down into the part? That would seem a bit odd to me. Another version of the code does not have line 5 and I guess only makes 1 revolution before getting all the way down.

See what I think I want to do is make it go around and around several times constantly ramping down very slowly. Is that right? How do I make it do that? Someone please help.

EDIT: I think I may have a solution. What if I incrementally went down to rought out a little bit smaller hole, and then I absolutely went around to just enlarge it slightly and to get a nice finish. Would that work?


I think you are getting really close. Couple of things. First, you should be able to download a free version of FlashCut CNC Offline and play around with it.

This is the software that my Smithy CNC runs on at home. It will directly import your .DXF file and convert it to G Code for you. As for bringing down the Z while cutting a circle. Make sure your controller is capable of 3 axis circular interpolation. Mine can only cut 2 axis at a time. Therefore I bring the Z down into the part like your line above then start to cut the circle. If you want you can slightly undercut it then make a final circular path to get a smooth dimension. Now would be a good time to find out about the backlash of the machine you are on also since ANY backlash will show up quickly when you cut circles on a CNC mill since your x & y change direction 4 times in the circle. I got so fed up on mine that I just had new ballscrews made and am putting them on this weekend which should clean up a bunch of slop.

Also the Flashcut manual is available for download which has all of the G codes listed and how they work.

Nope. With MasterCam you have to actually have the software to run the programs.

No matter how you create the part (in autocad, inventor, solidworks, mastercam etc) after importing the drawing into Mastercam, you simply use a post processor (specific to the mill you are using) to convert the toolpaths etc, into an NC file that the mill can load (which will be in mill-specific g-code, HAAS specific in your case).

You seem like you have learned alot already. :cool:

Hehe, I deleted my post above because afterwards I feared I could indeed be the one who was wrong but now that you have cleared that up, apparantly I was not. Anyway, it’s not important who was wrong or right, just that we all learned something in the process.

No worries, thanks for asking though. I got it all figured out and have made my beautiful part. :slight_smile:

lol, ok, i’m taking classes on mastercam at the actual CNC Software Inc.