User's Manual

PMAC User Manual
212 Writing Programs for PMAC
Preparing to Run
To prepare to run a rotary program in a coordinate system, use the B0 command (go to Beginning of
program zero — the rotary program) when addressing that coordinate system. This must be done when
no buffers are open, or it will be interpreted as a B-axis command. Once prepared this way, the program
is started with the R command. This command can be either given with the buffer open or closed. If the
R command is given for an empty rotary buffer, the buffer will simply wait for a command to be given to
it, then execute that command immediately.
Opening for Entry
The OPEN ROT command opens all of the rotary program buffers that have been defined. Program lines
following this are sent to the buffer for the host-addressed coordinate system (&n). Most users of rotary
program buffers will have only one coordinate system, so this will not be of concern to them, but it is
possible to switch coordinate systems on the fly and use several rotary buffers at once.
It is important to realize that after the OPEN ROT command, PMAC is treating as many commands as
possible as buffered commands, even if it is executing them immediately (some commands mean one
thing as an on-line command, and another thing as a buffered command). For instance, an I100
command is a request for a value of I-variable 100 when buffers are closed, but it is a command to do a
full circle with a 100-unit radius when a motion program buffer is open (the I-value is the X-axis
component of the radial vector. Since no axis positions are given, they are all assumed to be the same as
the starting point).
Staying Ahead of Executing Line
The key to the handling of a rotary program buffer is knowing how many lines ahead the program is; that
is, how many program lines have been loaded ahead of the program line that PMAC is executing.
Typically, load ahead until a certain number of lines ahead is reached, and then wait until the program
catches up to within a smaller number of lines ahead. A real-time application may work one line ahead of
the executing line; an application doing periodic downloading of a huge file may get 1000 lines ahead,
then start again when the program has caught up to within 500 lines.
PR Command
The PR (program remaining) command returns the number of lines ahead. This provides a simple polling
scheme, but one that is probably not good for tight real-time applications.
BREQ Interrupt
For tightly coupled applications, there are hardware lines to handle the handshaking for the rotary buffer,
and variables to control the transition points of the lines. The BREQ (Buffer Request) line goes high
when the rotary buffer for the addressed coordinate system wants more program lines, and it goes low
when it does not. This line is wired into PMAC PC's programmable interrupt controller, so it can be used
to generate an interrupt to the host PC. The complement, BREQ/, is provided on the JPAN connector. In
addition, there is a Buffer Full (BREQ/) status bit for each coordinate system.
I17 Stops Interrupts
Variable I17 controls how many lines ahead the host can load and still get BREQ true. If a program line
is sent to a rotary buffer, BREQ is taken low, at least temporarily. If still less than I17 lines ahead of the
executing line, BREQ is taken high again, which can generate an interrupt. If I17 or more lines ahead,
BREQ is left low. When a rotary program buffer is entered with OPEN ROT or change the addressed
coordinate system, BREQ is taken low, and then set high if the buffer is less than I17 lines ahead of the
executing point.