omron — Learning a Motion Program

PMAC Product Guide PLC PROGRAMS PMAC will stop the scanning of the motion program lines when enough move commands are calculated ahead of time. This feature is called look-ahead and it is necessary to properly blend the moves together and to observe the motion safety parameters. In the following example, PMAC calculates up to the third move and will stop the program scanning until the first move is completed; that is, when more move planning is required: Example:

OPEN PROG 1 CLEAR ; Open program buffer I13=0 ; Two moves ahead of calculation LINEAR INC TA100 TS0 F50 ; Mode commands X1 ; First Move X1 ; Second Move X1 ; Third Move M1=1 ; This line will be executed only after the ; first move is completed CLOSE ; Close written buffer, program one In contrast, enabled PLCs are continuously executed from beginning to end regardless of what any other PLC or motion program is doing. PLCs are called asynchronous because are designed for actions that are asynchronous to the motion. In addition, they are called PLC programs because they perform many of the same functions as hardware programmable logic controllers. PLC programs are numbered 0 through 31.

PLC programs 1-31 are executed in background. Each PLC program executes one scan (to the end or to an ENDWHILE statement) uninterrupted by any other background task (although it can be interrupted by higher priority tasks). In between each PLC program, PMAC will do its general housekeeping and respond to a host command, if any. At power-on\reset PLCC programs run after the first PLC program runs. These are the suggested uses of all the available PLC buffers: • PLC0: PLC program 0 is a special fast program that operates at the end of the servo interrupt cycle with a frequency specified by variable I8 (every I8+1 servo cycles).

This program is meant for a few time-critical tasks and it should be kept small, because its rapid repetition can steal time from other tasks. A PLC 0 that is too large can cause unpredictable behavior and can even trip PMAC’s watchdog timer by starving background tasks of time to execute. • PLC1: This is the first code that PMAC will run on power-up, assuming that I5 was saved with a value of 2 or 3. This makes PLC1 the appropriate PLC to initialize parameters, perform commutated motors phase search and run motion programs. PLC1 can also disable other PLCs before they start running and can disable itself at the end of its execution. • PLC2:

Since PLC1is suggested as an initialization PLC (and can run potentially only once on power- up), PLC2 is the first PLC in the remaining sequence from 2 to 31. This makes PLC2 the ideal place to copy digital input information from I\O expansion boards like the ACC-34 into its image variables. This way, PLCs 3 to 30 can use the input information, writing the necessary output changes to the outputs image variables. • PLC3 to PLC30: PLC programs are useful particularly for monitoring analog and digital inputs, setting outputs, sending messages, monitoring motion parameters, issuing commands as if from a host, changing gains, and starting and stopping moves.

By their complete access to PMAC variables and I/O and their asynchronous nature, they become powerful adjuncts to the motion control programs. PLC Programs 85