0% found this document useful (0 votes)
45 views100 pages

CNC Machines

The document discusses NC/CNC machines and their components and operation. NC/CNC machines use motors and sensors for automated control of machine functions like feed rate and spindle speed. They can machine complex multi-axis parts using preparatory functions in programming languages like word sequential format.

Uploaded by

Sourit Saha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views100 pages

CNC Machines

The document discusses NC/CNC machines and their components and operation. NC/CNC machines use motors and sensors for automated control of machine functions like feed rate and spindle speed. They can machine complex multi-axis parts using preparatory functions in programming languages like word sequential format.

Uploaded by

Sourit Saha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 100

NC/ CNC Machines

What is a NC/CNC machine

• An NC machine is functionally same as a conventional machine


tool (e.g. Lathe, milling m/c)

• In a conventional machine an operator controls the machine


function like feed rate, coolant, speed etc. While in a NC machine
the machine functions are controlled by the MCU (controller).

• A conventional machine tool can be retrofitted to make a NC


machine.
NC/CNC for machining multi axis parts
• NC/CNC machines can have up to 5 axis and can machine
complex parts having 3D geometry. Manual machining may be
impossible (e.g. complex turbine blades).

• Autonomous operations.

• Integration with other machines, robots, AS/RS etc.

• Integrated into Industry 4.0 framework.


Control structure of a NC machine
• DC motors working in closed loop position control.
Analogue and Digital system
ADC
DAC
Construction differences:

• Conventional machine tables move on slides and screw threads

• NC machine slides move on ball screws to reduce friction.

• For motion of tool and/or guides ways, actuators and sensors are
used.

• NC machines are controlled using closed look control.


Special ball screws to reduce friction:
Ball screws – how it works ?
Characteristics of ball screws

• High mechanical efficiency


In ball screws, about 90% or more of the force used to rotate the screw
shaft can be converted to the force to move the ball nut.

Since friction loss is extremely low, the amount of force used to


rotate the screw shaft is as low as one third of that needed for the acme
thread lead screw.

• Low in wear
Because of rolling contact, wear is less than that of sliding contact.
Thus, the accuracy is high.

Ball screws move smoothly enough under very slow speed.


They run smoothly even under a load.

1
2
Advantages of ball screws
• Highly efficient and reliable.
• Less starting torque.
• Lower co efficient of friction compared to sliding type screws and
run at cooler temperatures
• Power transmission efficiency is very high and is of the order of 95
%.
• Could be easily preloaded to eliminate backlash.
• The friction force is virtually independent of the travel velocity
and the friction at rest is very small; consequently, the stick-slip
phenomenon is practically absent, ensuring uniformity of
motion.
• Has longer thread life hence need to be replaced less frequently.
• Ball screws are well -suited to high through output, high speed
applications or those with continuous or long cycle times.
• Smooth movement over full range of travel.
1
3
Harmonic drives for high reduction
 Use of Stepping Motors in Slide Movement

The slides and spindle of the CNC machine are


driven by stepper motors.

STEPPER MOTOR – A digital signal is sent from the


controller to the motor in the form of pulses, which will
cause the motor to rotate through a specified angle,
which causes the slide to move by the required distance.

1
5
Stepper motors : Variable reluctance,
permanent magnet
Working of a stepper motor

Sequence of rotation
(CW): B – C – D - A’
Mega-torque motors
Linear stepper motors
DC Motors : basic working
Brushless DC motors

Fig. Brush type DC motor Fig. Brushless DC motor


Position Sensor : Potentiometer
Incremental encoder

Position sensor:
Incremental Encoder

Using XOR gate


Direction of rotation of encoder ?
Absolute encoder
Axes assignment in CNC

Z axis aligned with the spindle axis for cutting


(or perpendicular to work holding surface)

X is towards the right of the z axis looking


from the spindle to workpiece.

U,V, W supplementary linear motions


