1.2 NC program name, structure and content rules
The NC program consists of a sequence of blocks. Each block represents a machining step. Instructions in a block are written in the form of words. The last block in the order of execution of the blocks contains a special word for the program end: M02, M30.
1.2.1 Program names
Each program has its own program name, when creating a program, the program name can be freely selected, observing the following rules:
Program names can only use letters, digits or underscore.
1. Do not use delimiters;
2. Case sensitive;
3. Can not use the same name of the systemstandard cycles;
4. Decimal point is as the extension of the file,the extension of the main programis compatible with multiple formats, such as (txt, iso, etc);
5. Extension ofsubroutinemust be ‘iso’;
6. Do not use more than 32 characters.
Example:
SHLLE_527.iso
1.2.2 Program block and stucture
The NC program consists of a sequence of blocks, a separate line for each block. Each block represents a machining, logic processing or mathematical calculations step.
Example:
N10 G94 G01 Z80 F100 ; 1st block
N20 G00 X100 ; 2nd block
N30 ……
N40 M02 ; End of program
The block consists of several words, the order of execution of each function is independent of its arrangement, NC system will automatically re-arrange. If a block contains several instructions, the following order is recommended:
Example:
/N10□G…□X…□Z…□F…□S…□T…□D…□M…
; Comment
/ indicate Blocks of a program, which are to be executed not with each program run;
N… indicate Block numbers, up to five digits;
□ indicate Blank/ Space;
; indicate The instructions in the blocks of a program
Instructions in one block perform in the following order:
1. N
2. T and
3. F and S
4. G
5. M(P18)
6. X and Z etc.
7. M(P18)
In one block can be programmed multiple functions G and function M, but only one functions (X, Z, T, F, etc.). G functions are divided into different groups, you can not use the function of two or more of the same group G in the same block.
The block numbers are usually in steps of 5 or 10. Thus, you can later insert blocks and nevertheless observe the ascending order of block numbers. Although it does not affect the execution of the program when it is not written the block number, it is recommended that before the program involving coordinate movement and auxiliary functions, add an instruction segment block number to increase readability. After block number, the instruction must be followed by a space.
1.2.3 Word structure and address
A word is a block element and mainly constitutes a control command. The word consists of(as shown Fig.1.3):
1. address character: generally a letter or string
2. numerical value: a sequence of digits which with certain addresses can be added by asign put in front of the address, and a decimal point. A positive sign can be omitted.
Fig.1.3 Word structure
1.2.4 Arithmetic functions
+ |
Addition |
- |
Subtraction |
* |
Multiplication |
/ |
Division |
DIV |
Division, result is integer |
MOD |
Division, result is remainder |
SIN( ) |
Sine, Degrees |
COS( ) |
Cosine, Degrees |
TAN( ) |
Tangent, Degrees |
ASIN( ) |
Arc sine, Degrees |
ACOS( ) |
Arc cosine, Degrees |
ATAN( ) |
Arc tangent, Degrees |
ATAN2( ) |
Arc tangent2, Degrees |
SQRT( ) |
Square root |
ABS( ) |
Amount |
POT( ) |
Square |
TRUNC( ) |
Integer portion |
LN( ) |
Natural logarithm |
EXP( ) |
Natural logarithm |
1.2.5 Comparative and and logic operators
= = |
Equal to |
!= |
Not equal to |
> |
Greater than |
< |
Less than |
>= |
Greater than or equal to |
<= |
Less than or equal to |
&& |
and |
|| |
or |
! |
not |
1.2.6 Messages
Messages are programmed in a separate block. A message is displayed in a special field and remains active until a block with a new message is executed or until the end of the program is reached. A message without message text will delete any previous message.
Example:
MSG (“THIS IS A SAMPLE=”, 25*4)
Result:“THIS IS A SAMPLE=100”
1.2.7 Program font color
The following rules apply to the program extension is lowercase iso program:
1. The defaultfonts aregenerallydisplayed in black;
2. Keywordsbluedisplay, andwith otherkeywordsseparatedby the symbol(addition, subtraction sign, comma, dots, semicolons, colons, parenthesesaroundthe small, equal signs, horizontal, spaces, tabsandnewline);
3. Specialsituation:
1)Beginning with ‘//’, green;
2)Beginning with ‘#’, gray(Onlywhen the "#" as the beginning of string);
3)Beginning with ‘ “ ’, brown;
4)Beginning with ‘’ ’, orange, usuallyit requires anothersingle quote ‘ ‘ ’. Aftermatchingtwo single quote,intermediatecharacter becomes orange, indicatesthe characterconstant.