PMAC Product Guide 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 How PMAC Executes a Motion Program Basically, a PMAC program exists to pass data to the trajectory generator routines that compute the series of commanded positions for the motors every servo cycle. The motion program must be working ahead of the actual commanded move to keep the trajectory generators fed with data. PMAC processes program lines either zero, one, or two moves (including DWELL s and DELAY s) ahead.
Calculating one move ahead is necessary in order to be able to blend moves together; calculating a second move ahead is necessary if proper acceleration and velocity limiting is to be done, or a three-point spline is to be calculated ( SPLINE mode). For linear blended moves with I13 (move segmentation time) equal to zero (disabled), PMAC calculates two moves ahead, because the velocity and acceleration limits are enabled here. In all other cases, PMAC is calculating one move ahead.
When a RUN command is given and every time the actual execution of programmed moves progresses into a new move, a flag is set saying it is time to do more calculations in the motion program for that coordinate system. At the next RTI, if this flag is set, PMAC will start working through the motion program processing each command encountered. This can include multiple modal statements, calculation statements, and logical control statements. Program calculations will continue (which means no background tasks will be executed) until one of the following conditions occurs: 1. The next move, a DWELL command or a PSET statement is found and calculated 2. End of, or halt to the program (e.g.
STOP ) is encountered 3. Two jumps backward in the program (from ENDWHILE or GOTO) are performed 4. A WAIT statement is encountered (usually in a WHILE loop) If calculations stop on condition 1 or 2, the calculation flag is cleared and will not be set again until actual motion progresses into the next move (1) or a new RUN command is given (2). If calculations stop on conditions 3 or 4, the flag remains set, so calculations will resume at the next RTI. In these cases, it is an empty (no-motion) loop.
The motion program acts similar to a PLC 0 during this period If PMAC cannot finish calculating the trajectory for a move by the time execution of that move is supposed to begin, PMAC will abort the program, showing a run-time error in its status word. 74 Motion Programs No Moves Ahead Two Moves Ahead One Move Ahead RAPID LINEAR with I13=0 LINEAR with I13>0 HOME SPLINE1 CIRCLE DWELL PVT b1s (step through the program) Ix92=1 (blending disabled)