beautypg.com

Language overview – Smithy CNC Mills User Manual

Page 6

background image

SmithyCNC Programmer’s Reference Manual:Language Overview

SmithyCNC Programmer’s Reference Manual: Language Overview

1-2

LANGUAGE OVERVIEW

The RS274/NGC, the program language for numerically controlled machines, is

based on lines of code. Each line (also called a "block") may include commands

to a machining center to do several different things. Lines of code may be col-

lected in a file to make a program or run a block at a time in MDI mode.

A typical line of code consists of an optional line number at the beginning fol-

lowed by one or more "words." A word consists of a letter followed by a number

(or something that evaluates to a number). A word may either give a command

or provide an argument to a command. For example, "G1 X3" is a valid line of

code with two words. "G1" is a command meaning "move in a straight line at

the programmed feed rate", and "X3" provides an argument value (the value of

X should be 3 at the end of the move). Most RS274/NGC commands start with

either G or M (for General and Miscellaneous). The words for these commands

are called "G codes" and "M codes."

The RS274/NGC language does not specify a special code for the start of a pro-

gram. When the “Interpreter”, however, deals with files it expects certain pro-

gram end codes. These codes include M2, M30, or M60. Whenever the

Interpreter encounters one of these codes it assumes that the current line is the

last line of the program. Lines of a file that occur after the end of a program

code are not to be executed. The interpreter does not even read them.

A file may also be demarcated with percents in the following way. The first non-

blank line of a file may contain nothing but a percent sign, "%", possibly

surrounded by white space, and later in the file (normally at the end of the file)

there may be a similar line. Demarcating a file with percents is optional if the

file has an M2 or M30 at the end, but is required if not. An error will be sig-

nalled if a file has a percent line at the beginning but not at the end. The useful

contents of a file demarcated by percents stop after the second percent line.

Anything after that is ignored.