0% found this document useful (0 votes)
10 views12 pages

Structure of A CNC Programming Block

The document outlines the structure and programming of CNC (Computer Numerical Control) programs, detailing the required format for blocks and instructions. It explains the use of various G and M functions for movement, tool control, and conditional operations, emphasizing the importance of proper sequencing and compatibility of commands. Additionally, it provides examples of programming in both metric and imperial units, along with explanations of specific functions and their applications in CNC machining.
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)
10 views12 pages

Structure of A CNC Programming Block

The document outlines the structure and programming of CNC (Computer Numerical Control) programs, detailing the required format for blocks and instructions. It explains the use of various G and M functions for movement, tool control, and conditional operations, emphasizing the importance of proper sequencing and compatibility of commands. Additionally, it provides examples of programming in both metric and imperial units, along with explanations of specific functions and their applications in CNC machining.
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/ 12

TECHNOLOGY WORKSHOP

DEPARTMENT OF DESIGN
NATIONAL UNIVERSITY OF INDUSTRIAL
THE SILVER

NUMERIC CONTROL PROGRAMMING


ISO STANDARD (CODE G)

STRUCTURE OF All programs must have a name or an identifying number.


A CNC PROGRAM Some numeric controls only accept numbers. CNC programs
they are composed of successive blocks. Each of these is a
instruction for control. The blocks may or may not be numbered. From
not having them, the control will execute them in the order in which they come
finding. The numbering of the blocks may not be sequential.
one. It can be in fives, in tens, etc. This is
convenient for later introducing intermediate blocks without altering the whole
numbering. The numbering must always be increasing. If there were a
block whose number is less than the previous one, the control stops the execution
of the program.

STRUCTURE OF A N G X Y Z F S T M
BLOCK OF
CNC PROGRAMMING Auxiliary Functions

Tool Number

Spindle speed

Feed rate

Quota according to Z axis

Quota according to Y axis

Quote according to the X axis

Movement instruction (Go)

Block number

Within each block, this order must be maintained. However, it is not


it is necessary that all items are present.
It can be programmed in metric system (mm) or in inches.

N4 G71 G2 X, Y, Z +/- 4.3 F5.5 S4 T2.2 M2 (metric)


N4 G70 G2 X, Y, Z +/- 3.4 F5.5 S4 T2.2 M2 (in inches)

The number accompanying each item indicates the number of digits.


admissible. For example:
N4 means that the number of blocks should not exceed 9999.
This varies according to the brand of numerical control.
Z +/- 4.3 means that the limits can have positive or
negatives of no more than 4 integer digits and 3 decimals. Normally the
The plus (+) sign is not programmed.

BLOCKS Conditional blocks are executed or not based on the presence


CONDITIONALS from an external signal to the program. They are used, for example, to program
stops for work inspections, tool changes, etc. They
determine the conditionality of a block by adding a period afterwards
block number. switch on the control. If this switch is activated, the execution of
The external signal the program will stop when it encounters a conditional block. If it is not, the
it is normally a the program will continue to run normally.

INSTRUCTIONS OF G00 Quick positioning


