You are on page 1of 78

Instrucción G00

Esta instrucción es la que provoca que el movimientos de los carros se efectúe a la máxima
velocidad. Es bien sencilla de entender.
Línea de código:
N0010 G00 X100 Y100 Z300
Aquí se envían los tres ejes a las cotas marcadas en la línea de programa (en el caso de una
fresadora).
Ésta es una de las funciones más peligrosas en el mundo de la programación CNC, debido a
que el movimiento de los carros se efectúa a la máxima velocidad de avance que tenga la
máquina, y muchas veces hay que tener en cuenta cual de los tres ejes llega primero a la
medida. Siempre que se pueda es muy aconsejable realizar este movimiento de alejamiento
en dos fases. La primera alejar la herramienta de la zona comprometida, por ejemplo, si en
Z podemos salir de manera vertical sin tropiezo alguno con ninguna brida o con la misma
pieza, yo llevaría la herramienta hasta una altura Z(lo suficiente como para alejarnos de los
elementos) y luego interpolaria ejes X y Y. Todo esto es válido en el caso de que la
máquina sea una fresadora. Si la máquina es un torno, debemos ser mucho más cautos aún
y tener en cuenta la herramienta que mecaniza y las que estan en el tambor de herramientas.

Instrucción G01

Es una interpolación lineal al avance programado. Normalmente


cuando usamos esta instrucción, lo hacemos para desprender viruta, es decir, realizamos el
mecanizado.
Instrucciones G02 y G03

Para programar una curva, lo primero a realizar es situar la máquina en el punto de inicio
del arco. Antes de continuar muestro como debe quedar el bloque de instrucciones para
realizar la curva.

N0010 G02/G03 X_ Y_ I_ J_

A continuación se detalla lo que es cada cosa:

- G02/G03 Interpolación circular a derechas o a izquierdas, respectivamente.

- X Coordenada "X" del punto final del arco. La cota se puede dar en absolutas o en
incrementales.

- Y Coordenada "Y" del punto final del arco. La cota se puede dar en absolutas o en
incrementales.

- I Distancia en sentido del eje "X", desde el punto inicial del arco hasta el centro del arco.
Esta cota siempre se dará en incrementales.

- J Distancia en sentido del eje "Y", desde el punto inicial del arco hasta el centro del arco.
Esta cota siempre se dará en incrementales.
Por lo tanto según lo arriba expuesto, el bloque para efectuar una curva como la de la figura
seria el siguiente:N0010 G02 X15 Y5 I0 J-5
G02: Interpolación circular a derechas (a la velocidad del avance programado).
X15: Cota X del punto final del arco.
Y5: Cota Y del punto final del arco.
I0: La distancia que hay en sentido del eje "X" desde el punto de inicio del arco hasta el
centro es 0.(Recordad que esta cota siempre será en incrementales, independientemente de
si estamos programando en cotas absolutas o incrementales.)
J-5: La distancia que hay en sentido del eje "Y" desde el punto de inicio del arco hasta el
centro es -5.(Recordad que esta cota siempre será en incrementales, independientemente de
si estamos programando en cotas absolutas o incrementales.)

Instrucción G73 (Ciclo fijo de taladrado rompiendo la viruta)

Los parámetros utilizados en la función G73 para realizar una operación de taladrado en
una fresadora con un control numérico FANUC 21i, son los siguientes:
N0150 G98/99 G73 X_ Y_ R_ Z_ Q_ F_

Donde:
G98 /99: Volver a "Z" de seguridad, es decir, arriba del todo, o al punto de referencia
indicado por el parámetro R.
G90 /91: Programación en cotas absolutas o incrementales.
X: Cota "X" del agujero a mecanizar.
Y: Cota "Y" del agujero a mecanizar.
Z: Profundidad del taladrado.
Q: Profundidad de ajuste.
R: Punto de referencia.
F: Avance.
K: Número de repeticiones.

Un ejemplo del uso de esta función, podría ser el siguiente:


...
N0130 G43 H3 Z10
N0140 G98 G73 X10 Y10 R5.5 Z-15. Q6. F60. (Mecanizado de taladro)
N0150 Y30 (Segundo mecanizado)
N0160 G80 (Anulación del ciclo)
Instrucción G74 (Ciclo fijo de roscado a izquierdas)

Cuando queremos mecanizar un agujero con rosca a izquierdas en un control FANUC 21i,
utilizaremos la función G74. Los parámetros de la función son los siguientes:
G98/99 G74 X_ Y_ R_ Z_ F_

Donde:
G98: Retorna a la Z inicial, es decir, la cota de la última "Z" programada antes del ciclo
fijo.
G99: Retorna la la altura "Z" indicada por el parámetro R del ciclo fijo.
X: Cota "X" del agujero.
Y: Cota "Y" del agujero.
R: Cota "Z" del plano a partir de la cual se inicia el avance con el avance programado.
Z: Profundidad final de la rosca.
F: Avance con el que se efectúa el roscado. Este avance debe estar sincronizado con la
velocidad de giro del cabezal.
Instrucción G28 (Aproximación al punto de referencia)

La función G28 se utiliza para enviar a los eje al punto de referencia pasando por una
posición intermedia, es decir, si programamos N050 G28 X150 Z0, primero se retiraría a la
posición (X,Z) indicada y posteriormente efectuaria la aproximación al punto de referencia.
Los dos movimientos se realizan con el máximo avance, en G00.

Instrucción G71 (Medidas en milímetros)

Esta función se utiliza de idéntica manera que la instrucción G70. Lo único que cuando
programamos G71 le indicamos al control que la representación de las medidas serán en
milímetros.
Cuando arrancamos el control, o utilizamos las funciones auxiliares M30 o M02, o hemos
utilizado el RESET, el control asumirá la instrucción G71 por defecto.
Por lo tanto, los avances serán en mm/min o mm/vuelta, la velocidad de corte en mm/min,
los decalajes, etc...

Instrucción G40

Se utiliza para anular la compensación del radio de la herramienta. Una manera bastante
correcta para utilizar esta función es descompensando ubicando la herramienta perpe

ndicular al ultimo punto. En el siguiente trozo de código de


programa se verá con más claridad.

N0030 G1 X0 Y50
N0040 G0 G40 x-20

Instrucción G41 y G42


Se utiliza fundamentalmente para realizar la compensación
del radio de la herramienta. Ambas funciones son modales. Cuando utilizamos G41,
estamos efectuando una "compensación a izquierdas". ¿Que es todo esto? Pues bien para
introducirnos un poco en el mundo de las compensaciones de radios hay que tener claros
una serie de conceptos:

-¿Cuando debo compensar? Siempre que se contornea. (figura 1)


-¿Dónde debo compensar? Llegados a este punto hay que tener muy clara una idea. En la
figura dos queda reflejada.

La herramienta dibujada en gris oscuro representa el acercamiento de la herramienta a la


pieza antes de realizar la compensación, es decir, N.... G0 X-10 Y8. Una vez la herramienta
en esta posición es cuando debemos realizar la compensación (ya sea a derechas o a
izquierdas). Requisito fundamental para no tener problemas, es dejar como mínimo una
distancia entre ejes de más de 1 milímetro entre la posición actual de la herramienta
(herramienta gris oscuro) y la futura posición que ocupará la herramienta (herramienta gris
claro). Veamos como quedaría el pequeño código de programa para realizar el
acercamiento y la compensación:

N0010 G0 X-10 Y8 (llevamos la herramienta a la posicion que ocupa la herramienta de


color gris oscuro)
N0020 G1 G41 X0 Y8 (aqui estamos en la posición que ocupa la herramienta de color gris
claro).

Antes de continuar cabe remarcar que cuando digo "acercamiento de la herramienta a...",
doy por supuesto de que siempre vamos a tener en cuenta que no haya colisión con ningún
elemento de la máquina o con la misma pieza. SIEMPRE debe quedar este concepto en nue

stra cabeza. A pie de máquina es donde veremos la realidad,


por lo tanto, siempre debemos pensar como si estuviésemos delante de una máquina. Creo
que es la mejor filosofía, ya que de lo contrario podríamos llevarnos alguna que otra
sorpresa un tanto desagradable el día que estemos delante de una máquina de control
numérico.
Resumiendo se podria decir que utilizaremos G41 cuando en el sentido del mecanizado se
tiene que compensar el radio de la herramienta a la izquierda del material. De lo contrario
usaremos G42 cuando en el sentido del mecanizado se tenga que compensar el radio de la
herramienta a la derecha del material.

Instrucción G43 (Compensación de longitud)

Mediante esta función podemos compensar diferencias de longitud existentes entre la


herramienta programada y la herramienta que vamos a utilizar. La compensación se efectúa
en referencia al parámetro D00-D99 en el caso de controles 8050 y en el caso de controles
8025 .00-.99. Por ejemplo T1 D1 la compensación se efectuará en relación al parámetro D1
de la tabla de herramientas.

