What is G-code? – Alphacam #33

what is g-code

What is G-code?


The G-code is one of the expressions for the machining program next to the NC program. On a program that we write “manually” or generate using a CAM system, and then run on a CNC machine.

It is a set of instructions that one by one “tells” the CNC machine what to do. These instructions are standardized, they are described in the ISO 6983 standard. However, some manufacturers of control systems for numerically controlled machine tools use their own commands, which may differ from the normalized G-code. In spite of this, in the colloquial and workshop language the term G-code is used for a machining program, not necessarily written in the ISO standard. If someone talks about a g-code, it usually means a machining program for a specific machine.




Open our program that we previously generated. It should open by default in the Alphaedit application. But we will open the machining programs in any text editor.

g-code alphacam

At the beginning, what is green, is information that should not be visible to the machine. The machine controller should ignore this. I write ‘should ignore’, because control systems have different ways to “blank out” part of the program. We can include here information that is needed to run this program. For example, a list of tools, the working time of a specific tool, the total program time and the material. We can, for example, print it and attach it to the documentation.

The machining program starts below the ‘%’ sign, it is not about the program start command, but rather about the beginning of data, information. Then we have the program number after the ‘:’ sign. Next we have a program with numbered lines. Each line is a block. Block numbering is not always necessary. When generating programs using CAM systems, especially programs for 3-axis (or more) simultaneous machining, where there are a lot of lines of code, it is sometimes worth disabling line numbering to make the program lighter – which can affect the speed program reading by the controller.

It has been assumed that it is numbered every 10th. This may be due to the fact that during the “manual” writing programs, the programmer forget about something or had to add something after writing the entire program, between each block had a further 9 free blocks. He could put between N10 and N20, e.g. N15 and N16. Now, when generating programs from CAM systems, this is not so important, although it sometimes happens to be added manually to the generated program.

But it happens so that the number of lines is limited by the machine’s driver or the postprocessor. Then, after reaching the border, the numbering starts from the beginning, e.g. we have N99999 and after this block is block N1.

Information on G-codes is material for the entire separate course. Here I will present the basics of the basics and a few curiosities. And at this point it is enough, I will present further information in the next post.





 

 




Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.