CNC Programming Intro & Code PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 127
At a glance
Powered by AI
The document discusses the history and concepts of NC and CNC technology, types of CNC machines, machine control units, cutter compensation, and program planning.

NC technology uses fixed, hardwired logic while CNC technology uses an internal microprocessor, allowing for more flexibility in changing programs. CNC emerged about 20 years after NC.

Advantages include high accuracy, short production time, reliability, flexibility, simpler fixturing and contour machining. Disadvantages include high costs, maintenance requirements, training costs, complex programming needs and space requirements.

Robots & Automation – MFET 445

Robots & CNC in Integrated


Manufacturing – MFET 685
Agenda
• CNC
• Control System
• Program Planning
• Examples

2
What is NC and CNC technology?
NC - emerged in the mid 20th century
• Numerical Control
• Can be traced back to the U.S. Air
Force, MIT, John Parsons
• Definition: Operation of machine
tools by means of specifically coded
instructions to the machine control
system
• Uses fixed logical functions that are
built-in and permanently wired
within the control unit
• “Hardwired”
What is NC and CNC technology?
NC - emerged in the mid 20th century
• Numerical Control
• Can be traced back to the U.S. Air
Force, MIT, John Parsons
• Definition: Operation of machine
tools by means of specifically coded
instructions to the machine control
system
• Uses fixed logical functions that are
built-in and permanently wired
within the control unit
• “Hardwired”
What is NC and CNC technology?
NC - emerged in the mid 20th century
• Numerical Control
• Can be traced back to the U.S. Air
Force, MIT, John Parsons
• Definition: Operation of machine
tools by means of specifically coded
instructions to the machine control
system
• Uses fixed logical functions that are
built-in and permanently wired
within the control unit
• “Hardwired”
What is NC and CNC technology?
CNC - Also emerged in the mid 20th century, about 20 years after NC
 Computerized Numerical Control
 Modern CNC systems use an internal microprocessor
 Results in the ability of the user to change any program at the control unit
 Greatly increases the tool’s flexibility
Advantages and Disadvantages

Advantages Disadvantages

• Highly accurate • High cost
• Short production  • Maintenance
time • Training costs 
• Reliable • Complex 
• Flexible programming 
• Simpler fixturing  (requires skilled 
• Contour machining workers)
• Space 
Types of CNC Machine Tools
 Mills and Machining Centers
 Lathes and Turning Centers
 Drilling Machines
 Boring mills and Profilers
 EDM Wire Machines
 Punch presses and Shears
 Flame cutting Machines
 Routers
 Water Jet & Laser profilers
 Cylindrical Grinders
 Welding Machines
 Benders, Winding and Spinning Machines
CNC Milling Machine
CNC Milling Machine
CNC Lathe
CNC Flame/Plasma Cutting Machine
CNC Water Jets
Machine Control Unit
• A microcomputer that stores the program and executes the commands into
actions.
• The MCU consists of two main units: Data Processing Unit (DPU) and the
Control Loops Unit (CLU)

– DPU: a software that includes algorithm calculations, it converts a


part program into a usable format for the MCU.

– CLU: consists of the circuits for position and velocity control loops,
acceleration/de-acceleration and functions such as spindle ON/OFF.
Machine Control Unit

Human-
machine
Servo drives
interface
PLC
G-code
interpreter
Digital scales
Cartesian Coordinate system

• Right Hand Rule: Three axes positioned 
90 degrees from each other
CNC Sequence/Interface
CNC Milling
 Definition: A Milling machine is a machine capable of
simultaneous cutting motion, using an end mill as the primary
cutting tool, along at least two axes at the same time
 Common for modern CNC Milling machines to have more than 2
axes
 Milling machines can be divided into three categories
 By number of axes (2, 3, or more)
 By the orientation of axes (vertical or horizontal)
 By the presence or absence of a tool changer
CNC Milling, Machine Axes
• Milling machines and machining centers have at least three axes :
X,Y, Z.
• Flexibility can be further increased if they incorporate a 4th axis
(usually an indexing or rotary axis)
• Even more flexibility can be found on machines with 5 or more
axes ( usually 3 main ones + a rotary and one parallel to the Z)
https://www.youtube.co

4 axis m/watch?v=HpG9qlYFj
FU
https://www.youtube.com/watch

5-axis ?v=xZOiNdkJ8SU
CNC Milling, Machine Axes
• Vertical Machining Centers
• Most of the machining is
done on one face
• Mainly used for cutting
flat(-ish) parts
• Multiple axes can improve
flexibility
• Lighter maching
operations
CNC Milling, Machine Axes
https://www.youtube.com/watch?
v=KaMmVjTcAbw
• Horizontal Machining Centers
• Categorized as multi-tool and
versatile machines
• Mainly used for cutting
cubical parts
• Majority of machining has to
be done on more than one
face in a single step
• Much heavier machines,
faster stock removal
• Well suited for multi part
setups
Parts of a vertical mill
Vertical Milling Center Machine
Coordinates:
CNC Turning
 CNC Turning Centers, AKA CNC Lathes
 Can be categorized by type of design and number of axes
 Front Lathe - An engine lathe type with flat ways
 Slant Bed – ways tilted towards vertical
 Most vertical CNC Lathe designs have two available axes
 Horizontal CNC Lathe designs commonly have two axes, but are
also available with 3, 4, 6, or more axes, adding more flexibility to
the manufacturing of more complex parts
 A typical CNC Lathe is designed with two standard axes: X and Z
 X axis represents the cross-travel of the cutting tool
 Z axis represents the longitudinal motion of the cutting tool
 X and Z are perpendicular to each other
CNC Turning
CNC Lathe Axes
Lathe coordinates:
Coordinate Geometry
 One of the first major steps towards basic understanding of CNC
