Documente Academic
Documente Profesional
Documente Cultură
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
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_
- 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.)
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.
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.
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
N0030 G1 X0 Y50
N0040 G0 G40 x-20
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
Siempre se aplica dicha compensación al eje perpendicular al plano principal. G43 es una
función modal.
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.
Contents
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
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.
The X, Y & R are established as incremental values if G68 is specified with a G91 code.
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
Programming Notes
Notes
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 ;
;
M99 ;
Limitation
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
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
Programming Notes
Notes
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 ;
;
M99 ;
Limitation
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
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
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
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.
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
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
Working
Brief description of how G84 tapping cycle works,
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.
Working 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.
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,
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
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
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
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
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.
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,
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
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.
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
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)
Contents
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
Contents
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.
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,
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).
cnc machinist want to drill some holes and then he want to tap the same holes.
The simplest way to program can be read here G81 Drilling Cycle G84 Tapping Cycle
CNC Program Example.
Below is the same program example but this time we are using Sub-programming
technique.
Fanuc Subprogram Example
Contents
M98 P104001
Subprogram cuts contour by making 2mm depth of cut every time (in G91 Incremental
Programming)
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.
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 example for cnc programmers / cnc machinists who work or want to learn cnc mill
programming.
This is the same component but this time we are machining it in taper.
G Code Example
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
Usage
the above part-program instruction will delay current cnc machining operation for one
second.
Examples
or
G04 U10
or
G04 X2.5
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,
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
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).
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 .
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.
G94 G-code is a modal G-code. G94 instructs the control to interpret feed commands as
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).
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 ……
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)
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.
Programming
N... G44 H...
Programming
N... G49
Fanuc G33 Thread Cutting – CNC Mill
Contents
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
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)
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
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