How 2 Write a CNC Part Program? – Basic CNC Programming

How 2 Write a CNC Part Program? – Basic CNC Programming

A CNC Part Program is a first and foremost requirement to operate a CNC machine successfully. To write a CNC part program, a part programmer must have adequate knowledge in the field of manufacturing science, design, material science, etc.

CNC Part Program

A CNC Part Program consists of many blocks. A block has sufficient information to set up a machine for the operation or move the tool at least a single move.

A CNC Part Program may be divided into three parts :-

Start- up Program

The first part of a CNC part program is known as the start-up program. A start-up program mainly covers the commands used to prepare the machine for the upcoming operation. Start-up program usually has 5 – 6 block.

A typical start-up program may be like as follows :-

O0001;

N001 G21 G90 G98;

N002 G28 U0 W0;

N003 M06 T04;

N004 M03 S1500;

N005 G00 X40 Z2;

Main Profile Program

The main profile program is the most important portion of a CNC Part Program. The main profile program includes all the tool motion commands and coordinates. The main profile program starts just after the start-up program and continues until the last tool motion command. When a Special Cycle is used in a part program, the length of the main profile program gets drastically reduced.

End of the Program

This is the last portion of any CNC part program. It usually includes all those commands which are responsible for shutting down the Machine in an appropriate manner.

The following elements need to be taken into consideration to write the end of program.

  • The tool must be reached to its home position.
  • The spindle should be stopped.
  • The machine should be ready for the repeated operation

Following is the format for the end of the program;-

G28 U0 W0;

M05;

M30;

To Know more about a CNC part program Click here

Points consideration to write a CNC part program

To write a CNC Part program, a part programmer need to consider the following points as per the requirements;-

  • Selection of Origin /zero point
  • Selection of Coordinate System
  • Selection of Unit System
  • Selection of Program format
  • Selection of G/M codes

Now, we will discuss all these above points in detail.

Selection of Origin/zero point

To convert a 3D design into a machine-readable format, the part programmer needs to set the origin point. An origin point is used to measure the tool locations in the absolute coordinate system as well as in the incremental coordinate system.

A CNC machine offers two choices to set the origin/zero point for any CNC part program. These are as follows;-

Fixed Zero

Fixed origin/zero is always located at the same position for every operation. This location is usually a lower-left corner (south-west corner) of the machine work bed.

Fixed Zero

Floating Zero

Floating origin/zero is one of the advanced features of any CNC System. This feature makes it possible to set origin /zero points at any position over the machine table/work-bed. The new origin/zero point location has to be set and fed into the MCU manually for every product.

Floating Zero

Note;- The Fixed origin/zero or Floating origin/zero is required to set on the machine manually for every operation. There are No G/M codes available for them.

To set an Origin/zero point, the tool is placed at the required point and then the amount of tool travelled from home position is offset. By doing so, the machine considers the new point as the new home position of the tool.

Selection of Coordinate System

An NC Coordinate Drawing is the first requirement to run a CNC machine. A CAD Drawing of any product is not directly acceptable in any CNC machine. Thus, a CAD drawing needs to be converted into a machine-readable format that is NC Coordinate Drawing.

There are two types of coordinate system used in NC system.

  • Absolute Coordinate System
  • Incremental Coordinate System

Absolute Coordinate system

It is also known as Absolute Dimensioning System or Absolute Positioning System or Reference Dimensioning System. In this Coordinate System, all the part’s coordinates are measure about a single reference point or zero-point.

In other words, all the tool’s movements/locations are defined with respect to a single reference point or zero-point.

The reference point or zero-point is set fixed and remains the same throughout the tool’s movement.

Note:- To activate Absolute Coordinate System (ACS), G90 word is used in the part program.

Absolute Coordinate System

Incremental Coordinate System

It is also known as Incremental Dimensioning System or Incremental Positioning System or Relative Dimensioning System. An Incremental Dimensioning System makes use of the tool’s current position to find out the tool’s next position. 

In other words,  Tool’s current position works as a reference point for the next position.

The Reference point or zero-point keeps changing throughout the tool’s movement.

Note:- To activate Incremental Coordinate System (ICS), G91 word is used in the part program.

Incremental Coordinate System

Selection of Unit System

All the tool’s positions have to be fed into the MCU via a part program. A CNC system offers the flexibility to use more than one Unit system for the same.

There are two type of Unit system used in a CNC machine.

  • Inch Unit System
  • Metric Unit System

Inch Unit System

This System is activated by using G20 word in the start-up part of a part program. After activation of this system, the machine control system reads all tool feed rate data in inch unit.

Metric Unit System

Metric Unit System is activated by using G21 word in the start-up part of a part program. After activation of this system, the machine control system reads all the coordinate numerical data and tool feed rate data in millimetres unit.

Selection of Program format

To write a CNC Part Program, a part programmer has to follow a particular format. A format is nothing but the order in which the command words are used in a block of instruction.

There are at least three types of the format available for programming purpose:-

  • Word Address Format
  • Tab Sequential Format
  • Fixed Sequential Format

Word Address Format

This one is the most usable format in part programming. It is, sometimes, also known as Variable Block Format. In this format, each numerical data is preceded and identified by an alphabet.

Features of Word Address Format:-
  • NC words can be written in any sequence within a block as every numerical data is prefixed by an alphabet.
  • If the numerical value of any NC word remains unchanged, then there is no need to repeat that NC word in the subsequent block.

Fixed Sequential Format

It is also known as the Fixed Block Format. In Fixed Sequential format, All the NC words within a block must be written in a fixed standard sequence.

A typical Standard Sequence is as follows:-

N – G – X – Y – Z – F – S – T – M – EOB

Features of Fixed Block Format:-

  • No prefixed alphabets are required.
  • Every NC word is needed to be in block irrespective of their numerical data remains unchanged.
  • Every block must be of equal length.

Tab Sequential Format

This also comes under the category of the fixed block format. In Tab Sequential format, indeed all the NC words within a block are written in a fixed standard sequence but each NC word is separated by pressing a Tab key.

Features of Tab Sequential Format:-

  • No prefixed alphabets are required.
  • Every NC word is needed to be in block irrespective of their numerical data remains unchanged.
  • Every block must be of equal length.

Selection of G/M codes

This one is the last step to write a CNC part program. In this step, we choose the appropriate G/M codes according to the requirement.

To Know about the 5-Step Procedure of CNC system Click here

This is all about “How 2 Write a CNC Part Program? – Basic CNC Programming”

Hope you find it useful.

Happy Learning

Share Us

Leave a Reply

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