Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
CNC programming example code for the G83 Peck Drilling Cycle. G83 deep hole peck drilling cycle makes
the drilling of deep holes a breeze.
As with G81 drilling cycle you can do simple drilling in a fast and easy way.
But G83 peck drilling due to its specialty of pecking throws away the chips after every cut or peck and this
way also the coolant reaches to the bottom of the hole in a free way, so keeps the drill and component cool and
clean.
The following G83 peck drilling cycle example code illustrates the use of peck drilling cycle in an easy to
understand way, even the beginner level cnc programmers/cnc machinists will understand the working with
ease.
N1 T1 M06
N2 G90 G54 G00 X.3 Y.3
N3 S1200 M03
N4 G43 H01 Z1. M08
N5 G83 Z-1.5 Q.5 R.1 F10.
N6 X1.2 Y1.2
N7 G80 G00 Z1. M09
N8 G91 G28 Z0. M05
N9 M30
G83 Peck Drilling Cycle with G70 Bolt Hole Circle Sample
Program
Following cnc sample program illustrates the use of G83 Peck Drilling Cycle with G70 Bolt Hole Circle G-
code to machine evenly spaced deep drills in a circle.
Although G70 Bolt Hole Circle cycle works with G73, G74, G76, G77 and G81 G89.
Related:
O001
N10 T5 M06
N20 G90 G54 G00 X70. Y80.
N30 S1451 M03
N40 G43 H05 Z50. M08
N50 G83 R2. Z-25. Q2. F80. L0
N60 G70 I55. J0. L6
N70 G80 G00 Z50. M09
CNC Milling G70 Bolt Hole Circle Program Example
G70 Bolt Hole Circle command makes it easy to drill/tap/bore in a circle at even distances.
There is no need to know or calculate each hole position.
You just are required to know is the Radius of the circle, Starting angle of the first hole and Total number of
holes.
G70 I J L
Following cnc program example uses G81 Drilling Cycle in combination with G70 Bolt Hole Circle G-code to
drill 8 holes evenly spaced in a circle of 1 (inch) radius.
O0009
N1 T1 M06
N2 G90 G54 G00 X2. Y-1.5 (Center position of bolt hole circle)
N3 S1451 M03
N4 G43 H01 Z1. M08
N5 G81 G99 Z-0.45 R0.1 F8. L0
N6 G70 I1. J0. L8
N7 G80 G00 Z1. M09
N8 G53 G49 Z0. M05
N9 M30
G72 Bolt Hole Along an Angle CNC Sample Program
Following cnc programming code shows the use of G72 bolt hole along an angle.
As the names states G72 G-code makes it very easy to drill/bore/tap evenly spaced hole along a specified
angle.
Canned cycles G73, G74, G76, G77, or G81-G89 can be used with G72 bolt hole along an angle command.
Contents
G72 Bolt Holes Along an Angle Format
CNC Program Example G72 Bolt Hole Along an Angle
More info G72 Bolt Holes Along an Angle CNC Milling Programming
CNC Program Example G72 Bolt Hole Along an Angle
O0009
N10 T3 M06
N20 G90 G54 G00 X0.65 Y-1.5 (Start position of bolt holes along an angle)
N30 S1451 M03
N40 G43 H03 Z1. M08
N50 G81 G99 Z-0.45 R0.1 G72 I0.5 J20. L7 F8.
N60 G80 G00 Z1. M09
N70 G53 G49 Z0. M05
N80 M30
Fanuc G84 Rigid Peck Tapping Cycle
Tapping a deep hole in rigid tapping mode may be difficult due to chips sticking to the tool (tap) or increased
cutting resistance.
To make such deep hole tapping operations easy for CNC machinists there is a cycle on Fanuc cnc controls
G84 Peck Rigid Tapping Cycle.
For CNC machinists who work on Haas cnc controls you are also lucky read Deep Hole Tapping with
Chipbreaking or Peck Tapping on Haas CNC
In Fanuc G84 Rigid Peck Tapping Cycle, cutting is performed several times (Pecks) until the bottom of the
hole is reached.
G84 X_ Y_ Z_ R_ P_ Q_ F_ K_ ;
X Y Hole position.
Z Z-depth (feed to Z-depth starting from R plane).
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
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
After completing tapping the return height can be controlled by using G98 or G99.
G98, G99 can be used multiple times during G84 tapping cycle.
Repeat Drilling
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
G84 Tapping Cycle Example CNC Program
G84 tap cycle is one of the mostly used function of CNC machining centers.
This G84 tapping cycle example program illustrates the use of tapping in an easy to understand way.
G84 tapping cycle is a modal G-code, so is cancelled with G80 otherwise it will execute tap operation on every
X and/or Y move.
Contents
G84 Tapping Cycle Format
G84 Tapping Cycle Sample CNC Program
A complete article about G84 read G84 Tapping Cycle CNC Mill Programming
Another related article Deep Hole Tapping with Chipbreaking or Peck Tapping with G84
G84 Tapping Cycle Sample CNC Program
Contents
Syntax
Usage
Working
G98 G99 Modes
Repeat Drilling
Syntax
G85 X... Y... Z... R... 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.
Number of cycle repetitions (if required)
K .
F Feedrate.
Once given in program G85 boring cycle is repeated at every axis movement until G80 is given in program to
end this cycle.
Usage
N150 M6 T2
N160 G90 G00 X60 Y28 Z12 S100 M03
N170 G99 G85 X60 Y28 Z-15 R2 F120
N180 G98 Y12
N190 G91 G80 G28 X0 Y0 Z0 M05
N200 M30
Working
Repeat Drilling
If K parameter value is given with G85 boring cycle, then boring will repeat the number of times given with K.
See G81 drilling cycle example.
Fanuc G86 Boring Cycle
G86 boring cycle is used to bore a hole.
Contents
Syntax
Usage
Working
G98 G99 Modes
Repeat Drilling
Syntax
G86 X... Y... Z... R... 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.
Number of cycle repetitions (if required)
K .
F Feedrate.
Once given in program G86 boring cycle is repeated at every axis movement until G80 is given in program to
end this cycle.
Usage
N150 M6 T2
N160 G90 G00 X60 Y28 Z12 S100 M03
N170 G99 G86 X60 Y28 Z-15 R2 F120
N180 G98 Y12
N190 G91 G80 G28 X0 Y0 Z0 M05
N200 M30
Working
Repeat Drilling
If K parameter value is given with G86 boring cycle, then boring will repeat the number of times given with K.
See G81 drilling cycle example.
Complete CNC G Code List
Contents
Complete G Code List
o List of G-codes commonly found on Fanuc and similarly designed CNC controls
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
G04 Dwell
G10 Programmable data input
G20 Input in inch
G21 Input in mm
G32 Thread cutting
o G32 Taper Threading
G33 Thread Cutting
G70 Finishing cycle
G71 Stock removal in turning
G72 Stock removal in facing
G73 Pattern repeating
G74 End face peck drilling
o G74 Peck Drilling Cycle
o G74 Face Grooving
G75 Outer diameter/internal diameter drilling
G76 Multiple threading cycle
o G76 Threading Cycle One Line Format
o G76 Taper Threading
o G76 Multi Start Threading
o G76 Thread Infeed
G92 Thread cutting cycle
o G92 Taper Threading Cycle
G94 Facing Cycle (Endface turning cycle)
G94 Feed Per Minute / G98 Feed Per Minute
G95 Feed Per Revolution / G99 Feed Per Revolution
G Code
A B C Group Function
G30 G30 G30 2nd, 3rd and 4th reference position return
G50 G92 G92 Coordinate system setting or max. spindle speed setting
Grooving in X axis.
Thread cutting cycle, G76 threading cycle, Fanuc G76 threading cycle, G76 thread cycle.
Before going through this exercise you must fist read Circular Interpolation Concepts &
Programming articles (listed below). After reading articles you will be comfortable to understand this
example as a very simple and basic work.
Circular Interpolation Concepts & Programming articles
o Circular Interpolation Concepts & Programming Part 1 (Concepts)
o Circular Interpolation Concepts & Programming Part 2 (Use of R)
o Circular Interpolation Concepts & Programming Part 3 (Use of I J K)
o Circular Interpolation Concepts & Programming Part 4 (Unknown R)
o Circular Interpolation Concepts & Programming Part 5 (Examples)
o Circular Interpolation Concepts & Programming Part 6 (Uses & Exercises)
Contents
Circular Interpolation Programming Example 1 (Use of R)
o Explanation of CNC Program
o Incremental Dimensioning System Program
o Explanation of CNC G-Code/M-Code/S, F, D
Circular Interpolation Programming Example 1 (Use of R)
Finished Part
After completing the machining process, your job will look like this.
Machined component
Explanation of CNC Program
In this cnc program block no. N35 to N50 (points 2-3, 3-4, 4-5) are in straight movement (Linear Interpolation)
and for that propose we have the CNC G-Code G01 (linear interpolation),
Point 5-6 is not possible with G01 code because tool is not going straight, tool is traveling in a circular way,
for this purpose cnc machinists have circular interpolation codes G02/G03.
Before using G02/G03 G code cnc machinists must know the exact values of
(1) End-point
(2) Radius between start to end points.
So the required values at point 6 are
(1) X=70, Y=65 (as End-point)
(2) R=15 (as Radius).
After getting this information we are now in the position to write the CNC program block code for point 5
through 6.
First circular motion G02-G03, Second is End-point X, Y values and the Third is R (Radius), in this way we
can achive our required results.
Point 6-7 is again linear and point 7-8 is circular motion, so do the same as stated above but before writing the
code, check the motion direction whether it is clockwise or counter clockwise, and this motion is clockwise, so
use the code G02.
Every linear motion is cancelled by the circular motion (G01 is cancelled by G02/G03) and every circular
motion is cancelled by the linear motion (G02/G03 is cancelled by G01)
After reading that you will be comfortable to understand this program example. it is very simple and basic
work.
Contents
Circular Interpolation Programming Example 2
o Explanation of CNC G-Code
Finished Part
After completing the machining process, your job will look like this.
Completed Part
Explanation of CNC G-Code
o G90 X ____ Y____ defines the arc end point in the work co-ordinate system.
o G91 X_____ Y____ defines the signed distance of the arc end point from the arc start point
o I____ J____ defines the signed distance of the arc start point from the center point of the arc
Circular interpolation is quite a bit more demanding on your machine as two axes have to be precisely
coordinated. Drawing a complete circle involves not just coordinated motion but reversal of direction at each
of the 4 quadrant points. These would be the points corresponding to 0, 90, 180, and 270 degrees.
To program an arc when only the arc center is given (the radius is unknown) use the address letters I and J
o I relates to the address X and is the incremental value and direction (+/-) from the start point of the arc in
the X axis to the arc centre.
o J relates to the address Y and is the incremental value and direction (+/-) from the start point of the arc in
the Y axis to the arc centre.
In this figure the procedure is very clear to calculate I and J values. From the point where arc is started always
look to wards arc midpoint. If the arc is less than a quadrant than you must find out the both I and J values.
What is Dwell?
By specifying a dwell (G04), the execution of the next cnc program block is delayed by the specified time.
Some CNC programming cycles have their own dwell facilities within the cycle itself.
G04 U (sec)
G04 P (msec)
The dwell time starts at the moment when the tool movement speed is zero.
With address P no decimal point is allowed.
Example
G04 X10
G04 U10
G04 P10000
Example
Often cnc machinists has to complete such components which require a full circle machining sometimes inside
full circle sometimes you have to program an outside full circle.
This G-code example will show you how to program a full circle from out-side.
Contents
Full Circle CNC Program Example
How to Program Full Circle Explanation
o Summary
o Explanation
Explanation
1: The tool start point is N05 X10 Y25 this is the point P01
2: Now we want a complete circle so we will use G02 or G03 circular interpolation G-code
If you want a clock-wise circle you will use G02 as shown in this program.
but if you want a counter-clock-wise circle then use G03 G-code.
3: With G02 we will give the coordinates of the circle end point,
as for a full circle the start-point and end-point remains the same,
so we will use same X,Y coordinate
G02 X10 Y25
4: Now to complete G02 G-code we will have to give the circle-center-point coordinates,
I Distance from circle start-point to circle-center-point in X-axis.
J Distance from circle start-point to circle-center-point in Y-axis
so G02 X10 Y25 I20 J0
to show how to measure I and J the values of I and J are separately given in the above figure.
Contents
CNC Sub Programs
Example Without Fanuc Sub-Program Call
Example with Fanuc Sub-Program Call
Fanuc Subprogram Example
o Sub Program
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.
cnc machinist want to drill some holes and then he want to tap the same holes.
Below is the same program example but this time we are using Sub-programming technique.
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
M98 P104001
Subprogram cuts contour by making 2mm depth of cut every time (in G91 Incremental Programming)
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
%358
N1 (BRIDE)
N10 G90 G71 G80 G40
N20 G0 G52 Z0
(Contour)
N30 T4 D4 M6
N40 G97 S345
N50 G94 F110
N60 G0 X62 Y-18
N70 Z-5 M3 M41
N80 G1 G42 X50 M8
N85 G1 Y33
N90 G3 X38 Y45 R12
N100 G1 X-35 Y45
N110 G2 X-50 Y 30 R15
N120 G1 X-50 Y25
N130 G1 X-35 Y0
N140 G1 X-25 Y0
N150 G2 X25 Y0 R25
N155 G1 X50
N160 G1 G40 X68 Y-12 M9
N170 G0 G52 Z0 M5
(Drilling)
N180 T6 D6 M6
N190 G97 S1061
N200 G94 F74
N210 G0 X38 Y33
N220 Z3 M3 M42
N230 G1 Z-18 M8 (5+10+3)
N240 G0 Z3 M9
N250 G0 G52 Z0 M5
(Counterbore)
N260 T7 D7 M6
N270 G97 S530
N280 G94 F106
N290 G0 X38 Y33
N300 Z3 M3 M40
N310 G1 Z-5 M8
N320 G0 Z3 M9
N330 G0 G52 Z0 M5
N340 M2
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
Another such program example which mills a pocket the same way but in a taper is here CNC Milling
Machine Programming Example for Beginners.
N10 Spindle on clockwise rotation at 800 rev/min, tool rapid traverse to P01.
N20 Infeed in Z.
N30 Tool traverse P01 to P02, feedrate 150 mm/min.
N40/N50 Rapid traverse retraction.
N60 End of program.
Summary
For side milling, take speed 1200 rpm & feed 100 mm/min
For drilling holes, take speed 1200rpm & feed 80mm/min
For slot milling, take speed 1200rpm & feed 120mm/min
Take hole diameter as 15mm
Use absolute coordinate system.
Solution:
Sequence of operation:
1 Set ref point, cordinate system, tool, give feed & speed value
2 Set cutter for radius compensation left offset
3 set tool at A, start spindle & give down feed (-Z direction)
4 proceed further cutting of side milling and stop spindle at A
5 Move tool at ref point & set the tool for slot cutting
6 Move tool to P, start the spindle & give down feed
7 Proceed further cutting of slot milling and stop spindle at S
8 Move tool at ref point & set the tool for drilling
9 Move tool to P, start the spindle & give full depth cut
10 Move tool up & stop the spindle.
11 Bring back tool at refrence point.
12 End of the program
Drawing/Image
CNC Program
05007
N001 G71 G90 (Set dimension type mm, set absolute co-ordinate system)
N002 G92 X-15.0 Y-15.0 Z0.0 T01 F100 S1200 (Set reference point -15, -15, 0. Tool T01 side milling
tool. Feed 100mm/rev, spindle speed 1200 rpm)
N003 G41 G00 X0.0 Y0.0 Z2.0 (Cutter radius compensation left ON, move the tool at A & give clearance
of 2mm before starting spindle rotation)
N004 G01 Z-15.0 M03 (Start the spindle. Move tool down i.e. at Z direction for cut with feed
here M03 will execute first)
N005 G01 X0.0 Y110.0 (Go to B linearly)
N006 G02 X10.0 Y120.0 R10.0 (Go to C with clockwise circular interpolation with radius = 10)
N007 G01 X75.0 (Go to D linearly)
N008 G01 X100.0 Y92.0 (Go to E linearly)
N009 G01 Y10.0 (Go to F linearly)
N010 G02 X90.0 Y0.0 R10.0 (Go to G with clockwise circular interpolation with radius = 10)
N011 G01 X0.0 (Go to A linearly)
N012 Z2.0 M05 (Go up 2mm in Z direction for clearance. Stop spindle rotation here
M05 will execute last.)
N013 G40 G00 X-15.0 Y-15.0 (Cutter radius compensation OFF. Move tool to reference set point.)
N014 M06 T02 F120 (Change the tool & use tool T02 - here for slot mill tool with dia 6mm.
Set feed as 120mm/rev.)
N015 G00 X15.0 Y55.0 (Move tool to 'P' rapidly.)
N016 G01 Z-5.0 M03 (Start the spindle. Move tool 5mm down i.e. at Z direction for cut with
feed - here M03 will execute first)
N017 Y80.0 (Go to Q linearly.)
N018 X85.0 (Go to R linearly.)
N019 Y80.0 (Go to S linearly.)
N020 Z2.0 M05 (Go up 2mm in Z direction for clearance. Stop spindle rotation - here
M05 will execute last.)
N021 G00 X-15.0 Y-15.0 (Move tool to reference set point.)
N022 M06 T03 F80 (Change the tool & use tool T03 - here for drill bit with dia 15mm. Set
feed as 80mm/rev.)
N023 G00 X50.0 Y25.0 (Move tool to 'T')
N024 G01 Z-20.0 M03 (Go down 20mm for assuring full depth of hole.)
N024 Z2.0 M05 (Go up 2mm in Z direction for clearance. Stop spindle rotation - here
M05 will execute last.)
N025 G00 X-15.0 Y-15.0 (Move tool to reference set point.)
N026 M30 (Stop the program)
CNC Mill Program G91 G41 G43
CNC milling program examples shows the use of G91 G41 G43 G-codes.
Contents
CNC Mill Program G91 G41 G43
o CNC Part Program
o G M S T Codes Explanation
N05 G54
N10 M6 T1 G43 H1 M3
N15 S500 F120
N20 G0 X-22 Y-22
N25 Z-3
N30 G1 X3 Y6 G41 H2 (P1)
N35 G91 X0 Y24 (P2)
N40 X12 Y9 (P3)
N45 X36 (P4)
N50 Y-24 (P5)
N55 X-21 (P6)
N60 G90 X3 Y6 (P1)
N65 G0 X-21 G40
G M S T Codes Explanation
Code Description
G00 Rapid traverse
G01 Linear interpolation
G40 Cutter compensation cancel
G41 Tool nose radius compensation left
G43 Tool length compensation + direction
G54 Workpiece coordinate system 1 selection
G90 Absolute command
G91 Incremental command
M06 Tool change
T Tool
S Speed
F Feed