Guest Article

Secrets of CAD for CNC: What is G-code?

For CNC (Computer Numerically Controlled) machine tools or CNC systems, all information for processing work subject is obtained in the form of numerous, letters and other symbols. Numerous, letters and other symbols arranged according to certain rules and coded in the required form make up the program, necessary for providing the intended functions of the working bodies of the machine. This unique program, which controls almost all CNC machines, is called the NC program or better known G-code (This name was given because most functions in this programming language refer to defining the geometry of the part being processed - G functions). Today, different programming methods are used: Manual, programming in operation, programming using programming languages ​​(here we primarily mean other programming languages ​​such as APT, AUTOPRIT, AUTOPROGRAMER, COMPACT II, ​​etc.) and programming using CAD / CAM systems. This article refers to today's most used, most productive and most reliable method of programming - programming using CAD / CAM systems. But before that, let's get acquainted with the basic G functions, which we will later recognize in the generated G code.

G-Codes Explained

G-Codes Explained

The following table lists the basic G functions of the G-code programming language.

For an in-depth description of G-Codes, also check out: GCodeTutor's article

How to convert AutoCAD 2D and 3D drawings to G-code

CAD/CAM software interface

The geometry of complex parts (used for example in the aircraft, missile, military and other industries) is very complex with second-order surfaces, which require multi-axis machining (3-axis, 4-axis and 5-axis CNC processing). Complex programs for processing such surfaces require several thousand blocks (sentences) of which handwriting is very laborious and time-consuming. Therefore, it was necessary to use a computer for technical preparation, i.e. CNC programming for processing the above mentioned parts (components).

The integration of CAD and CAM has led to advances in NC programming methodology. Most CAD / CAM systems define geometry in CNC programs, while other technical information such as grips, basing and clamping, cutting tools and cutting modes are added through an interactive user dialogue with the CNC machine.

Nowadays, there is a large number of CAD / CAM software packages (CAD stands for Computer-Aided Design and CAM stands for Computer-Aided Manufacturing) for programming CNC machines, such as Autodesk Fusion 360, SolidWorks 3D CAD, Solid Edge CAM Pro, GibbsCAM, PTC Creo Parametric, etc. But the procedure in each of these software is similar.

In the picture above we can see the interface of one CAD / CAM software - it is PTC Creo Parametric, version 5.0.1.0. In particular, the drop-down menu of the "Manufacturing" card is interesting because it contains almost all the functions needed to generate a single G-code. Looking from the left to the right, all functions are given in the order we have shown in the previous scheme.

So, first, the CAD model of the part is imported with the "Reference model" function, and then the "workpiece" option defines the workpiece - based on the volume difference between these two CAD models, the software will later generate the tool path. The following four functions refer, respectively, to the selection of machines, tools, operations and work plane. After that, it is possible to simulate the tool path and create a CL file which is later post-processed and transformed into G-code. The following figure shows one generated G-code - Do you recognize some of the G functions we have shown in the table above?


How is G-code used in CNC machining?

Since we have shown how the G-code is obtained (How it is generated), it remains to be explained how this G-code is used in CNC machining. G-code saved in ASCII format (.txt or .tap file) should be transferred to the machine control unit.

This process is very simple and requires a simple transfer of the file from the PC platform (on which the G-code is generated) to USB and later from USB to the machine control unit. Today, this transfer can also be made with the help of an Internet connection between a PC and a CNC machine control unit.

In this way, the program is ready for processing, but not the machine setup itself. The operator has another more difficult task to prepare tools and workpiece for a particular processing process.


The Importance Of Using A Machine Operator Who Knows G-Code

An operator who knows the G-code is crucial for the production of parts, especially when programming the processing of a new part. Although, today's technology allows various types of simulation of program processing and verification, the final, the most important verification is the verification of the program on the machine itself. This process requires the operator to carefully monitor the behaviour of the machine at each sentence of the G-code and react in the event of an error, correcting the G-code on the machine control unit itself.

Once the program passes this verification, no one has to worry about it anymore and it is ready to produce a larger series of parts, and the operator is left with only the task of preparing tools and workpieces.

Conclusion

Nowadays, it is necessary to know CAD / CAM software for someone who wants to do CNC machining, that is, to program CNC machines. Compared to other programming methods, programming using a CAD / CAM system is simpler, faster, it can be said to be more reliable, but it can still happen that a mistake is made in the program. Therefore, it is necessary for the programmer to know the G-code, and even from the operator so that small errors in the program dropped by the software would not cause a catastrophe in production - the production of a lot of scrap parts or worse led to machine failure.



Wayken
Wayken

WayKen provides one-stop rapid prototyping services & low volume manufacturing services, including CNC machining, 3D printing, vacuum casting, rapid tooling, and injection moulding etc. With years of manufacturing experience, our customer covers from inventors or designers to commercial, medical, automotive, and even aerospace companies. Our experts offer the best solution for all your rapid manufacturing needs.

Share this article

For a complete tutorial on CNC Lathe Programming check out my course.

The quickest way to learn CNC Programming