1 0 0
Macros
96-8000 rev R June 2007
This executes a linear motion only if variable #1 has been assigned a value. Another example is:
IF [#1 GE 180] THEN #101=0.0 M99 ;
This says that if variable #1 (address A) is greater than or equal to 180, then set variable #101 to zero and return
from the subroutine.
Here is an example of an IF statement that branches if a variable has been initialized to contain any value. Other-
wise, processing will continue and an alarm will be generated. Remember, when an alarm is generated, program
execution is halted.
N1 IF [#9NE#0] GOTO3 (TEST FOR VALUE IN F) ;
N2 #3000=11(NO FEED RATE) ;
N3 (CONTINUE) ;
Iteration/Looping (WHILE DO END)
Essential to all programming languages is the ability to execute a sequence of statements a given number of times
or to loop through a sequence of statements until a condition is met. Traditional G coding allows this with the use of
the L address. A subroutine can be executed any number of times by using the L address.
M98 P2000 L5;
This is limited since you cannot terminate execution of the subroutine on condition. Macros allow flexibility with the
WHILE-DO-END construct. For example:
WHILE [<conditional expression>] DOn;
<statements>;
ENDn;
This executes the statements between DOn and ENDn as long as the conditional expression evaluates to True. The
brackets in the expression are necessary. If the expression evaluates to False, then the block after ENDn is ex-
ecuted next. WHILE can be abbreviated to WH. The DOn-ENDn portion of the statement is a matched pair. The
value of n is 1-3. This means that there can be no more than three nested loops per subroutine. A good example of
how nesting of WHILE loops can be used is in defining a matrix.
#101= 3;
#102= 4;
G0 X#101 Y4. ;
F2.5;
WH [#101 GT 0] DO1;
#102= 4;
WH [#102 GT 0] DO2;
G81 X#101 Y#102 Z-0.5;
#102= #102 - 1;
END2;
#101= #101 - 1;
END1;
;
M30;
This program drills a 3 x 4 matrix hole pattern.
Although nesting of WHILE statements can only be up to three levels, there really is no limit since each subroutine
can have up to three levels of nesting. If there is a need to nest to a level greater than 3, then the segment containing
the three lowest levels of nesting can be made into a subroutine thus overcoming the limitation.
Содержание Mill
Страница 12: ...96 8000 rev R June 2007 Safety 5 ...
Страница 14: ...96 8000 rev R June 2007 Safety 7 LATHE WARNING DECALS ...
Страница 15: ...8 Safety 96 8000 rev R June 2007 ...
Страница 17: ...10 Introduction 96 8000 rev R June 2007 ...
Страница 117: ...110 4 5 Axis Programming 96 8000 rev R June 2007 ...
Страница 199: ...Settings 192 96 8000 rev R June 2007 ...
Страница 213: ...206 Maintenance 96 8000 rev R June 2007 ...