G-code

INFORMATION

For a detailed description, refer to the ISO 6983‑1 standard.

G-code has established itself as a common language for programming machine tools (e.g. CNC machines). It can be used to define the course of paths and switch path-dependent actions using imperative programming. In addition to conventional programming, many CAD programs also allow the G-code to be generated from existing workpiece data.

Import

G-code cannot be executed directly by the MOVI-C® CONTROLLER. However, since the SEW-EURODRIVE Robot Language supported by the software module is based on G-code, the G-code can be converted into the SEW-EURODRIVE Robot Language. The RobotMonitor handles importing, conversion, and transfer of the G-code file, and it can be manually executed. For further information, refer to chapter Manual G-code import. Alternatively, an automatic import of the G-code is possible. For further information, refer to chapter Automatic G-code import.

Before the import process, the programmer can decide on which program slot of the interpreter the converted G-code is to be saved. Subsequent editing or teaching of additional motion commands is possible at any time in the RobotMonitor. RobotMonitor supports G-code programs that have been created according to ISO 6983-1 and in Siemens' Sinumerik dialect or Beckhoff's TwinCAT dialect. A G-code program can control exactly one robot instance.

Syntax

According to ISO 6983‑1, the structure of the G-code is defined by blocks, which consist of one or more words. A block is ended by a line break.

Words consist of an address letter (e.g. X, Y, Z, G, M, N, ...) and a key number (e.g. G4) or an expression (e.g. X200, F=1000). Each word is assigned a function, whereby the address letters G for path conditions, M for additional functions and N for the block number have a special significance in the G-code program. Depending on the function to be executed, one or more address letters must be present in a block.

The address letters define the function associated with a letter. The path conditions define the operating mode of a machine or control, such as interpolation mode or path control mode. The additional functions are switching functions that start or stop an action of the machine or controller, such as cooling water on/off. The block numbers determine which position a G-code block is assigned to in the program. In modern numerical controls, the block numbers usually no longer have the function of determining the execution sequence and are used more for the clarity and structuring of a G-code program.

The interpretation of address letters especially path conditions and additional functions may change depending on the G-code dialect used.

Comments are introduced by a character defined for each G-code dialect and are usually placed at the end of a block.

Examples of typical block structures:

N10 G1 X200 Y300 ; comment

N20 X300 Y300 F=1000 ; comment