User`s manual

5.0 - Motion Programs
Page - 43
5.3 - Writing a MOTION PROGRAM
1) Open a program buffer with OPEN PROG {constant} where {constant} is an integer from 1 to 32767
representing the motion program to be opened.
2) Motion Programs 1000, 1001, 1002 and 1003 could contain G-codes, M-codes, T-codes and D-codes for
machine tool “G-codes” or RS-274 programming method. Still these buffers could be used for general PMAC
code programming as long as G-codes programming is not needed in PMAC.
3) PMAC can hold up to 256 motion programs at one time. For continuous execution of programs larger than PMAC's
memory space a special PROG0, the rotary motion program buffers, allow for the downloading of program lines
during the execution of the program and for the overwriting of already executed program lines.
4) The CLEAR command empties the currently opened program, PLC, rotary, etc. buffer.
5) Many of the statements in PMAC motion programs are modal in nature. These include move modes, which specify
what type of trajectory a move command will generate; this category includes LINEAR, RAPID, CIRCLE, PVT, and
SPLINE.
6) Moves can be specified either incrementally (distance) or absolutely (location) -- individually selectable by axis -- with
the INC and ABS commands. Move times (TA, TS, and TM) and/or speeds (F), are implemented in modal commands.
Modal commands can precede the move commands they are to affect, or they can be on the same line as the first of
these move commands.
7) The move commands themselves consist of a one-letter axis-specifier followed by one or two values (constant or
expression). All axes specified on the same line will move simultaneously in a coordinated fashion on execution of the
line; consecutive lines execute sequentially (with or without stops in between, as determined by the mode). Depending
on the modes in effect, the specified values can mean, destination, distance, and/or velocity.
8) If the move times (TA, TS, and TM) and/or speeds (F) are not specifically declared in the motion program the default
parameters from the I-variables Ix87, Ix88 and Ix89 will be used instead. You are strongly encouraged not to rely on
these parameters and to declare your move times in the program. This will keep your move parameters with
your move commands, lessening the chances of future errors, and making debugging easier.
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 immediate 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 automatically appends a RETURN
statement to the end of the open program buffer. If any PROGRAM or PLC in PMAC is improperly structured (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