A,B, C rotatory motion along x, y and z axes.
origin location ?
Programming details
Fixed Sequential Format
Exhibit 6.1 Fixed Sequential Format
0050 00 +0025400 +0012500 +0000000 0000 00
0060 01 +0025400 +0012500 -0010000 0500 08
0070 01 +0025400 +0012500 +0000000 0500 09
Meaning:
(1)Using a rapid feed rate, the tool is positioned at the coordinate location (25.4, 12.5,0).
(2)The tool is then advanced -10 units in the z-direction at a feed rate of 500 mm/min, with
the flood coolant on.
(3)The tool is then retracted back 10 units at the rapid feed rate, and the coolant is turned off.

The corresponding motions are shown in the


figure on the left.
With the zero datum assumed to be 0.5 units
above the surface of the part, these commands
have the effect of drilling a through hole in a
workpiece material 9 units thick.
Tab Sequential Format
Tab Sequential Format

• This format is essentially the same as the fixed sequential format. The
difference is that each word within a block is preceded by a Tab
character.

• The main improvement over fixed sequential format is that the Tab
character for a specified word need not be followed by a numeric data if
data are not required in that particular block or they are modal data.
Word Sequential Format

• This is the format that is used on virtually all modern controllers and
will be explained in greater detail.
• With this type of format, each type of word is assigned as address
that is identified by a letter code within the part program.
• Thus, the letter code specifies the type of word that follows and then
its associated numeric data is given.
• For example, the code T represents a tool number. Thus, a word of the
form T01 would represent tool number 1.
• Theoretically, with this approach, the words in a given block can be
entered in any sequence and the controller should be able to interpret
them correctly.
Sequence and format of words:

N3 G2 X+1.4 Y+1.4 Z+1.4 I2.0 J2.0 K2.0 F5 S4 T4 M2

N sequence X,Y, Z destination F feed T Other function


no coordinates rate tool
I,J,K dist to center of S spindle
G preparatory circle
function speed
Word Sequential Format
Address Meaning
F Feed rate command
G Preparatory function
I Circular interpolation : x axis offset
J Circular interpolation : y axis offset
K Circular interpolation : z axis offset
M Miscellaneous commands
N Sequency number
R Arc radius
S Spindle speed
T Tool number
X x-axis data
Y y-axis data
Z z-axis data

Commonly used word addresses


Word Address Format
• The American National Standards institute (ANSI) has established a standard
method of specifying word address data for any controller, which has been adopted
by most manufacturers. A typical specification might look as follows:

• Within the specification, a letter identifies a specific type of word as in Table . A ‘ +


‘ symbol after the letter indicates that sign is significant for the associated numeric
data.
• Generally, a positive sign is assumed if numeric data has no sign specified. If one
numeral follows the letter, the data for that word are of integer form with upto the
number of digits specified by the numeral.
• If the letter (and the associated sign wherever applicable) is followed by two
numerals, the data for that word are real numbers.
• The decimal point is not to be programmed explicitly; its position is inferred by
counting the number of digits in the actual data associated with the word, counting
from the right.
• The second numeral in the specification gives the number of digits to count in the
data before the decimal point.
Word Address Format

So for the sample specification just given we have:

N word can have up to four integer digits with no associated signs.

G word can have upto two integer digits with no associated signs.

X word can have upto seven real digits, which may be positive or negative. The decimal point which
is not explicitly entered is assumed to be three digits from the right, and there can be upto four
digits to the left of the decimal point in metric format.

F script can have upto four real digits, which may be positive or negative. The decimal point, which is
not explicitly entered, is in the rightmost position and there can be upto four digits to the left of the
decimal points.

I word can have upto seven real digits with no associated signs. The decimal point, which is not
explicitly entered, is assumed to be three digits from the right, and there can be upto four digits to
the left of the decimal point in metric format.
Fundamentals of NC part programming
• The first step in writing an NC part program is to determine and organize the data that will be used within the
program.
• A fully coded NC part program generally consists of five broad categories or classes of command. These are
the following:

1. Preparatory functions: These are used to inform the MCU of the requirements for the machining that is
to be carried out and thus to establish the necessary operating conditions.

2. Axis motion commands: These are used to control the amount of relative motion between the cutting tool
and workpiece along each machine axis.

3. Feed and speed commands: These are used to set and control the cutting conditions for individual
machining operations.

4. Identification commands: These are used to identify specific entities in the program, such as cutting tools
used.
5. Miscellaneous Commands: These are used to control various other aspects of the machine’s operation not
addressed elsewhere, such as turning the spindle on and off and changing tools.
Preparatory Functions
• Preparatory functions form the largest class of commands used in NC
programs.

• They are identified by the word address letter ‘G’ followed by two digits.

• The digits specify the particular type of function.

• The combination is referred to as a ‘G’ code.

• In general, preparatory functions have the effect of making the MCU


assume specific operating conditions or command the controller to
perform the next task in a particular manner.
Preparatory functions
• Most preparatory functions are modal. Table Some common G codes
Efforts have been made to standardize Code Function
NC commands and the table below show G00 Point to point positioning , high rate
some widely used standard ‘G’ codes. G01 Linear interpolation, controlled feed rate
There are about 97 ‘G’ codes that are
G02 Circular interpolation, CW
used which go up to 99 in special
G03 Circular interpolation, CCW
controllers.
G04 Dwell for programmed duration
• However, not all ‘G’ codes are used in all
G17 Select x-y plane
machines and there are limitations
G18 Select x-z plane
offered by the manufacturer, machine
make etc. G19 Select y-z plane
G70 Inch units
G71 Metrics units
G90 Absolute dimensions
G91 Incremental dimensions
• With the word address format only the needed words for a
given operation have to be included within the block.

• The command to which the particular numeric data applies


is identified by the preceding address code.

• Word format has the advantage of having more than one


particular command in one block something that would be
impossible in the other two formats.

4
2
4
3
List of M codes
M codes vary from machine to machine depending on the
functions available on it. They are decided by the manufacturer of
the machine. The M codes listed below are the common ones.

4
4
Explanation of Some Commonly Used G-Codes
• G00 is a preparatory function to specify that the tool should be moved to a
specified location.
• This function is used only to control the final position of the tool and is not
concerned with the path that is followed in arriving at the final destination.
• For this reason, motion with this function is also referred to as positioning mode.
• The way this code is implemented in most controllers is that all axes that need to
be moved in order to get to the target point are moved simultaneously at the
beginning of the motion, with each axis being moved at maximum speed.

• As an example for motion that occurs in x-


y plane with the same maximum speed for
the x and y-axes, initial motion is at an
angle of 45 deg. to the axes until motion in
one of the axis is completed and then the
balance of motion occurs in the other axis.
This is called point to point motion
generally used for tool positioning. See
Fig. Fig. Positioning and linear
interpolation for NC
Commonly used ‘G’ codes
• G02 is also a preparatory function to specify that the tool should be moved to a
specified location.
• It differs from the G00 and G01 functions in that in this case the path followed by the
tool in moving to the target point is required to be a circular arc, starting from the
current tool position, moving in a clockwise direction, and ending at the target
position.
• Within the block in which G02 code is programmed, the center of the arc is given by
specifying its location relative to the start of the arc.
• An appropriate combination of I,J and K words is used to specify the location of the
center of the arc relative to the start of the arc.

• In this case, the motion in more than one axes is


always involved and the MCU coordinates the
simultaneous motions to generate the circular
path.
• A restriction imposed by this command is that
this interpolation can only be on one quadrant
formed by the intersection of axes of the
coordinate system and the maximum angle of the
Fig. Circular interpolation for NC
arc is 90 deg.
Canned Cycles
• Some sequences of machining operations are used so frequently with the different machines
and different components that they have a standardized and assigned special preparatory
functions. For example, a simple hole drilling operation involves the following sequence of
operations:
1. Position the tool just above the point where the hole is to be drilled.
2. Set the correct spindle speed.
3. Feed the tool into the workpiece at a controlled feed rate to a predetermined depth.
4. Retract the tool at a rapid rate to just above the point where the hole started.
• The same sequence of operations is repeated for any simple drilling operation regardless of
the machine used. The sequence of operations would require several blocks of code if each
motion were programmed individually.
• However, a special drilling cycle code (G81) has been developed. By using the G81
preparatory function, the programmer achieves the same effect in only one block.