MOVEMENTS OR G01 Linear Interpolation
PREPARATORIES G02 Circular Interpolation in a clockwise direction
(G FUNCTIONS) G03 Counterclockwise Circular Interpolation
G04 Timing
G05 Murdered broom
G06 Circular Interpolation centered on absolutes
G07 * ** Live Arista
G08 Arc tangent to the previous trajectory
G09 Circular interpolation defined by three points
G10 Cancellation mirror image
G11 Mirror image on the X axis
G12 ** Mirror image on the Y axis
G13 Mirror image on the Z axis
G17 * ** XY Plan
G18 ** Plan XZ
G19 ** YZ Plan
G20 Call to standard subroutine
G21 Call to parametric subroutine
G22 Definition of standard subroutine
G23 Definition of parametric subroutine
G24 End of subroutine definition
G25 Unconditional call
G26 Conditional call if equal to 0
G27 Conditional call if not equal to 0
G28 Conditional call if less Call
G29 conditional if greater than or equal to View
G30 error defined by K
G31 Save coordinate origin
G32 Recover coordinate origin
G33 Electronic roscado
G36 Controlled rounding of edges
G37 Tangential entry
G38 Tangential exit
G39 Flared
G40 Cancellation of radio compensation
G41 ** Left radio compensation
G42 ** Right radio compensation
G43 ** Length compensation
G44 Cancellation of length compensation
G47 Unique block
G48 Cancellation of single block
G49 Programmable feed
G50 Tool length loading
G53 ** Transfer from origin
G54 Transfer from origin
G55 ** Transfer from origin
G56 Transfer from origin
G57 Transfer from origin
G58 Origin transfer
G59 Transfer from origin
G70 Programming in inches
G71 Programming in millimeters
G72 Scaling defined by K
G73 Rotation of the coordinate system
G74 Zero machine search
G75 I work with a probe
G75 N2 Fixed cycles of probe
G76 Creation of blocks
G79 ** Fixed cycle defined by the user
G80 Cancellation of fixed cycles
G81 Fixed drilling cycle
G82 Fixed drilling cycle with timing
G83 Fixed cycle of deep drilling
G84 Fixed threading cycle with tap
G85 Fixed scarification cycle
G86 Fixed cycle of drilling with retract in G00
G87 Fixed cycle of rectangular cashier
G88 Fixed cycle of circular cashier
G89 Fixed cycle of boring with retraction in G01
G90 Absolute programming
G91 Incremental programming
G92 Preselection of quotas
G93 Polar coordinates
G94 * ** F in mm/min
G95 F in mm/rev
G96 Constant F
G97 F of the constant tip
G98 Return to the security plan
G99 Return to reference plane

(*) These are the instructions that the numerical control assumes by default.
when it is started, or after M02, M30, EMERGENCYRESET.
(**)MODALMeans that once the instruction appears, this
remains active until it is replaced by another instruction or by
M02,M30,EMERGENCYRESET

All the functions can be programmed in the same block.


want and in any order except G20, G21, G22, G23, G24, G25
G26,G27,G28,G29,G30,G31,G32,G50,G52
G53/59, G72, G73, G74, G92. These functions must be programmed.
in separate blocks. If functions are programmed in the same block
incompatibles stops the execution of the program.
Example:

N50 G01 X20 Y10 Z30 F200 S1000


N60 X100
N70 G00 Z50

BlockN50, orders the tool to go from the coordinates in


that is found (in those that remained after the execution of the block
previous), inG01(straight trajectory) to the coordinates X20 Y10 Z30, to
a feed rate (F) of 200 millimeters per minute, with the spindle
spinning at (S) 1000 revolutions per minute
Block N60, the new movement is in G01, it is not specified in the
block for being modal. Order to go to X100, this means that the movement
it will not have new quotas in YoZ, meaning that the new destination is X100 Y10
Z30. As there are no new quotas, it is not necessary to include them in the block.
they are also modals. In the absence of specification of Fni of S, the
the movement will be made with the same values as the previous block. FyS
they are also modals.
Block N70, rapid movement G00 from the previous elevation to Z50, assumes
The maximum speed of the machine. According to the last block.
It can be programmed absolutely (all values are given
regarding the 0,0,0) or incremental (the values are relative to the level
previously). By default, CNCs assume programming in absolute (G90).
In case you want to work in incrementals, you must program a G91.
on the initial line.

FUNCTIONS M The auxiliary functions produce different actions in the machine.


(AUXILIARIES) Example: start or stop the spindle, start or stop the supply
of refrigerant fluid. There are others that are related to execution
of the CNC program: end it, reset values, etc. They cannot be
scheduled along with other functions, must be in exclusive blocks and
up to seven can be included in the same block
These are the most used auxiliary functions:

M00 Program stop


M01 Conditional breakpoint of the program
M02 End of the program
M03 Spindle start in a clockwise direction
M04 Spindle start in counterclockwise direction
M05 Spindle stop
M06 Tool change
M30 End of the program with variable reset
ANALYSIS OF SOME
OF THE FUNCTIONS G

G00 They are the displacements according to the safety plan (Clearance Height)
POSITIONING at the maximum speed of the machine. This plane is defined by a
FAST enZque ensures that the tool will be able to move without crashing.
with an obstacle. Movements cannot be programmed G00
interpolated in 2 or more planes. Normally, it is programmed first the
exit in Z (e.g. to the security plan) and then, in another block, the
repositioning in XY. For this block, the machine will first search
the cotaX and then the
Y. That is to say, it will not interpolate. Although this mode is the most common,
It can vary depending on the different brands of numerical control.
The function G00 is modal and incompatible with G01, G02, G03, and G33.
In some controls, G00 does not override the last programmed F, in others it does.
so it needs to be reprogrammed after the execution of an G00.

