How to program to produce cnc parts?

How to program to produce cnc parts?

Currently, CNC machining is increasingly developing in the field of manufacturing activities. In order to create products of high quality and absolute precision, operators must understand the basics of programming cnc parts production. Knowing the basic programming steps of a cnc machine helps you save time and increase machining efficiency.

Softwares to support cnc machining programming

Some of the software used in cnc machining programming include:

  • CAD
  • CAM
  • CAE

CAD software used in cnc machining

Computer-aided design (CAD) software used to sketch and create 2D vector and surface renderings or 3D solid parts, as well as the necessary technical documents and specifications related to that part.

Designs and models created in a CAD program are typically used by a CAM program to create the machine program needed to manufacture the part through cnc machining.

CAD software is used to determine optimal part properties, evaluate and verify part designs, simulate products without prototypes, or provide design data to manufacturers.

CNC Machining with CAM

Software Computer-aided manufacturing (CAM) software are programs that use the extraction of technical information from a CAD model and create the machine programs needed to run the cnc machine and manipulate it. tools to create custom designed parts.

CAM software allows the cnc to run without the help of an operator and can automate product evaluation.

CAE software for cnc machining

Computer-aided engineering (CAE) software is a program used by engineers during the pre-processing, analysis, and post-processing stages of the development process.

CAE software is used as a support tool in technical analysis applications such as design, simulation, planning, manufacturing, diagnostics, repair, evaluation and modification of product designs.

Types of CAE software include finite element analysis (FEA), computational fluid dynamics (CFD) and multistream dynamics (MDB) software.

Learn about cnc detail production programming.

Programming cnc parts production 

Methods Manual cnc programming methods (Manual Programming)

From the manufacturing drawings and parts, the programmer will analyze and program in the head. Then use the keyboard on the control panel to compose and save the program to the memory of the machine control system.

Or you can compose a processing program on paper or a PC. Then check and input the machine with the keyboard on the machine or transfer the programming information via magnetic tape, magnetic disk, cnc transmission cable that can be read.

The manual programming steps are as follows:

Step 1: Study detailed drawings.

Step 2: Choose the right machine to process the part.

Step 3: Select cutting tools.

Step 4: Build the detailed machining process.

Step 5: Calculate the coordinates of the points and the detailed line.

Step 6: Determine the cutting mode.

Step 7: Write a cnc program.

Step 8: Prepare to install the machine and cutting tools.

Step 9: Test the program using virtual simulation tool.

Step 10: Edit the program.

Step 11: Run the program to produce details.

Automatic programming method (using CAD/CAM software)

Is a method of using CAD/CAM software to create machining programs on cnc machines.

When programming CAD/CAM, the programmer must:

  • Describe the geometry of the part where it needs to be processed and cut points, circles, arcs, straight lines or planes, curved surfaces. The information belongs to the CAD group.
  • Describe the technological elements of the machining process: including milling, drilling, roughing, finishing, and cutting procedures. The information belongs to the CAM group.

After describing the above-mentioned geometrical and technological parameters. Through the post-processing function, the software will automatically produce a machining program that is a data file in the form of G-code like what we programmed by hand. However, it must be adjusted at the beginning of the program to suit each type of cnc machine.

Automated programming steps:

Step 1: Build part according to 3D model with CAD software

Step 2: Choose the type of machine needed to process the part

Step 3: Select cutting tool

Step 4: Use the software CAM to program the machining, select the machining mode, cutting mode, cutting tools, … Simulate the machining process, check and export the cnc file.

Step 5: Load the cnc program created by CAD/CAM into the appropriate cnc machine selected.

Step 6: Check the program on the cnc machine with test mode and run it, edit if necessary.

Step 7: Run the program to produce details.

Programming method for automatic cnc part production.

Structure of programming cnc parts production 

Structure of a programming code programming cnc parts production 

Program The finished cnc program needs many different source code snippets. These code snippets all have the following general structure:

  • The first part is an overview declaration including: %, Oxxxx, N5, N10, N25, N30.
  • Next are the commands to move the tool, cut, and the time to start processing the product is the command N. ///
  • Finally the command to end the program and repeat the program.

The structure of setting up cnc programming command lines

  • The order of the command lines is arranged as follows:

Nxx Gxx X… Z… I… J… K… T… S… F… M… ; Nxx

  • Commands to prepare programming: Gxx
  • Commands for setting the size and positioning the tool to move: X… Y… Z… I… J… K…
  • regulation commands: F…
  • Instructions specified subheadings begin with: M…
  • To end the program, the operator only needs to type the “;” sign.
  • In CNC programming design, a command line is also known as a “Block”. To skip a block, the operator will use the “/” sign.
  • For example: /N30 G1 X30. Y40. ; N40 M5 M9
  • This means that the N30 command line will be ignored and the “single block” button will appear on the computer display.

Declare command in programming cnc parts production 

Commands to select the programming plane

  • G17: select the XY plane
  • G18: select the XZ plane
  • G19: select the YZ plane

The commands to declare the unit of measure

Here, the programmer will use the G20 and G21 commands.

  • G20 declares inch units
  • G21 declares metric units

Coordinate system declaration commands

In this step, the operator will use 2 commands G90 or G91 to perform coordinate system declaration.

  • With the G90 command, the coordinates will be declared absolute, the cutter will move to that position when required.
  • With command G91, coordinates will be declared relative. That is, the current position of the tool can be considered as the coordinates of the next points.

Feed commands

To set the feed rate, the operator will use the G94 and G95 commands:

  • G94 declares mm/min or inch/min units.
  • G95 declares mm/rev or inches/rev.

Commands to rotate the spindle

  • M3/M03 command: rotate the shaft clockwise.
  • M4/M04 command: rotate the shaft counterclockwise.
  • M5 command: make the shaft stop rotating.
Instruction code M03, M04 CNC machine.


  • commands Txxx M6 command: “xxx” is the tool number, M6 means tool change . Txxx is the knife call.
  • The command to return to the reference point is G28, G29, G30 (these commands all have the same effect).
  • The reference point is fixed at the machine and data is fed to the table.

End command for programming cnc parts production 

  • M30 command: end the chapter and start the program again.
  • M99 instruction: terminate the subroutine.
  • Command M01: pauses programs opened by OSP.
  • Command M00: pause the entire program.
  • Command M9: turn off the coolant.
  • M8 command: turn on the cooling program.

Some requirements for programming cnc parts production 

When programming manually or automatically, the programmer must be equipped with the following knowledge and abilities:

  • Having knowledge of cnc machining technology.
  • Knowledge of analytic geometry.
  • Use CAD software to assist with geometric calculations. If you are an automatic programmer, you must have basic knowledge of CAD/CAM.
  • Master and rationally apply the types of cutting tools commonly used on cnc machines, jigs if necessary, and detailed mounting methods.
  • Understand the rules, conventions, and syntax of programming statements.
  • Master programming rules, belong to common G codes and M codes , and master machining cycles.

Above, Apro has shared about programming cnc parts production for your reference. Hope the above article helps you better understand about CNC machining programming.