principles and geometrical concepts is through understanding the
system of coordinates
 Founded on a number of mathematical principles such as the real
number system and rectangular coordinates
 Real Number System
 Zero integer
 Positive integers
 Negative integers
 Fractions
 Decimal fractions
 Rectangular Coordinate System
4-axis, 5 axis + setup:
Control System
 In order to fully understand CNC Programming, it is especially
important to know how the computer, the CNC unit, actually
works. Below is a diagram of a Fanuc Control Panel
Control Systems Cont’d
 Any control unit has two basic components
 Operation panel
 Rotary switches, toggle switches, push buttons
 Display screen with a keyboard or a keypad
 Is the window to control operations
 Any active program can be viewed, even a graphical representation of the
toolpath
 The keyboard is used to input instructions to the control
 Existing programs can be modified or deleted
 New programs can be added
 It is important that the programmer knows and understands all of
the functions of the control system
Control System Cont’d
A typical operation panel of a CNC machining
center
Control System Cont’d, Important features
 Handle
 For setup purposes, CNC Machines have a rotary handle that will
move the selected axis by a certain multiplied increment
 See adjacent figure
Control System Cont’d, Important Features
 Parameter settings
 Binary codes
 Unit inputs
 Settings values
 Manual Program Interruption
 Single Block Operation
 Sequential operations
 Feedhold
 Special push button that stops all feeds on all active axes
 Emergency Stop
 Mushroom shaped, red button in a very accessible place on the machine.
 All machine activity will stop and the main power supply will be cut off
Control System Cont’d, Important Features
 Memory capacity
 Programs are stored in the control memory, limited by capacity
 Manual Data Input (MDI)
 Enables the input of program data into the system one line at a
time
 Program Data Override
 Rapid Feedrate Override (Rapid traverse)
 Spindle speed override
 Feedrate override (Cutting rate)
 Dry run mode
Program Planning
 Development of any CNC Program should always begin with a very carefully planned process.
 Typically starts with an engineering drawing or blueprint
 This is done before any machining process is done
 Basic steps and things to consider:
 Initial Information Provided / Machine tools features
 Part complexity / Evaluation of Machining features
 Manual programming / computerized programming
 Typical programming procedure / Program structure
 Part drawing / Engineering Data
 Methods sheet / Material Specifications
 Machining sequence - Operations / tool order
 Tooling selection / cutting holders / inserts / HSS Tools
 Part setup / Part Holding / Fixtures
 Technological decisions / cutting conditions
 Work sketch and individual calculations
 Quality considerations in CNC Programming
Program Planning Cont’d
 Initial Information
 The main purpose of most engineering drawings is to define the part
shape, individual dimensions, and relationships between part features
 Machine features
 Be sure that the selected CNC machine is suitable for a particular job
 Take into account machine type and size
 Being familiar with the CNC’s control system
 Part Complexity
 How difficult is it to manufacture the part? Manually? Automatically?
 Machine capabilities?
 Cost?
 Many simple jobs can be given to a less experienced programmer or to a
CNC operator
Program Planning Cont’d
 Manual Programming
 Without a computer, is a very common method in preparing a part
program
 Good for few uses, but should develop into a repeatable program if used
more frequently
 Disadvantages
 Length of time required to develop a fully functional program
 Manual calculations
 Large percentage of errors
 Lack of tool path verifications
 Advantages
 Offers virtually unlimited freedom in actual development
 Teaches a tight discipline and organization in program preparation
 Forces programmer to understand programming techniques to a very fine level
of detail
Program Planning Cont’d
 The use of CAD/CAM is also considered manual programming
due to the fact that a user has to design the part in a 3D software.
 Part Drawing
 The single most important document used in CNC Programming
 Identifies the shape, important dimensions, tolerances, surface
finish, and other requirements
Computer-aided design (CAD)
• Computer‐aided 
design (CAD) is the 
use of computer 
systems to assist in 
the creation, 
modification, 
analysis, or 
optimization of a 
design.
Computer-aided manufacturing (CAM)
• Computer‐aided 
manufacturing (CAM) 
is the use of computer 
systems to plan, 
manage, and control 
the operations of a 
manufacturing plant 
through direct or 
indirect computer 
interface with plant’s 
resources.
Computer Aided Engineering
(CAE)
• Computer Aided 
Engineering (CAE) 
use of computer 
systems to analyze 
CAD geometry. 
– It allows the designer 
to simulate how the 
product will behave 
allowing for 
optimization. 
• Finite Element 
Method (FEM)
– Divides model into 
interconnected 
elements
– Solves continuous 
field problems
CAD/CAM/CAE
How CAD/CAM/CAE works:
• Developing NC code requires an understanding of:
1. Part geometry
2. Tooling
3. Process plans
4. Tolerances
5. Fixturing
• Most CAD/CAM/CAE systems provide access to:
1. Part geometry
2. Tooling
Program Planning Cont’d
 Methods sheet
 Some companies have a staff of qualified manufacturing
technologists or process planners responsible for determining all
manufacturing processes
 Develop a series of machining instructions
 Detailing the exact route of each part through the manufacturing process
 Instructions are written on a Methods sheet
 Material specifications
 Material stock
 Raw material such as a bar, billet, plate, forging, casting
 The size and shape of the material determines that setup mounting method
 Material Uniformity
 Machinability Rating
Basic Motion G-Codes

Code Use
G00 Move at rapid speed to a new position
G01 Move at a controlled feed to a new position (cutting)
G02 Move in a clockwise circular arc at controlled feed (cutting)
G03 Move in a counterclockwise arc at controlled feed (cutting)

These four codes make up the bulk of most G-Code programs

These are “modal” codes. Once used, the control assumes all new coordinates are using
the same command until a new one is invoked

