omron — Passing Arguments to Subroutines

PMAC Product Guide 9. For troubleshooting purposes, change the feedrate override to a lower than 100% value. If the program is run for the first time, a preceding %10 command can be issued to run the motion program in slow motion. Running the program slowly will allow observing the programmed path more clearly, it will demand less calculation time from PMAC and it will prevent damages due to potentially wrong acceleration and/or feedrate parameters. 10. A motion program can be stopped by sending a &1a or a CTRL+A command which will stop any motion taking place in PMAC. 11.

If the motion of any axis becomes uncontrollable and should be stopped, a CTRL+K command can be issued killing all the motors in PMAC (disabling the amplifier enable line if connected). However, the motor will come to a stop in an uncontrollable way and might proceed to move due to its own inertia. 12. In addition, a motion program can be stopped by issuing a CTRL+Q command. The last programmed moves in the buffer will be completed before the program quits execution. It can be resumed by issuing an R command alone without first pointing to the beginning of the buffer by the B command.

Subroutines and Subprograms It is possible to create subroutines and subprograms in PMAC motion programs to design well-structured modular programs with re-usable subroutines. The GOSUBx command in a motion program causes a jump to line label Nx of the same motion program. Program execution will jump back to the command immediately following the GOSUB when a RETURN command is encountered. This creates a subroutine. 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. Motion Programs 73