G01 They can be movements with simultaneous variation in the 3 axes. This
INTERPOLATION it means that they can be spatial trajectories not parallel to any of
LINEAR the axes. The CNC will calculate the relative speeds according to each of the
axes, so that the result of the combination is a trajectory
rectilinear. ElG01 is executed as programmed, although this can be
then varied during the execution of the program. NormallyFes
modal.G01 cannot be included in the same block with G00, G02,
G03yG33.

G02 Y G03 Their trajectories follow arcs of circles. They can only be executed in
INTERPOLATIONS a determined plane: XY, XZoYZ. In this case, the CNC must not only
CIRCULARS calculate the relative speeds of each axis as well as the acceleration
and deceleration of the movements to achieve a circular trajectory.
The way to program it is as follows (for plane XY):

N G02(G03) X+/-4.3 Y+/-4.3 I+/-4.3 J+/-4.3 F

They define the center of the arc according to the axes X and Y, respectively.
Normally the incremental IyJson values regarding the point of
start of the circular trajectory (that is, the pair of coordinates X and Y of the block
previous). However, this may vary depending on the brand of the CNC. In
Some CNC values of IyJ must be programmed in absolute.
In CNCs that define center in incremental, a can be programmed
G02/G03 including a G06 in the block. The values I J must
always include them even if they are equal to 0. Normally the modalFes
for these functions. A G02/G03 can also be programmed.
next form:

N G02(G03) X+/-4.3 Y+/-4.3 R+/-4.3 F

In this case, there is no definition of the arc radius.


circumference. This mode has the following limitations: it cannot be
program complete circles; if the arc is less than 180°R
it will have a positive sign (+) and if it is greater, it will have a negative sign (-).

G05 When a G05 is included in a block, the CNC begins execution.


ARISTA MATADA of the next block during the slowdown period of the block
previous. The result is a splice of trajectories that produce a
rounded off the inflections of the trajectory. The radius of these
rounding is proportional to F. This function is modal.
G07 This function determines that a block does not start until the quotas
LIVING ARISTO the previous block have not been reached. In this case, they occur
live inflections. This function is modal.

G08 It allows you to program an arctangent to a previous trajectory without applying


TRAJECTORY G02/G03. It is not modal. It does not allow complete circles.
TANGENT CIRCLE
TO THE PREVIOUS N10 G01 X30 Y20
N20 G08 X50 Y40
N30 G08 X60 Y50
N40 G01 X90

G09 Allows you to program an arc by defining the endpoint and a point.
TRAJECTORY intermediate. The starting point is defined by the previous block. It is not
DEFINED CIRCULAR modal. Does not allow complete circles.
FOR 3 POINTS
N10 G01 X10 Y10
N20 G09 X90 Y30 I40 J40

The midpoint is programmed using IyJ.


G10, G11, G12 and G13 G10 Mirror image cancellation.
MIRROR IMAGES G11Mirror according to X axis.
G12Mirror according to the Y axis.
G13Mirror according to Z axis.

These types of functions are aids that simplify CNC programming.


In this case, they allow obtaining symmetries without having to program all the
movements.
The Mirror Image functions must be understood as the execution of
an earlier block with the sign of the corresponding limit for the axis
selected, changed.

N10 G01 X-40 Y20


N20 X-20 Y40
N30 X0
N40 G11
N50 G25 N10.30
N60 G10
The first three blocks define a polygon. N40 calls to execute
a Mirror Image changing the coordinates in X. N50 indicates that it
they will mirror the blocks from N10 to N30 inclusive, G25 is a
specific call for this type of instruction. In N60, G10 cancels the
mirror image.

G31 and G32 G31 allows you to save the coordinate origin that is being used for
SAVE AND establish a new origin with G53/G59. If necessary
RECOVER ORIGIN return to the initial origin, an G32 will be programmed. This function retrieves the
OF COORDINATES data saved with unG31.
G36 Allows for controlled rounding of trajectory inflections without
ROUNDING need to program circular interpolations. It must be programmed in
CONTROLLED BY the section of the trajectory whose end you want to round. The radius of the
ARISTAS rounding must be positive.