G00 X1. Y2. G00 X1. Y2.


G00 X4. Y1. is equivalent to X4. Y1
G00 X2. Y3. X2. Y3.
G01 X2. Y4. G01 X2. Y4.
Decimals

On modern CNC controllers the trailing decimal point is not needed

G00 X1. Y2. G00 X1 Y2

Are interpreted the same.

On old controllers with limited memory, extra zeroes used up too much space in small
moves

G00 X0.001 Y0.002

So they were implemented to work in 1/1000 inch increments unless the decimal place was
inserted

G00 X1. Y1. moves 1 inch in X and Y


G00 X1 Y1 moves 0.001 inch in X and Y
Other Basic G-codes and words

Code Use
G20 Sets units as INCHES
G21 Sets units in mm
G81 Simple drilling canned cycle

Code Use
X Distance along X axis
Y Distance along Y axis
Z Distance along Z axis
A 4th axis
B 5th axis
C 6th axis
G00
Syntax:

G00 X5. Y1. Z-3.

Move at the machine rapid speed from current position to position X, Y, Z

This command would go from wherever the tool is at the moment and drive it to:
• 5 inches in positive X direction from machine zero position
• 1 inch in positive Y direction from machine zero position
• 3 inches in negative Z direction from machine zero position

All these motions occur simultaneously, so use caution.

Better practice is to split up Z and X,Y motions to prevent collisions


G00 Z-3.
G00 X5. Y1.
G00
Do not use for cutting as it will likely break
Syntax: the tool! Straight line path is not guaranteed!

G00 X5. Y1. Z-3.

Move at the machine rapid speed from current position to position X, Y, Z

This command would go from wherever the tool is at the moment and drive it to:
• 5 inches in positive X direction from machine zero position
• 1 inch in positive Y direction from machine zero position
• 3 inches in negative Z direction from machine zero position

All these motions occur simultaneously, so use caution.

Better practice is to split up Z and X,Y motions to prevent collisions


G00 Z-3.
G00 X5. Y1.
G00
Do not use for cutting as it will likely break
Syntax: the tool! Straight line path is not guaranteed!

G00 X5. Y1.

X5 Y1
Y

X
G00
Do not use for cutting as it will likely break
Syntax: the tool! Straight line path is not guaranteed!

G00 X5. Y1.

X5 Y1
Y

X
G01
Syntax:

G01 X5. Y1. Z-3. F5

Move from current position to position X, Y, Z at F inches per minute (or mm/min if in G21 mode)

This command would go from wherever the tool is at the moment and drive it to:
• 5 inches in positive X direction from machine zero position
• 1 inch in positive Y direction from machine zero position
• 3 inches in negative Z direction from machine zero position

All these motions occur simultaneously, so use caution. Path will be a straight line in 3 dimensions at
5 inches/min speed
G01
Syntax:

G01 X5. F5

G01 command is typically used for actual cutting operations.

Usually do Z motions and X,Y motions separately unless you are doing 3D profiles.

G00 X0. Y0.


G01 Z-1. F3
G01 X1. F10
Y1
X0
Y0
G00 Z1
G02
Syntax:

G02 X0. Y0. I1. J0. F5

Move from current position to position X, Y at F inches per minute (or mm/min if in G21 mode)
following a clockwise circular path with centerpoint displaced by I in the X direction and J in the Y
direction

ending
Starting point X,Y
point
J

I centerpoint
G02
Syntax:

G02 X0. Y0. I1. J0. F5

(starting from X0, Y0) Complete clockwise circle starting from X0 Y0, radius=2

Starting
point

centerpoint

I=1
G02
Syntax:

G02 X0. Y0. I-1. J0. F5

(starting from X0, Y0) Complete clockwise circle starting from X0 Y0, radius=2

Starting
point

I=-1
G03
Syntax:

G03 X0. Y0. I1. J0. F5

Move from current position to position X, Y at F inches per minute (or mm/min if in G21 mode)
following a counterclockwise circular path with centerpoint displaced by I in the X direction and J in
the Y direction

Starting
ending
point
point X,Y
J

centerpoint I
G17
Specifies that G2 and G3 commands produce a circular motion in the XY plane

Z
I is center displacement
in X direction

J is center G03 X0. Y0. Z0. I1. J0. F5


displacement in Y
direction

Y
X
G18
Specifies that G2 and G3 commands produce a circular motion in the XZ plane

Z
I is center displacement
in X direction
G03 X0. Y0. Z0. I1. K0. F5
K is center
displacement in Z
direction

Y
X
G19
Specifies that G2 and G3 commands produce a circular motion in the YZ plane

Z
J is center
displacement in Y
direction G03 X0. Y0. Z0. J1. K0. F5

K is center
displacement in Z
direction

Y
X
What path does this code generate?

G17
G0 X0 Y0
G03 X0. Y0. I0. J1. F5
G02 X0 Y0 I0 J-1 F5
Other Basic Words

Code Use
M03 Start spindle rotating clockwise (viewed from above)
M04 Start spindle rotating counterclockwise (viewed from above)
M05 Stop spindle rotation
M08 Turn on flood coolant
M09 Turn off flood coolant
M30 End of program, rewind

S Set spindle speed in RPM


T Select cutting tool
Elements of an NC Part Program
• An NC program is composed 
of blocks (lines) of code. 
• Each block contains a string 
of words. An NC word is a 
code made up of an 
alphabetical character (called 
an address) and a number 
(called a parameter). 
Anatomy of a .tap file
O0001
N1 G20
N2 (1/4 EM HSS 2FL 1/2 LOC)
N3 G91
N4 T09 M06
N5 S3819 M03

