You are on page 1of 7

Outlines

NC Code System

NC codes NC programs (structure, example) NC functions NC programming Case study I

NC Codes
NC codes: the functional characters recognized by the NC controller. It is composed by: Characters Bit Address Word (Collection of characters) Block (Collection of words) Program

Character
NC coded instructions are carefully arranged by letters (A, B, Z), numbers (0, 1,9) and symbols (+,-,/)
Example1: G00 X0. Y0. Example2: G01 X2. Y2. Example3: G02 X4. Y0.

These characters are uniquely defined by a combination of 8 bits of digital information

Bit
A representation of one of two possible states (on or off, high or low, 1 or 0). It is signified by the presence or absence of a punched holes in a raw.

Character
A collection of 8 bits across a raw on the tape uniquely representing a number, letter or symbol

Character

A 1 %
5

Address
The letter used at the beginning of each word to define the meaning of the numerical data that follow.
A, B, C = Angular dimension around X, Y, Z F = Feed function G = Preparatory function I, J, K = X, Y, Z motion dimension for circular arc center M = Miscellaneous function N = Sequence number

Address (cont.)
S = Spindle speed (S1500) T = Tool function (T0101) X, Y, Z = Primary dimension U, V, W = Secondary motion dimension parallel to X, Y, and X

Word
A collection of characters arranged in a certain order to cause a special action by the NC machine.
Example:
N10 G01 X1. F20 T01 M06 sequence number linear interpolation X coordinate Feed rate Tool number Tool change command

Block
A collection of word. It can be a single word or a combination of words. Ended by EOB (end of block, ; ) Example: N01 G00 X1.5 Y 2.0 Four-word block N02 T0101 M06 Three-word block

10

Program
Collection of blocks Contains a complete set of coded instruction needed to machine a workpiece Depending on the function, a program may comprise following features:
Safety, tool change, Coordinate offset, Tool length offset, tool motion, cutter diameter compensation, misc. function

Example of program
N10 O334 N20 G90 G17 G70 S2000 F50. N30 M6 T12 N40 G0 E12 X0. Y0. Z0.5 M3 offset setup E12 (change) N50 G0 X0.5 Y0.5 N60 G01 Z-0.1875 N70 X2.5 N80 Y2.5 N90 X0.5 N100 G0 Z0.5 N120 G91 G28 X0. Y0. Z0. N130 M02 Program #334 Safety features Move to origin at

11

12

NC functions
Eight type of NC functions:
Sequence (N) Preparatory function (G) Dimension addresses (words) (X,Y,Z) Circular arc center address (words) (I,J,K) Spindle speed function (S) Tool Function (T) Feed rate (F) Miscellaneous (M)
13

Sequence number (N)


Starting from N001 to N999 Depending on the memory capacity of the machine, N can be more than three digits Sequence is required in early CNC machine Sequence is not required on most modern CNC machine, except branching logic is used to control flow of execution.

14

Preparatory Function G-code


Designated by the address G followed by two digits to specify the control mode of operation. G code Depending on type of machining process, some G c odes are different for milling and turning operation.

G00 rapid positioning


G00 X# Y# Z#
X, Y and Z represent end position

Two Possible motions:


Tool taking the shortest distance Move X or Y, then Z
Y Current location Commanded location

Y Current location

Commanded location

X
15

X
16

G00 Tool movement

G01- Linear interpolation


Tool move to the endpoint in a straight line @ specified feed rate (F). 01 X# Y# Z# F#
Modal feature: the commands remain in effect until canceled. For example, G00, G01, G02, G03, G90, G91,
Example: N01 G00 X1 Y1 N02 G01 X5 F7.5 - Tool will go to X=5 with feedrate 7.5 IPM N03 Y6.0 N04 X1. Y1. (1,1) (5,1) Y (5,6)

Appropriate movement

Wrong movement

17

X 18

G02 & G03 Circular Interpolation


Almost the same as G01. Required the following elements:
Plane
G17: XY plane G18: ZX plane G19: ZY plane
G02

G02 and G03


Arc Center or radius method
I, J, K arc center R radius method

Arc Start position X, Y, Z Rotation direction G02, G03 Arc end position Arc center coordinate

G03

19

20

I,J,K Method for G02 or G03


Command can write as:
G017 N100 G02 X# Y# I# J# F# Measure incrementally from the start position to the center of the arc in the X, Y, Z direction
A

R (Radius) Method
G02 Xx Yy Rr Ff Require the end point and the radius value Positive R - for the arc less than 1800 Negative R - for the arc larger than 1800 The arc must less 359.90 Arc 359 to 360 degrees required 2 consecutives arc interpolation

I = Xc - Xs J = Yc - Ys K = Zc - Zs

J C I B

Cut from A to B
21 22

Other G-Code
G90 G91 - Positioning System G70 G71 - Unit Selection G94 G95 - Feed Unit G17 G18 G19 - Plane Selection G92 Absolute zero setting

G92 absolute zero setting


A Program coordinate system must be defined before tool movement All NC machine has a fixed machine origin, but is seldom used. G92 is used to establish the origin of the absolute coordinate system G92 Xx Yy Zz
X, y, z are the coordinate values of the current tool position in the defined coordinate system. G92 code does not cause any tool movement, it simply indicates where the tool is located relative to the program zero.
23 24

G92 absolute zero setting


G92 X6 Y5 Z3 program origin is located 6,5,3 in the -X, -Y and -Z direction from the current tool position
Z Y Current tool position (6,5,3) 3

Reference Point Return G28


G28 Xx Yy Zz
Moves the tool rapidly from the current position to an intermediate point and then back to reference zero. Intermediate point is used to clear workpiece and clamping obstructions that may break the tool X, y, z coordinate vale of the intermediate point
Reference point in X & Y (9.5, 8.5)

workpiece

Current tool Position (2,1)

Intermediate Point (10,1)

Defined origin 6

5 X

25

26

Reference Point Return


G28
Purposes: change tool, rerun the same program, or run a new program Example
G91 G28 Z0 G91 G28 X0 Y0

Return From Reference Point G29


G29 Xx, Yy, Zz Moves the tool in rapid mode from the machine reference point to the intermediate point and then to the commanded position X, y, z coordinate value of the end point
27

Reference point in X & Y (9.5, 8.5)

workpiece

Commanded Position (2,1)

Intermediate Point (10,1)

28

Feed selection and input


G70 G94 inches per minute G71 G94 millimeters per minute G70 G95 inches per revolution G71 G95 millimeters per revolution

Other codes use in CNC


T# M6 - Tool Change S# M3(CW)/M4(CCW) M5 (s) - Spindle Speed M30 - End of Program M07 M08 M09 coolant (mist or flood) on/off

29

30

Dimension Code X, Y, Z
Xx, Yy, Zz For metric system input 053 (unit: mm)
XXXXX.XXX (with decimal point) X55125~X55.125 mm Y7100~Y7.1 mm Z125~Z0.125 mm

Dimension Code X, Y, Z
About decimal points
Do not omit the required decimal point; it will result in an error value
X1.~X1 (if inch system is used) X1~X0.0001 inch

For inch system input 044 (unit: inch)


XXXX.XXXX (with decimal point) X50000~X5.0 inch Z1500~Z0.15 inch
31

Any input digits exceeding the level of precision of the system will be neglected
3.49667 inch ~ 3.4966 inch

A dimension word cannot exceed eight digits, otherwise, an error message will be issued.
X1.23456789 will generate error message
32

General Procedure to Write an NC Program


Start with the safety feature. Confirm or change the tool that you are going to use. Set the program zero and move the tool to a stand-by position, where is close but clear to the work piece. Turn on the Spindle Start cutting process Move the tool off the workpiece after the cutting process. Move the tool back to its origin Turn off the spindle M05 End of the Program M30
33

Program Structure
N # O#### N# G90 G17 G70 S# F# N# M6 T12 N40 G00 E12 X0. Y0. Z0.5 M3 N50 G00 X0.5 Y0.5 N60 G01 Z-0.1875 N70 X2.5 N80 Y2.5 N90 X0.5 N100 G0 Z0.5 N120 G0 X0. Y0. Z0. N130 M02
N Incremental #, O Program id. G90 Positioning System, G17 Plane selection XY, G70 inch unit, S- spindle speed, F- feed rate M6- Tool change E offset setup T- tool number G00 Movement M02 end of program Returning tool to (0,0,0) position

34

Case Study I
The figure shown in next slide indicates the geometry of the material (solid line) and tool path (dash line). We assume that we will use Fadal Machine to cut this material, and the following parameters will be used: Tool:
tool # 5 with " end mill. Fixture offset: E12 Feed rate: 20 in/min Spindle speed: 1500 RPM depth of cut: 0.25 inch

Case Study I
Y 2.5 2.0 1.2 0.5 B A 0.5 2.0 4.0 F 4.5 X C D R=0.5 E

X A B C D
35

Y 0.5 1.2 2.5 2.5 -0.25 -0.25 -0.25 -0.25

Z E F 4.5 4.5

X 2.0 0.5

Y -0.25 -0.25

0.5 0.5 2.0 4.0

36

Case Study I
% N5 O21 N10 G90 G40 G80 G70 G17 G94 N20 E12 G00 X0.5 Y0.5 Z.25 N25 S1500 M3 N30 G1 Z-.25 F20 N50 Y1.2 N60 X2.0 Y2.5 N70 X4.0 N80 G2 X4.5 Y2.0 R0.5 N90 G1 Y0.5 N100 X0.5 N110 Z0.25 N140 G28 G91 Z0. N150 G28 G91 X0. Y0. N160 M30 % program # safety feature fixure offset #12, move to A set spindle, and spindle on feed to desired depth move to B move to C move to D move to E move to F move to A lift tool up to z=0.25 reference return end program
37

You might also like