Tuesday, April 26, 2022

Preface of CNC Programming

What is CNC Programming

CNC Programming is the process of generating coded information based on a drawing of a component or workpiece, which is a vital part of a CNC machine. This coded information is executed by the CNC controller, operating the machine and producing the desired workpiece. It is referred to as the 'Work-piece Program' of a CNC machine. This coded information consists of instructions for running the machine and controlling its various functions. Usually, the program is written using the alphanumeric keyboard of the CNC controller and stored in its memory. In some cases, it is written on an external computer with the assistance of specialized software (such as CAM software) and then transferred to the controller's memory for storage. Workpiece programs are sometimes called Part Programs or Main programs, while repetitive programs are written as Sub-programs and specific programs for tasks like drilling and tapping are called Cycle-programs. Certain CNC controllers utilize dedicated software that automatically generates complete programs, requiring only the modification of certain numeric parameters.

Programming language 

There are various programming languages used in CNC programming, but the most popular one is the 'G-code' programming language, which is employed by CNC controller manufacturers to write workpiece programs for CNC machines. Some controller manufacturers use their own programming language that does not utilize G-codes. However, major CNC system builders like SIEMENS and FANUC exclusively employ the G-code programming language for programming their controllers. In this discussion, we will focus solely on the G-code programming language. Similar to other programming languages, G-code programming utilizes words and numbers to represent different functions such as preparatory actions, miscellaneous functions, axis movements, speed, feed, and tool offsets.

 

Steps of program writing

Before writing a workpiece program, it is essential to learn about the programming language and coordinate system of a CNC machine. Typically, the program is documented, listing the coordinate values for the tool's path during component machining and the different 'G Codes' used for preparatory functions. For machining, the coordinate values determine the axis movements and describe the feed or speed of each axis. Special commands, known as miscellaneous codes or M codes, are also written separately to perform auxiliary functions like automatic tool change, pallet change, or coolant activation. All the instructions are written in separate blocks, and these blocks are organized in a specific sequence to form a complete program that can be understood by a CNC controller.

Four statements are commonly used in program writing: Character, Word, Block, and Program. The 'Character' is the smallest unit of a CNC machine program, represented by a digit, letter, or symbol. A 'Word' is an alphanumeric combination, with each word starting with a capital letter and ending with a numeric value. Words represent different positions of the axes, feed rate, speed, miscellaneous functions, etc. Multiple words are logically and sequentially written within a Block. The Blocks are then arranged in sequence to form a complete Program. The following is the standard format of a CNC machine program Block: 

 

Program writing formats may vary for different CNC controllers. The most widely used controllers, such as SIEMENS and FANUC, are prevalent in Indian manufacturing industries, and the programming formats and symbols used in this document adhere to these two controllers. CNC machine main programs are usually labeled with designations like MPF, %, or O, followed by a number, such as 'MPF 1234', '% 1234', or 'O 1234'. Sub-programs are commonly labeled with 'SPF' or 'L' and corresponding numbers, such as 'SPF 123' or 'L 123'. A program is always written sequentially, with several lines or blocks, and each block is assigned a specific number. The block number is identified by 'N' followed by a numerical value, such as 'N001' for the first block and 'N002' for the second block. Different machining instructions are written one after another within each block, with a space between them. The 'LF' or ';' mark is used at the end of each line to indicate the end of a block. 

For example, a program block may be written as 'N5 S1000 M03;', where 'N5' represents the block number, 'S' indicates the spindle speed of 1000 rpm, and 'M03' is a miscellaneous code indicating the spindle rotates in a clockwise direction. Finally, the ';' symbol denotes the end of the program block. An M30 or M17 command is usually placed at the end to signify the end of a Main program or Subprogram, respectively. The following is an example of a typical program format compatible with FANUC controllers:

 O1001                                                          Program Number 1001
 N01 G21 G94;                                             Preparatory function
 N02 G01 X10.0 Y20.0 Z30.0 F500;             Axis movement
 N03 T01 M06;                                             Tool change
 N04 M03 S1000;                                         Spindle rotation
 N05 M07;                                                    Coolant on
 N06 .......
 N07 .......
 N08 .......
 N09 .......
 N10 M30;   
                                                Program end 

How program is executed by a CNC controller?

Various CNC machines are utilized in modern machining industries, with some specializing in specific operations. CNC turning and milling machines are the most commonly used machines. Turning machines typically have two basic axes (X and Z) with one spindle and operate in a single plane (XZ plane) for programming. Simple CNC milling machines usually have three basic axes (X, Y, and Z) and a spindle for machining. Therefore, CNC milling programming involves movements along the X, Y, and Z axes, encompassing three planes (XY, YZ, and XZ). In some cases, one or two additional rotary axes (such as A, B, or C) are utilized, providing additional flexibility in machining operations. Simple turning operations are performed using two-axis movement, while simple milling operations require three-axis movement. Complex machining processes on CNC machines may require simultaneous movement along four or five axes, resulting in more complicated five-axis machining programming. This type of programming necessitates an advanced CNC controller equipped with specialized software. Additionally, different CNC machines have varying programming requirements. This discussion focuses on basic metal cutting operations such as turning and milling, which are commonly applied in modern machining industries.

A program is composed sequentially, block by block, until completion. The CNC controller executes the program starting from the initial block, and each subsequent block is executed one after another. This process continues only after the successful execution of the preceding program block. If any difficulties arise during the execution of a specific block, the CNC controller will not execute the subsequent blocks. The program execution stops immediately at that block, and the controller generates a fault message to indicate the reason for non-execution. To skip or bypass a program block, a '/' symbol is placed in front of the block number, such as '/N20...'. Sometimes, comments unrelated to the program need to be included, which can be enclosed within parentheses, e.g., '(Test program for...)'. The controller will disregard any information written inside the parentheses. The program execution can also commence from any block number within the program using the 'Block search' option, rather than starting from the beginning. The subsequent block numbers are then executed sequentially until the program execution is completed.



No comments:

Post a Comment

Popular Posts