Siempre se aplica dicha compensación al eje perpendicular al plano principal. G43 es una
función modal.

Instrucción G53-59 (Traslado de origen)

Básicamente y en pocas palabras podríamos decir


que estas funciones están directamente relacionadas con los decalajes. Sirven para guardar
traslados de origen siempre referidos al cero de referencia (cero de máquina). Es decir, las
cotas que introduzcamos en estos decalajes, es la distancia existente entre el cero de

referencia y el nuevo cero de pieza (con respecto a todos


los ejes).

Se pueden tener varios ceros de pieza (guardados en G53 hasta G59). En la figura de la
derecha OM seria el cero de referencia y OP el traslado del origen.
La forma de indicar al control el traslado de origen es la siguiente:
En cotas absolutas: N010 X_ Y_ Z_
En cotas incrementales: N010 I_ J_ K_
Estos mismos valores pueden estar almacenados en la memoria del control mediante la
tabla de decalajes.

Programación en cotas incrementales

La función G91 nos permite programar en cotas


incrementales. A diferencia que en las cotas absolutas, el punto de origen de la pieza no
tiene relevancia. Para representar en incremental una cota, basta con reflejar la distancia
existente entre un punto inicial y un punto final. Para entenderlo de una forma diferente se
podría decir que cuando programas en incremental, el ultimo punto donde ha llegado la
herramienta se convierte en el cero pieza. La representación del siguiente punto irá en
funcion de la distancia con respecto a éste.

Programación en cotas absolutas

La función G90 nos permite programar en cotas absolutas. Y....


¿Que quiere decir eso de cotas absolutas?. Pues es bien sencillo. Todas las cotas que se
indiquen en los bloques del programa, tienen siempre una misma referencia. La referencia
es el cero de pieza (0,0).
CNC machines work by following the commands or instructions (G-codes / M-codes)
which are given in Part Program. Here are G-codes for Fanuc cnc control which are
necessary for a cnc machinists to learn to understand cnc programming.

Contents

 Fanuc G-Code List (Lathe)


 Fanuc G-Code List (Mill)

Fanuc G-Code List (Lathe)


G code Description
G00 Rapid traverse
G01 Linear interpolation
G02 Circular interpolation CW
G03 Circular interpolation CCW
G04 Dwell
G09 Exact stop
G10 Programmable data input
G20 Input in inch
G21 Input in mm
G22 Stored stroke check function on
G23 Stored stroke check function off
G27 Reference position return check
G28 Return to reference position
G32 Thread cutting
G40 Tool nose radius compensation cancel
G41 Tool nose radius compensation left
G42 Tool nose radius compensation right
G70 Finish machining cycle
G71 Turning cycle
G72 Facing cycle
G73 Pattern repeating cycle
G74 Peck drilling cycle
G75 Grooving cycle
G76 Threading cycle
G92 Coordinate system setting or max. spindle speed setting
G94 Feed Per Minute
G95 Feed Per Revolution
G96 Constant surface speed control
G97 Constant surface speed control cancel

Fanuc G-Code List (Mill)


G code Description
G00 Rapid traverse
G01 Linear interpolation
G02 Circular interpolation CW
G03 Circular interpolation CCW
G04 Dwell
G17 X Y plane selection
G18 Z X plane selection
G19 Y Z plane selection
G28 Return to reference position
G30 2nd, 3rd and 4th reference position return
G40 Cutter compensation cancel
G41 Cutter compensation left
G42 Cutter compensation right
G43 Tool length compensation + direction
G44 Tool length compensation – direction
G49 Tool length compensation cancel
G53 Machine coordinate system selection
G54 Workpiece coordinate system 1 selection
G55 Workpiece coordinate system 2 selection
G56 Workpiece coordinate system 3 selection
G57 Workpiece coordinate system 4 selection
G58 Workpiece coordinate system 5 selection
G59 Workpiece coordinate system 6 selection
G68 Coordinate rotation
G69 Coordinate rotation cancel
G73 Peck drilling cycle
G74 Left-spiral cutting circle
G76 Fine boring cycle
G80 Canned cycle cancel
G81 Drilling cycle, spot boring cycle
G82 Drilling cycle or counter boring cycle
G83 Peck drilling cycle
G84 Tapping cycle
G85 Boring cycle
G86 Boring cycle
G87 Back boring cycle
G88 Boring cycle
G89 Boring cycle
G90 Absolute command
G91 Increment command
G92 Setting for work coordinate system or clamp at maximum spindle speed
G98 Return to initial point in canned cycle
G99 Return to R point in canned cycle

Fanuc 31i G Codes


G Code Description
G00 Positioning (rapid traverse)
G01 Linear interpolation (cutting feed)
G02 Circular interpolation CW or helical interpolation CW
G03 Circular interpolation CCW or helical interpolation CCW
G02.2,
Involute interpolation CW/CCW
G03.2
G02.3,
Exponential interpolation CW/CCW
G03.3
G02.4,
Three-dimensional coordinate conversion CW/CCW
G03.4
G04 Dwell
G05 AI contour control (high-precision contour control compatible command)
G05.1 AI contour control / Nano smoothing / Smooth interpolation
G05.4 HRV3,4 on/off
G06.2 NURBS interpolation
G07 Hypothetical axis interpolation
G07.1
Cylindrical interpolation
(G107)
G08 AI contour control (advanced preview control compatible command)
G09 Exact stop
G10 Programmable data input
G10.6 Tool retract and recover
G10.9 Programmable switching of diameter/radius specification
G11 Programmable data input mode cancel
G12.1 Polar coordinate interpolation mode
G13.1 Polar coordinate interpolation cancel mode
G15 Polar coordinates command cancel
G16 Polar coordinates command
G17 XY plane selection
G18 ZX plane selection
G19 YZ plane selection
G20 (G70) Input in inch
G21 (G71) Input in mm
G22 Stored stroke check function on
G23 Stored stroke check function off
G25 Spindle speed fluctuation detection off
G26 Spindle speed fluctuation detection on
G27 Reference position return check
G28 Automatic return to reference position
G29 Movement from reference position
G30 2nd, 3rd and 4th reference position return
G30.1 Floating reference position return
G31 Skip function
G31.8 EGB-axis skip
G33 Threading
G34 Variable lead threading
G35 Circular threading CW
G36 Circular threading CCW
G37 Automatic tool length measurement
G38 Cutter or tool nose radius compensation : preserve vector
G39 Cutter or tool nose radius compensation : corner circular interpolation
Cutter or tool nose radius compensation : cancel
G40
Three-dimensional cutter compensation : cancel
Cutter or tool nose radius compensation : left
G41
Three-dimensional cutter compensation : left
G41.2 Cutter compensation for 5-axis machining : left (type 1)
G41.3 Cutter compensation for 5-axis machining : (leading edge offset)
Cutter compensation for 5-axis machining : left (type 1) (FS16i-compatible
G41.4
command)
Cutter compensation for 5-axis machining : left (type 1) (FS16i-compatible
G41.5
command)
G41.6 Cutter compensation for 5-axis machining : left (type 2)
G42 Cutter or tool nose radius compensation : right
Three-dimensional cutter compensation : right
G42.2 Cutter compensation for 5-axis machining : right (type 1)
Cutter compensation for 5-axis machining : right (type 1) (FS16i-compatible
G42.4
command)
Cutter compensation for 5-axis machining : right (type 1) (FS16i-compatible
G42.5
command)
G42.6 Cutter compensation for 5-axis machining : right (type 2)
G40.1 Normal direction control cancel mode
G41.1 Normal direction control on : right
G42.1 Normal direction control on : left
G43 Tool length compensation +
G44 Tool length compensation -
G43.1 Tool length compensation in tool axis direction
G43.4 Tool center point control (type 1)
G43.5 Tool center point control (type 2)
G45 Tool offset increase
G46 Tool offset decrease
G47 Tool offset double increase
G48 Tool offset double decrease
G49 (G49.1) Tool length compensation cancel
G50 Scaling cancel
G51 Scaling
G50.1 Programmable mirror image cancel
G51.1 Programmable mirror image
G50.2 Polygon turning cancel
G51.2 Polygon turning
G52 Local coordinate system setting
G53 Machine coordinate system setting
G53.1 Tool axis direction control
G54 (G54.1) Workpiece coordinate system 1 selection
G55 Workpiece coordinate system 2 selection
G56 Workpiece coordinate system 3 selection
G57 Workpiece coordinate system 4 selection
G58 Workpiece coordinate system 5 selection
G59 Workpiece coordinate system 6 selection
G60 Single direction positioning
G61 Exact stop mode
G62 Automatic corner override
G63 Tapping mode
G64 Cutting mode
G65 Macro call
G66 Macro modal call A
G66.1 Macro modal call B
G67 Macro modal call A/B cancel
Coordinate system rotation start or 3-dimensional coordinate conversion
G68
mode on
Coordinate system rotation cancel or 3-dimensional coordinate conversion
G69
mode off
G68.2 Feature coordinate system selection
G72.1 Figure copy (rotation copy)
G72.2 Figure copy (linear copy)
G73 Peck drilling cycle
G74 Left-handed tapping cycle
G76 Fine boring cycle
G80 Canned cycle cancel
G80.5 Electronic gear box 2 pair: synchronization cancellation
G80.8 Electronic gear box: synchronization cancellation
G81 Drilling cycle or spot boring cycle
G81.1 Chopping
G81.5 Electronic gear box 2 pair: synchronization start
G81.8 Electronic gear box: synchronization start
G82 Drilling cycle or counter boring cycle
G83 Peck drilling cycle
G84 Tapping cycle
G84.2 Rigid tapping cycle (FS15 format)
G84.3 Left-handed rigid tapping cycle (FS15 format)
G85 Boring cycle
G86 Boring cycle
G87 Back boring cycle
G88 Boring cycle
G89 Boring cycle
G90 Absolute programming
G91 Incremental programming
G91.1 Checking the maximum incremental amount specified
G92 Setting for workpiece coordinate system or clamp at maximum spindle speed
G92.1 Workpiece coordinate system preset
G93 Inverse time feed
G94 Feed per minute
G95 Feed per revolution
G96 Constant surface speed control
G97 Constant surface speed control cancel
G98 Canned cycle : return to initial level
G99 Canned cycle : return to R point level
G107 Cylindrical interpolation
G112 Polar coordinate interpolation mode
G113 Polar coordinate interpolation mode cancel