N6 ( Rough Mill2 )
N7 G90 G54 G00 X-.06 Y-1.56
N8 G43 Z1. H09 M08
N9 G01 Z-.1 F3.
N10 G17 Y.06 F10.
N11 X3.06
N12 Y-1.56
N13 X-.06

.....

N684 Z1. M09 M05


N685 G40 X1.875 Y-.75
N686 G91 G28 Z0
N687 G28 X0 Y0
N688 M30
Anatomy of a .tap file
O0001 Meaning:
N1 G20
N2 (1/4 EM HSS 2FL 1/2 LOC) Program Name 0001
N3 G91
N4 T09 M06
N5 S3819 M03

N6 ( Rough Mill2 )
N7 G90 G54 G00 X-.06 Y-1.56
N8 G43 Z1. H09 M08
N9 G01 Z-.1 F3.
N10 G17 Y.06 F10.
N11 X3.06
N12 Y-1.56
N13 X-.06

.....

N684 Z1. M09 M05


N685 G40 X1.875 Y-.75
N686 G91 G28 Z0
N687 G28 X0 Y0
N688 M30
Anatomy of a .tap file
O0001 Meaning:
N1 G20
N2 (1/4 EM HSS 2FL 1/2 LOC) N1 = program line 1
N3 G91
N4 T09 M06 G20 = units in inches
N5 S3819 M03

N6 ( Rough Mill2 )
N7 G90 G54 G00 X-.06 Y-1.56
N8 G43 Z1. H09 M08
N9 G01 Z-.1 F3.
N10 G17 Y.06 F10.
N11 X3.06
N12 Y-1.56
N13 X-.06

.....

N684 Z1. M09 M05


N685 G40 X1.875 Y-.75
N686 G91 G28 Z0
N687 G28 X0 Y0
N688 M30
Anatomy of a .tap file
O0001 Meaning:
N1 G20
N2 (1/4 EM HSS 2FL 1/2 LOC) N2 = program line 2
N3 G91
N4 T09 M06 Everything enclosed in parenthesis is a
N5 S3819 M03 COMMENT. The mill control does nothing
with it.
N6 ( Rough Mill2 ) This is provided for the program user.
N7 G90 G54 G00 X-.06 Y-1.56
N8 G43 Z1. H09 M08 In this case it is a reminder to the user
N9 G01 Z-.1 F3. that the tool expected is a
N10 G17 Y.06 F10. • ¼ inch diameter endmill
N11 X3.06 • High speed steel
• 2 flutes
N12 Y-1.56
• ½ inch length of cut
N13 X-.06

.....

N684 Z1. M09 M05


N685 G40 X1.875 Y-.75
N686 G91 G28 Z0
N687 G28 X0 Y0
N688 M30
Anatomy of a .tap file
O0001 Meaning:
N1 G20
N2 (1/4 EM HSS 2FL 1/2 LOC) N3 = program line 3
N3 G91
N4 T09 M06 G91 = sets incremental program mode.
N5 S3819 M03 G00 and G01 moves are in reference to
the previous tool position
N6 ( Rough Mill2 ) (we are going to use G90 for this program
N7 G90 G54 G00 X-.06 Y-1.56 in a later step. This is just a default code
N8 G43 Z1. H09 M08 produced by this particular
N9 G01 Z-.1 F3. postprocessor. Since we don’t really know
N10 G17 Y.06 F10. what the last user of the mill did, we want
N11 X3.06 to set the control to a known starting
state)
N12 Y-1.56
N13 X-.06

.....

N684 Z1. M09 M05


N685 G40 X1.875 Y-.75
N686 G91 G28 Z0
N687 G28 X0 Y0
N688 M30
Anatomy of a .tap file
O0001 Meaning:
N1 G20
N2 (1/4 EM HSS 2FL 1/2 LOC) N4 = program line 4
N3 G91
N4 T09 M06 T9 = specify tool #9 from tool list
N5 S3819 M03
M06 = perform automatic tool change
N6 ( Rough Mill2 )
N7 G90 G54 G00 X-.06 Y-1.56
N8 G43 Z1. H09 M08
N9 G01 Z-.1 F3.
N10 G17 Y.06 F10.
N11 X3.06
N12 Y-1.56
N13 X-.06

.....

N684 Z1. M09 M05


N685 G40 X1.875 Y-.75
N686 G91 G28 Z0
N687 G28 X0 Y0
N688 M30
Anatomy of a .tap file
O0001 Meaning:
N1 G20
N2 (1/4 EM HSS 2FL 1/2 LOC) N5 = program line 5
N3 G91
N4 T09 M06 S3819 = specify spindle speed to be 3819
N5 S3819 M03 RPM

M03 = turn on spindle motor in clockwise


N6 ( Rough Mill2 ) direction
N7 G90 G54 G00 X-.06 Y-1.56
N8 G43 Z1. H09 M08
N9 G01 Z-.1 F3.
N10 G17 Y.06 F10.
N11 X3.06
N12 Y-1.56
N13 X-.06

.....

N684 Z1. M09 M05


N685 G40 X1.875 Y-.75
N686 G91 G28 Z0
N687 G28 X0 Y0
N688 M30
Anatomy of a .tap file
O0001 Meaning:
N1 G20
N2 (1/4 EM HSS 2FL 1/2 LOC) N6 = program line 6
N3 G91
N4 T09 M06 Comment in parentheses
N5 S3819 M03
(To help user understand what this block
of code is doing)
N6 ( Rough Mill2 )
N7 G90 G54 G00 X-.06 Y-1.56
N8 G43 Z1. H09 M08
N9 G01 Z-.1 F3.
N10 G17 Y.06 F10.
N11 X3.06
N12 Y-1.56
N13 X-.06

.....

N684 Z1. M09 M05


