18.04.2021

G codes for cnc router. M-codes. What are G-codes


The control program for the CNC machine consists of a sequence of blocks and usually begins with the program start character (%) and ends with M02 or M30.

Each program block represents one machining step and (depending on the CNC) may start with a block number (N1...N10, etc.) and end with the end of block (;) character.

The NC block consists of statements in the form of words (G91, M30, X10. etc.). A word consists of a character (address) and a digit representing an arithmetic value.

Addresses X, Y, Z, U, V, W, P, Q, R, A, B, C, D, E are dimensional movements, used to designate the coordinate axes along which movements are carried out.

Words that describe movement may have a (+) or (-) sign. If there is no sign, the displacement is considered positive.

Addresses I, J, K mean interpolation parameters.

G - preparatory function.

M - auxiliary function.

S - function of the main movement.

F is the feed function.

T, D, H - tool functions.

Symbols may take on different meanings depending on the specific CNC.

Preparatory functions (G codes)

G-code is executed for execution in machine control programs

The codes, denoted by the letter M, are called auxiliary and are designed to control the operating modes of the machine. The M code can stand alone or be in a frame with G codes. Some M codes work in conjunction with other addresses. For example, the M code, which is responsible for the direction of rotation of the spindle, is usually indicated with the address S, which is necessary to set the number of revolutions during rotation. The order in which commands and actions are executed when M and G codes are in a block depends on the CNC model. Some CNC systems allow you to specify only one M code per block.

Table 1 - Basic M codes

Stopping the execution of the control program - M00 and M01. Very often there are situations when it is necessary to temporarily interrupt the execution of the program. For example, to remove chips, check workpiece dimensions, or reposition fasteners.

Codes M00 and M01 temporarily suspend the execution of the part-program or, in other words, pause the production cycle of the machine. When the CNC reads the M00 code, a so-called programmed stop occurs. All axial movements are stopped and resumed only after the machine operator presses the "Cycle Start" key on the panel of the CNC. In this case, the spindle continues to rotate and other functions remain active. If the machine operator presses the Cycle Start key, the program will continue from the block following M00.

N40 M05 / Spindle stop

N50 M00 /Stop execution of part program

N60 M03 S1000 /Spindle engagement 1000 rpm

The M01 code is for selectable stop. It acts similarly to the M00 code, however, it gives the operator a choice - whether or not to interrupt the execution of the control program. On the CNC panel of almost any machine there is a key (or switch) "M01". If this key is pressed, then when reading a block from M01, a stop occurs. If the key is not pressed, then the M01 command is skipped and the execution of the UE is not interrupted.



Spindle rotation control - M03, M04, M05. Auxiliary codes M03 and M04 are designed to control the rotation of the spindle. Code M03 is responsible for forward (clockwise), and M04 - for reverse rotation of the spindle (counterclockwise). The direction of rotation is determined when viewed in the negative direction of the Z-axis (from the spindle side towards the workpiece). When milling, cutting tools must have direct rotation (M03). When withdrawing the tap from a hole, when cutting a left-hand thread, in cycles of automatic tool diameter measurement, reverse rotation of the spindle (M04) may be required. At the end of the part program and before changing the tool, the spindle rotation must be stopped using the M05 command.

Picture 1 - Forward and reverse rotation of the spindle

The S address is used to set the spindle speed. The S is followed by a numerical value expressing the spindle speed in revolutions per minute. Most control systems only accept the integer value S. Usually M03 and S are in the same block.

Coolant supply control - M07, M08, M09. During milling, coolant is supplied to the machining zone to increase tool life, improve surface quality and remove (wash out) chips. CNC machines are equipped with an automatic coolant supply system. This system is controlled by several M codes. Typically, code M08 is used to turn on the coolant supply, and code M09 is used to turn it off. Some machines allow you to supply coolant to the processing zone in various ways. For example, code M08 may cause coolant to be sprayed, and code M07 to spray.

It is customary to turn off the coolant supply before changing the tool and at the end of the machining program. Many modern machines do this automatically when reading code M06 (tool change), codes M30 and M02 (end of program). In addition to program control of the automatic coolant supply system, there is also manual control that allows the machine operator, using certain keys on the CNC panel, to turn on or off the coolant supply if necessary.

Usually to perform automatic shift tool in the program, the following command is indicated:

Address T indicates the number of the tool called (in this case tool #1) and M06 provides the change. Most controls allow any order of data words in a tool change block.

Completion of the program - M30 and M02. At the end of any control program, there must be a code for its completion - M30 or M02. When any of these codes is executed, the machine stops regardless of what function it was performing. The only difference between M30 and M02 is that at the end of the machining program with M30, the current position cursor is moved to the very beginning of the program, and with M02 it remains at the end.

Typically, at the end of a machining program, the work table or tool is moved to a position that makes it easier for the operator to remove the finished part from the machine. This movement is done with the G74 homing code.

In a manufacturing environment where different CNC machines are used, a lot of different software is used, but in most cases, all control software uses the same control code. Software for amateur machines, is also based on a similar code. In everyday life it is called "G-code". V this material presented general information by G-code (G-code)

G-code is a conventional naming language for programming CNC devices (Numeric program control). Created by the Electronic Industries Alliance in the early 1960s. The final revision was approved in February 1980 as the RS274D standard. The ISO Committee approved G-code as ISO 6983-1:1982, the State Committee for Standards of the USSR - as GOST 20999-83. In Soviet technical literature, G-code is referred to as the ISO-7 bit code.

Manufacturers of control systems use G-code as a base subset of the programming language, extending it as they see fit.

A program written using G-code has a rigid structure. All control commands are combined into frames - groups consisting of one or more commands. The block is terminated by a line feed character (FS/LF) and has a number, except for the first block of the program. The first frame contains only one "%" character. The program ends with an M02 or M30 command.

Summary code table

The main, in the standard are called preparatory, language commands begin with the letter G:

  • Moving the working bodies of the equipment at a given speed (linear and circular)
  • Performing typical sequences (such as drilling holes and threads)
  • Controlling tool parameters, coordinate systems, and work planes

Preparatory (basic) teams

Table of basic commands

The codeDescriptionExample
G00 Rapid tool movement (idle) G0 X0 Y0 Z100;
G01 Linear interpolation G01 X0 Y0 Z100 F200;
G02 Clockwise circular interpolation G02 X15 Y15 R5 F200;
G03 Circular interpolation counterclockwise G03 X15 Y15 R5 F200;
G04 Delay by P milliseconds G04 P500;
G10 Set new coordinates for origin G10 X10 Y10 Z10;
G11 Cancel G10 G11;
G15 Cancel G16 G15 G90;
G16 Switching to polar coordinate system G16 G91 X100 Y90;
G20 Inch Mode G90 G20;
G21 Operating mode in metric system G90 G21;
G22 Activate the set limit of movements (The machine will not go beyond their limit). G22 G01 X15 Y25;
G23 Cancel G22 G23 G90 G54;
G28 Return to reference point G28 G91 Z0 Y0;
G30 Z-axis lift to tool change point G30 G91 Z0;
G40 Cancel Tool Size Compensation G1 G40 X0 Y0 F200;
G41 Compensate tool radius left G41 X15 Y15 D1 F100;
G42 Compensate Tool Radius Right G42 X15 Y15 D1 F100;
G43 Compensate tool height positively G43 X15 Y15 Z100 H1 S1000 M3;
G44 Compensate tool height negatively G44 X15 Y15 Z4 H1 S1000 M3;
G53 Switch to machine coordinate system G53 G0 X0 Y0 Z0;
G54-G59 Switch to operator-defined coordinate system G54 G0 X0 Y0 Z100;
G68 Rotate coordinates to the desired angle G68 X0 Y0 R45;
G69 Cancel G68 G69;
G80 Cancel drilling cycles (G81-G84) G80Z100;
G81 Drilling cycle G81 X0 Y0 Z-10 R3 F100;
G82 Dwell cycle G82 X0 Y0 Z-10 R3 P100 F100;
G83 Retract drilling cycle G83 X0 Y0 Z-10 R3 Q8 F100;
G84 Threading cycle
G90 Absolute coordinate system G90 G21;
G91 Relative coordinate system G91 G1 X4 Y5 F100;
G94 F (feed) - in mm/min format. G94 G80 Z100;
G95 F (feed) - in the format mm / rev. G95 G84 X0 Y0 Z-10 R3 F1.411;
G98 Cancel G99 G98 G15 G90;
G99 After each cycle, do not retreat to the “approach point” G99 G91 X10 K4;

Technology code table

Technological commands of the language begin with the letter M. They include actions such as:

  • Change Tool
  • Enable/disable spindle
  • Enable/disable cooling
  • Call/End Subroutine

Auxiliary (technological) commands

The codeDescriptionExample
M00 Suspend the operation of the machine until pressing the "start" button on the control panel, the so-called "technological stop" G0 X0 Y0 Z100 M0;
M01 Pause the machine until the "start" button is pressed if the stop confirmation mode is enabled G0 X0 Y0 Z100 M1;
M02 End of program M02;
M03 Start spindle rotation clockwise M3 S2000;
M04 Start spindle rotation counterclockwise M4 S2000;
M05 Stop spindle rotation M5;
M06 Change Tool M6 T15;
M07 Enable additional cooling M3 S2000 M7;
M08 Turn on main cooling M3 S2000 M8;
M09 Turn off cooling G0 X0 Y0 Z100 M5 M9;
M30 End of information M30;
M98 Subroutine call M98P101;
M99 End of subprogram, return to main program M99;

There is a special language for CNC machines. This language is called ISO 7 bit. The G code system for CNC is a special command for the operation of milling and turning machines with NC, special parameters are set in the commands. CNC programming is taught in technical colleges or in additional education courses.

What is a G-code

The code system for turning is a special group of commands that are recognized by machines with program control functions. The code system was developed by the Electronic Industries Allience in 1960 and finalized in 1980. Since 1982, she began to operate in Russia. The code language is included in the structure of the basics of programming, it is constantly being improved and changed.

What are G-codes

G-code programs are written in text format, each line is called a block. A frame consists of an alphabetic character - this is an address and a digit in which a numerical value is expressed. Codes are basic and auxiliary. On the basis of such a program, a CNC turning and milling machine works.

Group G teams are called preparatory. They set the movement of work items on the machine at a certain speed. The speed can be circular or linear. G-code is also used for hole and thread machining. Another function is to control the parameters and coordinate systems of the equipment.

The main commands of the program are aimed at performing the following functions:

  • G00 - G04 positioning function;
  • G17 - G19 carry out switching of operating parameters;
  • G40 - G44 compensation of length and diameter of various elements of the device;
  • G54 - G59 switching of coordinate systems;
  • G71 - hole machining function;
  • G80 - G84 tapping and drilling function;
  • G90 - G92 switching between absolute and relative coordinate systems.

The symbols are different: M performs auxiliary functions, such a command is necessary to change the tool, call the subroutine and complete it, S is the function of the main movement, F is the feed, T, D, H are the expression of the tool functions.

The meaning of the symbol depends on the type of CNC machine. Programming is carried out on the basis of these codes.

Preparatory Functions

Preparatory functions in the code system are expressed by the symbol G. Each code has a special meaning. All preparatory commands, for example, the choice of the work plane or the choice of the movement speed, are given first in the program. A certain function is encrypted in the code. Parameters are set by numerical values.

Deciphering basic G codes for CNC

Let's move on to consider how the main G codes for PU machines are deciphered.

G00

Sets the speed positioning. It is used when you need to quickly move the cutting tool to a ready state to start work or place it in a safe position. The accelerated version is not used in the process of processing parts, since the speed that develops in this case is very high. This command can be canceled with the command G01, G02, G03.

G01

Represents a linear interpolation. Such a command is necessary to move the tool in a straight line, the speed is set by the symbol F. The function is canceled by codes G00, G02, G03. Command entry example: G01 X20 Y150 F60.

G02

Sets the movement in a clockwise direction, the cutting tool starts to move along an arcuate path, the speed is set by the symbol F. Also, parameters are set in the coordinate plane. The symbols I, J, K are the defining coordinates of the arc in the plane. Cancellation is carried out by codes G00, G01, G03.

G03

This is a counter-clockwise movement along an arc at a given speed.

G04

Set a break at work. pause duration is specified by X or P character. The pause usually lasts about one second.

G17

Specifies a plane. Use the G17 code to select the XY coordinates. Such a function is necessary for rotating movements and the drilling process.

G18

Specifies a plane in XZ coordinates, this plane becomes the working plane in the process of circular interpolation, rotational movements and the drilling process.

G19

Allows you to select the working area in YZ coordinates. This function is necessary for tool movement in circular interpolation and drilling canned cycle.

G20

Allows you to enter data in inches. The function is designed to work with inch indicators.

G21

Allows you to work with metrics. It is necessary when working with data expressed in meters.

G40

Cancels the function automatic correction to the specified tool radius specified by G41 and G42.

G41

Turns on auto-correction for the radius of the tool, which is located to the left of the workpiece relative to the course of its movement. The program also includes function D.

G42

Similar to code G41, it is intended for auto-correction to the radius located to the right of the workpiece. The program is also given with function D.

G43

Required for tool length compensation, corrects tool position and is set together with H tool function.

G52

Specifies local coordinate parameters in addition to the standard parameters.

G53

Allows you to switch to the coordinate system of the working machine.

G54 - G59

Carry out a given offset of the work item relative to the coordinate parameters of the machine. Using the codes G54, G55, G56, G57, G58, G59, you can determine in which coordinate system the work will be performed. By changing the codes, the programmer is able to process a variety of details.

If any coordinate system has been specified with codes G54 to G59, it will remain in effect until it is canceled and other parameters are entered.

G64

This is a cutting mode, and other functions are automatically cancelled.

G68

The rotation of coordinates is set, the command allows you to shift the coordinate system at a certain angle. The rotation plane, center and angle of rotation are specified by G17, G18, G19, R commands. G69 command cancels this function.

G71

Allows you to make holes in products.

G73

This is a high speed hole drilling function.

G74

Used for cutting left hand threads.

G81, G82, G83

Used for the drilling cycle: standard, dwell and intermittent.

G85 - G87

Allows different boring cycles.

G92

Allows you to set absolute position accumulators.

G97

Sets the parameters of revolutions produced in one minute.

All codes interact with each other and form a separate group. In the program system, one function is replaced by another. An example of a code program can be found on the Internet. The code table must be in view during programming.

Requirements for writing a program

Programs that are written for a CNC machine based on the use of ji codes have a certain very clear structure, which consists of several commands. All commands for working with the machine are combined into groups - frames. The end of one block is marked with the symbol CR/LF, the program ends with the auxiliary code M02 or M30.

If you need to make a comment to the program, then it is placed in parentheses. For example, (move to the milling start point). The comment can be right after the code, but you can also put it on a separate line.

The same command can be repeated multiple times, a given number of times in a certain sequence. The program is written with the help of main and auxiliary functions. It is read by turning and milling machines.

The generation of codes for working at the machine in production is done by special programs. At each enterprise, such a system operates smoothly and is controlled by the operator. If necessary, any program can be generated independently using special software that can be downloaded from the Internet.

No special knowledge is required for this, it is enough to have an idea about the Cartesian coordinate system, to know the physical quantities and definitions from the geometry course. As an example, you can use a ready-made program. To work, you will need tables with decoding codes.

To create a code, you need to have the following knowledge:

  • introduction of geometric parameters and dimensions of the workpiece;
  • know the parameters of the tools and devices with which the work is carried out;
  • the thickness of the layer to be removed;
  • insertion depth of the slitting tool.

In practice, such actions are easy to perform. In order to understand how the system works, you can see an example of recording commands, you will also need an auxiliary table with codes.

There are special services that allow you to create programs for machine tools online, they can be generated on finished example. No additional software needs to be installed on the computer. All you need is internet access. When programming, special care is required, if you make a mistake in maintaining a numerical reading, you can damage the part or break the machines. Programs created in this way can be used on turning, milling, plasma machines and processing a wide variety of materials.

In a manufacturing environment where different CNC machines are used, a lot of different software is used, but in most cases, all control software uses the same control code. Software for amateur machines is also based on a similar code. In everyday life it is called " G-the code". This material provides general information on the G-code (G-code).

G-code is a conventional naming language for programming CNC devices (Computer Numerical Control). Created by the Electronic Industries Alliance in the early 1960s. The final revision was approved in February 1980 as the RS274D standard. The ISO Committee approved the G-code as ISO 6983-1:1982, the USSR State Committee for Standards - as GOST 20999-83. In Soviet technical literature, G-code is referred to as the ISO-7 bit code.

Manufacturers of control systems use G-code as a base subset of the programming language, extending it as they see fit.

A program written using G-code has a rigid structure. All control commands are combined into frames - groups consisting of one or more commands. The block is terminated by a line feed character (FS/LF) and has a number, except for the first block of the program. The first frame contains only one character "%". The program ends with an M02 or M30 command.

The main (in the standard called preparatory) commands of the language begin with the letter G:

  • movement of the working bodies of the equipment at a given speed (linear and circular;
  • execution of typical sequences (such as the processing of holes and threads);
  • control of tool parameters, coordinate systems, and work planes.

Summary code table:

Table of basic commands:

The code Description Example
G00 Rapid tool movement (idle) G0 X0 Y0 Z100;
G01 Linear interpolation G01 X0 Y0 Z100 F200;
G02 Circular interpolation of the hour hand G02 X15 Y15 R5 F200;
G03 Circular interpolation counterclockwise G03 X15 Y15 R5 F200;
G04 Delay by P milliseconds G04 P500;
G10 Set new coordinates for origin G10 X10 Y10 Z10;
G11 Cancel G10G11;
G15 Cancel G16G15 G90;
G16 Switching to polar coordinate system G16 G91 X100 Y90;
G20 Inch Mode G90 G20;
G21 Operating mode in metric system G90 G21;
G22 Activate the set limit of movements (The machine will not go beyond their limit). G22 G01 X15 Y25;
G23 Cancel G22G23 G90 G54;
G28 Return to reference point G28 G91 Z0 Y0;
G30 Z-axis lift to tool change point G30 G91 Z0;
G40 Cancel Tool Size Compensation G1 G40 X0 Y0 F200;
G41 Compensate tool radius left G41 X15 Y15 D1 F100;
G42 Compensate Tool Radius Right G42 X15 Y15 D1 F100;
G43 Compensate tool height positively G43 X15 Y15 Z100 H1 S1000 M3;
G44 Compensate tool height negatively G44 X15 Y15 Z4 H1 S1000 M3;
G53 Switch to machine coordinate system G53 G0 X0 Y0 Z0;
G54-G59 Switch to operator-defined coordinate system G54 G0 X0 Y0 Z100;
G68 Rotate coordinates to the desired angle G68 X0 Y0 R45;
G69 Cancel G68G69;
G80 Cancellation of drilling cycles (G81-G84)G80 Z100;
G81 Drilling cycle G81 X0 Y0 Z-10 R3 F100;
G82 Dwell cycle G82 X0 Y0 Z-10 R3 P100 F100;
G83 Waste drilling cycle G83 X0 Y0 Z-10 R3 Q8 F100;
G84 Threading cycle
G90 Absolute coordinate system G90 G21;
G91 Relative coordinate system G91 G1 X4 Y5 F100;
G94 F (feed) - in mm/min format. G94 G80 Z100;
G95 F (feed) - in the format mm / rev. G95 G84 X0 Y0 Z-10 R3 F1.411;
G98 Cancel G99G98 G15 G90;
G99 After each cycle, do not retreat to the “approach point” G99 G91 X10 K4;

Technology code table:

Technological commands of the language begin with the letter M. They include actions such as:

  • Change Tool
  • Enable/disable spindle
  • Enable/disable cooling
  • Call/End Subroutine

Auxiliary (technological) commands:

The code Description Example
M00 Suspend the operation of the machine until pressing the "start" button on the control panel, the so-called "technological stop" G0 X0 Y0 Z100 M0;
M01 Pause the machine until the "start" button is pressed if the stop confirmation mode is enabled G0 X0 Y0 Z100 M1;
M02 End of program M02;
M03 Start spindle rotation clockwise M3 S2000;
M04 Start spindle rotation counterclockwise M4 S2000;
M05 Stop spindle rotation M5;
M06 Change Tool M6 T15;
M07 Enable additional cooling M3 S2000 M7;
M08 Turn on main cooling M3 S2000 M8;
M09 Turn off cooling G0 X0 Y0 Z100 M5 M9;
M30 End of information M30;
M98 Subroutine call M98P101;
M99 End of subprogram, return to main program M99;

Command parameters are specified in Latin letters:

Constant code Description Example
X Trajectory point X coordinate G0 X0 Y0 Z100
Y Trajectory point Y coordinate G0 X0 Y0 Z100
Z Trajectory point Z coordinate G0 X0 Y0 Z100
F Cutting feed speed G1 G91 X10 F100
S Spindle speed S3000 M3
R Radius or canned cycle parameter G1 G91 X12.5 R12.5 or G81 R1 0 R2 -10 F50
D Selected Tool Offset Parameter M06 T1 D1
P Delay amount or number of subroutine calls M04 P101 or G82 R3 Z-10 P1000 F50
I,J,K Arc parameters for circular interpolation G03 X10 Y10 I0 J0 F10
L Subroutine call with given label L12 P3

2022
maccase.ru - Android. Brands. Iron. news