EasyManua.ls Logo

Centroid M400 - Page 181

Centroid M400
302 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
M-Series Operator’s Manual 4/9/15 11-9
GOTO - Branch Execution
To branch to another line within the same program or subprogram, use the statement:
GOTO <expression>
where <expression> is any expression that evaluates to a valid block number in the program. GOTO causes an
immediate branch to the specified destination. Program codes preceding a GOTO on the same line will be
executed normally. Any program codes following GOTO on the same line will cause an error.
If fast branching is disabled (parameter 145 = 0) then the CNC software searches forward in the program for the
first matching block number and resumes searching, if necessary from the top of the program. For this reason when
fast branching is disabled, backward branches take longer than forward branches and backward branch times
depend on the total program size. If the program is sufficiently large, use of the GOTO statement could introduce
temporary pauses.
When fast branching is enabled (parameter 145 = 1) then the CNC software remembers the locations of block
numbers as it finds them during program execution. Backward branches always take place immediately. The first
forward branch to a block not yet encountered will take additional time as the CNC software searches forward for
the block number; however, subsequent forward branches to that block number will take place immediately. The
trade-off for using fast branching is that all line numbers at a given level of program or subprogram must be unique
and programs will use more memory (approximately 16kilobytes of memory for every 1000 block numbers in the
program.)
IF THEN ELSE - Conditional Execution
Program symbols, G codes, M codes and GOTO commands may be executed conditionally using the IF statement.
The general form of the IF statement is:
IF <expression> THEN <execute if true> ELSE <execute if false>
where <expression> is any valid expression, <execute if true> is one or more program codes to execute if
<expression> evaluates to “true” (non-zero) and <execute if false> is one or more program codes to execute if
<expression> evaluates to “false” (zero). All parts of the IF statement must appear on the same line. The
“ELSE <execute if false>” part of the statement is optional and may be omitted. The “THEN” may be
omitted; however, <expression> must be enclosed in brackets ([]). The IF statement may follow other
program codes on the same line. Compound conditionals are possible but they cannot be nested. The first
THEN always pairs with the first IF. ELSE always pairs with the first <expression> that evaluates to “false”.
All program codes executed are executed as part of the same block.
Examples:
; Branch to N200 if machine position is okay, otherwise go to N300
N100 IF #5041 LE 5.0 THEN GOTO 200 ELSE GOTO 300
; Force subprogram parameter #D to be within range.
IF [#D LE 0.005] #[D] = 0.005
; Compound conditionals
IF [#A LE 0.0] GOTO 100 ELSE IF [#A LE 2.5] GOTO 200 ELSE GOTO 300
IF [#A GT 0.0] IF [#D/#A GE 0.0] #[C] = SQRT[#D/#A]

Table of Contents

Related product manuals