omron — Руководство по эксплуатации PMAC - системы контроля движения (EN)

PMAC Quick Reference Guide The CALLx command in a motion program causes a jump to PROG x, with a jump back to the command immediately following the CALL when a RETURN command is encountered. If x is an integer, the jump is to the beginning of PROG x; if there is a fractional component to x, the jump is to line label N(y*100,000) , where y is the fractional part of x. This structure permits the creation of special subprograms, either as a single subroutine, or as a collection of subroutines, that can be called from other motion programs. The PRELUDE command allows creating an automatic subprogram call before each move command or other letter-number command in a motion program.

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). Letters N or O cannot be passed. This structure is useful particularly for creating machine tool style programs in which the syntax must consist solely of letter number combinations in the parts program.

Since PMAC treats the G, M, T, and D codes as special subroutine calls, the READ statement can be used to let the subroutine access values on the part-program line after the code. The READ statement also provides the capability of seeing what arguments have actually been 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. Example:

close delete gather undefine all #1->2000X open prog1 clear LINEAR INC TA100 TS0 F50 ;Mode and timing parameters gosub 100 H10 ;Subroutine call passing parameter H with value 10 return ;End of the main program section (execution ends) n100 ;Subroutines section. First subroutine labeled 100 read(h) ;Read the H parameter value passed IF (Q100 & $80 > 0) ;If the H parameter has been passed …

X(Q108) ;Use the H parameter value contained in Q108 endif return ;End of the subroutine labeled 100 close ;End of the motion program code G, M, T, and D-Codes (Machine-Tool Style Programs) PMAC permits the execution of machine tool style RS-274 (G-Code) programs by treating G, M, T, and D codes as subroutine calls. This permits the machine tool manufacturer to customize the codes for their own machine, but it requires the manufacturer to do the actual implementation of the subroutines that will execute the desired actions. When PMAC encounters the letter G with a value in a motion program, it treats the command as a call to motion program 10n0, where n is the hundreds’ digit of the value.

The value without the hundreds’ digit (modulo 100 in mathematical terms) controls the line label within program 10n0 to which operation will jump – this value is multiplied by 1000 to specify the number of the line label. When a return statement is encountered, it will jump back to the calling program. 48 Motion Programs