Reference Guide

PMAC Quick Reference Guide
46 Motion Programs
9. In a motion program, PMAC has WHILE loops and IF..ELSE branches that control program flow.
These constructs can be nested indefinitely. In addition, there are GOTO statements, with either
constant or variable arguments (the variable GOTO can perform the same function as a CASE
statement). GOSUB statements (constant or variable destination) allow subroutines to be executed
within a program. CALL statements permit other programs to be entered as subprograms. Entry to
the subprogram does not have to be at the beginning -- the statement CALL 20.15000 causes entry
into Program 20 at line N15000. GOSUBs and CALLs can be nested only 15 deep.
10. The CLOSE statement closes the currently opened buffer. This should be used immediately after the
entry of a motion, PLC, rotary, etc. buffer. If the buffer is left open, subsequent statements that are
intended as on-line commands (e.g. P1=0) will get entered into the buffer instead. It is good practice
to have close at the beginning and end of any file to be downloaded to PMAC. When PMAC receives
a CLOSE command, it appends a RETURN statement to the end of the open program buffer
automatically. If any program or PLC in PMAC is structured improperly (e.g. no ENDIF or
ENDWHILE to match an IF or WHILE), PMAC will report an ERR003 at the CLOSE command for
any buffer until the problem is fixed.
Example:
close ; Close any buffer opened
delete gather ; Erase unwanted gathered data
undefine all ; Erase coordinate definitions in all coordinate systems
#1->2000X ; Motor #1 is defined as axes X
OPEN PROG 1 CLEAR ; Open buffer to be written
LINEAR ; Linear interpolation
INC ; Incremental mode
TA100 ; Acceleration time is 100 msec
TS0 ; No S-curve acceleration component
F50 ; Feedrate is 50 Units per Ix90 msec
X1 ; One unit of distance, 2000 encoder counts
CLOSE ; Close written buffer, program one
Running a Motion Program
1. Select the coordinate system where the motion program will be running. This is done by issuing the
& command followed by the coordinate system number, e.g., &1 for the coordinate system one.
2. Select the program that to run with the B{constant} command, where the {constant}
represents the number of the motion program buffer. Use the B command to change motion
programs, and after any motion program buffer has been opened. It is not necessary to use it if
running the same motion program repeatedly without modification; when PMAC finishes executing a
motion program, the program counter for the coordinate system is set automatically to point to the
beginning of that program, ready to run it again.
3. Once it is pointing to the motion program to run, issue the command to start execution of the
program. For continuous execution of the program, use the R command (<CTRL-R> for all
coordinate systems simultaneously). The program will execute all the way through unless stopped by
command or an error condition.
4. To execute just one move or a small section of the program, use the S command (<CTRL-S> for all
coordinate systems simultaneously). The program will execute to the first move DWELL, DELAY, or
if it first encounters a BLOCKSTART command, it will execute to the BLOCKSTOP command.