N685 G40 X1.875 Y-.75
N686 G91 G28 Z0
N687 G28 X0 Y0
N688 M30
Anatomy of a .tap file
O0001 Meaning:
N1 G20
N2 (1/4 EM HSS 2FL 1/2 LOC) N7 = program line 7
N3 G91
N4 T09 M06 G90 = turn on absolute position mode, all
N5 S3819 M03 X Y Z coordinates will be relative to part
zero configured during setup
N6 ( Rough Mill2 ) (This is the standard mode most
N7 G90 G54 G00 X-.06 Y-1.56 programs will be using)
N8 G43 Z1. H09 M08
N9 G01 Z-.1 F3. G54 = use first work coordinate system
N10 G17 Y.06 F10.
N11 X3.06 G00 = move to coordinates
X-0.06, Y-1.56
N12 Y-1.56
N13 X-.06

.....

N684 Z1. M09 M05


N685 G40 X1.875 Y-.75
N686 G91 G28 Z0
N687 G28 X0 Y0
N688 M30
Anatomy of a .tap file
O0001 Meaning:
N1 G20
N2 (1/4 EM HSS 2FL 1/2 LOC) N8 = program line 8
N3 G91
N4 T09 M06 G43 = set tool height compensation to be
N5 S3819 M03 negative

(This chooses the tool length to hang


N6 ( Rough Mill2 ) below the position of the spindle. If tool 9
N7 G90 G54 G00 X-.06 Y-1.56 is defined as 1 inch long, the machine
N8 G43 Z1. H09 M08 knows that it is 1 inch below the spindle
N9 G01 Z-.1 F3. offset line. If we used G44 it would define
N10 G17 Y.06 F10. the tool as 1 inch above the spindle offset
N11 X3.06 line.)
N12 Y-1.56
N13 X-.06

.....

N684 Z1. M09


N685 G40 X1.875 Y-.75
N686 G91 G28 Z0
N687 G28 X0 Y0
N688 M30
Anatomy of a .tap file
O0001 Meaning:
N1 G20
N2 (1/4 EM HSS 2FL 1/2 LOC) N8 = program line 8
N3 G91
N4 T09 M06 G43 = set tool height compensation to be
N5 S3819 M03 negative

Z1 = move to Z=1 (remember G00 is still in


N6 ( Rough Mill2 ) effect from line N7)
N7 G90 G54 G00 X-.06 Y-1.56
N8 G43 Z1. H09 M08 H09 = pick tool offset for tool #9 from tool
N9 G01 Z-.1 F3. table
N10 G17 Y.06 F10.
N11 X3.06 M08 = turn on flood coolant pump
N12 Y-1.56
N13 X-.06

.....

N684 Z1. M09 M05


N685 G40 X1.875 Y-.75
N686 G91 G28 Z0
N687 G28 X0 Y0
N688 M30
How do we specify tool length?
VMC spindle
VMC spindle

Want the distance from


the tip of the tool to the
workpiece Z=0 position

Varies from tool to tool


VMC spindle

We can measure the


position of the spindle
flange in machine
coordinate system

Never changes

Obtains physical distance


between spindle flange
and machine table
VMC spindle

Cat30
Cat40
Cat50

BT taper
NMTB taper
Tormach TTS

These all preserve the position


of the tool relative to the
spindle face DATUM
Tool Type Length Diameter
1 #21 Drill HSS 2FL 5.347 0.1590
2 ¼” C EM 4FL 3.758 0.247
3 ½” C EM 2 FL 3.955 5.0013
4 4” insert face mill 4.057 4.055
5 0.375 HSS reamer 4FL 6.755 0.3752
Machine coordinate system
ZMCS = 12.000 in
Tool 1 length
L1 = 5.347 in
Touch off on part

Set ZTCS = 0.000 in


Move up 4 inches

ZTCS = 4.000 in
Replace Tool 1 with Tool 2

Tool 1 length
L1 = 5.347 in

Tool 2 length
L1 = 3.758 in

Tool offset
1.589 in

New ZTCS = 4+1.589


= 5.589in
Anatomy of a .tap file
O0001 Meaning:
N1 G20
N2 (1/4 EM HSS 2FL 1/2 LOC) N8 = program line 8
N3 G91
N4 T09 M06 G43 = set tool height compensation to be
N5 S3819 M03 negative

(This chooses the tool length to hang


N6 ( Rough Mill2 ) below the position of the spindle. If tool 9
N7 G90 G54 G00 X-.06 Y-1.56 is defined as 1 inch long, the machine
N8 G43 Z1. H09 M08 knows that it is 1 inch below the spindle
N9 G01 Z-.1 F3. offset line. If we used G44 it would define
N10 G17 Y.06 F10. the tool as 1 inch above the spindle offset
N11 X3.06 line.)
N12 Y-1.56
N13 X-.06

.....

N684 Z1. M09


N685 G40 X1.875 Y-.75
N686 G91 G28 Z0
N687 G28 X0 Y0
N688 M30
Anatomy of a .tap file
O0001 Meaning:
N1 G20
N2 (1/4 EM HSS 2FL 1/2 LOC) N8 = program line 8
N3 G91
N4 T09 M06 G43 = set tool height compensation to be
N5 S3819 M03 negative

Z1 = move to Z=1 (remember G00 is still in


N6 ( Rough Mill2 ) effect from line N7)
N7 G90 G54 G00 X-.06 Y-1.56
N8 G43 Z1. H09 M08 H09 = pick tool offset for tool #9 from tool
N9 G01 Z-.1 F3. table
N10 G17 Y.06 F10.
N11 X3.06 M08 = turn on flood coolant pump
N12 Y-1.56
N13 X-.06

.....

N684 Z1. M09 M05


N685 G40 X1.875 Y-.75
N686 G91 G28 Z0
N687 G28 X0 Y0
N688 M30
Anatomy of a .tap file
O0001 Meaning:
N1 G20
N2 (1/4 EM HSS 2FL 1/2 LOC) N9 = program line 9
N3 G91
N4 T09 M06 G01 = move spindle to position Z=-0.1 at a
N5 S3819 M03 speed of 3 inches per minute

N6 ( Rough Mill2 ) (This move lowers the tool until it starts


N7 G90 G54 G00 X-.06 Y-1.56 cutting the part. The part zero is meant to
N8 G43 Z1. H09 M08 be defined as the top of the stock for this
N9 G01 Z-.1 F3. program, so this move drives the tool
N10 G17 Y.06 F10. slowly into the stock until it is 0.1 inches
N11 X3.06 deep)
N12 Y-1.56
N13 X-.06

.....

N684 Z1. M09 M05


N685 G40 X1.875 Y-.75
N686 G91 G28 Z0
N687 G28 X0 Y0
N688 M30
Anatomy of a .tap file
O0001 Meaning:
N1 G20
N2 (1/4 EM HSS 2FL 1/2 LOC) N10 = program line 10
N3 G91
N4 T09 M06 G17 = select XY plane for any rotational
N5 S3819 M03 G02 or G03 moves

Then the table moves to Y=0.06 at a feed


N6 ( Rough Mill2 ) of 10 inches per minute
N7 G90 G54 G00 X-.06 Y-1.56
N8 G43 Z1. H09 M08 (remember G01 is still active from line N9)
N9 G01 Z-.1 F3.
N10 G17 Y.06 F10.
N11 X3.06
N12 Y-1.56
N13 X-.06

.....

N684 Z1. M09 M05


N685 G40 X1.875 Y-.75
N686 G91 G28 Z0
N687 G28 X0 Y0
N688 M30
Anatomy of a .tap file
O0001 Meaning:
N1 G20
N2 (1/4 EM HSS 2FL 1/2 LOC) N11, N12, etc
N3 G91
N4 T09 M06 Many X, Y moves
N5 S3819 M03
System is still in G01 mode from line N9
N6 ( Rough Mill2 ) Feed was last set at 10 inches/minute
N7 G90 G54 G00 X-.06 Y-1.56 from line N10
N8 G43 Z1. H09 M08
N9 G01 Z-.1 F3.
N10 G17 Y.06 F10.
N11 X3.06
N12 Y-1.56
N13 X-.06

.....

N684 Z1. M09 M05


N685 G40 X1.875 Y-.75
N686 G91 G28 Z0
N687 G28 X0 Y0
N688 M30
Anatomy of a .tap file
O0001 Meaning:
N1 G20
N2 (1/4 EM HSS 2FL 1/2 LOC) N684 = line 684
N3 G91
N4 T09 M06 Z1 = move spindle to Z=1 position
N5 S3819 M03
(This removes tool from contact with part)
N6 ( Rough Mill2 ) M09 = turn off flood coolant pump
N7 G90 G54 G00 X-.06 Y-1.56
N8 G43 Z1. H09 M08 M05 = turn off machine spindle
N9 G01 Z-.1 F3.
N10 G17 Y.06 F10.
N11 X3.06
N12 Y-1.56
N13 X-.06

.....

N684 Z1. M09 M05


N685 G40 X1.875 Y-.75
N686 G91 G28 Z0
N687 G28 X0 Y0
N688 M30
Anatomy of a .tap file
O0001 Meaning:
N1 G20
N2 (1/4 EM HSS 2FL 1/2 LOC) N685 = line 685
N3 G91
N4 T09 M06 G40 = turn off cutter compensation mode
N5 S3819 M03
(cutter compensation mode is used for
precision size cuts by measuring the wear
N6 ( Rough Mill2 ) on the tool with a micrometer and entering
N7 G90 G54 G00 X-.06 Y-1.56 it into the tool table)
N8 G43 Z1. H09 M08
N9 G01 Z-.1 F3. Part moves to X 1.875, Y -0.75
N10 G17 Y.06 F10.
N11 X3.06 (system still in G01 mode from previous
lines)
N12 Y-1.56
N13 X-.06

.....

N684 Z1. M09 M05


N685 G40 X1.875 Y-.75
N686 G91 G28 Z0
N687 G28 X0 Y0
N688 M30
Anatomy of a .tap file
O0001 Meaning:
N1 G20
N2 (1/4 EM HSS 2FL 1/2 LOC) N686 = line 686
N3 G91
N4 T09 M06 G91 = incremental programming mode
N5 S3819 M03 enabled

G28 Z0 = drive spindle to Z vertical home


N6 ( Rough Mill2 ) position passing through Z=0
N7 G90 G54 G00 X-.06 Y-1.56
N8 G43 Z1. H09 M08
N9 G01 Z-.1 F3.
N10 G17 Y.06 F10.
N11 X3.06
N12 Y-1.56
N13 X-.06

.....

N684 Z1. M09 M05


N685 G40 X1.875 Y-.75
N686 G91 G28 Z0
N687 G28 X0 Y0
N688 M30
Anatomy of a .tap file
O0001 Meaning:
N1 G20
N2 (1/4 EM HSS 2FL 1/2 LOC) N687 = line 687
N3 G91
N4 T09 M06 G28 X0 Y0 = drive table to X, Y home
N5 S3819 M03 positions passing through X0 Y0

N6 ( Rough Mill2 )
N7 G90 G54 G00 X-.06 Y-1.56
N8 G43 Z1. H09 M08
N9 G01 Z-.1 F3.
N10 G17 Y.06 F10.
N11 X3.06
N12 Y-1.56
N13 X-.06

.....

N684 Z1. M09 M05


