Quick Question on the G-Code - G3 and K, and 3D Milling

This forum is dedicated to those Hobbyists Interested in CNC machining & 3D Printing in their home shops. (Digital Read Outs are also topical, as is CAD/CAM as it relates to CNC)

Moderator: Harold_V

User avatar
Dave_C
Posts: 960
Joined: Mon Apr 21, 2008 10:34 am
Location: Springfield. MO.

Re: Quick Question on the G-Code - G3 and K, and 3D Milling

Post by Dave_C »

CTWO,

You posted this from above:

{N16S3400M03}

Mach 3 used N in front of every line to designate the line number. So the above line is

"N16 is" line 16, "S3400" is you spindle speed and "M03" is you command for forward spindle.

It seems a bit odd they have no spaces because Mach3 post the same line for me as this:

N16 S3400 M03

It still works the same without the spaces.

Dave C.
I learn something new every day! Problem is I forget two.
User avatar
ctwo
Posts: 2996
Joined: Tue Mar 27, 2012 12:37 pm
Location: Silly Cone Valley

Re: Quick Question on the G-Code - G3 and K, and 3D Milling

Post by ctwo »

Thanks Dave. I eventually discovered the line numbering, but did not know about spindle speed setting yet, so I am reading the Mach3 manual and CNCCookbook site. I discovered that you can do looping and if/then type statements. Cool!
Standards are so important that everyone must have their own...
To measure is to know - Lord Kelvin
Disclaimer: I'm just a guy with a few machines...
RET
Posts: 960
Joined: Wed Jun 07, 2006 8:36 am
Location: Toronto, Canada

Re: Quick Question on the G-Code - G3 and K, and 3D Milling

Post by RET »

Hi ctwo,

As a working example, here is the first of three programs I use for the top of the side plate that I'm making in "Richard's latest project."

