omron — Writing a Motion Program

PMAC Product Guide 5. Moves can be specified 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. 6. 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. 7. 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. Do not to rely on these parameters and to declare the move times in the program.

This will keep the move parameters with the move commands, lessening the chances of future errors and making debugging easier. 8. 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 . GOSUB and CALL statements can be nested only 15 deep. 9. 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 be 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 Motion Programs 71