Search This Blog

Showing posts with label cnc part programming. Show all posts
Showing posts with label cnc part programming. Show all posts

Wednesday, June 11, 2014

How should be a CNC Programming structure ???



CNC Programming has a defined structure which machine can read the codes without errors. NC Programming can be categorized into 3 parts:

1.      Main Program.

2.      Part program.

3.      Sub program.

1.     Main Program Structure


The main program is first read or accessed on machine tool when the entire part program sequence is run. Normally, the controller operates according to one program. In this case the main program is also the part program. This controlling program can then call a number of smaller programs into operation. These smaller programs, called Sub Programs. These subprograms are generally used to perform repeat tasks, before returning control back to the main program.

Each block, or program line, contains addresses which appear in this order:

N, G, X, Y, Z, F, M, S, T;

This order should be maintained throughout every block in the program, although individual blocks may not necessarily contain all these addresses.


Meaning of addresses:

N          - Refers to the block number.

G          - Refers to the G code (Preparatory function).

X          - Refers to the distance travelled by the tool in the X axis direction.

Y          - Refers to the distance travelled by the tool in the Y axis direction.

Z          - Refers to the distance travelled by the tool in the Z axis direction.

F          - Refers to the feed rate.

M         - Refers to the M code (Miscellaneous function).

S          - Refers to the spindle speed.

T          - Refers to the tooling management.






2.      PART PROGRAM STRUCTURE


A part program is a list of coded instructions with series of letters and numbers. The part program includes all the geometrical and technological data to perform the required machine functions and movements to manufacture the part.

The part program can be further broken down into separate lines of data, each line describing a particular set of machining operations. These lines run in sequence, are called blocks. A block of data contains words which is called codes. Each word refers to a specific cutting/movement command or machine function. The programming language recognised by the CNC, the machine controller, is an I.S.O. code, which includes the G-Code and M-code groups. Each program word is composed from a letter, called the address, along with a number.


BLOCK EXAMPLE:  N010 G01 X50 Y100 F100


Word Example: G01


Address Example: G


The part program can contain a number of separate programs, which together describe all the operations required to manufacture the part.


3.      SUB PROGRAM STRUCTURE


In order to simplify the main Program in case of repeated patterns or fixed sequences the Sub program is called in between the main program. The Sub program always ends with M99 which indicates the end of sub program. Sub program can be called any number of times in a main program. When the main program calls one sub program into operation, the process is called a one-loop sub program call. It is possible to program a maximum four loop sub program call within the main program. Shown below is an illustration of a two-loop sub program call.  








Note:


1.      If cutter compensation is required on a tool and the co-ordinates for the tool are within the sub program, the cutter compensation must be applied and cancelled within the sub program.

2.      A sub program call command (M98 P1000) can be specified along with a move command in the same block. For example, G01 X63.2 M98 P1000;


Sub Program Repeat:



A call command can be set to call a sub program repeatedly. This call can specify up to 999 repetitions of a sub program. A sub program repeat command has the following format:

M98 P000 0000

When the repetition is omitted, the sub program will be called once only.

For example,

M98 P100001

This command is read call the sub program number 0001 ten times.