CNC Programming Languages
CNC Programming Languages
The bit, or binary digit, is the basic unit of data which can be interpreted by the digital
computer. It is easily adaptable to the binary number system because there are only two
possible conditions which can take on the values of 0 or I. The meaning of successive digits in
the binary system is based on the number 2 raised to successive powers. The first digit is 20,
the second is 21, the third is 22, and so forth.
The two numbers, 0 or 1, in successive bit positions indicate either the absence or
presence of the value. Table 2.4 shows how the binary number system can be used
to represent numbers in the more familiar decimal system.
The conversion from binary to decimal systems makes use of the following type of
computation. We will illustrate the conversion for the decimal number 5:
1 x 20 + 0 X 21 + 1 X 22 + 0 X 23 = lXl+0x2+1X4+0x8 = 5
The preceding section demonstrated how the binary number system could be used to
represent any decimal number, alphabetic letter, or other common symbol. Data
and instructions are communicated to the computer in the form of binary words. In
executing a program, the computer interprets the configuration of bits as an instruction
to perform electronic operations such as add, subtract, load into memory, and
so forth. The sequence of these binary-coded instructions define the set of calculations
and data manipulations by which the computer executes the program.
The binary-coded instructions that computers can understand are called
machine language. Unfortunately, binary-coded instructions and data are very difficult
for human programmers to read or write. Also, different machines use different
machine languages. To facilitate the task of computer progranuning,
higher-level languages are available which can be learned with relative ease by
human beings. In all there are three levels of computer progranuning languages:
1. Machine language
2. Assembly language
3. Procedure-oriented (high-level) languages
FIGURE 2.6
High-level language
Assembly languages are machine oriented.
High-level languages, by contrast, are procedure oriented. They are to a large extent
independent of the computer on which they are used. This means that a program written on
one computer can be run on a different computer without significant modifications to the
program.
High-level languages consist of English-like statements and traditional mathematical
symbols. Each high-level statement is equivalent to many instructions in machine
language. To illustrate, Figures 2.5 and 2.6 present two lists of instructions, written in
machine language and assembly language, respectively.
Both sets of programming instructions accomplish the same task, which is to transfer the
contents of one memory location into another memory location. This can be accomplished
in FORTRAN (a high-level language) with two lines of instruction as shown in Figure 2.7.
The advantage of high-level languages is that it is not necessary for the programmer
to be familiar with machine language. The program is written as an English-like algorithm to
solve a problem. Like assembler languages, high-level languages must also be converted
into machine code. This is accomplished by a special program called a compiler. The
compiler takes high-Ievel program, and converts it into a lower-level code, such as the
machine language. If there are any statement errors in the program (e.g., misspelled
words), error messages are printed in a special program listing by the compiler.
There are many different high-level languages. Table 2.6 describes several of
the common high-level languages used for business and engineering' applications.
APT language, is a high-level language used to program automatic machine tools.
TABLE 2.6 Some Common High-Level Computer Programming Languages for Business and
Engineering Applications
FORTRAN
FORTRAN stands for FORmula TRANslation. It is one of the oldest and most popular of the
high-level languages. FORTRAN was developed in the mid-1950s for scientists, engineers,
and mathematicians, but it has also been used for some business processing applications.
FORTRAN consists principally of mathematical notation. Data items and variables are given
names, and these names are used as symbols in the program to be operated on by
mathematical and logical operators. Other instructions are also allowed in FORTRAN, for
example to form lists and tables, or to call various input/output functions, such a; printing
or accepting data from a file. FORTRAN is quite efficient for mathematical computations but
is not very efficient for applications such as file processing or document production.
COBOL
COBOL (COmmon Business-Oriented Language) was developed around 1959. It has
become a major computer language for business data processing applications. COBOL can
be used for numeric and alphabetic data processing and in data-file applications
COBOL is similar to FORTRAN in the sense that it uses English-like statements. Indeed,
COBOL statements are called sentences. A series of sentences is termed a paragraph.
COBOL's vocabulary tends to make it self-documenting. It is very easy to read a program and
understand what operations are taking place. However, the language presumes an
understanding of information processing principles. Therefore, it is not intended for the
inexperienced programmer. While COBOL is suitable for a file environment, it is not capable
of the complex mathematical calculations that can be accomplished with FORTRAN.
BASIC
BASIC (Beginners's AIl-Purpose Instruction Code) was developed in the 1960s at
Dartmouth
College to be an easy-to-learn programming language. Learning the "basics" of this
language requires only a few hours.
BASIC was developed as an interactive language, where the user appears to be interacting
directly with the computer rather than through punched cards or other off-line I/O format,
Each line of code is interpreted as it is typed, so that the programmer is informed of many
types of program errors immediately upon their entry. Programs are usually entered and
executed by means of CRT terminals in a time-sharing network. BASIC is used heavily in the
field of microcomputers, and is being used increasingly as an interactive teaching tool in
schools.
APL
APL (A Programming Language) was designed for interactive problem solving. A significant
feature is that it permits users to define complex algorithms efficiently. The primary data
structure in APL is in the form of arrays and an extensive set of array operators is
provided.
RPG
RPG (Report Program Generator) is a language designed for writing programs that
produce printed reports as output. It is widely used in business environments, where it
updates data flies, performs analysis of data, and generates documents and reports. .
RPG is relatively easy to learn and programs can often be written in a short time, making it
suitable for the needs of upper-level managers, who often desire to have immediate
access to information in a given format. It is most appropriate for simple, straightforward
problems which do not require complicated logic or use of data files. It is a common
language on minicomputers because of its relatively modest memory requirements.
PL/1
PL/1 is a general-purpose programming language designed to be a compromise between
FORTRAN and business languages, each of which has obvious strong and weak points. It
uses standard arithmetic operators, similar to FORTRAN. PL/1 is a flexible language which
meets the needs of a wide variety of programmers. Default conditions assumed by the
compiler when explicit alternative statements are omitted allow many functions to be
perfonned in fewer steps than in FORTRAN or other languages.
PASCAL
Pascal is a high-level language developed in the early 1970S and named for the famous
French mathematician Blaise Pascal. The objectives in developing the language were to
facilitate the teaching of computer programming as a systematic discipline of knowledge
and to accomplish programming implementations which are reliable and efficient on
modern computers.