Fanuc M-Code List (Lathe)


M code Description
M00 Program stop
M01 Optional program stop
M02 End of program
M03 Spindle start forward CW
M04 Spindle start reverse CCW
M05 Spindle stop
M08 Coolant on
M09 Coolant off
M29 Rigid tap mode
M30 End of program reset
M40 Spindle gear at middle
M41 Low Gear Select
M42 High Gear Select
M68 Hydraulic chuck close
M69 Hydraulic chuck open
M78 Tailstock advancing
M79 Tailstock reversing
M94 Mirrorimage cancel
M95 Mirrorimage of X axis
M98 Subprogram call
M99 End of subprogram
Fanuc M-Code List (Mill)
M code Description
M00 Program stop
M01 Optional program stop
M02 End of program
M03 Spindle start forward CW
M04 Spindle start reverse CCW
M05 Spindle stop
M06 Tool change
M07 Coolant ON – Mist coolant/Coolant thru spindle
M08 Coolant ON – Flood coolant
M09 Coolant OFF
M19 Spindle orientation
M28 Return to origin
M29 Rigid tap
M30 End of program (Reset)
M41 Low gear select
M42 High gear select
M94 Cancel mirrorimage
M95 Mirrorimage of X axis
M96 Mirrorimage of Y axis
M98 Subprogram call
M99 End of subprogram
Fanuc G68 Coordinate Rotation G-Code makes it easy for cnc machinist to run a pattern of
operations in a rotated angle.
Here is a basic cnc programming Example which helps to understand the actual working of
G68 coordinate rotation.

Fanuc G68 Program Example

T1 M6
G0 G90 G40 G21 G17 G94 G80
G54 X20 Y0 S1500 M3
G43 Z100 H1
Z5
G81 R3 Z-20 F? M8
X30
X45
G68 X0 Y0 R120
X20 Y0
X30
X45
G68 X0 Y0 R240
X20 Y0
X30
X45
G69 G80
G0 G90 Z100 M30

G68 Coordinate Rotation


Fanuc G68 Coordinate Rotation G-Code makes it easy for cnc machinist to run a pattern of
operations in a rotated angle.
In short: By designating a rotation angle with G68 in the program, actual machining will be
performed on the rotated coordinate.

You can specify the Center-point (origin) and Angle-of-rotation, and whole the pattern of
operation will be executed there.

Programming
G68 X…Y… R…

Parameters

Parameter Description
X,Y Centre of rotation.
R Angle of rotation (R+ = Anti-clockwise).

If the X & Y values are not programmed with G68 Coordinate Rotation then the current
tool position becomes the rotation pole center.

G91 Incremental Mode

The X, Y & R are established as incremental values if G68 is specified with a G91 code.

G69 Cancel Coordinate Rotation


The Rotation must be cancelled with G69 when finished.

Programming
G69
Fanuc G72.1 Rotational Copy
Using G72.1 Rotational Copy G-code a figure specified by a subprogram can be repeatedly
produced with Rotational movement.

Contents

 Programming
o Parameters
 Programming Notes
o Notes
o First block of the subprogram
o Limitation
 G72.1 Programming Example

Programming
G72.1 P... L... X... Y... R...

Parameters

Parameter Description
P Subprogram number
L Number of times the operation is repeated
X Center of rotation on the X axis
Y Center of rotation on Y axis
Angular displacement (a positive value indicates a counter clockwise angular
R
displacement. Specify an incremental value.)

G-Code Data

Modal/Non-Modal G-Code Group


Non-Modal 00

Programming Notes
Notes

1. In the G72.1 block, addresses other than P, L, X, Y and R are ignored.


2. P, X, Y and R must always be specified.
3. If L is not specified, the figure is copied once.
4. The coordinate of the center of rotation is handled as an absolute value even if it is
specified in the incremental mode.
5. Specify an increment in the angular displacement at address R. The angular
displacement (degree) for the Nth figure is calculated as follows: Rx(N-1).

First block of the subprogram

Always specify a move command in the first block of a subprogram that performs a
rotational copy. If the first block contains only the program number such as O00001234;
and does not have a move command, movement may stop at the start point of the figure
made by the n-th (n = 1,2, 3, …) copying.
Example of an incorrect program

O00001234 ;
G00 G90 X100.0 Y200.0 ;

;
M99 ;

Example of a correct program

O00001000 G00 G90 X100.0 Y200.0 ;

;
M99 ;

Limitation

Specifying two or more commands to copy a figure


G72.1 cannot be specified more than once in a subprogram for making a rotational copy (If
this is attempted, alarm PS0900 will occur).
In a subprogram that specifies rotational copy, however, linear copy (G72.2) can
be specified. Similarly, in a subprogram that specifies linear copy, rotational copy can be
specified.

Commands that must not be specified


Within a program that performs a rotational copy, the following must not be specified:
Command for changing the selected plane (G17 to G19)
Command for specifying polar coordinates (G16)
Reference position return command(G28)
Axis switching
Coordinate system rotation (G68)
scaling (G51)
programmable mirror image (G51.1)
The command for rotational copying can be specified after a command for coordinate
system rotation, scaling, or programmable mirror image is executed.
Single block
Single-block stops are not performed in a block with G721.1 or G72.2.

G72.1 Programming Example

Main program

O1000 ;
N10 G90 G00 X80. Y100. ; (P1)
N20 Y50. ; (P2)
N30 G01 G17 G42 X43.301 Y25. D01 F100 ;(P3)
N40 G72.1 P1100 L3 X0 Y0 R120. ;
N50 G90 G40 G01 X80. Y50. ; (P2)
N60 G00 X80. Y100. ; (P1)
N70 M30 ;

Sub program

O1100 G91 G03 X-18.301 Y18.301 R50. ; (P4)


N100 G01 X-5. Y50. ; (P5)
N200 G03 X-40. I-20. ; (P6)
N300 G01 X-5. Y-50. ; (P7)
N400 G03 X-18.301 Y-18.301 R50. ; (P8)
N500 M99 ;

Fanuc G72.2 Linear Copy


Using G72.2 Linear Copy G-code a figure specified by a subprogram can be repeatedly
produced with Linear movement.

Contents

 Programming
o Parameters
 Programming Notes
o Notes
o First block of the subprogram
o Limitation
 G72.2 Programming Example

Programming
G72.2 P... L... I... J...

Parameters

Parameter Description
P Subprogram number
L Number of times the operation is repeated
I Shift along X-axis
J Shift along Y-axis

G-Code Data

Modal/Non-Modal G-Code Group


Non-Modal 00

Programming Notes
Notes

1. In the G72.2 block, addresses other than P, L, I and J are ignored.


2. P, I and J must always be specified.
3. If L is not specified, the figure is copied once.
4. For shifts (I, J), specify increments. The n-th geometric shift is equal to the
specified shift times (n – 1).
First block of the subprogram

Always specify a move command in the first block of a subprogram that performs a linear
copy. If the first block contains only the program number such as O00001234; and does not
have a move command, movement may stop at the start point of the figure made by the n-th
(n = 1,2, 3, …) copying.
Example of an incorrect program

O00001234 ;
G00 G90 X100.0 Y200.0 ;

