Professional Documents
Culture Documents
CNC Machining
History of CNC machines
Introduction to CNC
G codes
Basic Programming
Startup block when programming
Absolute / Incremental
Rapid, Linear Interpolation, Circular Interpolation
Introduction to Spindle and Feed functions
Other commands
Dwell
Fixed cycles
Coordinate Rotation
Miscellaneous Functions
Program Structure
1725 – systematized punched cards were used to control the cloth pattern
1808 – punched holes in sheet metal cards to automatically control patterns made
by weaving machines
1863 – automatic player piano controlled by the Programmed sequence
1947 – First 3-axis curvature data employed to control M/C Tool.
1951 – First numerical control (NC) machine tool
1960s – Direct numerical control (DNC) was introduced
1970s – CNC machine introduced
1980s – Distributive numerical control
NC CNC
NC Numerical Control uses fixed logical functions that are hardwired in the
controller. The system can interpret a part program, but does not allow any changes to the
program. All changes must be done away from the controller The NC system requires the
use of punched tapes for input of the program information.
G code:
- alphanumeric code delivering instructions to the machine
- uses the standard Cartesian coordinate system
- interpreted language evaluated one line segment at a time on the machine
controller
Machine Geometry
Right hand coordinate system
Axes, planes, point of origin X0, Y0, Z0
o Z axis axis along which a simple hole can be machined with a single
point tool
o X axis longitudinal direction
o Y axis cross direction (vertical) column direction (horizontal)
o Z axis spindle direction
o machine origin part origin relationship work offset
Additional Axes:
o secondary axes (mounted on the spindle) U, V, W parallel to X, Y, Z
respectively
o rotary axes (fixture) A, B, C rotated about the X, Y, Z axes
respectively)
o Positive direction for the rotary axes follow the right hand rule
From a programming perspective programming always takes place from the viewpoint
of the spindle, NOT the operator. The positive and negative motion of the machine axes
may be OPPOSITE to the positive and negative programming directions.
Program Planning suggested order of operations [There will be iterations in this process]
Basic Programming
A program for a numerically controlled machine tool is comprised of a series of program
blocks, each block being terminated by an “end of block” code. [The EOB button on the
keypad generates a semicolon (;) as the end of block code.] A block is comprised of one
or more words. A word is comprised of an address followed by numbers. Those
numbers that require decimal point programming are signed values. A positive value is
the default and thus the plus sign (+) need not be programmed. The address is a letter
which indicates the meaning of the numerical value following the address. Some
addresses may differ in meaning depending on the preparatory functions specified in the
program.
Character Word Block Program
Character: smallest unit of the CNC program, and can be a digit, letter or symbol
*Use capital letters*
Block: consists of one or more words Each block must be separated form all others
EOB or “end of block” code
X ±5.3
Number of digits after the decimal point
Decimal point
Number of digits before the decimal point
Possible value
Address
If there is no decimal point for a notation, the decimal point is not used. The following
address codes require decimal programming:
X, Y, Z, I, J, K, R, Q, F
If the decimal point is omitted, the value programmed represents the number of minimum
dimension units and in the metric mode would result in the value being multiplied by
0.001 mm. For example, X5 would result in a value of 0.005 mm in the x direction,
whereas X5. yields a value of 5.0 mm.
The functions, the address codes along with their numeric value ranges, and the meanings
of the functions are listed in the following table:
Modality: Once a Modal command is turned on and executed, it remains active until it is
overridden by another modal command. If a command is not a modal command, it must
be repeated on every line of the CNC program that it is used.
G00 is the rapid mode and is a code for a particular type of tool motion.
G01 is the linear interpolation command, and has an associated feed rate.
Both commands cannot be active at the same time. If a conflict situation occurs, then the
latter code will be active. In the above example, a rapid motion will occur. The feed rate
is ignored.
Word order in a block: G codes are normally programmed at the beginning of a block,
after the block number, before the other significant data. This is good programming
practice, and will avoid surprises, such as if you were switching between rapid and
interpolation modes, absolute and incremental modes, etc.
Group Codes (Grouping of commands): Fanuc has grouped “like commands” into
arbitrarily numbered group codes. If two or more commands are used in the same
program block, they are in conflict with each other. The group codes vary from 00 to 25.
English / Metric
All controls are based on the metric system. Any switching does not ensure a full
conversion will take place. Some tool offset screens may still be in the metric mode.
Units must be consistent for dimensional words (X, Y, Z, I, J, K, …) Feedrate function
(F), tool offset values (H, D), and for constant surface speed mode (CSS – lathes).
G20: select English mode.
G21: select Metric mode.
Absolute / Incremental
There are two ways to command axis travel; the absolute command mode and the
incremental command mode. In the absolute command mode, the absolute coordinate
values (X,Y,Z) of the end points are programmed. The (X,Y,Z) values are measured with
respect to the program origin. In the incremental mode, the actual distance the tool is to
be moved is from one point to another is programmed. If the required motion for any axis
is zero, that axis in general need not be programmed. In the absolute mode if any of the
axis are not programmed, the existing absolute values in the buffers remain the same and
no motion is produced along those axes; in the incremental mode, if any of the axes are
not programmed, the incremental distance to be moved is assumed to be zero and thus no
incremental motion is produced along those axes.
G90: absolute
G91: incremental
Active Plane
The G codes to set the active planes are summarized in the following table. For three
dimensional helical interpolation, the arc vectors are I, J and K.
Interpolation
Linear Interpolation
If we have two points, A and B, which lie in the XY plane and if we wish to move the
cutter from point A to point B, the path that is generated between A and B will depend on
the feedrates that are applied to the X and Y axes. For any machine tool there will be a
maximum federate that can be applied to each of its axes. In some machine tools the
maximum federate allowed will be the same for all axes; however, this is not always the
case.
If the reason for the move is merely to reposition the tool and cutting takes places during
the move, the actual path taken between A and B may not be important as long as the tool
is guaranteed to be at point B at the end of the move. This type of motion is referred to as
“point to point” because only the end point criterion must be satisfied and the path that
the tool takes to get there. Under these conditions, it would be desirable to perform the
positioning as quickly as possible and therefore point-to-point motion is usually
performed in a rapid feedrate mode.
On the other hand, if the pupose of moving the tool from A to B is to perform a straight
line cut along the line AB, then the path that the tool takes in moving from A to B is
critical and must be linearly interpolated. Linear interpolation is accomplished by
setting the relative feedrates of each axis such as to ensure that a straight line motion
between A and B is generated at the required feedrate.
Y
Point to Point C B 50,30
Path
Interpolated
A Path
10,10
Consider the above example illustrated above. The tool is to be moved 40 units in X and
20 units in Y. To rapid position the tool, the maximum feedrate, which is assumed to be
the same for both axes, is applied simultaneously to both axes. The resulting motion is
ACB since the required distances are not the same. The Y axis motion is completed
before the X axis motion.
If the tool is to perform a straight line motion, the feedrates must be calculated as
follows:
x y
Fx F . , F y F . , L x 2 y 2
L L
x and y are the distances required along the x and y axes
Here in the above example, Fx is twice Fy.
The above discussion on interpolation has been limited to a two dimensional example.
However, the concepts are identical when working with all three dimensions.
Circular Interpolation
The circular interpolation mode permits the tool to be moved in a circular arc, if, and only
if, the arc line in a plane which is parallel to one of the three Cartesian planes (XY, ZX,
ZY). To specify circular interpolation, four pieces of data must be provided:
(1) plane selection (G17, G18, G19),
(2) direction of rotation CW or CCW (G02, G03 respectively)
(3) the end point position on the arc, and
(4) the distance from the starting point on the arc to the centre of the arc or the arc
radius
This section covers the use of G2 to make arcs in the X-Y plane on controllers that use
incremental center coordinates.
Example:
G1 X1.375 Y0.25 (GO TO START OF ARC)
G2 X1.75 Y-0.125 I0 J-0.375 (CLOCKWISE CIRCULAR MOVE)
Note that Z values have been ignored. We are assuming that Z was set prior to the G1
linear move and we are creating a 2D arc so the Z value, whatever it is, remains the same
throughout.
This section covers the use of G2 to make arcs in the X-Y plane on controllers that let
you specify the arc radius with an R-word.
Example:
G1 X1.375 Y0.25 (GO TO START OF ARC)
G2 X1.75 Y-0.125 R0.375 (CLOCKWISE CIRCULAR MOVE)
You are defining an arc using two points and a radius so there are two possible arcs that
will fit your values - you need to tell the control which one you mean. This is done by
using a positive R value if the arc is less than 180 degrees and a negative R value is
greater than 180 degrees.
If the arc is exactly 180 degrees, you have a choice to make. You can try a positive value
and see what happens (best to "cut air" for this and a bit of prayer won't hurt) or you can,
and should, break the arc into two segments and program it in two moves.
Some controllers will not handle arcs that pass through an "axis crossover point" (a
quadrant boundary - 0, 90, 180, 270 degrees.) If this is the case, you need to break the arc
at these points. Many people recommend doing this for all arcs, regardless of controller
capabilities, and many postprocessors offer the option to do it automatically. Also, see if
your controller uses a G-code for this, usually a G75 for "multi-quadrant" mode which is
cancelled by a G74. A bit of needless info - the "axis crossover" restriction usually relates
to motors having to change direction at this point.
Example:
G1 X1.1053 Y0.1355
G2 X1.375 Y0.25 I0.2697 J-0.2605
G2 X1.75 Y-0.125 I0 J-0.375
G2 X1.6887 Y-0.3305 I-0.375 J0
Regarding complete circles - some controllers handle them and some don't. A controller
that can process multi-quadrant arcs may accept an arc end point that is identical to the
current tool position and machine a complete circle. Others may do nothing, and others
may throw an error condition. If you have any doubt about the capabilities, break the
circle into pieces and cut each arc separately.
On many machines, G2 and G3 commands can be used to drive arcs in the ZX and YZ
planes. G18 is usually used to switch to the ZX plane and G19 selects the YZ plane.
Don't forget, though, that to make a circular feature on a part in these planes using a 3
axis machine the tool path itself won't be circular unless an angled head is used.
A G2 causes clockwise motion as viewed from the positive direction of the perpendicular
axis and the figure reflects this.
Y X Z
G03 G03 G03
X Z Y
To determine the direction of rotation, the plane is viewed from the positive direction of
the Z axis (X / Y) onto the XY plane (ZX or YZ) in the right hand Cartesian coordinate
system. Note the axis labels and the G02 / G03 directions. Do not get this confused or
you will have unexpected results.
Lathes
Use of G2 and G3 on a lathe is similar to their use on a machining center, although tool
shape is more of a consideration. A 2 axis lathe operates in the ZX plane, and uses the I
and K words for center location.
The figure shows a simple case using an imaginary tool tip as a reference point. The nose
radius is 0.0625. The program fragment below follows the part profile, accounting for
insert geometry.
G1 Z1.6875
G2 X0.9375 Z1.6875 I1.6875 K0
G1 X1.5 (GO PAST)
Note that the G2 direction is "backwards" based on normal G18 conventions. This just
illustrates how important it is to read the programming manual applicable to the machine
being programmed. If we programmed this move using the center point of the nose
radius, the instructions would be more like previous examples although the setup would
be different.
Cutter Compensation
Cutter (radius) compensation can generally be used for G2 and G3 moves just as for
linear moves. Most considerations are the same - you need to be careful where you turn it
on and off and so on. Also, be sure that you don't inadvertently enter a tool radius that is
larger than, or even equal to, the smallest arc radius used in an inside corner.
3D Circular Interpolation
Some machines provide helical interpolation via G2 and G3 commands. Programming it
is pretty straightforward - just include a Z value in the G2/G3 that differs from the
starting position. The motion will end with the tool in the specified Z position. The Z
increments will be determined by the number of actual XY moves to complete the arc. In
other words, when the arc is 40 percent done, so is the Z motion. This can be used for
ramping into a pocket or other approach moves.
Also, some controllers allow a more advanced form of 3D arcs using a sphere to control
depth. An explanation is outside the scope of this course.
Spindle Function
The program command relative to spindle speed is controlled in the CNC system by the
address S. The actual spindle speed range of values must be determined by the machine
specifications.
There are two main methods of programming the spindle speed. They are:
Most machine spindles can be rotated both clockwise and counter clockwise. There are
two miscellaneous functions that control the direction of the spindle.
M03: CW
M04: CCW
Feedrate Function
The address for a feedrate word is F, followed by the number of digits. There are two
types of feedrates:
To select the best spindle speed and feedrate, some general knowledge of machining is
required. There are several parameters that must be considered, such as:
During a contouring operation, the cutting direction is constantly being changed. The
control may have to stop the X axis motion, then start the Y axis motion. To stop, the X
axis must decelerate, and the Y axis must accelerate. A possible cutting error may occur
at sharp corners because of undesirable overshoot, especially when using high feedrates.
Exaggerated
overshoot
Exact Stop
G09/G61 used
If the error needs correction, Fanuc controls provides two Gcodes to alleviate this
problem (note: this increases cycle time):
G09 Exact stop check (one block only)
G61 Exact stop check mode (modal)
For completeness, there are 3 other feedrate modes, G62 (automatic corner override),
G64 (normal) and G63 (tapping mode ignores any feedrate override settings on the
control panel). G62 and G64 are illustrated below.
G62 G64
Cutter Compensation
In the homework assignment, the tool coordinates had to be hand calculated. These points
would then need to be incorporated into the program to generate the correct tool path.
You spent some time to create the coordinate values. For complex geometry or a non-
standard cutter, errors could be easily made. The results will be potentially a scrapped
part, tool, fixture, and machine damage. If a different tool is used, the program needs to
be completely rewritten – obviously there has to be a better way. There is no guarantee
that the person developing the program will know the actual cutter diameter at the time of
programming. We will now examine cutter compensation – or 2D cutter offset
compensation IN THE COMPENSATION PLANE (remember G17, G18, G19).
G41 G42
Left Right
M03
Right Left
None None
The concept of compensation is simple, but there are three steps that must be taken:
Select the tool plane
Select the compensation mode for the tool path under consideration
o Must know the direction of the cutter motion and which side of the feature
is being cut (i.e. clockwise / counter clockwise direction, internal or
external tool path)
CANCEL the compensation immediately after it is utilized to prevent catastrophic
problems
When you are using cutter compensation, the outline of the part is programmed.
The controller must determine the 2D offset vector based on the effective radius of the
cutter in order to generate the tool coordinates for the required cutter path. The vector is
calculated base on the offset amount that has been set in the tool offset memory and is
specified in the program by the D code. The compensation methods are controller
specific. Some generic issues (based on Fanuc controllers) are presented here.
The D code is a two digit integer code (address notation from lecture 1). This code
represents the location in the tool offset file memory where the actual tool offset value is
stored. It is good programming practice to relate the D code to the designated tool
number for which the code is used.
The appropriate side of the part to be cut is determined by viewing the geometry in the
direction the cutter is to travel – you compensate the cutter either to the left or to the
right.
G40, G41 and G42 are used simultaneously with G00, G01, G02 and G03 to define a
mode that determines the amount and direction of the offset vectors and the direction of
tool motion. A G41 or G42 command causes the controller to enter the offset mode with
the offset specified by the D code, and a G40 command cause the controller to cancel the
offset mode. Thus for sections of programming that employ cutter compensation there are
three modes or sequences of blocks that must be programmed: they are the start up block,
subsequent machining blocks, and the cancel block.
ALWAYS CANCEL THE CUTTER COMPENSATION WHEN FINISHED.
Following are some illustrations (using G42) how the tool paths are generated when
employing cutter compensation. The controller may generate “intermediate” tool path
motions internally. You must be aware of the potential tool path variations to ensure that
the tool motion programmed will yield the desired results. The tool paths for G41 AND
G40 are similar in nature.
180
r
3
2
1 G42
Always select the start position of the cutter away from the contour,
in a clear area.
Always apply the cutter radius offset together with a tool motion.
Notes: In order for the controller to determine the offset vectors, it may employ a look
ahead operation reading two blocks ahead of the current block being executed (which is
how you can get screwed up if you are mixing metric and inch systems!). If this is the
case (older controllers do not have two block look ahead) as a result, the controller
imposes the restriction that when cutter compensation is in effect two consecutive
program blocks in which no motion is programmed (in the compensated plane) is NOT
ALLOWED. If you do not follow this practice, unexpected results may occur.
…
Consider the tool motion for the following block: N21 G01 G41 X0 D01 F17.0
N22 M08 (coolant on)
N6 G41 X0 D01 F15.0 N23 G04 P1000 (dwell 1 sec.)
N24 Y 2.5
What happens? Example of 2 no motion codes will
create problems
It depends.
If the controller cannot compute a
On what? compensation mode, compensation
will not be turned on.
The NEXT move
If the next move is a Y +ve move, the cutter moves to the left of the X axis.
If the next move is a Y –ve move, the cutter moves to the right of the X axis.
The controller must look ahead to properly apply the compensation mode.
G41 G41
D01 D01
X0 X0
Arc commands (G02 & G03) are not allowed in the cutter compensation start up
and cancel blocks.
The start up and cancel blocks are often used to position the cutter and in such a case no
actual machining takes place in these blocks (i.e. move the cutter to a safety zone).
Make certain that the plane selection G code is active and that the required D code is
programmed.
Preventing Scrap:
(1) Ensure the cutter radius is smaller than smallest inside radius of the part
contour.
(2) Ideal conditions are rare. You can use tool wear offsets to change the effective
radius of the cutting tool. The goal is to create some temporary settings that
will leave residual stock, and allow you to make adjustments before
performing the final cut.
External cut make the part intentionally larger positive offset value to
increase radius
Internal cut make the part intentionally smaller negative offset value to
decrease radius
Measure the part to determine the effective diameter size, adjust the offsets
again, and then recut to the right size.
Reference Points
Machine Reference Point – machine zero or the home position for each axis
Program Reference Point – program zero point
Part Reference Point – part datum
Tool Reference Point – tool tip
All of these reference points interact. The Machine Reference Point is the origin of the
machine coordinate system. This point will vary between machine manufacturers, and the
various machine configurations. The part is located in a work fixture. The location of this
device is critical you must check for angular alignment in all 3 planes. [Note: the
spindle must be square as well]. The program zero should take into consideration
practical restrictions:
o part datum points and feature relationships
o convenience of setup and operation
o safety of the working conditions
There may be multiple datum points on a part – i.e. casting datum points, machining
datum points, feature datum points, and so forth. A datum is selected on the basis of its
geometric relationship to other features and the functional requirements of the design. A
part datum may NOT be the best point for a program zero. The part drawing must be
carefully analysed to determine the best program zero.
The relationship between the machine zero point and the workpiece zero is established
using a work offset. The relationship between tool, part and the machine is established
using a tool offset.
Work Offsets
The coordinate system used for machining is called the work coordinate system. Up to 6
different work coordinate systems can be specified in a Fanuc controller. With the newer
Fanuc controllers, even more coordinate systems can be specified. A work coordinate
system is established by measuring the program zero datum points relative to the machine
zero point, and storing the values in the appropriate workpiece offset table. The G codes
representing the work offsets are modal.
Offset Offset
P02 P03
Offset Offset
P01 P04
Machine Zero
The Z offset interacts with the tool length offset, which is discussed in the next section. A
Z offset is used when there are several parts with variable height, within the same setup.
If there is only one part to be considered, set the Z offset to Z=0, and utilize the tool
length offset.
z
Use this surface to
establish tool offsets Z25
Z0 x
-Z10
G56
G54 G55
Table
There are 6 work offset tables in the Fanuc controller. If this is not sufficient, the work
offset vector can be programmed directly in the main program using the following
notation:
G10 Program parameter input
Tool Offsets
Realistically, all tools are of different lengths and we would like to simplify our
programming by ignoring this fact. Most CNC machine tools provide a mechanism by
which the tools can be measured and their relative lengths or OFFSETS stored so that
when a particular tool is called up, the controller will automatically compensate for these
differences in length. There are length offsets (H code address notation – lecture 1) and
radius offsets (D code). Typically there are two parameters associated with a tool offset
one for geometry, and one for wear. The amount of tool length offset that is to be
compensated for each tool is stored in the tool length offset table. For example, if tool 1
were being used, H01 would be the required H code. Correlate the tool numbers, H
and D codes.
Various points can be selected on a tool you must understand the repercussions of the
reference point selection. For example, if you have the offset the extreme tip of the drill,
the depth of the hole must take the drill tip geometry (depth) into consideration. Note:
CAM software will take care of these issues automatically.
Care must be
taken with the
tool position
or final part
program
geometry
The logic is simple: the stored tool length value is added (G43) or subtracted (G44) from
the absolute value of the programmed Z coordinate (work offset).
until the paper cannot move under the tool. Then you push the offset button on the
controller to establish the offset length. The offset value is the travel distance
between the machine zero PLUS the tip of the tool and the touch off surface
(program zero). This value will be a negative number. You use a G43 to add this
value to the absolute Z coordinate, which is Z0 in this case. (This method induces
non – productive time on the machine).
Gauge
Line
H01 H02
part
(2) Off Machine Tool Setting: Some users prefer to preset the tools away from the
machine, which eliminates non-productive setup time. The actual value for the
tool length is stored in the offset table, and is a positive number. Z does not equal
0 for the work offset value. Presetting equipment and trained personnel is
expensive.
Gauge
Line
H01
H02
G54
part
At the end of the program, cancel the tool length offset using a G49.
tools have a different design, there are some unique programming considerations for a
lathe. There are centreline tools such as drills, reamers and taps, but boring, facing, and
other turning operations have offset tool positions. As well, inserts are commonly used,
which have different configurations, and the cutting edge has a small corner radius.
Therefore, a complementary method for tool setting is used for a lathe. Both the work and
tool offsets are tied in together.
Centreline tools are always measured from the centre of the tool to the centreline of the
spindle along the X axis, and from the tool tip to the program zero along the Z axis.
Turret
@ home
T01
(X)
(Z)
Once the X and Z values are established, the tool / work offsets are set.
For turning / boring tools, the situation is different. The tool nose reference point is a
virtual or imaginary point.
T01
(X)
(Z)
There are many insert styles used in turning / boring, as shown in Figure 2.17. The
X+Z+ orientation is used for OD turning, the X-Z+ orientation is used for ID boring. It is
difficult to determine the actual radius periphery. When establishing the work offset, you
touch off on the furthest points on the insert in X and Z, and create an imaginary
intersection point in space.
to Z0 to Z0
X+ Z+
to X0 X- Z+ to X0
Reference
Pt
How do we find the centre of the
insert radius? (green)
We cannot easily – but we can
find the reference point (red).
The theoretical sharp point created from the work offset is established. However, this is
not correct. Compensation is applied to create an offset to generate the correct tool path.
An offset is used which is based on the nose radius, and the X Z distances from the centre
of the tool to the reference point.
Dwell
The time for a dwell, or a pause in the machining program is in milliseconds. The P or X
code is used with a G04 command. The structure is G04 P1000 for a 1 second pause.
G04 Dwell
This command is not modal. The dwell function is used to break up chips when drilling,
grooving, parting off, and so forth. It may also be used when tapping, between feeding in
and out of the hole. It is also used for non-cutting applications after certain miscellaneous
functions such as moving the tailstock, a bar feeder, etc.
Canned Cycles
Canned cycles or fixed cycles are pre-programmed cycles within the controller that
reduces repetitive programming for common features. The G codes are listed below. The
general format for these fixed cycles is a series of parameter values specified by a unique
address. The general format is
N## G## G@@ X.. Y.. R.. Z.. P.. Q.. I.. J.. F.. L.. K..
N – line number
X – hole position X
Y – hole position Y
R – z axis start position (R level)
Z – z axis end position (Z depth)
P – dwell time
Q – G73 or G83
Depth of each peck cycle
Q – G76 or G87
Amount of shift for boring
I – Amount of X axis shift for boring G76 or G87
J – Amount of Y axis shift for boring G76 or G87
F – feedrate specification
L or K – number of cycle repetitions
_______________________________________________________________________
Initial level
1
point
rapid
2 6 feed
Rapid
plane Z0
3 5
4
Bottom of hole
The tool can retract to either a programmed initial level or rapid level. Absolute or
incremental programming can be used with canned cycles. Common cycles are
summarized below:
G81 – drilling cycle mainly used for drilling and centre drilling
G82 – spot drilling / counter boring / spot facing cycle uses a dwell at the bottom of
the hole to create a smooth finish
G83 – peck (deep hole) drilling cycle used to break up and clear the chips when
drilling deep holes (note: the depth of rapid motion between pecks is set using a system
parameter)
Bottom of hole
G73 – High speed peck (deep hole) drilling cycle same as above, but the tool never
clears the hole between pecks (note: the depth of rapid motion between pecks is set using
a system parameter)
The best peck depth is based on the design of the cutting tool, the machinability of the
material, the depth of the hole, and the fixturing.
G84 – normal tapping cycle using M03 the spindle turns CW when the tool is
feeding in, and then turns CCW when feeding out
G74 – reverse tapping cycle using M04 the spindle turns CCW when the tool is
feeding in, and then turns CW when feeding out
_______________________________________________________________________
When a selected fixed cycle is programmed for many holes, it is processed only once
unless the L or K address is used. This can be used in absolute or incremental modes to
repeat the canned cycle at other XY locations. The following examples provide the
equivalent results
Y20.0
Coordinate Rotation
The two rectangles below are identical except that the bottom rectangle has been rotated
30 °. It is much easier to program the top rectangle than the bottom. Instead of
determining what the end coordinates are for the rectangle with the angular rotation, the
controller can do so if the coordinate rotation feature is used.
The XY coordinates are the pivot point (XZ for G18, YZ for G19). The plane selection
command must be entered before the coordinate rotation command. R can be positive
(CW) or negative (CCW).
35
10
Milling Turning
M00 Compulsory program stop M00 Compulsory program stop
M01 Optional program stop M01 Optional program stop
M02 End of program (reset no rewind) M02 End of program
M03 Spindle rotation normal (CW) M03 Spindle rotation normal (CW)
M04 Spindle rotation reverse (CCW) M04 Spindle rotation reverse (CCW)
M05 Spindle stop M05 Spindle stop
M06 Automatic Tool Change M06
M07 Coolant mist ON M07 Coolant mist ON
M08 Coolant ON (pump motor ON) M08 Coolant ON (pump motor ON)
M09 Coolant OFF (pump motor OFF) M09 Coolant OFF (pump motor OFF)
M10 . M10 Chuck open
M11 . M11 Chuck closed
M12 . M12 Tailstock quill IN
M13 Spindle ON CW + coolant ON M13 Tailstock quill OUT
M14 Spindle ON CCW + coolant ON M14 .
M15 Spindle OFF + coolant OFF M15 .
M16 . M16 .
M00 – program is stopped, and the spindle and coolant turned off. When the cycle start
button is pressed on the console, the program is resumed.
M01- if the optional stop on the console is on, the M01 function is identical to the M00
function, else it is ignored.
M03 / M04 – turn the spindle on CW or CCW respectively. The rpm must be
previously defined by the spindle speed command (S).
M30 – this indicates the end of the program. The spindle and coolant are turned off, and
the program reset to the beginning.
Machining Centres (both mill and lathe) have a multiple tool storage in a tool magazine
(machining centre) or a turret (lathe) and the ability to change tooling automatically a
feature called automatic tool change. Each pocket has a number associated with it; hence,
when tool 1 is chosen, the tool loaded in pocket 1 will be placed in the spindle or rotated
into position if using a lathe.
Programming a tool change is easy. For a machining centre, to bring tool in pocket four
into the spindle, one programs:
To load a tool into a waiting position (to reduce waiting time on the machine), on the next
line, program the address of the next tool to be used.
N ## TXXYY
XX – turret position and work offset number
YY – wear offset number
Program Structure
Program Number
Comments to describe the program, part, and other critical information such as revisions.
Start up block
Comment for tool 1
Program cutting motions for tool 1
Comment for tool 2
Program cutting motions for tool 2
.
.
Clear / cancel all settings
End of program
Stop code
O####
(COMMENT TO DESCRIBE THE PROGRAM SUCH AS MACHINE,
CONTROLLER, UNITS, JOB NUMBER, …)
(PART DESCRIPTION SUCH AS STOCK MAT’L, PROGRAM DATUM POINT)
(PROGRAMMER / DATE / REVISIONS………………)
N1 G17 G21 G40 G49 G54 G64 G80 G90 G94; (start up block)
N2 (½ INCH HSS DRILL)
N2 T01 M06;
N3 G00 X.. Y.. Z.. S.. M03 T02; (select a spindle speed, start up spindle, setup tool 2 to
be ready for tool change)
N4 G43 Z2.0 H01; (use tool length offset for tool 1)
.
.
N## cancel settings
N## M30;
%
Sample Program:
%
O0000
(PROGRAM NAME - MACHINE_GROUP_1_COMPG42 )
N1 G21
N2 G0 G17 G40 G49 G80 G90
( 8. FLAT ENDMILL TOOL - 8 DIA. OFF. - 8 LEN. - 8 DIA. - 8. )
( 3 flute endmill )
N3 T8 M6
N4 G0 G90 G54 X16. Y17. A0. S537 M3
N5 G43 H8 Z50.
N6 Z10.5
N7 G1 Z-13. F4.
N8 G42 D8 X8. F8.1
N9 G2 X0. Y25. R8.
N10 G1 Y50.
N11 X100.
N12 Y0.
N13 X0.
N14 Y25.
N15 G2 X8. Y33. R8.
N16 G1 G40 X16.
N17 Z-3. F4.
N18 G0 Z50.
N19 M5
N20 G91 G28 Z0.
N21 G28 X0. Y0. A0.
N22 M30
%