• The location and depth of the hole to be


drilled, speed and feed to be used, and
height above the part surface for
positioning before and after drilling are
all specified in the block.
List of Canned Cycles

Table Commonly used Canned cycles

• The effect of any one of these canned cycles is cancelled by programming a G80
function.
Axis Motion Commands
• Axis motion commands are used to specify the axes that are required to move during the
execution of a given command.
• They are made up of a letter specifying an axis such as x, followed by dimensional
information associated with the motion of the axis in question.
• The X,Y, and Z commands, respectively, specify the motion of the cartesian coordinates
themselves; I,J and K values specify the offset relative to x,y,and z axes.
• Some controllers support the use of polar coordinates, in which case R and A axes are
used to specify the radial and angular directions, respectively.
• The dimensional data associated with an axis command can represent absolute
dimensions (if G90 was specified) or they may be incremental values (if G91 was
specified)
• The dimensional data associated with the axis commands consists of real numbers that
may or may not have a sign associated with them.
• An important point to remember is that the axis commands guide the motion of the point
defining the tool position. For some operations, such as profile milling, the periphery of
the cutter moves along the surface to be machined, rather than the tool-point (i.e., center
of the cutter)
Axis motion commands
• Thus, the actual motion of the tool has to be along a path different
from the geometry of the machined surface. This difference is called
a tool offset which the programmer has to consider when writing the
program.
• Most modern controllers can be programmed using an offset tool by
applying a compensation factor called cutter compensation.
• With this approach one the offset between the tool point and the
machined surface is specified, the tool motion can be programmed as
if the tool point followed the actual machined surface.
• The controller adjusts internally for the difference in the actual path
followed by the tool point.
• Cutter compensation is programmed using G41 and G42 codes and
cancelled using G40 code.
Feed and speed commands
• Feed and speed commands are used to specify the feed rate and speed
to use during the machining operation.
• The feed command is specified by the address script ‘F’ followed by
the numerical value of the feed rate required; the speed command is
specified by the address word ‘S’ followed by the required speed.
• The feed rate and the speed used during the machining are of crucial
importance in determining how long it will take to make a part.
• The units for cutting conditions can be specified in a variety of ways
in the NC program. The feed rate may be specified directly in units/
min. or units/rev., where the units may be in inches or millimeters.
• The preparatory functions G92-G98 are used to designate how the
cutting conditions are to be specified.
Identification commands
• Identification commands are used within a NC program for the simple task of being able to
identify certain entities within the program.
• The ‘N’ word is the most widely used identification command and it is used to identify
individual blocks within the program.
• The identification data in this case consist of integer numbers written in a format given as
part of the machine specification.
• Usually three or four digits are used and leading or trailing zeros are not suppressed.
• The ‘N’ word is purely for the convenience of human writing or using the program, so that
they can distinguish between the various blocks in the program.
• The MCU itself does not use the data contained in the ‘N’ word.
• Because the controller does not use the block identification data, it is not strictly necessary
to number the blocks in any particular order.
• However, for the convenience of the human users, blocks are generally numbered in
ascending order, with increments of 5 or 10 between consecutive blocks.
• The reason for having increments of 5 or 10 is that, when necessary, additional blocks may
be inserted in the program while maintaining the generally ascending order in which blocks
are numbered.
Identification Commands
• The other widely used command is the ‘T’ word.
• This is used to identify individual cutting tools used within the program.
• For most components, more than one tool is needed to complete the
machining operations needed to make the part.
• For many NC machines, multi-station tool turret or tool magazines housing
several cutting tools are used.
• The programmer uses the ‘T’ word to specify to the controller regarding
the various tools available should be used for a particular machining
operation.
• The format of ‘T’ word usually consists of two unsigned digits after ‘T’.
• Other identification commands are used to identify special sections of the
part program, such as loops and macros, that can be executed more than
once during the running of the program.
Miscellaneous Commands
• Miscellaneous commands are used to control a variety of
machine functions that are not covered by the other
commands.
• The address word ‘M’ followed by two unsigned digits is
used to specify miscellaneous commands.
• Examples of functions controlled by miscellaneous
commands are turning the spindle on and off, turning
coolant on and off, initiating a tool change, clamping and
unclamping the work-piece interrupting and restarting
program execution, stopping the program and rewinding
the program.
Miscellaneous Commands
• Generally, miscellaneous
Table Some common M codes
commands take effect after
execution of the other CODE FUNCTION
commands in the block in M00 Program stop
which they are programmed. M01 Optional stop
• It is usually permissible to M02 End of program
program more than one M03 Spindle on CW
miscellaneous command in a M04 Spindle on CCW
given block provided they do
not have conflicting effects. M05 Spindle off
M06 Tool change
• Many of the ‘M’ codes have
M07 Mist coolant on
been assigned standardized
functions. Some ‘M’ codes M08 Flood coolant on
are given in the table : M09 Coolant off
M30 End of program-rewind
Special Characters
• In addition to the commands outlined in the preceding pages,
certain special characters are used in NC part programs to achieve
special effects.
• Some of these special characters are used with all controllers, but
others are particular to specific controllers.
• These characters include the % sign, common to all controllers,
which is used as the first line of the NC program.
• The character signals the controller when the beginning of the
program has been reached during a rewind of the program, an end
of block character is used at the end of each block of the program.
• This special character is produced by hit of a carriage return on a
keyboard.
• The character itself does not print when the program is printed.
• During coding , the end-of-block is frequently represented by *
symbol or the letters EOB.
G02/G03 Circular interpolation
Format
N G02/03 X Y Z I J K F using the arc center
or
N G02/03 X Y Z R F using the arc radius
Arc center
The arc center is specified by addresses I, J and K. I, J and K are the X, Y and Z
co-ordinates of the arc center with reference to the arc start point.

G02 moves along a CW arc

G03 moves along a CCW arc


G90 ABSOLUTE POSITION COMMAND
• When using a G90 absolute position command, each dimension or move is
referenced from a fixed point, known as ABSOLUTE ZERO (part zero).

• Absolute zero is usually set at the corner edge of a part, or at the center of a
square or round part, or an existing bore. ABSOLUTE ZERO is where the
dimensions of a part program are defined from.

• Absolute dimensions are referenced from a known point on the part, and
can be any point the operator chooses, such as the upper-left corner, center
of a round part, or an existing bore.

Syntax: N.. G90 X.. Y.. Z.. A.. B.. C..


G91 INCREMENTAL POSITION COMMAND
• This code is modal and changes the way axis motion
commands are interpreted. G91 makes all subsequent
commands incremental. Zero point shifts with the new
position.

Syntax: N.. G91 X.. Y.. Z.. A.. B.. C..


Control surfaces while machining:
• ds : Drive surface
• cs : Check surface
• ps: Part surface
G 17 G18 G19 :
PLANE SELECTION
G 17 : XY plane selection
Syntax: N.. G17

G 18 : ZX plane selection
Syntax: N.. G18

G 19 : ZY plane selection
Syntax: N.. G19

Syntax: N020 G17 G75 F6.0 S300 T1001 M08


G 70 Inch data input

G 71 Metric data input

Syntax : N010 G70 G90 G94 G97 M04


Example of NC code
Write an NC program to machine a ½ in. wide L-shaped slot in a mild steel workpiece with
dimensions 3X2.5X0.75 in as shown in Figure:

Fig. A slot milling example

Assumptions:
1. The top lower left corner will be used for program zero.
2. Machining motion will start in the indicated position.
3. The tool is ¼ in. above the top surface of the part prior to start of machining.
4. The tool diameter used is ½ in., so only one pass is required.
5. A cutting speed of 500 rpm and feed rate of 10in./ min are used for machining.
6. Machine specification: N3G2X + 43Y + 43Z+ 43R+ 43F4S4T2M2
NC Program

•% Start of the program


NC Program

•% Start of the program

• N005 G90 G70 Specifies absolute dimensions in inch units.


NC Program

•% Start of the program

• N005 G90 G70 Specifies absolute dimensions in inch units.


• N010 G97 G94 T01 Specified units for speed and feed rate;
loads tool 1
NC Program

•% Start of the program

• N005 G90 G70 Specifies absolute dimensions in inch units.


• N010 G97 G94 T01 Specified units for speed and feed rate;
loads tool 1
• N015 G00 X1000 Y2750 Z250 F0
Rapid positioning of tool to start point .
NC Program

•% Start of the program

• N005 G90 G70 Specifies absolute dimensions in inch units.


• N010 G97 G94 T01 Specified units for speed and feed rate;
loads tool 1
• N015 G00 X1000 Y2750 Z250 F0
Rapid positioning of tool to start point .
• N020 G01 Z-375 M03 S500 F 10
Turns on spindle, feeds tool to required depth,
Turns spindle on clockwise
NC Program

•% Start of the program

• N005 G90 G70 Specifies absolute dimensions in inch units.


• N010 G97 G94 T01 Specified units for speed and feed rate;
loads tool 1
• N015 G00 X1000 Y2750 Z250 F0
Rapid positioning of tool to start point .
• N020 G01 Z-375 M03 S500 F 10
Turns on spindle, feeds tool to required depth, Turn spindle on CW
• N025 Y750 M/c s the vertical portion of the L shape.
NC Program

•% Start of the program

• N005 G90 G70 Specifies absolute dimensions in inch units.


• N010 G97 G94 T01 Specified units for speed and feed rate;
loads tool 1
• N015 G00 X1000 Y2750 Z250 F0
Rapid positioning of tool to start point .
• N020 G01 Z-375 M03 S500 F 10
Turns on spindle, feeds tool to required depth, Turn spindle on CW
• N025 Y750 M/c s the vertical portion of the L shape.

• N030 X2500 M/c s the horizontal portion of the L shape.


NC Program
•% Start of the program
• N005 G90 G70 Specifies absolute dimensions in inch units.
• N010 G97 G94 T01 Specified units for speed and feed rate;
loads tool 1
• N015 G00 X1000 Y2750 Z250 F0
Rapid positioning of tool to start point .
• N020 G01 Z-375 M03 S500 F 10
Turns on spindle, feeds tool to required depth., Turn spindle on CW
• N025 Y750 M/c s the vertical portion of the L shape.
• N025 X2500 M/c s the horizontal portion of the L shape.
• N035 Z250 Retracts tool to 0.25 in above part surface.
NC Program

• % Start of the program


• N005 G90 G70 Specifies absolute dimensions in inch units.
• N010 G97 G94 T01 Specified units for speed and feed rate;
loads tool 1
• N015 G00 X1000 Y2750 Z250 F0
Rapid positioning of tool to start point .
• N020 G01 Z-375 M03 S500 F 10
Turns on spindle, feeds tool to required depth, Turns spindle on CW
• N025 Y750 M/c s the vertical portion of the L shape.
• N025 X2500 M/c s the horizontal portion of the L shape.
• N035 Z250 Retracts tool to 0.25 in above part surface.
• N040 X-1000 Y-1000 F0 M05
Move to safe location at rapid rate after spindle switch off.
NC Program

• % Start of the program

• N005 G90 G70 Specifies absolute dimensions in inch units.