;
M99 ;

Example of a correct program

O00001000 G00 G90 X100.0 Y200.0 ;

;
M99 ;

Limitation

Specifying two or more commands to copy a figure


G72.2 cannot be specified more than once in a subprogram for making a linear copy (If this
is attempted, alarm PS0901 will occur).
In a subprogram that specifies linear copy, however, rotational copy (G72.1) can
be specified. Similarly, in a subprogram that specifies rotational copy, linear copy can be
specified.

Commands that must not be specified


Within a program that performs a linear copy, the following must not be specified:
Command for changing the selected plane (G17 to G19)
Command for specifying polar coordinates (G16)
Reference position return command(G28)
Axis switching
Coordinate system rotation (G68)
scaling (G51)
programmable mirror image (G51.1)

Single block
Single-block stops are not performed in a block with G721.1 or G72.2.
G72.2 Programming Example

Main program

O3000 ;
N10 G90 G00 X-30. Y0 ;
N20 X0 ;
N30 G01 G17 G41 X30. D01 F100 ; (P0)
N40 Y20. ; (P1)
N50 X40. ; (P2)
N60 G72.2 P3100 L3 I90.0 J0 ;
N70 G90 X310. Y0 ; (P8)
N80 X0 ;
N90 G40 G00 X-30.0 ;
N100 M30 ;

Sub program

O3100 G91 G01 X20. ; (P3)


N100 Y30. ; (P4)
N200 G02 X40. I20. ; (P5)
N300 G01 Y-30. ; (P6)
N400 X30. ; (P7)
N500 M99 ;
Fanuc G73 High Speed Peck Drilling Cycle
Fanuc G73 High Speed Peck Drilling cycle performs high–speed peck drilling. It performs
intermittent cutting feed to the bottom of a hole while removing chips from the hole.

Fanuc G73 High Speed Peck Drilling Cycle is also called Fanuc G73 Chip Break Drilling
Cycle. Fanuc G73 High Speed Peck Drilling Cycle is used on Fanuc control with CNC
Milling machines.

Programming
G73 X Y Z R Q F K

G73 is a modal G codes so remain in effect until canceled.

Parameters
Parameter Description
XY Hole position data
Z Z-depth (feed to Z-depth starting from R plane)
R The distance from the initial level to point R level (Position of the R plane)
Q Depth of cut for each cutting feed (depth of each peck)
F Cutting feedrate
K Number of repeats (if required)

Cycle Operation
The tool dips into the workpiece for the infeed Q, drives back (retraction) 1mm to break
chips, dips in again, until end depth is reached, then retracts with rapid feed. Retraction
Retraction amount can be set in parameter 5114

G98 G99
When G98 is active, the Z-axis will return to the start position (initial plane) when it
completes a single operation. When G99 is active, the Z-axis will be returned to the R point
(plane) when the canned cycle completes a single hole. Then the machine will go to the
next hole. Generally, G99 is used for the first drilling operation and G98 is used for the last
drilling operation

Cancel G73
To cancel Fanuc G73 canned cycle, use G80 or a group 01 G code. Group 01 G codes G00
: Positioning (rapid traverse) G01 : Linear interpolation G02 : Circular interpolation or
helical interpolation (CW) G03 : Circular interpolation or helical interpolation (CCW)
Example Program
The following Fanuc G73 Chip Break Drilling Cycle example code shows how to use G73
drilling cycle and how to use G98 and G99 G-code with G73 cycle.

M3 S2000
G90 G99 G73 X300. Y–250. Z–150. R–100. Q15. F120.
Y–550.
Y–750.
X1000.
Y–550.
G98 Y–750.
G80 G28 G91 X0 Y0 Z0
M5

G74 Reverse Tapping Cycle


Called with many names like
G74 Left-hand tapping cycle, G74 Reverse tapping cycle, G74 Counter tapping cycle etc.
But works the way as G84 tapping cycle works.
As G84 tapping cycle is just for right hand tapping, so cnc machinists can do left-hand
tapping with G74 tap cycle.

Programming
G74 X_ Y_ Z_ R_ F_

Parameters
Parameter Description
X Y Hole position data
Z Z-depth (feed to Z-depth starting from R plane)
R Position of the R plane
F Cutting feedrate

Operation
Tapping with G74 tapping cycle is performed by rotating the spindle counter-clockwise.
When the bottom of the hole has been reached, the spindle is rotated in the clockwise
direction for retraction. This operation creates left hand threads.

Feed Calculation
With Rigid Tapping, the ratio between feedrate and spindle speed must be calculated for
thread pitch being cut. The calculation is 1 Threads Per Inch x rpm = tapping feedrate.
F (Feed) = RPM x Pitch.

Cancel G74
G74 Left-hand tapping cycle G-code is modal, so cancelled with G80 otherwise it will
execute tapping operation on every X and/or Y move.

Use G98 and G99 for the Z position clearance location.

Fanuc G74 Left-hand Peck Tapping Cycle


Fanuc G74 is used for left-hand tapping on cnc mill. Tapping with Fanuc G74 tapping
cycle is performed by rotating the spindle counter-clockwise.
For a complete article about Fanuc G74 tapping cycle read G74 Left-hand Tapping Cycle
or Reverse Tapping Cycle
Fanuc cnc controls gives the cnc machinists the ability to do left-hand tapping with added
benefit of Peck Tapping.
Tapping a deep hole may be difficult due to chips sticking to the tool (tap) or increased
cutting resistance,
So Fanuc G74 peck tapping cycle makes this whole process easier for cnc machinists.

Programming
G74 X Y Z R Q F

Parameters
Parameter Description
X Y Hole position data
Z Z-depth (feed to Z-depth starting from R plane)
R Position of the R plane
Q Depth of cut for each cutting feed (Peck depth).
F Cutting feedrate

G74 Left-hand Tapping Cycle can create a peck at a value of Q?


if programmed with either
a short chip break retraction or
a full retraction
as set in parameter 5200 #5 (1 = full retract).
At Z finish position the tool retracts at twice speed/feed automatically.

Example
S1000
G74 G99 X10. Y10. Z-25. R2. Q5. F1.25 M4
X30.
Y20.
G0 G90 G80 Z100
Fanuc G84 Tapping Cycle

G84 tapping cycle performs tapping operation, tapping is performed by rotating the spindle
clockwise, when bottom of the hole has been reached, the spindle is rotated in the reverse
direction for retraction. This whole operation creates threads.

Contents

 Syntax
o Notes
 Usage
 Working
 G98 G99 Modes
 Repeat Drilling
 Working Example

Syntax
G84 X... Y... Z... R... P... F... K...
Parameter Description
X Hole position in x-axis.
Y Hole position in y-axis.
Z Depth, tapping from R-plane to Z-depth.
R Position of the R plane.
P Dwell time.
Number of cycle repetitions (if required)
K
.
F Feedrate.

Once given in program G84 tapping cycle is repeated at every axis movement until G80 is
given in program to end tapping cycle.

Notes

Feedrate override is ignored during tapping.


Feed-hold does not stop the machine until the return operation is completed.
Usage
N150 M6 T2
N160 G90 G00 X60 Y28 Z12 S100 M03
N170 G99 G84 X60 Y28 Z-17 P300 R2 F120
N180 G98 Y12
N190 G91 G80 G28 X0 Y0 Z0 M05
N200 M30

Working
Brief description of how G84 tapping cycle works,

G84 tapping cycle working

0- CW Spindle rotation command (M03) must be given in part-program.


1- Rapid traverse to X, Y position (pre-drill hole position).
2- Rapid traverse to R-plane.
3- Tapping operation is done till Z-depth (with tapping feed given with G84).
4-1- Dwell for time specified with P
4-2- Spindle is rotated CCW
5- Tap is Retracted with the specified feed.
At R-plane spindle is rotated CW.
If G99 is specified then tapping for this hole ends here,
6- if G98 is given in program then tap is moved to Initial-level.

G98 G99 Modes


After completing tapping the return height can be controlled by using G98 or G99.
G98 Tap will return to the Initial level
G99 Tap will return to R-plane.

G98, G99 can be used multiple times during G84 tapping cycle.

Repeat Drilling
G84 tapping cycle can be repeated multiple times if K value is given.

For working example see G81 drilling cycle.

Working Example

G84 tapping cycle example

N10 T1 M06
N20 G90 G54 G00 X30 Y25
N30 S100 M03
N40 G43 H01 Z5 M08
N50 G84 Z-20 R2 F1.25
N60 X80 Y50
N70 G80 G00 Z100 M09
N80 M30
Fanuc G76 Fine Boring Cycle – CNC Mill
Fanuc G76 Fine Boring Cycle
Fanuc G76 Fine Boring Cycle bores a hole precisely. When the bottom of the hole has
been reached, the spindle stops, and the tool is moved away from the machined surface of
the workpiece and retracted.
Fanuc G76 Fine Boring Cycle is used for enlarging borings with boring and facing
heads, Fanuc G76 Fine Boring Cycle is also called Fanuc G76 Fine Drilling Cycle.

