204 J. Ramón Alique and R. Haber
The following observations refer only to the new properties of advanced CNCs,
as it is to be supposed that the reader has a good knowledge of classic manual pro-
gramming. Afterwards, the discussion will turn briefly to the automatic program-
ming languages currently used in CAD/CAM (computer-aided design/computer-
aided manufacturing) systems.
A CNC program consists of a set of blocks or instructions that, when properly
organised in subroutines or in the program body, provide the CNC with all the
data required to machine a particular part. The CNC program may consist of
several local subroutines, which are defined at the beginning of the program,
along with the main body of the program. The body of the program contains
a header (to indicate the start of the program), several program blocks (which
contain the movements, operations, etc.) and an end-of-program instruction. An
auxiliary M02/M30 function is used for the end-of-program instruction (Fagor
®
CNC 8070).
A subroutine is a set of blocks that may be called upon several times from the
main program or from another subroutine. Subroutines can be either global or
local. A global subroutine is stored in the CNC memory as an independent pro-
gram. A local subroutine is defined as part of a program and is only called upon
from the program where it has been defined. In modern CNCs, the blocks com-
prising the subroutines or the program body may be defined using ISO code com-
mands or high-level language. Each individual block must be written in a single
language, though the program may combine blocks written in both languages.
The high-level programming language allows the operator to use control com-
mands like $IF, $GOTO, etc. With both types of language, the operator can use
constants, mathematical parameters, variables and mathematical expressions.
Programming in ISO code still involves the use of typical N, G, F, S, T, D, M, etc.
addresses for each instruction. All of today’s controllers have a look-ahead func-
tion that allows the machine to read several blocks ahead of the one currently in
operation, to improve calculation of the forthcoming trajectory.
In contrast to their older counterparts, the latest CNCs incorporate logical and
mathematical operations and functions. An operator can program all kinds of
mathematical operations, make comparisons (e.g., greater than or equal to), per-
form binary operations (e.g., exclusive OR), use logic operators (e.g., logic AND),
Boolean constants, trigonometric functions (e.g., arctangent), mathematical func-
tions (e.g., Neperian logarithm) and other functions, such as “return the integer”
[4].
Modern controllers also incorporate functions such as acceleration control.
There is a manufacturer-defined nominal acceleration, a
0,
and an acceleration a
p
,
which is the acceleration to be applied according to the operator. To do so, G func-
tions of the following kind are used:
G130 percentage of acceleration to be applied per axis.
G131 percentage of acceleration for both axes.
Thus, the block:
G130 X50Y20