%
(Machining top side of Side Plate for Large Riding Truck finished thickness .9375")
(Use 3/8" dia. end mill .75" long, depth of cut .050," max .060" possible)
(Spindle speed #7.0 - not below 5.8 - with belt on large pulley step. Higher rpm. is better with 2 flutes)
(Home is at center of truck on axle center line)
g 40 g 0 g 90
x0 y0 z0
(machining to upper face of truck side)
g0 x 3.05 y -1.625
z -1.025
g1 z -1.0755 f .163
g1 x -3.86 y -1.625 f 2.0
g1 x -3.86 y 1.35
g1 x -3.76 y 1.45
g1 x -3.86 y 1.35
g1 x -6.26 y 1.35
g0 z 0
x -6.26 y -1.65
z -1.025
g1 z -1.0755 f .2
g1 x -6.266 y 1.35 f 2.0
g1 x -5.4 y 1.70
g1 x 5.4 y 1.70
g1 x 6.266 y 1.35
g1 x 6.266 y -1.35
g0 z 0
x 6.266 y 1.35
z -1.025
g1 z -1.0755 f .2
g1 x 3.66 y 1.35 f 2.0
g1 x 3.86 y 1.35
g1 x 3.86 y -1.35
g1 x 3.86 y -1.29
g1 x -3.59 y -1.29
g1 x -3.5 y -1.29
g1 x -3.5 y 1.355
g1 x 3.52 y 1.355
(raise surface for center support on this pass)
g1 x 3.52 y -1.035
g1 x 3.5 y -.995
g1 x 2.125 y -.995
g1 x 1.375 z -.75
g1 x -1.375 z -.75
g1 x -1.885 z -.9688125 f .45
g1 x -2.125 z -1.0755 f .15
g1 x -3. 26 y -.995 f 2.0
g1 x -3.21 y .995
g1 x -3.21 y 1.027
g1 x -3.21 y .997
g1 x 3.26 y .997
g1 x 3.2 y .997
g1 x 3.2 y -.69
g1 x 3.2 y -.65
g1 x 2.0 y -.65
g1 x -2.95 y -.65
g1 x -2.9 y -.65
g1 x -2.9 y .68
g1 x 2.9 y .68
g1 x 2.9 y -.31
g1 x -2.6 y -.31
g1 x -2.6 y 3.62
g1 x 2.6 y .362
g1 x 2.6 y .01
g1 x - 2.35 y .01
g0 z 0
x 0 y 0 z 0
%

Unfortunately I couldn't cut & paste it, I had to copy all this in! Yes, you don't have to put g1 in line after line or repeat coordinates that don't change, but I do that because it makes it easier to understand when you go back six months or a year later. If anyone is interested, where the code goes out a bit & then returns, that is done to remove the little leftovers that are produced in the corners because the cutter is round.

What I'm doing with all the g1's is making a rectangular spiral to cover the flat surface. In the part where the section is raised, the cutter doesn't mind going up, but it really doesn't like going down, so that part has to be done quite slowly to reduce the chatter.

Hi hwboivin3 The blue arrow is pointing the wrong way for the curve labelled G3. The way its pointing, the curve is actually G2 like the one on the next face of the cube.

Hope this helps.

Richard Trounce.
hwboivin3

Re: Quick Question on the G-Code - G3 and K, and 3D Milling

Post by hwboivin3 »

RET wrote:
As a Hi hwboivin3 The blue arrow is pointing the wrong way for the curve labelled G3. The way its pointing, the curve is actually G2 like the one on the next face of the cube.

Hope this helps.

Richard Trounce.

The arrow and G3 are correct. It's a counterclockwise move from the Y+ view. What's misleading is that the view of the diagram is from the Y- side. Think of it like a clock and you were inside the clock looking out. All of the G2 and G3 commands are based off the + side looking towards the - side. The arc on the XZ plane is viewed from the Y+ side.......so if you're at the Bridgeport.....walk behind it, look at your part......that's how it's programmed. When You're at a mill you are looking down at the part (Z+ side). If you stand at the right side and look at the part, you're looking from the X+ side. But when you're at the machine looking in front of you, you are on the Y- side. Opposite of where it the G2 and G3 are programmed to mill an arc with X and Z.
hwboivin3

Re: Quick Question on the G-Code - G3 and K, and 3D Milling

Post by hwboivin3 »

One thing about using R instead of I,J and K is that with using R, you're milling an arc using a start point, end point and radius. This will work for certain things, but not for all. It is best to use your I,J and K. Using these, you're defining you're center point of circle. So you have a start point, end point and center point. "I" is your incremental distance from your "X" start point. "J" is your incremental distance from your "Y" start point. "K" is your incremental distance from your "Z" start point (G18/G19).

G17 uses X and Y coordinates with I and J as center points
G18 uses X and Z ......with I and K
G19 uses Y and Z.....with J and K.


Attached is a picture of a simple code. Starting from X,Y zero....moves to end and then comes back.

First sketch shows your X and Y numbers
2nd sketch shows I and J needed for the G2 line
3rd sketch shows I and J need for the G3 Line


It is possible with certain geometry to make a mistake using R instead of I and J.

As a rule of thumb, if I use R and my arc is over 90 degrees, I use multiple lines. So if I was to do a complete circle using R, I'd have 4 lines. Using I and J, you'd only need one line.
Attachments
WP_20160121_002.jpg
Last edited by hwboivin3 on Thu Jan 21, 2016 11:49 pm, edited 1 time in total.
hwboivin3

Re: Quick Question on the G-Code - G3 and K, and 3D Milling

Post by hwboivin3 »

ctwo,


you're sine coordinates are the only way to program what you wanted to do.......without software.

I did a similar part before I learned cam software. It was a smokestack base for a locomotive. I couldn't use the sine numbers because the part had 4 lugs around the diameter. I drew a top view and side view and figured out the points (xyz) for every .005 increment in a 90 degree section, then reversed them to get 180 and then mirrored to get 360. It took a long time to write it! But, it worked and I learned a lot by doing that.
hwboivin3

Re: Quick Question on the G-Code - G3 and K, and 3D Milling

Post by hwboivin3 »

Here's the difference between using I,J instead of R.

Both are .500 R, but without defining center of circle or doing 4 lines with R, you could get the path on the right.


not to hijack you're topic. :shock:
Attachments
WP_20160121_003.jpg
User avatar
ctwo
Posts: 2996
Joined: Tue Mar 27, 2012 12:37 pm
Location: Silly Cone Valley

Re: Quick Question on the G-Code - G3 and K, and 3D Milling

Post by ctwo »

hwboivin3, not a hijack at all, but rather quite on point of my concern. I've been learning so much that there is some I've already forgotten. Such as with line segments too long you can end up with "facets" or what the correct term is now I forgot. I guess one can address that with shorter segments, but at the expense of longer code and run times.
Standards are so important that everyone must have their own...
To measure is to know - Lord Kelvin
Disclaimer: I'm just a guy with a few machines...
User avatar
Bill Shields
Posts: 10459
Joined: Fri Dec 21, 2007 4:57 am
Location: 39.367, -75.765
Contact:

Re: Quick Question on the G-Code - G3 and K, and 3D Milling

Post by Bill Shields »

With 99% of controls, you must tell it which plane is the arc and which is linear, otherwise it is confused as to which is arc and line.

It is typically best if you state the G17/18/19 on a line by itself. With many controls, if you state one of the coordinate plane designators on a line with XY or Z, then you run the risk of actually REDEFINING the orientation of the plane. This is not true with all controls, but it is best to avoid the problem. Mitsubishi has this 'feature' as do many Fanuc controls if you are using G18 as a plane.

R works with many (most?) controls, but many will not take R for an arc / helix greater than 180 degrees, so you should typically break it into quarters to avoid the -R output.

Accuracy of R vs IJK is not really an issue for the past 15-20 years, nor is speed of calculation (assuming that the guy that wrote the core code knows what he is doing). Single 360 degree circles can be programmed using -R<RADIUS> values which tells the control that the arc is = or greater than 180 degrees.

Some controls will not take helical moves in combination with G41/G42. Some controls have Helical as a $$$ option (Fanuc is one).

Note: Just because you have a CAM program does not mean that it is giving you the correct output. Many people that write processors for CAM do not understand (or know about) many of the items I have mentioned.

In short -> breaking these types of moves into 'itty bitty lines' gets around most of the problems. The only thing you then have to worry about it 'big files'...and ensuring that you set the software correctly so that your 'chord deviation' stays within your desired tolerances.

RET: you can get around the COMP ON / OFF linear move by programming the 'theoretical diameter' tool and using G41/42 to account for 'wear' only. Using this technique, you can often get away with small lead in / out moves (on the order of 0.010" or so without worrying about math errors)...assuming that your programmed tools are close to 'actual' tools.

VERY few controls will allow comp on / off in an arc (I know of only one).

Very few controls offer, and fewer yet actually DO 3D cutter comp correctly, so for something like this you set the tool, calculate path to the theoretical diameter origin and have at it.

Note about IJK:

They are not ALWAYS incremental.

If you are running a FANUC or MITSUBISHI, that is true -> and many controls copy this convention, but it is by no means an 11th commandment.

Some controls IJK follow the general coordinate mode, so if you are in ABSOLUTE mode, then IJK are ABSOLUTE.

If you are in incremental, then IJK are incremental.

FAGOR is one control that comes to mind that works in that manner.

Siemens controls can be programmed with any type of mixed coordinate sets -> any coordinate in a line can be ABSOLUTE or INCRMENTAL by specifying the address correctly...so you can have ABSOLUTE X, Incremental Y, ABSOLUTE IJ and incremental Z for the helical motion....all in the same line.

To a limited extent, you can do the same with FANUC controls setup using the LATHE programming structure...using XYZ, UVW you can mix / match absolute and incremental coordinates all in a line...however arc centers will always be incremental.
Too many things going on to bother listing them.
Post Reply