CNC Notes
CNC Notes
Definition
Computer Numerical Control (CNC) is one in which the functions and motions of a machine
tool are controlled by means of a prepared program containing coded alphanumeric data.
CNC can control the motions of the workpiece or tool, the input parameters such as feed,
depth of cut, speed, and the functions such as turning spindle on/off, turning coolant on/off.
Applications
The applications of CNC include both for machine tool as well as non-machine tool areas.
In the machine tool category, CNC is widely used for lathe, drill press, milling machine,
grinding unit, laser, sheet-metal press working machine, tube bending machine etc. Highly
automated machine tools such as turning center and machining center which change the
cutting tools automatically under CNC control have been developed. In the non-machine tool
category, CNC applications include welding machines (arc and resistance), coordinate
measuring machine, electronic assembly, tape laying and filament winding machines for
composites etc.
The benefits of CNC are (1) high accuracy in manufacturing, (2) short production time, (3)
greater manufacturing flexibility, (4) simpler fixturing, (5) contour machining (2 to 5 -axis
machining), (6) reduced human error. The drawbacks include high cost, maintenance, and the
requirement of skilled part programmer .
ELEMENTS OF A CNC
1. Part program
2. Machine Control Unit (MCU)
3. Machine tool (lathe, drill press, milling machine etc)
Part Program
The part program is a detailed set of commands to be followed by the machine tool. Each
command specifies a position in the Cartesian coordinate system (x,y,z) or motion (workpiece
travel or cutting tool travel), machining parameters and on/off function. Part programmers
should be well versed with machine tools, machining processes, effects of process variables,
and limitations of CNC controls. The part program is written manually or by using computer-
assisted language such as APT (Automated Programming Tool).
MACHINE TOOL
The machine control unit (MCU) is a microcomputer that stores the program and executes the
commands into actions by the machine tool. The MCU consists of two main units: the data
processing unit (DPU) and the control loops unit (CLU). The DPU software includes control
system software, calculation algorithms, translation software that converts the part program
into a usable format for the MCU, interpolation algorithm to achieve smooth motion of the
cutter, editing of part program (in case of errors and changes) . The DPU processes the data
from the part program and provides it to the CLU which operates the drives attached to the
machine leadscrews and receives feedback signals on the actual position and velocity of each
one of the axes. A driver (dc motor) and a feedback device are attached to the leadscrew.
The CLU consists of the circuits for position and velocity control loops, deceleration and
backlash take up, function controls such as spindle on/off.
Machine Tool
The machine tool could be one of the following: lathe, milling machine, laser, plasma,
coordinate measuring machine etc. Figure 3 shows that a right-hand coordinate system is used
to describe the motions of a machine tool . There are three linear axes (x,y,z), three rotational
axes (i,j,k), and other axes such as tilt (9) are possible. For example, a 5-axis machine
implies any combination of x,y,z, i,j,k,and 6.
5
PRINCIPLES OF CNC
Each BLU unit corresponds to the position resolution of the axis of motion. For example,
1 BLU = 0.0001" means that the axis will move 0.0001" for every one electrical pulse
received by the motor . The BLU is also referred to as Bit (binary digit).
Point-to-Point Systems
Point-to-point systems are those that move the tool or the workpiece from one point to
another and then the tool performs the required task. Upon completion, the tool (or
workpiece) moves to the next position and the cycle is repeated (Figure 4). The simplest
example for this type of system is a drilling machine where the workpiece moves .
In this system, the feed rate and the path of the cutting tool (or workpiece) have no
significance on the machining process . The accuracy of positioning depends on the system's
resolution in terms of BLU (basic length unit) which is generally between 0 .001" and 0.0001" .
Workpiece
Example 1
The XY table of a drilling machine has to be moved from the point (1,1) to the point
(6,3). Each axis can move at a velocity of 0.5"/sec, and the BLU is 0.0001", find the
travel time and resolution.
These systems provide continuous path such that the tool can perform while the axes are
moving, enabling the system to generate angular surfaces, two-dimensional curves, or three-
dimensional contours . Example is a milling machine where such tasks are accomplished
(Figure 5). Each axis might move continuously at a different velocity. Velocity error is
significant in affecting the positions of the cutter (Figure 5). It is much more important in
circular contour cutting where one axis follows sine function while the other follows cosine
function. Figure 6 illustrates point-to-point and continuous path for various machines .
Figure 5. (a) Continuous path cutting and (b) Position error caused by the velocity error
Example 2
A CNC milling machine has to cut a slot located between the points (0,0) and (4,3)
on the XY-plane where the dimensions are in inches. If the speed along the slot is to
be 0.1 in/sec, find the cutting time and axial velocities.
If the velocity is Y-axis is off by 10%, what would be the new position ?
2-axis contour
milling milling
Figure 6. Schematic illustration of drilling, boring, and milling with various paths.
Interpolator
The input speed of l in/sec in example 2 is converted into the velocity components by an
interpolator called the linear interpolator whose function is to provide the velocity signals to x
and y directions. Similarly we have circular and parabolic interpolators. See Figure 7.
CNC systems are further divided into incremental and absolute systems (Figure 8). In
incremental mode, the distance is measured from one point to the next. For example, if you
want to drill five holes at different locations, the x-position commands are x + 500, + 200, +
600, - 300, -700, -300 . An absolute system is one in which all the moving commands are
referred from a reference point (zero point or origin) . For the above case, the x-position
commands are x 500,700, 1300, 1000, 300, 0. (Figure 8) . Both systems are incorporated in
most CNC systems. For an inexperienced operator, it is wise to use incremental mode.
10
Figure 8. (a) Absolute versus incremental ; In absolute positioning, the move is specified
by x = 6, y = 8 ; in incremental, the move is specified by x=4, y=5 for the tool
to be moved from (2,3) to (6,8)
The absolute system has two significant advantages over the incremental system :
Interruptions caused by, for example, tool breakage (or tool change, or checking
the parts), would not affect the position at the interruption.
If a tool is to be replaced at some stage, the operator manually moves the table, exchanges the
tool, and has to return the table to the beginning of the segment in which the interruption has
occurred . In the absolute mode, the tool is automatically returned to the position. In
incremental mode, it is almost impossible to bring it precisely to that location unless you
repeat the part program
1. Inspection ofthe program is easier because the sum of position commands for each
axis must be zero . A nonzero sum indicates an error . Such an inspection is impossible
with the absolute system .
2. Mirror image programming (for example, symmetrical geometry of the parts) is simple
by changing the signs of the position commands.
The open-loop control means that there is no feedback and uses stepping motors for driving
the leadscrew . A stepping motor is a device whose output shaft rotates through a fixed angle
in response to an input pulse (Figure 9) . The accuracy of the system depends on the motor's
ability to step through the exact number . The frequency of the stepping motor depends on the
load torque. The higher the load torque, lower would be the frequency . Excessive load torque
may occur in motors due to the cutting forces in machine tools . Hence this system is more
suitable for cases where the tool force does not exist (Example : laser cutting) .
Work table
Pulse
train a stepping
motor
Lead screw
The stepping motor is driven by a series of electrical pulses generated by the MCU . Each
pulse causes the motor to rotate a fraction of one revolution. The fraction is expressed in
terms of the step angle, oc, given by
If the motor receives "n" number of pulses then the total angle,
A = n (360/N), degrees
If there is a 1 :1 gear ratio between the motor and the leadscrew, then the leadscrew has (n/N)
revolutions . If the pitch of leadscrew is p (in/rev), then the distance traveled axially, say x,
x = p(n/N)
10
The pulse frequency, f, in pulses/sec determines the travel speed of the tool or the workpiece .
Example 3
A stepping motor has N = 150, p = 0.2"/rev ; If n = 2250 pulses, what is the distance
traveled in x-direction ? What should be the pulse frequency for a travel speed of 16
in./min ?
Example 4
Closed -loop NC systems are appropriate when there is a force resisting the movement of the
tool/workpiece . Milling and turning are typical examples . In these systems (Figure 10) the DC
servomotors and feedback devices are used to ensure that the desired position is achieved .
The feedback sensor used is an optical encoder shown in Figure 11 . The encoder consists of
a light source, a photodetector, and a disk containing a series of slots. The encoder is
connected to the leadscrew . As the screw turns, the slots cause the light to be seen by the
photodetector as a series of flashs which are converted into an equivalent series of electrical
pulses which are then used to characterize the position and the speed. The equations remain
essentially the same as open-loop except that the angle between the slots in the disk is the
step angle, a.
Both the input to the control loop and the feedback signals are a sequence of pulses, each
pulse representing a BLU unit. The two sequences are correlated by a comparator and gives
a signal, by means of a digital-to-analog converter, (a signal representing the position error),
to operate the drive motor (DC servomotor) .
Work table
Input
do
Comparator DAC Gear
servomotor
Position
Feedback signal sensor
Signal pulses
Photocell Time
(a) (b)
12
Example 5
a. Table speed
b. Motor speed in RPM
c. Distance traveled by the table
Example 6
a. Table speed
b. BLU
c. Frequency of pulses transmitted by the encoder
13
PRECISION IN CNC MACHINING
The combined characteristics of the machine tool and the control determine the precision of
positioning . Three critical measures of precision are :
o Resolution
o Accuracy
o Repeatability
Control resolution (BLU) is the distance separating two adjacent points in the axis movement
(the smallest change in the position) . The electromechanical components of the positioning
system that affect the resolution are the leadscrew pitch, the gear ratio, and the step angle in
the stepping motor (open loop) or the angle between the slots in the encoder (closed-loop).
The control resolution for a 1 :1 gear ratio of a stepped motor is,
Features smaller than the control resolution could not be produced . The programming
resolution can not exceed the control resolution .
Accuracy of a CNC system depends on the resolution, the computer control algorithms, and
the machine inaccuracies . The inaccuracy due to the resolution is considered to be (1/2)BLU
on the average. The control algorithm inaccuracy is due to the rounding off the errors in the
computer which is insignificant. The machine inaccuracy could be due to several reasons
(described below) . The designer minimizes this inaccuracy to be under (1/2)BLU and hence
Machining Inaccuracy
Cutting tool deflection, machine tool chatter, mechanical linkage between the leadscrew and
the tool, and thermal deformations are the chief contributing factors . The leadscrew transmits
the power to the table or toolholder by means of a nut that engages the leadscrew . This will
create what is known as "backlash"due to the friction between the screw and the nut. If the
nut consists of ball bearings, the friction is reduced . Thermal deformations are significant.
For example, a temperature difference of 1 °C along 1000 mm can cause an error of 0.01 mm.
14
EMEMOMME
MOMEMENN
MMMMMMMM
MEME ME"O
MEN"E"""
MMOMMOME
s
ONNEEMEN
EMOMMEN
IMMEMENE
MENNOMME EMMMOMME M"MM IMSN
ME MEN .... .... ...LO...
MI No MEMM EME" MMMMMMMM
MMEMEMEN MOMMOMME M"""M"N
MEMEMMEN """" MM""
Low Accuracy Low Accuracy High Accuracy
Low Repeatability High Repeatability High Repeatability
Figure 12. Diagram showing the difference between accuracy and repeatability
Example 7
What is the control resolution for a 4 :1 gear ratio (motor: leadscrew), pitch of
leadscrew 0.2 in/rev, and the motor receives 600 pulses per revolution
Since the motor shaft rotates 4 times faster than the leadscrew, N = 600/4 = 150
Resolution = 0.2/150 = 0.001333"
What would be the accuracy and repeatability if the machining inaccuracy is about
(1/2)BLU ?
15
PART PROGRAMMING FOR CNC
First, the machining parameters are determined . Second, the optimal sequence of operations
is evaluated . Third, the tool path is calculated . Fourth, a program is written. Each line of the
program, referred to as a block, contains the required data for transfer from one point to the
next.
Sequence Number, N
Consisting of typically three digits, its purpose is to identify the specific machining operation
through the block number particularly when testing a part program.
Preparatory Function, G
It prepares the MCU circuits to perform a specific operation . The G-codes (some) are shown
in Table 1 . G91 implies incremental mode of operation.
Dimension Words
While (1) and (3) are expressed either by incremental or absolute mode, (2) is always in given
in incremental mode. All angular dimensions are specified in revolutions or degrees.
In the above block, X moves a distance of 5 in. in the negative direction while Y moves a
distance of 7 in. in the positive direction. Other axes remain stationary. In some systems,
actual distances are used. In others, the dimension words are programmed in BLUs .
16
Feedrate, F
In linear motions, the feedrate of the cutting tool is not corrected for the cutter radius . But
in circular motions, the feedrate should be corrected for the tool radius as follows :
For cutting around the outside of a circle, the plus sign in the above equation is used, and the
feedrate is increased. For cutting around the inside of a circle, the minus sign is used, and the
feedrate is decreased .
Example 8
See Figure 5(a). If the required feedrate is 6 in/min, part contour radius is 1 .5 in,
and the cutter diameter is 1 in, what is the feedrate athe top and bottom circles ?
Spindle speed, S
Toolword, T
Consisting of a maximum of five digits, each cutting tool has a different code number. The
tool is automatically selected by the automatic tool changer when the code number is
programmed in a block.
Miscellaneous Function, M
Consisting of two digits, this word relates to the movement of the machine in terms of spindle
on/off, coolant on/off etc shown in Table 2.
EOB
The EOB character is used at the end of each block to complete a line.
17
Table . .1 Preparatory commands (G-code)
G00 Point-to-point positioning
G01 Linear interpolation
G02 Clockwise circular interpolation
G03 Counter-clockwise circular interpolation
G04 Dwell
G05 Hold
G33 Thread cutting, constant lead
G40 Cancel tool nose radius compensation
G41 Tool nose radius compensation - left
G42 Tool nose radius compensation - right
G43 Cutter length compensation
G44 Cancel cutter length compensation
G70 Dimensions in inches
G71 Metric dimensions
G90 Absolute dimensions
G91 Incremental dimensions
G92 Datum offset
18
4-7-2 G Functions (SEICOS-MII)
G codes with " " are set when the power is .turned on .
G40, G49 and G80 are set by resetting the NC unit .
G code Group Function
G52 00 .Local coordinate system setting
G53 Machine coordinate system selection
G54 Work coordinate system 1 selection
G55 12 Work coordinate system 2 selection
G56 Work coordinate system 3 selection
G57 Work coordinate system 4 selection
G58 Work coordinate system 5 selection
G59 Work coordinate system .6 selection
G60 00 I One directional positioning
G61 Exact stop check mode
G63 13 I Tapping mode
G64 Continuous cutting mode
G65 00 Macro call
G66 14 Macro modal call A
G67~ C Macro modal call cancel
4 - 30
4-7-3 M Functions
(* : Optional function)
13 Spindle forward & coolant start ''*46 (Spare tool offset disabled
14 Spindle reverse & coolant start *47 Jet coolant start
*66
*67
*68 Additional axis clamp
*69 Additional axis unclimp
*70 M70 output
*71 M71 output
*72 M72 output
*73 M73 output
*74 Skip selection OFF
*75 Skip selection ON
*76 .
*77
*78 Additional axis clamp
*79 Additional axis unclamp
*80 Tool nose air blow ON
*81
*82
i
*83
*84
*85
Measurement NG tool breakage
*86
detect
*87
*90
*91
*92
*93
*94
*95
*96
*97
98 Subprogram call
99 End of subprogram
4- 3 2
M Maintenance mode
*1001 Arm swing-in to spindle side
*101
*102. Arm advance
*103 Arm turn CW
*104 Arm turn CCW
*105 Arm retract
*106 Arm slide to home position__
*107
*108 Arm slide to magazine side
*109
*110
*111
*112
*113
*114
*115
*116
*117
*118
*119 Orientation
*120 Magazine positioning pin OUT
*121 Magazine positioning pin IN 1
*122
*123,
*124 Pallet slider advance (APC)
*125 Pallet unclamp (APC)
*1261 Pallet slider retract (APC)
*1271 Pallet right turn (APC)
*128 Pallet left turn (APC) -
1
*129 Pallet unclamp (APC)
4-33