Programming
G76 X Y Z R Q P F K

Parameters
Parameter Description
XY Hole position data
Z Absolute hole depth position
R Position of the R plane
Q Shift amount at the bottom of a hole
P Dwell time at the bottom of a hole
F Cutting feedrate
K Number of repeats (if required)

Operation
When the bottom of the hole has been reached, the spindle is stopped at the fixed rotation
position, and the tool is moved in the direction opposite to the tool tip and retracted. This
ensures that the machined surface is not damaged and enables precise and efficient boring
to be performed.

Be sure to specify a positive value in Q. If Q is specified with a negative value, the sign is
ignored. Set the direction of shift in bits 4 and 5 of parameter 5101.

Bit 5 Bit 4 = Shift


00 X+
01 X-
10 Y+
11 Y-

Example Program
M3 S500
G90 G99 G76 X300. Y–250. Z–150. R–120. Q5. P1000 F120.
Y–550.
Y–750.
X1000.
Y–550.
G98 Y–750.
G80 G28 G91 X0 Y0 Z0
M5
Fanuc G81 Drilling Cycle
Syntax
G81 X... Y... Z... R... K... F...
Parameter Description
X Hole position in x-axis.
Y Hole position in y-axis.
Z Depth, tool will travel with feed to Z-depth starting from R plane.
R Position of the R plane.
Number of cycle repetitions (if required)
K
.
F Feedrate.

Once G81 drilling cycle is defined, the canned cycle is repeated at every X-Y position in
sequential blocks. So G81 drilling cycle must be cancelled with G80.

Usage
N30 G81 X10 Y30 Z-17 R2 F75
N40 Y10
N50 X30
N60 Y30
N70 X90
N80 Y10
N90 G80

In the above example drilling will start with G81 drilling cycle at X10 Y30, so first drill
will be at X10 Y30, then second at Y10, third at X30, fourth at Y30, fifth at X90 and the
last one at Y10, because next block have G80 code, so drilling cycle will no more be
repeated.

Working
Here is briefly described how G81 drilling cycle operates,

1- Rapid traverse to the specified x,y axis position (drilling position).


2- Rapid traverse to the R plane position.
3- Drilling with specified Feed from R-plane position to Z-depth position.
4- Rapid traverse to Initial level or R-plane depends on G98, G99 modes.
G81 drilling cycle working

G98 G99 Modes


After completing drilling depth the return is made with Rapid feed, the return height can be
controlled through using G98 or G99.

G98 Drill will return to the Initial level


G99 Drill will return to R-plane.

G98, G99 can be used multiple times during G81 drilling cycle.

Example
N30 G81 X10 Y30 Z-17 R2 F75
N40 Y10
N50 G98 X30
N60 G99 Y30
N70 X90
N80 Y10
N90 G80

Repeat Drilling
With G81 drilling cycle drilling operation can be repeated multiple times. The drilling is
repeated K times when that parameter is given with G81 drilling cycle.

Repeat drilling is normally used with G91 Incremental mode, and a good example of
repeated drilling is Grid-plate drilling. the example for repeat drilling is given below.

Working Examples
G81 Drilling Cycle Example

N10 T1 M06
N20 G90 G54 G00 X30 Y25
N30 S1200 M03
N40 G43 H01 Z5 M08
N50 G81 Z-10 R2 F75
N60 X80 Y50
N70 G80 G00 Z100 M09
N80 M30

G98 G99 Example


G81 drilling cycle usage with G98 G99

N10 M06 T1
N20 G90 G00 X12.5 Y10 Z12 S1000 M03
N30 G99 G81 X12.5 Y10 Z-17 R2 F75
N40 Y30
N50 G98 X57.5
N60 G99 Y10
N70 G91 G80 G28 X0 Y0 Z0 M05
N80 M30

Repeat Drilling Example


Repeat drilling with G81 Drilling Cycle

T1 M6
G00 G90 G40 G21 G17 G94
G54 X0 Y0 S1000 M03
G43 H1 Z100
Z3
G81 G99 G91 X20 Y20 R3 Z-20 K3 F100 M08
G80
G00 G90 Z100
M30

OR

T1 M6
G00 G90 G40 G21 G17 G94
G54 X20 Y20 S1000 M03
G43 H1 Z100
Z3
G81 G99 R3 Z-20 F100 M08
G91 X20 Y20 K2
G80
G00 G90 Z100
M30
Fanuc G82 Drilling Cycle
G82 drilling cycle is also called G82 counter boring cycle.

G82 is a normal drilling cycle the only difference is that it dwell for specified time at the
bottom of the hole, normally used for accurate depth drilling.

Contents

 Syntax
 Usage
 Working
 G98 G99 Modes
o Example
 Repeat Drilling
 Working Example

Syntax
G82 X... Y... Z... R... P... F... K...
Parameter Description
X Hole position in x-axis.
Y Hole position in y-axis.
Z Depth, tool will travel with feed to Z-depth starting from R plane.
R Position of the R plane.
P Dwell at the bottom of hole.
Number of cycle repetitions (if required)
K
F Feedrate.

Usage
N30 G82 X10 Y30 Z-17 R2 P1000 F75
N40 Y10
N50 X30
N60 Y30
N70 G80

Once G82 drilling cycle is specified with it’s parameters in a program block, this will keep
drilling at every axis movement, until cycle is ended with G80

Working
How G82 drilling cycle works

1- Rapid traverse to x, y position


2- Rapid traverse to R-plane position
3- Drilling with feed from R-plane to Z-depth position.
4- Dwell for specified time at hole bottom.
5- Rapid traverse to R-plane or Initial-level depends on G99, G98 mode.

G82 drilling cycle working

G98 G99 Modes


How G82 drilling cycle behaves upon G98 or G99 mode,

G98 Drill will return to the Initial level


G99 Drill will return to R-plane.

For a working example see G81 drilling cycle.

Example
N30 G82 X10 Y30 Z-17 R2 P2000 F75
N40 Y10
N50 G98 X30
N60 G99 Y30
N70 X90
N80 Y10
N90 G80

Repeat Drilling
If K parameter value is given with G82 drilling cycle, then drilling will repeat the number
of times given with K. An effective use of repeat drilling is while drilling multiple same
distance holes, this way G82 cycle is used in G91 incremental mode. See G81 drilling cycle
for repeat drilling example.
Working Example

G82 drilling cycle example

N10 T1 M06
N20 G90 G54 G00 X30 Y25
N30 S1200 M03
N40 G43 H01 Z5 M08
N50 G82 Z-10 R2 P1000 F75
N60 X80 Y50
N70 G80 G00 Z100 M09
N80 M30

G82 drilling cycle with dwell can be used for normal drilling where bottom of the hole need
more accurate machining.

Otherwise if you just want a drilling cycle without a dwell time at the bottom of the hole
G81 drilling cycle is a big time saver.

Following is a cnc programming example which illustrates the use of G82 Drill cycle.

G82 Drilling Cycle CNC Milling Example Program


G82 Drilling Canned Cycle with Dwell CNC Milling Example Program

O10076
N10 T11 M06
N20 G90 G54 G00 X0.5 Y-0.5
N30 S1200 M03
N40 G43 H11 Z1. M08
N50 G82 G99 Z-0.375 P1 R0.1 F7.5
N60 X1.5
N70 Y-1.5
N80 X0.5
N90 G80 G00 Z1. M09
N100 G53 G49 Z0. M05
N110 M30

Note N50 – CNC machines with Fanuc cnc control will use P1000 instead of P1 which is
used for Haas CNC machines.
Fanuc G83 Peck Drilling Cycle

G83 peck drilling cycle perform the drilling operation in multiple pecks, this technique
makes deep-hole drilling easy and economical.

Cutting feed is performed intermittently to the bottom of the hole while chips are
discharged.

As the drilling is performed to the bottom of the hole with feed in multiple small steps,
every time a specified depth is made and then drill retracts, then drill makes the next peck,
this operation is repeated again and again until the drill depth is reached.

Contents

 Syntax
 Usage
 Working
 G98 G99 Modes
o Example
 Repeat Drilling
 Working Example

Syntax
G83 X... Y... Z... R... Q... F... K...
Parameter Description
X Hole position in x-axis.
Y Hole position in y-axis.
Z Depth, tool will travel with feed to Z-depth starting from R plane.
R Position of the R plane.
Q Depth of cut for each cutting feed (Peck).
Number of cycle repetitions (if required)
K
F Feedrate.

