Delta Tau GEO BRICK LV User Manual

Page of 440
Turbo PMAC User Manual 
Writing and Executing Motion Programs
 
327
 
Passing Arguments to Subroutines 
These subprogram calls are made more powerful by use of the READ statement.  The READ statement in 
the subprogram can go back up to the calling line and pick off values (associated with other letters) to be 
used as arguments in the subprogram.  The value after an A would be placed in variable Q101 for the 
coordinate system executing the program, the value after a B would be placed in Q102, and so on (Z 
value goes in Q126).   
This structure is particularly useful for creating machine-tool style programs, in which the syntax must 
consist solely of letter-number combinations in the parts program.  Since Turbo PMAC treats the G, M, T, 
and D codes as special subroutine calls (see below), the READ statement can be used to let the subroutine 
access values on the part-program line after the code. 
Example 
For example, the command CALL500 X10 Y20 causes a jump to the top of PROG 500.  If, at the top 
of PROG 500, there is the command READ(X,Y), the value with X will be assigned to Q124 (X is the 
24th letter) and the value with Y will be assigned to Q125.  Now the subroutine can work with the values 
of Q124 and Q125 (in this case, 10 and 20, respectively), processing them as needed. 
What Has Been Passed? 
The READ statement also provides the capability of seeing what arguments have actually been passed (the 
letters listed in the READ statement are those that can be passed).  The bits of Q100 for the coordinate 
system are used to note whether arguments have been passed successfully; bit 0 is 1 if an A argument has 
been passed, bit 1 is 1 if a B argument has been passed, and so on, with bit 25 set to 1 if a Z argument has 
been passed.  The corresponding bit for any argument not passed in the latest subroutine or subprogram 
call is set to 0. 
If the logic of the subroutine needs to know whether a certain argument has been passed to it or not, it 
should use the bit-by- bit AND operator (&) between Q100 and the value of the bit in question.  The value 
of bit 0 is 1, of bit 1 is 2, of bit 2 is 4, and so on (bit value is 2
N-1
, for the Nth letter of the alphabet).  For 
instance, to see if a D-argument has been passed, the condition would be: 
IF (Q100 & 8 > 0) ... 
D is the 4th letter, so the bit value is 2
3
 = 8.  To see if an S argument has been passed – S is the 19th letter, 
so the bit value is 2
18
 = 262,144 – the condition would be: 
IF (Q100 & 262144 > 0) ... 
The READ statement instructions in the Program Command Specification section of the manual show the 
Q-variable, bit number, and bit value for each letter’s argument. 
PRELUDE Subroutine Calls 
Turbo PMAC allows the creation of an automatic subprogram call before each move command or other 
letter-number command in a motion program or section of a motion program.  If the subprogram starts 
with a READ command, then the move command or letter-number command itself is turned arguments for 
the subprogram call.  This functionality is very useful for executing canned cycles in machine-tool style 
programs, or for turning ordinary move commands into arguments for a subprogram that executes inverse 
kinematic or similar calculations. 
This capability is accomplished through the motion-program PRELUDE command.  To turn on the 
function, declare PRELUDE1 in the motion program, followed by the subprogram call you wish to be 
executed before each subsequent move command or letter-number command.  This subprogram call can 
be declared with a CALL command, or a GMT, or D-code, any of which is a special subprogram call.  In 
PRELUDE1 declaration the value in the subprogram call specifying which subprogram and which line 
must be a constant; it cannot be a variable or expression.