Introduction

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.
Explanation

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.


Geometric instructions

These are the instructions corresponding to the movements between the tool and the workpiece.


Processing instructions

These are the instructions that indicate cutting speeds, feed rates, cutting tools, coolant control, among other factors.


Advance instructions

These commands indicate the type of interpolation (circular or linear) and speed of movement of the tool or worktable.


Switching instructions

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.


Codes M

Miscellaneous functions, comprising actions necessary for machining, are related to switching functions, such as spindle rotation or stop, coolant feed or coolant feed stop.


Codes N

They provide the information block number.


Codes X, Y, and Z

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.


Codes I, J, and K

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.


Codes F

Used to specify feed rate.


Source S

Used to specify spindle speed.


Codes T

Used to specify the identification number of the tool to be used in subsequent operations.


Source R

Used to specify retraction distance or radius dimension, depending on the G-code with which it is associated.


Source P

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:

  • N41 means that the block is assigned the number 41 in the programming sequence.
  • The value G97 means that the constant cutting speed is disabled (off).
  • The word S600 indicates that the spindle speed is 600 rpm.
  • The word M03 means that the spindle will rotate clockwise.

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:

  • G73 Drilling cycle with retraction to the safety plane
  • G81 Drilling cycle
  • G82 Drilling cycle with pause
  • G83 Deep drilling cycle
  • G84 Grinding cycle
  • G80 Cancellation of the drilling cycle

Programming cycles in CNC turning centers.

  • G70 Finishing cycle
  • G71 Longitudinal roughing cycle
  • G72 Roughing cycle in face
  • G73 Copying cycle
  • G74 Grooving, drilling cycle (Z-axes)
  • G75 Grooving cycle (X Axis)
  • G76 Threading cycle

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:

  1. Make the 3D model in NX.
  2. Switch to manufacturing mode.
  3. Configure.
    • Part zero
    • Geometry
    • Tool
  4. Cutting operation.
  5. Simulate machine operation.
  6. Post-processing (obtaining numerical control code).

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.

Conclusion

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.

Checkpoint

Make sure that you:

  • Explain the CNC programming codes.
  • Describe CNC programming path and miscellaneous functions and their applications.
  • Exemplify the absolute and incremental programming modes and the implications of both.
  • Understand programming cycles and calling subprograms.
References

  • Groover, M. (2018). Automation Production System and Computer Integrated Manufacturing (5th ed.). United States: Pearson.
  • HASS AUTOMATION, INC. (2015). MILL SERIES PROGRAMMING WORKBOOK. RETRIEVED from https://www.haascnc.com/content/dam/haascnc/videos/bonus-content/ep81-essential-9-lines/programming-workbooks/mill---programming-workbook.pdf
Additional Resources

The following links do not belong to Tecmilenio University, when accessing to them, you must accept their terms and conditions.

Videos

To learn about NX CAM, check out the following video: 

To learn about lines of code, check out the following video: 

Readings

To learn more about CAM, we recommend reading:

To learn more about Canned cycles, we recommend reading:

Activity CNC programming codes

Description

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

  • Siemens NX 12.0 software
  • Manufacturing cell of your campus

Instructions

Individually

  1. First, visit the manufacturing cell on your campus and inquire about the features of the machining center that is installed in it.
    Prepare a short summary including the following data:
    1. Brand
    2. Year of manufacture
    3. Model
    4. Number of axes
    5. Tool capacity
    6. CONE type
    7. Minimum/maximum RPM
    8. Example of a basic CNC program including setup, cutting, and finishing instructions that are compatible with the machining center.
  2. Next, inquire with your campus manufacturing cell manager about the materials they have available for hands-on practice in the machining center and perform the following activities.
    1. Using the Siemens NX 12.0 software, you must design and model the TecMilenio University logo (limit your logo dimensions in relation to the maximum size of the material block available in your campus).
    2. With the aid of the Siemens NX 12.0 manufacturing tool software and the information related to the machining center that is available on your campus, elaborate the CNC program needed to manufacture the part designed in the previous point.
    3. Request the support of the head of the manufacturing cell to check the operation of your program in the machining center, make the necessary modifications and carry out the machining of the designed part.
  3. Finally, prepare a document in which you present your results, including evidence of the activities carried out. Add a short conclusion at the end of the document.

Deliverable(s)

Document with the development of the activity and the physical part elaborated in the machining center.

Evaluation criteria

  1. Performs the summary with the data from the machining center located in the manufacturing cell of your campus.
  2. Produces the 3D model of the requested part using Siemens NX 12.0 software.
  3. Obtains the CNC program corresponding to the modeled part.
  4. Performs the physical machining of the designed part.
  5. Performs the physical machining of the designed part.
  6. Prepares the final document with the summary of the results obtained.
Homework 9

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

  1. First, conduct research and answer the following questions.
    1. What is computer numerical control and what kind of machines can use this technology?
    2. What are the advantages and disadvantages of using computer numerical control?
    3. Explain the axes on which a CNC machining center, in particular a milling machine, can move.
    4. Explain the concepts of absolute coordinates and relative or incremental coordinates and how they apply to the CNC.
    5. What are the zero parts and zero machine in a CNC machining center?
    6. Develop a CNC program in incremental mode that describes the contour shown in figure 1. Consider the trajectory to be A-B-C-D.
    7. Modify the program of the previous paragraph, using this time the absolute mode.

     



Figure 1. Representation of the part contour