Once given in program G83 peck drilling cycle is repeated at every axis movement until
G80 is given in program to end peck drilling cycle.
Usage
N150 M06 T02
N160 G90 G00 X60 Y28 Z12 S750 M03
N170 G99 G83 X60 Y28 Z-17 Q6 R2 F60
N180 G98 Y12
N190 G91 G80 G28 X0 Y0 Z0 M05
N200 M30

In the above example code first drill is done at X60 Y28 and second at Y12 and then peck
drilling is cycle is ended with G80.
6mm pecks are taken to complete total drilling depth of 17mm.

Working
Here is briefly described how G83 peck drilling cycle works,

1- Rapid traverse to X, Y drilling position.


2- Rapid traverse to R-plane.
3- Drilling with feed Q deep.
4- Retraction with Rapid traverse to R-plane.
5- Rapid traverse to Q-d deep (d value is specified in parameters).
6- Drilling with feed Q+d deep.
7- Retraction with Rapid traverse to R-plane
- this whole procedure is repeated until drill reaches Z-depth position,
- then drill is retracted to R-plane or Initial-level depends on G99 or G98 which one is
given in program.

G83 peck drilling cycle working

G98 G99 Modes


After completing drilling depth the return is made with Rapid feed, the return height can be
controlled through using G98 or G99.

G98 Drill will return to the Initial level


G99 Drill will return to R-plane.

G98, G99 can be used multiple times during G83 peck drilling cycle.

Example
N30 G83 X10 Y30 Z-17 Q5 R2 F75
N40 Y10
N50 G98 X30
N60 G99 Y30
N70 X90
N80 Y10
N90 G80

Repeat Drilling
G83 peck drilling cycle, drilling operation can be repeated multiple times. The drilling is
repeated K times if K value is given with G83.

Repeat drilling is normally used with G91 Incremental mode, and a good example of
repeated drilling is Grid-plate drilling. For working example see G81 drilling cycle.

Working Example
G83 Peck drilling cycle Example

N10 M06 T1
N20 G90 G00 X12.5 Y10 Z12 S1000 M03
N30 G99 G83 X12.5 Y10 Z-17 R2 Q4 F75
N40 Y30
N50 G98 X57.5
N60 G99 Y10
N70 G91 G80 G28 X0 Y0 Z0 M05
N80 M30

G83 Peck Drilling Cycle G-code is modal so that it is activated every X and/or Y axis
move, and it will rapid to that position and then cause this canned cycle (Drilling) to be
executed again, until it’s canceled (G80).

Contents

 G83 Deep Hole Peck Drilling Cycle Operation


 G83 Peck Drilling Cycle Format

G83 Deep Hole Peck Drilling Cycle Operation

G83 Deep Hole Peck Drilling Cycle for Fanuc

As G83 is a Peck drilling cycle so the depth for each peck in G83 drilling cycle will be the
amount defined with Q.
The tool will take the peck (Q deep)
Then the tool will rapid up to the R plane after each peck
and then back in for the next peck
until Z depth is reached.

Use G98 and G99 for the Z position clearance location for positioning between holes.

G83 Peck Drilling Cycle Format


G83 X_ Y_ Z_ R_ Q_ F_ K_ ;

X Y – Hole position data


Z – Z-depth (feed to Z-depth starting from R plane)
R – Position of the R plane
Q – Depth of cut for each cutting feed (depth of each peck)
F – Cutting feedrate
K – Number of repeats (if required)

A complete cnc programming example of G83 Peck drilling cycle G81 Drilling Cycle G83
Peck Drilling with G98 G99 Example Program
Fanuc G85 Boring Cycle – CNC Mill
Programming
Fanuc G85 Boring Cycle is also called Fanuc G85 Reaming Cycle.
As Fanuc G85 boring cycle can be used for Reaming operation.

Contents

 Fanuc G85 Boring Cycle – Reaming Cycle


 Fanuc G85 Boring Cycle Format
 Fanuc G85 Boring Cycle Operation
 Fanuc G85 Boring Cycle Example Program

Fanuc G85 Boring Cycle – Reaming Cycle


Tool traverses down to end depth with feed and retracts the withdrawal plane with feed.

Fanuc G85 Boring Cycle Format


G85 X Y Z R F K

X Y – Hole position
Z – Boring depth (Absolute).
R – Tool starting position above the hole.
F – Cutting feed rate
K – Number of repeats (if required)

Fanuc G85 Boring Cycle


Fanuc G85 Boring Cycle Operation
1 – After positioning along X and Y axis, rapid traverse is performed to point R.
2 – Boring/Reaming is performed from point R to end-depth-point Z with specified feed F.
3 – After completing depth Z with feed F, Tool returns with the same feed F.

Return plane is dependant on G98, G99 G-codes.


If G98 is specified with G85 boring cycle the tool returns to Initial-level.
If G99 is specified then tool will return to R level.

Fanuc G85 Boring Cycle Example Program


M3 S100
G90 G99 G85 X300. Y–250. Z–150. R–120. F120.
Y–550.
Y–750.
X1000.
Y–550.
G98 Y–750.
G80 G28 G91 X0 Y0 Z0
M5
G86 Boring Cycle – Fanuc Mill
Programming

Contents

 G86 Boring Cycle


 G86 Boring Cycle Format
 G86 Boring Cycle Operation
 G86 Boring Cycle Program Example

G86 Boring Cycle


Fanuc G86 Boring Cycle is used to bore the hole(s).
The tool travels to the bottom of the hole with feed and then retracts back out of the hole at
rapid feedrate.

G86 Boring Cycle Format


G86 X Y Z R F K

Parameters
X Y - Hole position data.
Z – Boring depth (Absolute).
R – Tool starting position above the hole.
F – Cutting feed rate.
K – Number of repeats (if required).
G86 Boring Cycle

G86 Boring Cycle Operation


1 – After positioning along the X– and Y–axes, rapid traverse is performed to point R.
2 – Drilling is performed from point R to point Z.
3 – When the spindle is stopped at the bottom of the hole, the tool is retracted in rapid
traverse.

Tool Return Position


Return plane is dependant on G98, G99 G-codes.
If G98 is specified with G86 boring cycle the tool returns to Initial-level.
If G99 is specified then tool will return to R level.

G86 Boring Cycle Program Example


M3 S2000
G90 G99 G86 X300. Y–250. Z–150. R–100. F120.
Y–550.
Y–750.
X1000.
Y–550.
G98 Y–750.
G80 G28 G91 X0 Y0 Z0
M5
Fanuc Sub Programming

Contents

 Fanuc Sub Programming


 Sub-Program Call
 Sub-Program End
 Sub-Program Repeats
 M99 Command

Fanuc Sub Programming


Fanuc cnc control provides the ability to access other part programs stored inside the main
directory.

For a cnc program example for sub-program call read Multi Start Threads with Fanuc G76
Threading Cycle

Sub-Program Call
Sub-program is called by the use of an M98 command followed by the sub-program
number preceded with a letter P.

N10 M98 P1004

In the above cnc program line the sub-program 1004 will be called, which is stored in the
control memory as O1004

Sub-Program End
To return to the last program (main-program) position for the program to continue,

an M99 command on the last line of sub-program is used


N100 M99
Fanuc Sub Programming

Sub-Program Repeats
The control also has the ability to contain a repeat command as part of the M98 program
line.

When the program line is written with the M98 P1004 command the control actually reads
the line of information as M98 P00001004 , the first 4 digits after the P word being the
repeat amount.
To repeat a sub-program (O1004) 33 times, the program line would read as follows:

M98 P331004

Above cnc program code will call O1004 program 33 times then will return to main
program.

M99 Command
Fanuc control has the ability to jump to a specific program line number on its return to the
main program using the M99 command as:

M99 P100
This command above will move the control to line number N100 in the main program.

M99 can also be written at the end of a main program, and would result in a continuous
program loop.
CNC Subprogram Example with G91
Incremental Mode
Drawing/Image

CNC Program
;Main Program

O777
G91 G28 Z0
M06 T01
M03 S1200
G90 G54 G43 H1
G00 X30 Y110
Z2
M98 P030888 (call subprog O888 three times)
G28 Z0
M30

;Subprogram

O888
G91
G01 Z-9 F200
Y-80
X50
Y80
G00 Z9
G00 X30
M99
CNC Sub Programs
Sub-programming is a way in which cnc machinists can call other cnc programs stored in
cnc machines from their programs (called as main-programs).

Read article about How to do Fanuc Sub Programming.

This Sub-programming process makes it easier for cnc programmers/machinists to keep


their cnc programs small by dividing programs into small pieces of repeatable useful code.

Fanuc Sub Programming

As the below cnc program example shows,

cnc machinist want to drill some holes and then he want to tap the same holes.

Example Without Fanuc Sub-Program Call

The simplest way to program can be read here G81 Drilling Cycle G84 Tapping Cycle
CNC Program Example.

Example with Fanuc Sub-Program Call

Below is the same program example but this time we are using Sub-programming
technique.
Fanuc Subprogram Example

