9 8
Macros
96-8000 rev R June 2007
Unconditional Branch (GOTOnnn and M99 Pnnnn)
In the Haas control, there are two methods of branching unconditionally. An unconditional branch will always branch
to a specified block. M99 P15 will branch unconditionally to block number 15. The M99 can be used whether or not
macros is installed and is the traditional method for branching unconditionally in the Haas control. GOTO15 does the
same as M99 P15. In the Haas control, a GOTO command can be used on the same line as other G-codes. The
GOTO is executed after any other commands like M codes.
Computed Branch (GOTO#n and GOTO [expression])
Computed branching allows the program to transfer control to another line of code in the same subprogram. The
block can be computed as the program is running, using the GOTO [expression] form. Or the block can be passed
in through a local variable, as in the GOTO#n form.
The GOTO will round the variable or expression result that is associated with the Computed branch. For instance, if
#1 contains 4.49 and GOTO#1 is executed, the control will attempt to transfer to a block containing N4. If #1
contains 4.5, then execution will transfer to a block containing N5.
The following code skeleton could be developed to make a program that ads serial numbers to parts:
O9200
(Engrave digit at current location.)
;
(D=Decimal digit to engrave);
IF [[#7 NE #0] AND [#7 GE O] AND [#7 LE 9]] GOTO99;
#3000=1
(Invalid digit)
;
N99
#7=FIX[#7]
(Truncate any fractional part)
;
;
GOTO#7
(Now engrave the digit) ;
;
N0
(Do digit zero)
...
M99
;
N1
(Do digit one)
;
M99
;
N2
(Do digit two)
;
...
;
(etc.,...)
With the above subroutine, you would engrave digit five with the following call:
G65 P9200 D5;
Computed GOTOs using expression could be used to branch processing based on the results of reading hardware
inputs. An example might look like the following:
Summary of Contents for Mill
Page 12: ...96 8000 rev R June 2007 Safety 5 ...
Page 14: ...96 8000 rev R June 2007 Safety 7 LATHE WARNING DECALS ...
Page 15: ...8 Safety 96 8000 rev R June 2007 ...
Page 17: ...10 Introduction 96 8000 rev R June 2007 ...
Page 117: ...110 4 5 Axis Programming 96 8000 rev R June 2007 ...
Page 199: ...Settings 192 96 8000 rev R June 2007 ...