N685 G40 X1.875 Y-.75
N686 G91 G28 Z0
N687 G28 X0 Y0
N688 M30
Anatomy of a .tap file
O0001 Meaning:
N1 G20
N2 (1/4 EM HSS 2FL 1/2 LOC) N688 = line 688
N3 G91
N4 T09 M06 M30 = end program and rewind to start
N5 S3819 M03

N6 ( Rough Mill2 )
N7 G90 G54 G00 X-.06 Y-1.56
N8 G43 Z1. H09 M08
N9 G01 Z-.1 F3.
N10 G17 Y.06 F10.
N11 X3.06
N12 Y-1.56
N13 X-.06

.....

N684 Z1. M09 M05


N685 G40 X1.875 Y-.75
N686 G91 G28 Z0
N687 G28 X0 Y0
N688 M30
G02
Conventional Syntax:

G02 X0. Y0. I1. J0. F5

Move from current position to position X, Y at F inches per minute (or mm/min if in G21 mode)
following a clockwise circular path with centerpoint displaced by I in the X direction and J in the Y
direction

ending
Starting point X,Y
point
J

I centerpoint
G02
Alternative Syntax:

G02 X0. Y0. R1. F5

Move from current position to position X, Y at F inches per minute (or mm/min if in G21 mode)
following a clockwise circular path with radius R

ending
Starting point X,Y
point R

centerpoint
G02
Alternative Syntax:

G02 X0. Y0. R1. F5

The R word is modal. Useful if you are doing a series of fillets or similar features

R1 G01 X0 Y5 F5
G02 X1 Y10 R1
G01 X9 Y10
G02 X10 Y9
G01 X10 Y1
G02 X9 Y0
G01 X1 Y0
G02 X0 Y1

Starting
point
G02
Syntax:

G02 X0. Y0. I1 J0. F5

(starting from X0, Y0) Complete clockwise circle starting from X0 Y0, radius=2

Starting
point

centerpoint

I=1
G02
Alternative Syntax:

G02 X0. Y0. R1. F5

(starting from X0, Y0) Complete clockwise circle starting from X0 Y0, radius=1

Starting
point

centerpoint

R=1
G02
Alternative Syntax:

G02 X0. Y0. R1. F5

(starting from X0, Y0) Complete clockwise circle starting from X0 Y0, radius=2

Starting
point Centerpoint undefined

This syntax cannot be used


to generate a complete
circle!
G02
Alternative Syntax:

G02 X2. Y1. R1. F5

clockwise arc starting from X1 Y2, radius=1

Starting
point
X1 Y2

R=1

X2 Y1
G02
Alternative Syntax:

G02 X2. Y1. R1. F5

clockwise arc starting from X1 Y2, radius=1

Starting
point R=1
X1 Y2

X2 Y1
G02
Alternative Syntax:

G02 X2. Y1. R1. F5

Normally controller chooses shortest


pathway

R= -1
X1 Y2

R=1
Some: Specify the longer pathway by using
negative R value
X2 Y1
Some controllers do not allow crossing a
quadrant boundary for circular arcs (90o arcs
maximum)
Canned Cycles

G81 – simple drilling cycle

G00 X0 Y0 Z3 Rapid move to X0 Y0 Z3

G90 G81 X1 Y0 Z-1 R2 F5 Absolute coordinate system

Rapid move to X1 Y0

Move in Z direction at speed 5 inches/min to a depth of Z = -1


retract
Rapid retract to Z = 2
Canned Cycles
Rapid move to X0 Y0 Z3
G81 – simple drilling cycle
RELATIVE coordinate system

Rapid move to X1 Y0
G00 X0 Y0 Z3
Move in Z direction at speed 5 inches/min to a depth of Z = -1
G91 G81 X1 Y0 Z-1 R2 K3 F5
Rapid retract to Z = 2

Rapid move to X2 Y0

repeats Move in Z direction at speed 5 inches/min to a depth of Z = -1

Rapid retract to Z = 2

Rapid move to X3 Y0

Move in Z direction at speed 5 inches/min to a depth of Z = -1

Rapid retract to Z = 2
Canned Cycles

G82 – dwell drilling cycle

G00 X0 Y0 Z3 Rapid move to X0 Y0 Z3

G90 G82 X1 Y0 Z-1 R2 P1000 F5 Absolute coordinate system

Rapid move to X1 Y0

Move in Z direction at speed 5 inches/min to a depth of Z = -1


Dwell time
(msec) Dwell at bottom of hole for 1000 milliseconds

Rapid retract to Z = 2
Canned Cycles
Rapid move to X0 Y0 Z3

Absolute coordinate system


G83 – peck drilling cycle
Rapid move to X1 Y0
G00 X0 Y0 Z3
Move in Z direction at speed 5 inches/min to a depth of Z = -0.1
G90 G83 X1 Y0 Z-1 Q0.1 R2 F5
Retract to Z = 2

Rapid to Z = -0.1 + a bit

Move in Z direction at speed 5 inches/min to a depth of Z = -0.2


Peck retract
Retract to Z = 2

Rapid to Z = -0.2 + a bit

Move in Z direction at speed 5 inches/min to a depth of Z = -0.2

(8 more times until Z = -1 is reached)

Retract to Z = 2
Canned Cycles
Rapid move to X0 Y0 Z3

Start spindle at 150 rpm in CW direction


G84 – tapping cycle
(tapping head – right hand threads)
Absolute coordinate system

Rapid move to X1 Y0
G00 X0 Y0 Z3 S150 M03
Move spindle down until Z = -1 is reached. Feedrate is
G90 G84 X1 Y0 Z-1 P500 R2 F20
specified in threads/inch with the G84 command – thus, the
spindle moves down 1/20 inch for every revolution of the
spindle – dwell for P msec

Reverse spindle to 150 rpm in CCW direction