Fanuc Subprogram Example


O1000 ;
N1 T1 M6 ;
N2 G0 G90 G40 G21 G17 G94 G80 ;
N3 G54 X10 Y10 S? M3 ;
N4 G43 Z100 H1 ;
N5 Z5 ;
N6 G81 R3 Z-20 F? M8 ;
N7 M98 P1001 ;
N8 G0 G90 Z100
N9 T2 M6 ;
N10 G0 G90 G40 G21 G17 G94 G80 ;
N11 G54 X10 Y10 S? M3 ;
N12 G43 Z100 H1 ;
N13 Z5 ;
N14 G84 G99 G95 R3 Z-20 F1.25 M8 ;
N15 M98 P1001 ;
N16 G0 G90 Z100 ;
N17 T0 M6 ;
N18 M30 ;
Sub Program
O1001 ;
N101 Y30 ;
N102 Y50 ;
N103 Y70 ;
N104 X30 ;
N105 X50 ;
N106 X70 ;
N107 X90 ;
N108 Y50 ;
N109 Y30 ;
N110 Y10 ;
N111 X70 ;
N112 X50 ;
N113 X30 ;
N114 G80 ;
N115 M99
CNC Mill Contour Pecking – Fanuc
Subprogram Repeat Example
A very simple cnc programming example which shows
how a contour can be repeated multiple times with the added benefit of pecking.
So like peck drilling this time cnc machinists are pecking a specific contour of cnc mill.

What is Fanuc Sub programming read Fanuc Sub Programming

Contents

 CNC Mill Contour Pecking


 Fanuc Subprogram Repeat Example

CNC Mill Contour Pecking


The subprogram is a simple mix of G-code instructions.
The main program O4000 calls subprogram O4001 to repeat 10 times

M98 P104001

Subprogram cuts contour by making 2mm depth of cut every time (in G91 Incremental
Programming)

G1 G91 Z-2 (Incremental peck depth)

Then subprogram switches back to G90 Absolute Programming this makes contour
programming easy.
So this program cuts a specific contour 20mm deep by taking 10 pecks of 2mm each.

Fanuc Subprogram Repeat Example


Contour Pecking – Fanuc Mill Subprogram Repeat Example

O4000
T1 M6
G0 G90 G40 G21 G17 G94 G80
G54 X-75 Y-75 S? M3 (Start Point)
G43 Z100 H1
Z5
G1 Z0 F?
M98 P104001 (Call sub-program & repeat 10 times)
G0 G90 Z100
M30

Subprogram
The sub program below takes cut in G91 Incremental Programming Mode
Then switches back to G90 Absolute Programming Mode for the contour machining.

O4001
G1 G91 Z-2 (Incremental peck depth)
G90 G41 X-40 D? M8 (Absolute Move to position 1 with comp. - Switch on
coolant)
Y40 (Move to position 2.)
X40 (Move to position 3.)
Y-40 (Move to position 4.)
X-75 (Move to position 5 - Clear of material - cutter diameter)
G40 Y-75 (Cancel compensation)
M99
G Code Example Mill – Sample G Code Program for
Beginners
 Sample G Code Program for Beginners
 G Code Example

Sample G Code Program for Beginners

Sample G code program example for cnc programmers / cnc machinists who work or want to learn cnc mill
programming.

A similar G code example can be found here


Simple G Code Example Mill – G code Programming for Beginners

If you are interested in G code subroutine example (sub program) read


CNC Mill Contour Pecking – Fanuc Subprogram Repeat Example

This is the same component but this time we are machining it in taper.

G Code Example

G Code Example Mill

O1000
T1 M6
G0 G90 G40 G21 G17 G94 G80
G54 X-75 Y-25 S500 M3 (Start Point)
G43 Z100 H1
Z5
G1 Z-20 F100
X-50 M8 (Position 1)
Y0 (Position 2)
X0 Y50 (Position 3)
X50 Y0 (Position 4)
X0 Y-50 (Position 5)
X-50 Y0 (Position 6)
Y25 (Position 7)
X-75 (Position 8)
G0 Z100
M30
Fanuc G04 Dwell
G04 dwell G-code halts/delays current operation for the specified time (seconds or milliseconds) but during
this whole process only axis motions of cnc machine are stopped and spindle keeps rotating.

Contents

 Syntax
 G-Code Data
 Usage
 Examples
 How to dwell for Revolutions?
o Example

Syntax

G04 P...

or

G04 X...

or

G04 U...
Parameter Description
P Dwell in milliseconds (msec)
X Dwell in seconds (sec)
U Dwell in seconds (sec)

G-Code Data

G-Code Group Modal/Non-modal


G04 00 Non-modal

Usage

G04 P1000 (wait for 1 second)

the above part-program instruction will delay current cnc machining operation for one
second.

Examples

So to program a 10 Seconds dwell


G04 X10

or

G04 U10

or

G04 P10000 (dwell time 1sec = 1000msec)

So to program a 2.5 Seconds dwell

G04 X2.5

How to dwell for Revolutions?


It is possible to have the pause in number of revolutions by using following formula,
Dwell = 60 / S (spindle speed in rpm)

Example

If the spindle rotates at 300 rpm, the dwell time for one revolution will be
0.2 seconds = 60 / 300
So if a dwell is required for 3 spindle rotations,

G4 U0.6 (0.2 seconds x 3 rpm)


Fanuc G10 G-Code for CNC Machine Programmable Offset
Setting
o Programmable Offset Setting
 Fanuc G10 Programmable Offset Setting
o Workshift Value Setting or Machine Zero Offset Setting with Fanuc G10
o Tool Wear with Fanuc G10
o Tool Offset Setting or Tool Geometry Offsetting with Fanuc G10

Programmable Offset Setting

On almost all cnc machine controls the tool offset setting and cnc machine zero offset
setting ( workshift value, shift value, machine zero offset value) are given on separate
pages. But these cnc controls also allow the cnc programmer to add offset values through
cnc program. On Fanuc cnc controls we can use G10 (Programmable Offset Setting), On
Sinumerik 840D we can use Sinumerik 840D system variables to access and update the
offset settings.

You might like Haas CNC Lathe G10 Programmable Offset Setting G-Code

Fanuc G10 Programmable Offset Setting


On a cnc lathe machine we do two types of offset setting. Tool Offset Setting and
Workshift Setting. With G10 we can do both functions.

Workshift Value Setting or Machine Zero Offset Setting with Fanuc G10

This version of Fanuc G10 is used to set the workshift value. P00 means that we want to
set the workshift value. The x-axis value is normally set to 0, the value for z-axis is the
distance from the machine zero point to workpiece zero point (this distance is called
workshift value or zero offset).

N10 G10 P00 X0 Z200

Tool Wear with Fanuc G10

This version of the Fanuc G10 code is a bit tricky, the value with P is the tool for which we
want to make changes. This G10 code adds the given value to the tool wear offset .

N10 G10 P1 U0.02 W0.02

Tool Offset Setting or Tool Geometry Offsetting with Fanuc G10


This version of G10 sets the Tool Offset Setting. If you want to set the tool offset
setting value for tool number 8 then you will add 10000 and the value will be (10000 + 8 =
10008), now put that value with P. For G10 x and z values put the tool value in x and z.

N10 G10 P10001 X95 Z54

Note:- When G10 code block is run it overwrites or changes the previous values which are
in Offset Geometry , Workshift Value pages! so take care.

G-Code G94 Feed Per Minute

Feed Per Minute (G94)

G94 G-code is a modal G-code. G94 instructs the control to interpret feed commands as

 inches/minute or mm/minute for linear moves.


 degrees/minute for rotary moves.
 inches/minute or mm/minute for a combination of linear and rotary moves.

When a combination of linear and rotary moves is programmed, the rotary moves match the
time it takes to make the linear moves.

The G94 function selects feed F in mm/min or inches/minute. When this function is active
the feed values will be programmed as follows: F50, F150, F500, F2000 and so forth.

G94 (feed per minute) G-code is used to perform movements with work feed when the
spindle is stationary, or when it is necessary to release the axis feed from the spindle
revolutions (e.g.: when milling with motor driven tools or live tooling).

Related: Live tooling on Haas CNC lathe machine program examples

 C-Axis Lathe Programming Example with Live Tooling on Haas CNC


 Live Tooling Lathe Programming Code – Spindle Orientation Haas CNC

Related: G Code Lists

 Complete G Code List


 Fanuc G Codes List
 Haas CNC Lathe G-Codes
G94 (feed per minute) G-code is used to perform movements with work feed when the
spindle is stationary

G94 is a modal function and can be cancelled by programming the code G95 (Feed Per
Revolution).

N7 ……
N8 G94 ; mm/min feed
N9 G1 X… Z… F400
N10 ……
N11 ……
N12 G95 ; mm/rev feed
N13 G1 X… Z… F0.12
N14 ……

