|
The Dreaded G2 and G3
"We're captive on the
carousel of time
We can't return, we can only look behind
From where we came
And go 'round and 'round
In the circle game"
Joni
Mitchell - The Circle Game © 1966 Crazy Crow Music
Many people seem to have trouble understanding how G2 (Circle) commands are
used but, if you know the specific format required by your machine tool's
controller, it's really not that complicated.
You can usually assume that a G2 makes a clockwise arc and a G3 makes a
counterclockwise arc, and that G2 and G3 will have the same format - whatever it
happens to be. We will generally describe G2 only and you can assume that G3 is
the same.
Important - This page
is intended as a general introduction only. It may help if you are having
trouble understanding the explanation in your machine tool manual. In all cases,
the manual should be consulted and the manufacturer's information should be
used for any actual programming.
A typical case - XY plane and incremental center (X, Y, I, and J)
This section covers the use of G2 to make arcs in the X-Y plane on
controllers that use incremental center coordinates.
Center location method: Incremental
using I and J Controller modes: G90 (Absolute coordinates) G17 (XY plane circles)
Example:

G1 X1.375 Y0.25 (GO TO START OF ARC)
G2 X1.75 Y-0.125 I0 J-0.375 (CLOCKWISE CIRCULAR MOVE)
The G1 positions the tool at the start of the arc. The G2
drives the arc to the coordinate position specified by X and Y. The center point
is specified by I and J coordinates. I is measured along the X axis and J along
the Y axis. These are incremental values from the start point - in other words,
they are the distance from the start point to the center along X and Y. I is
zero because the start and center points have the same X value, and J is
negative because the center point is in a negative direction on the Y axis.
Note that Z values have been ignored. We are assuming that
Z was set prior to the G1 linear move and we are creating a 2D arc so the Z
value, whatever it is, remains the same throughout.
A fairly common case - XY plane and a radius (X, Y, and
R)
This section covers the use of G2 to make arcs in the X-Y plane on
controllers that let you specify the arc radius with an R-word.
Center location method: R word Controller modes: G90 (Absolute coordinates) G17 (XY plane circles)
Example:

G1 X1.375 Y0.25 (GO TO START OF ARC)
G2 X1.75 Y-0.125 R0.375 (CLOCKWISE CIRCULAR MOVE)
The G1 positions the tool at the start of the arc. The G2
drives the arc to the coordinate position specified by X and Y. The center point
is calculated based on the radius which is specified in the R0.375.
It looks almost too easy - what's the catch?
There are a several things to consider.
1. If you need to program a 360° circle, you probably can't use an R-word -
you'll need to use I and J.
2. You are defining an arc using two points and a radius so there are two
possible arcs that will fit your values - you need to tell the control which one
you mean. This is done by using a positive R value if the arc is less than 180
degrees and a negative R value is greater than 180 degrees. The figure shows the
path generated with
G2
X1.75 Y-0.125 R0.375 (UNDER 180 DEG) and
G2 X1.75 Y-0.125 R-0.375 (OVER 180 DEG)
3. If the arc is exactly 180 degrees, you have a choice to make. You can try
a positive value and see what happens (best to "cut air" for this and
a bit of prayer won't hurt) or
you can, and should, break the arc into two segments and program it in two
moves.
Special cases - Quadrants and complete circles
Some controllers will not handle arcs that pass through an "axis
crossover point" (a quadrant boundary - 0, 90, 180, 270 degrees.) If this
is the case, you need to break the arc at these points. This may be a nuisance
but isn't too difficult. Many people recommend doing this for all arcs,
regardless of controller capabilities, and many postprocessors offer the option
to do it automatically. Also, see if your controller uses a G-code for this,
usually a G75 for "multi-quadrant" mode which is cancelled by a G74. A
bit of needless info - the "axis crossover" restriction usually
relates to motors having to change direction at this point.
Example:

G1
X1.1053 Y0.1355
G2 X1.375 Y0.25 I0.2697 J-0.2605
G2 X1.75 Y-0.125 I0 J-0.375
G2 X1.6887 Y-0.3305 I-0.375 J0
The G1 positions the tool at the start of the arc. The G2's
drive the arc to the quadrant boundaries and the end positions specified by X and Y. The center point
is specified by I and J coordinates. I is measured along the X axis and J along
the Y axis. These are incremental values from the start point of each arc
segment. Don't forget that the controller sees this as three separate arcs,
not just one. Most controllers would not require that the "G2" be
repeated in each block above.
Regarding complete circles - some controllers handle them and some don't. A
controller that can process multi-quadrant arcs may accept an arc end point that
is identical to the current tool position and machine a complete circle. Others
may do nothing, and others may throw an error condition. If you have any doubt
about the capabilities, break the circle into pieces and cut each arc
separately.
Some exceptions - Check your manual
Many controls require an absolute circle center via I and J rather than
incremental values. This can be easier to deal with. Be careful if in G91 mode
because the centers are probably going to shift to incremental also.
Some controls use a P-word instead of R for an arc radius.
Be careful if omitting I or J words from a G2 or G3. Some controls allow
this, some don't, and some depend on the prevailing mode (G90 or G91).
Planes other than XY
On many machines, G2 and G3 commands can be used to drive arcs in the ZX and
YZ planes. G18 is usually used to switch to the ZX plane and G19 selects the YZ
plane. Don't forget, though, that to make a circular feature on a part in these
planes using a 3 axis machine the tool path itself won't be circular unless an
angled head is used.

A G2 causes clockwise motion as viewed from the positive direction of the perpendicular
axis and the figure reflects this.
In the XY plane, I and J are used to locate the center of the arc and are
measured along X and Y. To locate the arc center in the YZ or ZX planes, a
K-word is used, measured along the Z axis. Therefore, I and K are used in the ZX
plane and J and K are used in YZ.
G17 is used to reselect the XY plane and is usually the default mode for
machining centers.
Lathes
Use of G2 and G3 on a lathe is similar to their use on a machining center,
although tool shape is more of a consideration. A 2 axis lathe operates in the
ZX plane, of course, and uses the I and K words for center location.

The figure shows a simple case using an imaginary tool tip as a reference
point. The nose radius is 0.0625. The program fragment below follows the part
profile, accounting for insert geometry.
G1
Z1.6875
G2 X0.9375 Z1.6875 I1.6875 K0
G1 X1.5 (GO PAST)
Note that the G2 direction is "backwards" based on normal G18
conventions. This just illustrates how important it is to read the programming
manual applicable to the machine being programmed. If we programmed this move
using the center point of the nose radius, the instructions would be more like
previous examples although the setup would be different.
Cutter Compensation
Cutter (radius) compensation can generally be used for G2 and G3 moves just
as for linear moves. Most considerations are the same - you need to be careful
where you turn it on and off and so on. Also, be sure sure that you don't
inadvertently enter a tool radius that is larger than, or even equal to, the
smallest arc radius used in an inside corner.
3D Circular Interpolation
Some machines provide helical interpolation via G2 and G3 commands.
Programming it is pretty straightforward - just include a Z value in the G2/G3
that differs from the starting position. The motion will end with the tool in
the specified Z position. The Z increments will be determined by the number of
actual XY moves to complete the arc. In other words, when the arc is 40 percent
done, so is the Z motion. This can be used for ramping into a pocket or other
approach moves.
Also, some controllers allow a more advanced form of 3D arcs using a
sphere to control depth. An explanation is outside the scope of this page.
So that's all there is to it, then?
No - we've probably forgotten something. But that's why CNC programmers make
those big bucks.
|