N10 G36 R20 G01 X80 Y50


N20 Y0

G36 is not modal.

G37 This function allows for tangentially connecting the defined trajectory in
ENTRY the following block. It is used to prevent the tool from leaving marks
TANGENTIAL undesirables in the part. It is the typical case of surface machining.
convex (e.g. males) in which the tool attacks laterally to the
material.

N10 G37 R10 G01 X40 Y20


N20 G02 X100 Y20 I30 J0

The resulting trajectory is that of the dotted line. It can only be


to program G37 in G01 in G00.R=2r of the end mill or greater.
G38 Allows to exit tangentially from a trajectory. It is used to avoid
TANGENTIAL EXIT that the tool leaves undesirable marks in the machining of parts
convex

N10 G38 R10 G02 X60 Y20 I30 J0


N20 G01 X100

The resulting trajectory is that of the dashed line. G38 must be programmed.
in the block from which it exits.

G39 This function allows for the joining of two straight paths through a
flourishing third, also straight, without the need to calculate the points of
intersection.

N10 G39 R30 G01 X90 Y30


N20 X20 Y10

R specifies the distance between the beginning and the end of the bevel and the
intersection of the two trajectories.
G40, G41 and G42 G40 Tool Radius Compensation Cancel. G41
COMPENSATION OF Compensation of Radio to the right of the trajectory. G42
RADIOS OF Left trajectory radio compensation.
TOOL
Suppose we want to machine a cube with a side of 100 mm.
a Ø20 strawberry. As the CNC trajectories are defined by the
The "tip" of the tool (its lowest central point) needs to be recalculated.
the trajectory 10 mm. outside of the cube. If this is not done, and if
programming along the lines that define the cube, a form of would be obtained
90 mm on each side. Recalculate the trajectories to obtain a cube.
not be difficult. But doing it for a complex form can be very
complicated.
Applying the Radio Compensation functions, this is not necessary.
recalculation. For this, the tool must be specified at the beginning of
program with the format Txx.pp.
the two-digit number with which a certain tool is
archived (at the moment when the CNC is configured, it can be created
a table of available tools.
yes a correction value of the nominal diameter of the tool. These
Corrections are usually necessary due to wear and tear.
These correction values are also stored in memory.
permanent of the CNC. final dimensions of the piece. They must be included in the previous block
Scheduled a to those who wish to execute with compensation. These functions are
G41/G42 canceled by unG40. This cancellation must be included in the block that
they will be able
to program oneself the define the last compensated trajectory. Only one G40 can be included
trajectories according to the a straight trajectory.

G53 A G59 In certain machining jobs, it can be useful to relocate the origin.
TRANSFERS OF from coordinates to another point of the piece. For example, when one wants
ORIGIN repeat a shape in another(s) place(s). Normally in a single
The program allows up to 7 source changes to be entered. The format of
the application is the following:

N10 G53 X... Y... Z...(a new origin is created)


N10 G53 (the new origin created in the previous block is applied)

These functions are normally used in combination with


G31/G32 (already analyzed).

G72 This function allows you to enlarge or shrink the dimensions of a piece without
FACTOR OF change the program. It can be applied in two ways
ESCALATED
N10 G72 K+/-2.4

This is the factor by which all the quotas will be multiplied. This way
scale the piece according to the three axes.

N10 G72 X+/-2.4 (for example)

This mode will scale the piece according to the factor only on the X axis.
the same way can be scaledI. Normally this function does not
should be applied in programs that apply compensations of
tool.
G73 This function is a programming aid similar to mirroring.
ROTATION OF this case allows reproducing a pre-programmed machining by rotating it
SYSTEM OF regarding the origin of coordinates.
COORDINATES
(from the previous block) X-20 Y0
N10 G03 X-50 I-15 J0
N20 G01 X-20
N30 G73 A-45
N40 G25 N10.20.3

It is the angle of rotation. In the example, it has a negative sign (-) because the
CNC programming takes the direction as positive by default.
counterclockwise, and clockwise as negative. The function G25 calls
repeat to the blocks defined by N, that is, the blocks from 10 to 20. The
The third digit (3) indicates the number of times the rotation will be repeated.
Note that the value of Aes is incremental.
FIXED CYCLES Fixed cycles allow the definition of a series in a single block.
cyclical operations characteristic of a specific machining process. The cycles
The most common fixed ones are those used for drilling and those used for cashiers.

G81 The fixed cycle drilling blocks have the following configuration:
DRILLED
N4 G81 G98/99 X/Y/Z+/-4.3 I+/-4.3 K2.2 N2

G?: Fixed cycle code.


G98: Retract to the reference plane (usually located near the
surface of the piece).
G99: Return to the safety plan (already explained).
X/Y/Z: If working on the XY plane (G17), X and Y define the point where
the first drilling will be done. Define the reference plane beforehand
mentioned. If you work in absolutes, define the distance from zero.
piece. If working in increments, define the distance from the plane.
of security.
I: Define the depth of the drilling. If working in absolutes I
define the distance from the zero piece. If working in incrementals I
define the distance from the reference plane
K: Define the waiting time in the drilling fluid before
start the countdown. Values in seconds.
N: Define the number of times the Fixed Cycle will repeat. If not,
Program, the cycle executes. Repetitions greater than 1 only have
it makes sense if worked on incrementally.
G83 This type of fixed cycle is applied when, due to the depth of the
DRILLING drilling, it is necessary to lift the drill bit cyclically so that it
DEEP download the shavings.
The fixed cycle blocks for deep drilling have two
possible conformations.
The first one is:

N4 G83 G98/99 X/Y/Z+/-4.3 I+/-4.3 J2 N2

The difference with G81 is that it defines each depth of penetration in


Incremental. Defines the number of penetrations according to the increment.
I.
The second is:

N4 G83 G98/99 X/Y/Z+/-4.3 I+/-4.3 B4.3 C4.3 D4.3 H4.3 J2 K2.2

Total machining depth. In absolute terms, with respect to zero


part. In increments, regarding the reference plane.
Incremental deepening for each step (positive value).
Distance from the previous deepening to lower in G00.D:
Distance between the reference plane and the surface of the part.
H: Retract distance in G00. If not specified, retracts to PR.
J: How many penetrations are there before going back to PR?
K: Time in seconds before a reversal begins.

FIXED CYCLES OF Operations for emptying molds are referred to as Cashiers (Pockets).
cashiers closed. They can be Rectangular Drawers or Circular Drawers. In these
operations the tool not only goes around the outline of the figure but also
that also carries out all the necessary movements to withdraw the
material included within the figure.

RECTANGULAR
G87
CASHIER
The format of X/Y/Z: Quotas of the cashier's center.
block of this I: Total depth of the drawer. In absolute terms, relative to the zero part.
function is the In increments, with respect to the reference plane.
next Distance in X from the center to the edge of the cashier.
Distance in Y from the center to the edge of the cashier.
N4 G87 X/Y/Z+/- Incremental deepening per pass.
4.3 I+/-4.3 J+/- C: Lateral increment (Step-over).
4.3 K+/-4.3 B4.3 D: Distance between the PR and the surface of the piece.
C4.3 D4.3 N2 N:Number of times the cycle will be repeated. Only in G91.

G88 It has the same format as the Rectangular Cashier. It differs in that J
CIRCULAR CASHIER define the radius of the Cashier and the valueK is not included.
D: Distance between the PR and the surface of the piece.
N:Number of times the cycle will repeat. Only in G91.
OTHER FUNCTIONS As can be seen in the complete list of functions of
CNC programming, there are many others that have not been explained in
this note. These correspond to execution operations
circumstantial and are rarely applied. The explained functions are the
of more frequent use.

FUNCTIONS CAM systems apply only 4 functions: G00, G01, G02 and
USED BY They can eventually generate Fixed Drilling, Tapping Cycles,
THE CAM SYSTEMS etc., and generate programs with Tool Offsets. From
made a CAM is a basic but extremely fast programmer.
Much faster than manual programming. If the 100 are analyzed
functions of the list, it can be concluded that the vast majority have the
function to alleviate the task of manual programming. The CAM does not apply
these aids.
Although this course concludes with the learning of system operations.
CAM is considered that, to achieve the proposed objectives, the student
must have a minimum base of programming knowledge
manual.

You might also like