G-Code G95 Feed Per Revolution

Feed Per Revolution (G95)

G95 Feed Per Revolution


G95 (Feed Per Revolution) is a modal G-code that instructs the control to interpret
feed commands as mm per revolution (mm/rev) or inches per revolution of the spindle.

G01 F0.02

the above cnc program code would cause the axis to advance 0.02mm for every revolution
of the spindle.

When G95 is active the feed values will be programmed as follows: F0.05, F0.15, F0.3,
F0.5 and so forth.

N11 ……
N12 G95 ; Program with G95 (F= mm/rev.)
N13 G1 Z-20 F0.2
N14 ……
G65 Macro for Internal Helical

CNC Program

T? M6 (THREADMILL)
G0 G90 G40 G21 G17 G94 G80
G54 X? Y? S? M3 (Move to bore centre)
G43 Z? H?
;
G65 P1002 A? B? D?
(A = THREAD DIAMETER)
(B = PITCH)
(D = RADIUS OFFSET NUMBER)
M30

O1002
#11=[[#1*0.8]/2]
#12=[[#1/2]-#11]
;
G91 Y#12
G41 X#11 D#7
G3 X-#11 Y#11 R#11 Z#2/4
J-[#1/2] Z#2
X-#11 Y-#11 R#11 Z#2/4
G1 G40 X#11
G0 G90 Z100
M99
CNC Mill Program (G41 Cutter Radius Compensation
Left)

CNC Mill Program with G41Cutter Radius Compensation Left

N10 T2 M3 S447 F80


N20 G0 X112 Y-2
N30 Z-5
N40 G41
N50 G1 X95 Y8 M8
N60 X32
N70 X5 Y15
N80 Y52
N90 G2 X15 Y62 I10 J0
N100 G1 X83
N110 G3 X95 Y50 I12 J0
N120 G1 Y-12
N130 G40
N140 G0 Z100 M9
N150 X150 Y150
N160 M30
Fanuc G43 G44 G49 Tool Length Compensation
Contents

 G43 Tool Length Compensation positive


o Programming
o Example
 G44 Tool Length Compensation negative
o Programming
 G49 Cancel Tool Length Compensation
o Programming

G43 Tool Length Compensation positive


With G43 a value from the offset register (OFFSET) can be called up and added to tool
length.
To all following Z movements (with active XY plane – G17) in the program this value will
be added.

Programming
N... G43 H...
Example
N... G43 H05

The value, which is written into the register under H05, will be added to all following Z
movements as tool length.

G44 Tool Length Compensation negative


With G44 a value from the offset register (OFFSET) can be called up and subtracted from
tool length.
To all following Z movements (with active XY plane – G17) in the program this value will
be subtracted from.

Programming
N... G44 H...

G49 Cancel Tool Length Compensation


The positive (G43) or negative (G44) shift will be cancelled.

Programming
N... G49
Fanuc G33 Thread Cutting – CNC Mill
Contents

 Fanuc G33 Thread Cutting


 Programming
 Parameters

Fanuc G33 Thread Cutting


With a fitting tool (boring or facing head) threads can be cut.

Notes •Feed and spindle override switch are not active while G33 (100%).

Programming
N... G33 Z... F..

Parameters
Parameter Description
F Thread pitch [mm]
Z Thread depth
G65 Macro for Internal Elipse

Drawing/Image

CNC Program
T1 M6
G0 G90 G40 G21 G17 G94 G80
G54 X0 Y0 S? M3
G43 Z5 H?
G1 Z-? F?
#20 = 2 ; Incremental degree calculation
#21 = 0 ; Start Angle
#22 = 30 ; Y Axis Radius
#23 = 50 ; X Axis Radius
G41 X#23 D? ; Compensation motion to right side of internal pocket
N10 #21 = [#21 + #20] ; Angular Count
#24 = SIN[#21] ; Incremental Y axis calculation
#25 = COS[#21] ; Incremental X axis calculation
#24 = [#24*#22] ; Absolute Y calculation
#25 = [#25*#23] ; Absolute X calculation
X#25 Y#24 ; Movement in X & Y axis
IF [#21 LT 360] GOTO 10 ; Restart if less than 360 degree motion
IF [#21 GT 360] GOTO 20 ; If final angle becomes greater than 360 degrees
recalculate
IF [#21 EQ 360] GOTO 30 ; Finish if total angle is equal to 360 degree
N20 #21 = 360
GOTO 10
N30 G40 X0
G0 G90 Z100 M30
Fanuc G52 Local Coordinate G15 G16 Polar Coordinate Program
Example

Drawing/Image

CNC Program
;Fanuc Program Example
;G52 Local Coordinate System
;G15 G16 Polar Coordinate

O1453
G91 G28 X0 Y0 Z0
M06 101
M03 S1000
G90 G54 G43 H1
G52 X100 Y100
G00 X0 Y0
G00 Z5
G16
G81 X80 Y45 Z-16 R2 F200
Y135
Y225
Y315
G15
G52 X300 Y100
G00 X0 Y0
G16
G81 X80 Y45 Z-16 R2
Y135
Y225
Y315
G15
G28 Z0
M30
Fanuc G15 G16 Polar Coordinate Command Bolt Circle Program Example

Drawing/Image

CNC Program
O777
G91 G28 X0 Y0 Z0
M06 T01
M03 S500
G90 G54 G43 H1
G00 Y41 X0
Z5
G81 Z-12 R2 F200
G16
X41 Y150
X41 Y210
X41 Y270
X41 330
X41 Y30
G15
G28 Z0
M06 T02
G43 H2
G00 X0 Y41
G00 Z5
G84 Z-12 R2 F625 P1.25
G16
X41 Y150
X41 Y210
X41 Y270
X41 Y330
X41 Y30
G15
G28 Z0
M30
Fanuc G72.1 Rotational Copy Program Example

Contents

o Fanuc G72.1 Rotational Copy


o Fanuc G81 Drilling Cycle
 Fanuc G72.1 Program Example

Fanuc G72.1 Rotational Copy

Using G72.1 Rotational Copy G-code a figure specified by a subprogram can be repeatedly
produced with Rotational movement.
Read more Fanuc G72.1 Rotational Copy (Figure Copy Function CNC Mill)

Fanuc G81 Drilling Cycle

G81 drilling cycle is used for simple drilling/spot drilling operations.


Read complete article with program examples Fanuc G81 Drilling Cycle

Fanuc G72.1 Program Example

Main program

O2000 ;
N10 G90 G00 G17 X250. Y100. Z100. ; (P0)
N20 G72.1 P2100 L6 X100. Y50. R60. ;
N30 G80 G00 X250. Y100. ; (P0)
N40 M30 ;

Sub program

O2100 N100 G90 G81 X100. Y150. R60. Z10. F200. ; (P1)
N200 M99 ;
Fanuc G68 Coordinate Rotation – Subprogram Example
Contents

 G68 Coordinate Rotation Example


o Main-program
o Subprogram

G68 Coordinate Rotation Example

Main-program
N5 G54
N10 G43 T10 H10 M6
N15 S2000 M3 F300
M98 P030100 ; Subprogram call
N25 G0 Z50
N30 M30

Subprogram
O0100
N10 G91 G68 X10 Y10 R22.5
N15 G90 X30 Y10 Z5
N20 G1 Z-2
N25 X45
N30 G0 Z5
N35 M17
Fanuc Bolt Hole Circle Custom Macro (BHC)

Drawing/Image

CNC Program

/*Parameters
G65 P9100 Xx Yy Zz Rr Ff Ii Aa Bb Hh
X: X coordinate of the center of the circle (#24)
Y: Y coordinate of the center of the circle (#25)
Z: Hole depth (#26)
R: Coordinates of an approach point (#18)
F: Cutting feedrate (#9)
I: Radius of the circle (#4)
A: Drilling start angle (#1)
B: Incremental angle (Clockwise when negative value) (#2)
H: Number of holes (#11)
*/

O9100
#3=#4003
G81 Z#26 R#18 F#9 K0
IF[#3 EQ 90]GOTO 1
#24=#5001+#24
#25=#5002+#25
N1 WHILE[#11 GT 0]DO 1
#5=#24+#4*COS[#1]
#6=#25+#4*SIN[#1]
G90 X#5 Y#6
#1=#1+#2
#11=#11-1
END 1
G#3 G80
M99

/*Fanuc Bolt Hole Macro Example


Example macro call to drill 5 holes at intervals of 45 degrees
after a start angle of 0 degrees
on the circumference of a circle with radius 4”.
The absolute center of the circle is (10”, 5”).*/
O0002
G90 G92 X0 Y0 Z4.0
G65 P9100 X10.0 Y5.0 R1.0 Z-2.0 F20 I4.0 A0 B45.0 H5
M30

You might also like