The application of numerical control in manufacturing processes is quite varied. The best-known CNC function is the control of the displacement of a work head in relation to the workpiece on which the process is carried out; a typical example of the use of this type of control is the management of the cutting or machining of a part.
Numerical control has historically been related to the field of machine tools, but with the rise of new technologies and the versatility of its implementation it is possible to find it almost anywhere.
Writing programs for a CNC system is called CNC part programming, since each part requires a specific one. The program is carried out by an expert in the metal cutting process, with extensive knowledge in the operation of the equipment on which the machining will be performed.
In the early days of CNC systems, two main variants were developed: direct numerical control and computer numerical control. In direct numerical control (DNC) a single central computer controls several machines directly. All of them are programmed and monitored from a central node, with the disadvantage that, since they depend on a single piece of equipment, they are subject to its operation. In computerized numerical control, each machine has a computer that allows programming, data storage and control independently. It is currently the most widespread system due to the considerable reduction in implementation costs.
Direct control can be implemented on machines that have their own individual control and interconnect them with each other by means of a central computer, with all the advantages of operation that this offers. This arrangement is called distributed numerical control.11.1 CNC programming codes
A numerical control program is composed of a series of instructions, commands and parameters that allow a CNC machine to perform a given operation. Each program incorporates four groups of commands: geometric, processing, feed forward and switching instructions. A more detailed description of each can be found in table 1.
|
These are the instructions corresponding to the movements between the tool and the workpiece. |
|
These are the instructions that indicate cutting speeds, feed rates, cutting tools, coolant control, among other factors. |
|
These commands indicate the type of interpolation (circular or linear) and speed of movement of the tool or worktable. |
|
These are the instructions for turning on or off different machine functions, such as coolant supply, spindle rotation, workpiece feed, clamping, among others. |
Table 1. Instruction sets used by numerical control programs
A high-level alphanumeric language is used to write a CNC program, where each instruction consists of a letter followed by a number. Each letter corresponds to a specific type of action or information (table 2).
Codes G |
Preparation functions, indicating tool movements. |
|
Miscellaneous functions, comprising actions necessary for machining, are related to switching functions, such as spindle rotation or stop, coolant feed or coolant feed stop. |
|
They provide the information block number. |
|
They provide specifications for the coordinate axes, the number following them defines the coordinate at the end of a movement and may require a specific format. |
|
Used to specify the coordinate axes when defining the center of a circle, the number following them defines the coordinate of the center of the circle and may require a specific format. |
|
Used to specify feed rate. |
|
Used to specify spindle speed. |
|
Used to specify the identification number of the tool to be used in subsequent operations. |
|
Used to specify retraction distance or radius dimension, depending on the G-code with which it is associated. |
|
Used to specify the length of stay, used in conjunction with certain G-codes. |
Table 2. CNC code families and their functions
The structure of a program must follow a sequence that guarantees the correct execution of the actions by the machine (figure 1).
Figure 1. Sequence actions in a CNC program
A CNC program is made up of blocks, each of which contains one or more words.
An example of a block is as follows:
N41 G97 S600 M03
The block contains the words N41, G97, S600 and M03.
Codes N, G, S and M are used with values 41, 97, 600 and 03.
To interpret the previous block, we must consider the following:
Therefore, the complete reading of the block indicates that there is no relative motion between the workpiece and the tool, starting the spindle turning clockwise at a speed of 600 rpm.
The execution of the blocks is carried out by the machine sequentially, one after the other and in the order in which they have been programmed; in addition, the words of each one is executed in a specific order. For example, miscellaneous codes M are executed before any axis movement.
CNC programming path and miscellaneous programming functions
M commands are known as miscellaneous, logical, additional or machine functions. While G-codes are known as path or preparatory functions. Below, is a partial list of the main G and M functions with a brief description of the actions they control (tables 3 and 4).
Image displayed when accessing the hyperlink.
Table 3. Selected path functions (G-functions)
Table 4. Selected miscellaneous functions (M-functions)
Vertical machining center
Hass. (2021). Vertical machining center.
Retrieved from https://haas.com.mx/
For educational purposes only.
Programming in absolute and incremental mode
Coordinating programming in a CNC program can be performed in absolute or incremental mode.
In absolute mode, the coordinates points of a trajectory are specified with respect to a fixed origin (figure 2). In incremental mode, the coordinates points of a path are specified in respect to the last point visited by the path (figure 3).
Figure 2. Representation of the coordinates points in absolute form in respect to the origin (0,0)
Figure 3. Representation of the coordinates points incrementally following the A-B-C path
Absolute mode is very easy to use when the points of a path are easily defined from the geometry of the finished part. However, this is not always the case, especially when there are complex geometries and there is no electronic file of the drawing of the part to be made and a computer to interpret it. When this happens, the points of the trajectory necessary for the realization of the program must be calculated, generally with trigonometric methods. Calculating successive points with trigonometric methods is simpler when the previously calculated point is taken as the base and not the absolute origin of the geometric system in question. This makes it simpler to feed the obtained data to the program incrementally, as they do not have to further complicate the calculations by referring them to the absolute origin (Groover, 2018).
Figure 4 shows an example of a CNC program using incremental mode to generate a part contour.
Figure 4. Example of a CNC program that performs a contour incrementally
Figure 5 uses the absolute mode to make the same part contour shown in figure 4.
Figure 5. Example of a CNC program that performs a contour in absolute mode
11.2 Programming cycles
Programming cycles are used to reference sets of operations that are common to various machining processes (for example, drilling, tapping, making cavities, among others).
These are instructions that have programmed within them other instructions that are repeated continuously just by specifying it in a program line.
According to Hass, the objective of the programming cycles is to reduce the length of the programs, as well as to reduce the risk of collisions in CNC programming. There are programming cycles for milling and turning processes, some examples are as follows:
Programming cycles for milling:
Programming cycles in CNC turning centers.
Here, is how to program some cycles on a vertical machining center.
G81. Drilling cycle (figure 6)
Figure 6. Programming cycle 81 (DRILL CANNED CYCLE).
HASS AUTOMATION, INC. (n.d.). Programming Cycle 81 (DRILL CANNED CYCLE).
Retrieved from https://www.haascnc.com/content/dam/haascnc/videos/bonus-content/ep81-essential-9-lines/programming-workbooks/mill---programming-workbook.pdf
For educational purposes only.
G82. Drilling cycle with pause (figure 7).
Figure 7. Programming Cycle 82 (SPOT DRILL~COUNTERBORE CANNED CYCLE)
HASS AUTOMATION, INC. (n.d.). Programming Cycle 82 (SPOT DRILL~COUNTERBORE CANNED CYCLE).
Retrieved fromhttps://www.haascnc.com/content/dam/haascnc/videos/bonus-content/ep81-essential-9-lines/programming-workbooks/mill---programming-workbook.pdf
For educational purposes only.
11.3 Calling subprograms
One more feature that CNC machines have is the ability to invoke a subprogram. In this case, a program considered as the main program has the option to call another program, or subprogram, which will run within the main program for a defined number of times. The advantage of using subprograms is that geometric shapes commonly used in a manufacturing process can be defined and called at any time, thus, saving programming time.
The codes used in calling subprograms are as follows (table 5).
Source |
Description |
Examples of use |
M98 |
Subprogram call (the M98 code must be accompanied by a letter "P" followed by five numbers, the first number of times the subprogram will be repeated, the last four digits indicate the name of the subprogram to be run). |
M98 P21010 |
Invokes the 1010 applet, and it runs twice before returning to the main program. |
||
M98 P1020 |
||
Invokes the 1020 applet, but it will only run once. |
||
M99 |
End of subprogram (within a subprogram should be the last line of code, indicating the return to the main program. If code M99 is omitted, execution stops at the end of the subprogram). |
M99 |
If it is not accompanied by another word, it returns to the main program and continues with the execution of the next instruction. |
||
M99 N05 |
||
If accompanied by address NXX, it means that a jump will be made to the indicated line of the main program, where xx is the line number; for example, make a jump to program line N05. |
Table 5. Codes used in calling subprograms
The figure 8 shows an example of the different ways of working with subprograms.
Figure 8. Example of subprogram use
It is important to note that a subprogram must begin with a letter O and four numbers (Oxxxx). However, when called as a subprogram with the M98 command, the letter O is omitted and only the four numbers are entered.
Moreover, the M99 can also be used in the main program and means jump to a program line; thus, if the instruction is used in this way: M99 N05, it means to make a jump to program line N05 whereupon the CNC machine will be running the program indefinitely.
11.4 CNC Programming with NX
Programming through specialized software facilitates and optimizes the machining process. The industry has been adopting this type of software for several years, which is the key point to increase quality and productivity in new and demanding environments.
There are several tools on the market that allow us to generate numerical control programs in a simple way and with a high degree of precision. In the case of the Siemens NX 12.0 tool, it is possible to generate the numerical code from the manufacturing application. The process to generate the CNC program in Siemens NX 12.0 is as follows:
To learn more about machining in NX, watch the following video:
Siemens Software. (2020, November 16). G-Code-Driven Machining Simulation in NX CAM [Video file]. Retrieved from https://www.youtube.com/watch?v=XrDy8GO-PDw&t=158s
The following link do not belong to Tecmilenio University,
when accessing to them, you must accept their terms and conditions.
As we have seen in this topic, it is very important to understand and use the CNC programming codes. Therefore, as a future engineer, you need to be able to describe its programming path and functions to provide results measure by absolute and incremental programming modes. However, you must consider that each one of them has implications, cycles, subprograms, among other important elements.
Make sure that you:
The following links do not belong to Tecmilenio University, when accessing to them, you must accept their terms and conditions.
To learn about NX CAM, check out the following video:
To learn about lines of code, check out the following video:
To learn more about CAM, we recommend reading:
To learn more about Canned cycles, we recommend reading:
With the support of the Siemens NX 12.0 program, the student will generate a CNC code required for the machining of a part in the manufacturing cell of his/her campus.
Objective
To design a numerical control program for the machining of a part in the manufacturing cell.
Requirements
Instructions
Individually
Deliverable(s)
Document with the development of the activity and the physical part elaborated in the machining center.
Evaluation criteria
Description
Through a search for information and classification, describe the main codes used on a CNC machining center. In addition, develop a practice program describing a part contour.
Instructions
Individually
Figure 1. Representation of the part contour