User's Manual

PMAC User Manual
198 Writing Programs for PMAC
Entering a Motion Program
The motion program statements are entered one program buffer at a time into PMAC. For each program
buffer, the first step is to open the buffer for entry with the OPEN PROG n command (where n is the
buffer number – with a range of 1 to 32,767). Next, if there is anything currently in the buffer that should
not be kept, it should be emptied with the CLEAR command. Existing lines cannot be edited or new lines
cannot be inserted between existing lines. However, new lines can be appended to the end (with, of
course, the option of clearing the whole buffer first).
Typically, in program development, the editing will be done in a host-based text editor such as the PMAC
Executive Program editor, and the old version of the PMAC program buffer is cleared every time the new
version is downloaded to the card. After the last of the program statements is downloaded, a CLOSE
command should be sent to the card to close the program buffer.
It is a good idea to issue a few commands before the OPEN PROG n command to make sure the buffer
space is ready for the program statements. First, make sure that no motion programs are currently
executing (except for rotary programs). The A (for the addressed coordinate system) or <CTRL-A> (for
all coordinate systems) abort command can be used to make sure execution has stopped. Also make sure
that no other buffer is open; use the CLOSE command for this. Next, to make sure that all the open buffer
space has not been taken up with a data gathering buffer; use the DELETE GATHER command for this.
All of these (on-line) commands can be included in the editor file with the actual motion program
statements, even though they are not part of the actual program. They would not be reported as part of the
program if PMAC were asked to LIST PROG n. (The PMAC Executive program editor, as part of its
Upload function, appends these commands to the returned program.)
The advisable format to use when working in a text editor is:
A
CLOSE
DELETE GATHER
OPEN PROG n
CLEAR
{program statements}
CLOSE
After the program has been downloaded and the buffer closed, a coordinate system that is to execute this
program must be pointed to the program with the B command. For example, B6 would point the
addressed coordinate system's program counter to the beginning of motion program 6. This can be
confirmed with the PC (program counter) query command, which should return P6:0 if it is pointing to
the top of program 6. If it returns a <BELL> character, it is not pointing to any valid program. Once the
coordinate system is pointing to the top of the program, execution can be started with the R command.
The B and the R commands can be combined into one command line, such as B6R.
Learning a Motion Program
It is possible to have PMAC learn lines of a motion program using the on-line LEARN command. In this
operation, the axes are moved to the desired position and the command is given to PMAC. PMAC then
adds a command line to the open motion program buffer that represents this position. This process can be
repeated to learn a series of points.
The motors can be open loop or closed loop as they are moved around. At the time of the LEARN
command, PMAC reads the motor commanded positions (in open-loop, commanded positions are always
equal to actual positions) and converts them to axis positions by effectively executing a PMATCH
command, inverting the axis definition equations.