• N010 G97 G94 T01 Specified units for speed and feed rate;
loads tool 1
• N015 G00 X1000 Y2750 Z250 F0
Rapid positioning of tool to start point .
• N020 G01 Z-375 M03 S500 F 10
Turns on spindle, feeds tool to required depth, Turns spindle on CW
• N025 Y750 M/c s the vertical portion of the L shape.
• N025 X2500 M/c s the horizontal portion of the L shape.
• N035 Z250 Retracts tool to 0.25 in above part surface.
• N040 X-1000 Y-1000 F0 M05
Move to safe location at rapid rate after spindle switch off.
• N045 M30 Turns off all machine functions
Full Solution
Manual Part Programming Example 5”
2.5”
p4
p2 p3 p5

1”

Tool size = 0.25 inch,


5” Feed rate = 6 inch per minute,
Cutting speed = 300 rpm,
Tool start position: 2.0, 2.0
Programming in inches
45°

(4, 4)
p1
Motion of tool:
p0  p1  p2  p3  p4  p5  p1  p0
p0 (2, 2)
1. Set up the programming parameters
5”
2.5”
p4
p2 p3 p5

1”

Programming in inches
5”
Use absolute coordinates

Feed in ipm
45°
N010 G70 G90 G94 G97 M04
(4, 4)
p1
Spindle speed in rpm
p0 (2, 2)
Spindle CCW
2. Set up the machining conditions
5”
2.5”
p4
p2 p3 p5

1”
Machine moves in XY-plane

Use full-circle interpolation


5”
Feed rate

Spindle speed
45°
N020 G17 G75 F6.0 S300 T1001 M08
(4, 4)
p1
Tool no.
p0 (2, 2)
Flood coolant ON
3. Move tool from p0 to p1 in straight line
5”
2.5”
p4
p2 p3 p5

Linear interpolation
1”
target coordinates

5” N030 G01 X3.875 Y3.698

45°

(4, 4)
p1

p0 (2, 2)
4. Cut profile from p1 to p2 5”
2.5”
p4
p2 p3 p5

1”

Linear interpolation

5” target coordinates

N040 G01 X3.875 Y9.125


45°
or
(4, 4)
p1 N040 G01 Y9.125

p0 (2, 2)

X-coordinate does not change  no need to program it


5. Cut profile from p2 to p3 5”
2.5”
p2 p3
p4
p5 Linear interpolation

target coordinates
1”

N050 G01 X5.634 Y9.125

5”

y = 9 + 0.125 = 9.125
(6.5 - x)2 + 0.1252 = (1 - 0.125)2
x = 5.634
45° p3
(x, y)
(4, 4)
p1 (6.5, 9)
.125

p0 (2, 2)

1”
6. Cut along circle from p3 to p4
5”
2.5”
p4
p2 p3 p5

1”

circular interpolation, CCW motion

5”
target coordinates

45° N060 G03 X7.366 Y9.125 I6.5 J9.0

(4, 4) coordinates of center of circle


p1

p0 (2, 2) N060 G03 X7.366 Y9.125 I0.866 J-0.125


7. Cut from p4 to p5 5”
2.5”
p4
p2 p3 p5

1”

5”

Linear interpolation

45° target coordinates (Y is unchanged)

(4, 4) N070 G01 X9.302


p1

p0 (2, 2)
8. Cut from p5 to p1 5”
2.5”
p4
p2 p3 p5

1”

5”
Linear interpolation

target coordinates (see step 3)


45°
N080 G01 X3.875 Y3.698
(4, 4)
p1

p0 (2, 2)
9. Return to home position, stop program
5”
2.5”
p4
p2 p3 p5

1”

Linear interpolation

5” target coordinates (see step 3)

N090 G01 X2.0 Y2.0 M30

45°
end of data
(4, 4)
N100 M00
p1

p0 (2, 2) program stop


