User's Manual

PMAC User Manual
200 Writing Programs for PMAC
Sequential Moves
If the program is in LINEAR, CIRCLE, PVT, or SPLINE mode, and there is more than one move
command line in a program without a DWELL or DELAY in between (there can be other statements in
between), the moves will blend together without stopping. The exact form of the blending will depend on
the move mode in force (see the Program Trajectory section of this manual). However, if Ix92 for the
coordinate system (Move Blend Disable), this blending capability is disabled.
Adding Logic
A little logic can be added to make the language more powerful. Suppose we wanted to repeat the above
sequence 100 times. Rather than repeating the above statements 100 times, we can create a loop:
F5000
P1=0
WHILE (P1<100)
X10000
DWELL1000
X0
DWELL1000
P1=P1+1
ENDWHILE
Notice that the F5000 statement is not inside the loop. By putting it before the loop, we save PMAC
from having to interpret and execute the statement every time through the loop. Since it is a modal
statement, its effect stays in force. This is not essential, but if loop time is very short, it can make a
difference.
Line Labels
It is possible to put line labels in the motion program to mark particular sections of the program. The
syntax for a line label is N{constant} or O{constant}, where {constant} is an integer from 1
to 262,143.
Notice that these are line labels, not line numbers (even though they are specified by number). A line
does not require a label; and the labels do not need to be in numerical order. These line labels are used
only to specify the jumps in GOTO, GOSUB, and CALL commands (all discussed below).
GOTO Command
PMAC provides a GOTO{data} command in its motion program syntax, which causes a jump to line
label N{data} in the same motion program (without return). In general, the use of GOTO commands is
strongly discouraged, because of the tendency to build up programs that are very hard to decipher.
However, when the {data} in a GOTO command is a variable or expression (e.g. GOTO(P20), it can be
used to build the equivalent of a structured CASE statement, creating a multiple-pronged branching point.
Adding Variables and Calculations
Motion programs can be made a lot more flexible with the use of variables and mathematical calculations.
The above example program will command the same moves with the same timing every time it is
executed. If any parameter for the program would need to be changed, the entire program would need to
be re-entered (or a different program used). However, if we use variables in place of the constants, we
only need to change variable values to change the action of the program:
F(P2)
P1=0
WHILE (P1<P3)
X(P4)
DWELL(P5)
X0