Move spindle up until Z = 2 is reached. Feedrate is specified in


threads/inch with the G84 command – thus, the spindle moves
up 1/20 inch for every revolution of the spindle
Canned Cycles
Rapid move to X0 Y0 Z3

Start spindle at 150 rpm in CCW direction


G74 – tapping cycle
(tapping head – left hand threads)
Absolute coordinate system

Rapid move to X1 Y0
G00 X0 Y0 Z3 S150 M03
Move spindle down until Z = -1 is reached. Feedrate is
G90 G74 X1 Y0 Z-1 P500 R2 F20
specified in threads/inch with the G84 command – thus, the
spindle moves down 1/20 inch for every revolution of the
spindle – dwell for P msec

Reverse spindle to 150 rpm in CW direction

Move spindle up until Z = 2 is reached. Feedrate is specified in


threads/inch with the G84 command – thus, the spindle moves
up 1/20 inch for every revolution of the spindle
Canned Cycles
Rapid move to X0 Y0 Z3

Start spindle at 150 rpm in CW direction


G84.2 – tapping cycle
(rigid tapping – right hand threads)
Absolute coordinate system

Rapid move to X1 Y0
G00 X0 Y0 Z3 S150 M03
Move spindle down until Z = -1 is reached. Feedrate is
G90 G84.2 X1 Y0 Z-1 P500 R2 F20
specified in threads/inch with the G84 command – thus, the
spindle moves down 1/20 inch for every revolution of the
spindle – stop and dwell for 500 msec

Uses a spindle position sensor Reverse spindle to 150 rpm in CCW direction
that perfectly synchronizes motion
in Z direction with rotation Move spindle up until Z = 2 is reached. Feedrate is specified in
threads/inch with the G84 command – thus, the spindle moves
up 1/20 inch for every revolution of the spindle
Canned Cycles
Rapid move to X0 Y0 Z3

Start spindle at 150 rpm in CCW direction


G84.3 – tapping cycle
(rigid tapping – left hand threads)
Absolute coordinate system

Rapid move to X1 Y0
G00 X0 Y0 Z3 S150 M03
Move spindle down until Z = -1 is reached. Feedrate is
G90 G84.3 X1 Y0 Z-1 P500 R2 F20
specified in threads/inch with the G84 command – thus, the
spindle moves down 1/20 inch for every revolution of the
spindle – stop and dwell for 500 msec

Uses a spindle position sensor Reverse spindle to 150 rpm in CW direction


that perfectly synchronizes motion
in Z direction with rotation Move spindle up until Z = 2 is reached. Feedrate is specified in
threads/inch with the G84 command – thus, the spindle moves
up 1/20 inch for every revolution of the spindle
Canned Cycles

G80 – cancel canned cycles


Cancels modal commands related to canned cycles such as
G74, G81, G82, G83, G84, etc
G80
Cutter Compensation
Tool Type Length Radius
1 #21 Drill HSS 2FL 5.347 0.0795
2 ¼” C EM 4FL 3.758 0.1235
3 ½” C EM 2 FL 3.955 0.251
4 4” insert face mill 4.057 2.005
5 0.375 HSS reamer 4FL 6.755 0.1874

Often cutters do not have their nominal diameter


• Worn cutters
• Reground cutters
• Cutter different than size used to program g-code and post from CAM
Cutter Compensation

Y=2

Y=0

X=0 X=3
Cutter Compensation

D = 0.5

Y = 2.25
Y=2

Y=0
Y = -0.25
X=0 X=3
Cutter Compensation

D = 0.496

Y = 2.25
Y=2.002

Y=-0.002
Y = -0.25
X=0 X=3
Cutter Compensation

D = 0.25

Y = 2.125
Y=2

Y=0
Y = -0.125
X=0 X=3
Cutter Compensation

G41 – tool radius compensation left


G42 – tool radius compensation right

G41 D2 G41 G41 P0.255


Uses radius of Uses radius of Uses radius of 0.255
tool in slot 2 current tool

= 0.1235 Tool Type Length Radius


1 #21 Drill HSS 2FL 5.347 0.0795
2 ¼” C EM 4FL 3.758 0.1235
3 ½” C EM 2 FL 3.955 0.251
4 4” insert face mill 4.057 2.005
5 0.375 HSS reamer 4FL 6.755 0.1874
Cutter Compensation
Program all toolpaths on center line, allow
G41 – tool radius compensation left compensation to determine actual
G42 – tool radius compensation right toolpaths

Y=2
G00 X4 Y0
G41 D3

G01 X0

Y=0
Y = -0.251
X=0 X=3

D3=0.251
Cutter Compensation
Programming a proper tool entry is
G41 – tool radius compensation left important!!!
G42 – tool radius compensation right

Y=2
G00 X4 Y0
G41 D3

G01 X0
D3=0.251

Y=0
Y = -0.251
X=0 X=3

What happens here? Might clip off corner


of part
Cutter Compensation
Programming a proper tool entry is
G41 – tool radius compensation left important!!!
G42 – tool radius compensation right

Y=2
G00 X4 Y-1
G41 D3

G01 X3.25 Y0
G01 X0

Y=0
Y = -0.251
X=0
X=3 D3=0.251
Preferred practice
Program Planning Cont’d
 Revolutions per minute = 12 * ft/min / ( pi * Dia [in]).
Imperical
 Revolutions per minute = 1000 * m/min / (pi * Dia[mm])
Metric
 Machining sequence
 Defines the order of machining operaitons
 Technical skills and machine shop experience help in program
planning, but much a common sense approach is equally important
 Machining sequences must have logical order
 Ex: Drilling must be programmed before tapping
 Ex: Roughing operations before finishing
 There are no fixed rules, but should be based on safety, quality, and
efficiency

You might also like