10. Complete RS-274 program
N010 G70 G90 G94 G97 M04
N020 G17 G75 F6.0 S300 T1001 M08
N030 G01 X3.875 Y3.698
N040 G01 X3.875 Y9.125
N050 G01 X5.634 Y9.125
N060 G03 X7.366 Y9.125 I0.866 J-0.125
N070 G01 X9.302
N080 G01 X3.875 Y3.698
N090 G01 X2.0 Y2.0 M30
Simple G Code Example CNC Lathe
PART PROGRAM

N5 M12
N10 T0101
N15 G0 X100 Z50
N20 M3 S600
N25 M8
N30 G1 X50 Z0 F600
N40 Y-30 F200
N50 X80 Y-20 F150
N60 G0 X100 Z50
N70 T0100
N80 M5
N90 M9
N100 M13
N110 M30
Code Explanation
N5 Clamping workpiece
N10 Changing No.1 tool and executing its offset
N15 Rapidly positioning to A point
N20 Starting the spindle with 600 r/min
N25 Cooling ON
N30 Approaching B point with 600mm/min
N40 Cutting from B point to C point
N50 Cutting from C point to D point
N60 Rapidly retracting to A point
N70 Cancelling the tool offset
N80 Stopping the spindle
N90 Cooling OFF
N100 Releasing workpiece
N110 End of program, spindle stopping and Cooling OFF
CNC MILLING EXAMPLE
N5 G90 G71
N10 T1 M6
N15 G92 X-100 Y86 Z95
N20 G0 X0 Y0 S2500 M3
N25 Z12.5
N30 G1 Z-12.5 F150
N35 X-20 Y30
N40 G2 X10 Y100 R80
N45 G1 X140 Y60
N50 G2 X150 Y0 R50
N55 G1 X0 Y0
N60 G0 Z12.5
N65 G91 G28 Z0 M5
N70 G91 G28 X0 Y0
N75 M30
CODE EXPLANATION
N5 absolute positioning, metric unit
N10 tool change to T1
N15 define work zero point at A
N20 rapid traverse to A, spindle on (2500 RPM, CW)
N25 rapid plunge to 12.5 mm above Z0
N30 feed to Z-12.5, feed rate 150 MMPM
N35 cut line AB to B
N40 cut arc BC to C
N45 cut line CD to D
N50 cut arc DE to E
N55 cut line EA to A
N60 rapid retract to Z12.5
N65 reference point return in Z direction, spindle off
N70 reference point return in X and Y directions
N75 end of program
SAMPLE PROGRAM ON DRILLING
N1 T16 M06
N2 G90 G54 G00 X0.5 Y-0.5
N3 S1450 M03
N4 G43 H16 Z1. M08
N5 G81 G99 Z-0.375 R0.1 F9.
N6 X1.5
N7 Y-1.5
N8 X0.5
N9 G80 G00 Z1. M09
N10 G53 G49 Z0. M05
N11 M30
CODE EXPLANATION
N1- Tool change (M06) to tool no.16
N2- Tool rapidly moves (G00) to first drilling position X0.5
Y-0.5 while taking into account Zero-offset-no. 1 (G54)
N3- Drill starts rotating clockwise (M03) with 1450 rpm
(S1450).
N4- Drill takes depth Z1. taking into account tool length
compensation (G43 H16), coolant is turned on (M08).
N5- Drilling cycle (G81) parameters, drill depth (Z) and
cutting feed (F) are given,
with this command first drill is made at current position
(X0.5 Y-0.5).
N6- As drilling cycle continues it’s work with every axis
movement so next drill is
done at X1.5
N7- Third drilling hole at Y-1.5
N8- Fourth drill at X0.5
N9- Drilling cycle is cancelled (G80), Coolant is turned off (M09).
N10- Taking Machine-coordinate-system (G53) into account the drill is taken
to Z0 position. Tool length compensation is cancelled (G49), cutter rotation
is stopped (M05).
N11- CNC part-program is ended.
References

•Computer integrated design and


manufacturing, Nanua Singh, John
Wiley and sons, Inc.

You might also like