Documents

G CODE Manual Basic

Description
CNCinst
Categories
Published
of 13
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Related Documents
Share
Transcript
  G Code Basics RS274NGC G-CODE PROGRAMMING BASICS Contents   Introduction   Blocks   Numbers   Words   Line Numbering Words   Axis Words   G Preparatory Words   M Miscelaneous Words   F, S, T, Control Words   Modal Codes   CreditsIntroduction  RS-274D is the recommended standard for numerically controlled machines developed by the Electronic Industry Association in the early 1960's. The RS-274D revision was approved in February, 1980. These standards provide a basis for the writing of numeric control programs. There are a number of historical sidelights to this standard, many having to do with the srcinal use of punched paper tape as the only data interchange medium. The 64-character EIA-244 paper tape standard is now (thankfully) obsolete, and ASCII character bit patterns are now the standard representation. This old tape standard had specific characters used for 'searching' for specific lines (program blocks) on the tape, 'rewinding' the tape, etc. Ocasionally this obsolete language is still used when referring to some cnc control tasks. The full NIST Enhanced Machine Controller is nc programmed using a variant of the RS274D language to control motion and I/O. This variant is called RS276NGC because it was developed for the Next Generation Controller, a project of the National Center for Manufacturing Science. The version of RS274 used by EMC adheres closely to the publications of the NCMS wherever those publications produce an unambiguous set. In some cases reference to other implementations of RS274 had to be made by NIST. (back to contents)  http://www.linuxcnc.org/handbook/gcode/g-code.html (1 of 13) [6.3.2007 16:54:42]  G Code Basics Blocks  The basic unit of the nc program is the 'block', which is seen in printed form as a 'line' of text. Each block can contain one or more 'words', which consist of a letter, describing a setting to be made, or a function to be performed, followed by a numeric field, supplying a value to that function. A permissible block of input is currently restricted to a maximum of 256 characters. The following order is required for the construction of a block. 1. an optional block delete character, which is a slash / . 2. an optional line number. 3. any number of segments, where a segment is a word or a comment. 4. an end of line character.The interpreter allows words starting with any letter except N (which denotes a line number and must be first) to occur in any order. Execution of the block will be the same regardless of the order. An example of a program block would be  /N0001 G0 X123.05This block is constructed using three words, N0001, G0, and X123.05. The meanings of each of these words is described in detail below. In essence, the n word numbers the line, the g0 word tells the machine to get to its destination as quickly as it can, and the final position of the x axis is to be 123.05. Since it is constructed with a preceeding slash, this block could be deleted during a run if optional block delete were activated. There are some general considerations when writing nc code for the EMC: ●   The interpreter allows spaces and tabs anywhere within a block of code. The result of the interpretation of a block will be the same as it would if any white spaces were not there. This makes some strange-looking input legal. The line g0x +0. 12 34y 7 is equivalent to g0 x+0.1234 y7 , for example. ●   Blank lines are allowed in the input by the interpreter. They are ignored. ●   The interpreter also assumes input is case insensitive. Any letter may be in upper or lower case without changing the meaning of a line.Whenever you write nc programs, you would do well to be considerate of others who may have to read that code, even though the interpreter itself does not care about white space and case. Unless your are really up against the 256 digit block size limit, white space between words and the absense of it within words makes a block much easier to understand. There are a number of limitations about the number or types of words that can be strung together into a block. The interpreter uses the following rules: ●   A line may have zero to four G words. ●   Two G words from the same modal group may not appear on the same line. ●   A line may have zero to four M words. http://www.linuxcnc.org/handbook/gcode/g-code.html (2 of 13) [6.3.2007 16:54:42]  G Code Basics ●   Two M words from the same modal group may not appear on the same line. ●   For all other legal letters, a line may have only one word beginning with that letter.Don't worry to much about modal codes or the order of execution of the words within a block of nc program just yet. These will become clear as you work your way through the definitions of the permissible words listed in the next unit. For now it is enough to remember that a program block is more than the words that are written in it. Various words can be combined to specify multi-axis moves, or perform special functions. While a block of code has a specific order of execution, it must be considered to be a single command. All of the words within a block combine to produce a single set of actions which may be very different from the actions assigned to the same words were they placed in separate blocks. A simple example using axis words should illustrate this point. n1 x6 - moves from the current x location to x6 n2 y3 - moves from current y location to y3 at x6 n3 z2 - moves from current z location to z2 at x6 and y3 n10 x6 y3 z2 - moves on a single line from current x, y, z to x6 y3 z2The final position of the first three blocks (n1-n3) and the (n10) block are the same. The first set of blocks might be executed in sequence to move the tool around an obstacle while the path of the tool for the combined block (n10) might run it into the part or the fixture. To make the specification of an allowable line of code precise, NIST defined it in a production language (Wirth Syntax Notation). These definitions appear as Table *** at the end of this chapter. In order that the definition in the appendix not be unwieldy, many constraints imposed by the interpreter are omitted from that appendix. The list of error messages elsewhere in the Handbook indicates all of the additional constraints. (back to contents)  Numbers  Since every nc word is composed of a letter and a value. Before we begin a serious discussion of the meaning of nc programming words we need to consider the meaning of value within the interpreter. A real_value is some collection of characters that can be processed to come up with a number. A real_value may be an explicit number (such as 341 or -0.8807), a parameter value, an expression, or a unary operation value. In this chapter all examples will use explicit numbers. Expressions and unary operations are treated in the computation chapter. The use of parameter values or variables are a described in detail in the Using Variables chapter. EMC uses the following rules regarding numbers. In these rules a digit is a single character between 0 and 9. A number consists of : http://www.linuxcnc.org/handbook/gcode/g-code.html (3 of 13) [6.3.2007 16:54:42]  G Code Basics ●   an optional plus or minus sign, followed by ●   zero to many digits, followed, possibly, by ●   one decimal point, followed by ●   zero to many digits provided that there is at least one digit somewhere in the number.There are two kinds of numbers: integers and decimals. An integer does not have a decimal point in it; a decimal does. Some additional rules about the meaning of numbers are that: ●   Numbers may have any number of digits, subject to the limitation on line length. ●   A non-zero number with no sign as the first character is assumed to be positive. ●   Initial and trailing zeros are allowed but not required. ●   A number with initial or trailing zeros will have the same value as if the extra zeros were not there.Numbers used for specific purposes in RS274/NGC are often restricted to some finite set of values or to some range of values. In many uses, decimal numbers must be close to integers; this includes the values of indexes (for parameters and changer slot numbers, for example). In the interpreter, a decimal number which is supposed be close to an integer is considered close enough if it is within 0.0001 of an integer. (back to contents)  Words  An nc program word is an acceptable letter followed by a real_value. Table 2 shows the current list of words that the EMC interpreter recognizes. The meanings of many of these words are listed in detail below. Some are included in and in the chapter on tool radius compensation and the chapter on canned cycles. Table 2 Words acceptable to the EMC interpreter http://www.linuxcnc.org/handbook/gcode/g-code.html (4 of 13) [6.3.2007 16:54:42]
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks