112
96-8000 Rev AC
May 2010
Here, the conditional is for the M99 portion of the statement only. The machine
tool is instructed to X0, Y0 whether or not the expression evaluates to True or
False. Only the branch, M99, is executed based on the value of the expression.
It is recommended that the IF GOTO version is used if portability is desired.
Conditional Execution (IF THEN)
Execution of control statements can also be achieved by using the IF THEN
construct. The format is:
IF [<conditional expression>] THEN <statement>;
Note: To preserve compatibility with FANUC syntax “THEN” may not be
used with GOTOn.
This format is traditionally used for conditional assignment statements such as:
IF [#590 GT 100] THEN #590=0.0 ;
Variable #590 is set to zero when the value of #590 exceeds 100.0. In the Haas
control, if a conditional evaluates to FALSE (0.0), then the remainder of the IF
block is ignored. This means that control statements can also be conditioned
so that we could write something like:
IF [#1 NE #0] THEN G1 X#24 Y#26 F#9 ;
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 ini
-
tialized to contain any value. Otherwise, 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 state-
ments 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 condi
-
tion. Macros allow flexibility with the WHILE-DO-END construct. For example:
Содержание 96-8000
Страница 15: ...6 96 8000 Rev AC May 2010 Mill Warning Decals ...
Страница 16: ...7 96 8000 Rev AC May 2010 Safety Lathe Warning Decals ...
Страница 41: ...32 96 8000 Rev AC May 2010 ...
Страница 93: ...84 96 8000 Rev AC May 2010 ...
Страница 129: ...120 96 8000 Rev AC May 2010 ...
Страница 133: ...124 96 8000 Rev AC May 2010 ...
Страница 268: ......
Страница 269: ......