Macro Language Runtime Environment
Valid for S300, S700
Table of Contents
Up to 7 different execution tasks for an application program can be used, one interrupt task, up to 32 error handling procedures and unlimited number of user defined programs.
All procedures are definable with:
PROGRAM "task-name"
...
END_PROGRAM
There are some predefined names for the "task-name":
- PLCINIT
- PLCMAIN
- PLC62
- PLC250
- PLC1
- PLC4
- PLC16
- PLCIRQ
- ERRORxx with xx=1...32
The calls for the routines with the predefined names are handled by the operating system of the S300/S700. All other names can be used for user defined programs.
Call of these programs with a sequence like:
FUNCTION(CALC_DATA);
can occur at any place inside the PLC program. The according function would like this:
PROGRAM CALC_DATA ... END_PROGRAM
Program initialization
The user procedure PLCINIT is called once at power up of the S300/700. The PLINIT task should be the first program in the application source code due to the sequential compiling process. It makes sense to define and initialize variables in this task.
Example:
PROGRAM PLCINIT LONG TEST:=10; END_PROGRAM ;
This example will define a variable TEST and will initialize it with 10.
Interrupt routines
The user procedure PLCIRQ allows to execute a very short application program interrupt driven by a rising edge of digital Input 2. Input 1 is not available. This program has to be very fast to not disturb the multitasking system of the servo amplifier.
Example:
PROGRAM PLCIRQ LATCHDATA := DATA ; LATCHFLAG := 1 ; END_PROGRAM ;
This program will latch the actual value of the variable DATA in the moment of the rising edge of input 2. The flag LATCHFLAG will signalize that the data is latch to a low priority application task. Also it is possible to poll the data via a fieldbus.
PLCn
The user procedure PLC62,PLC250,PLC1, PLC4 and PLC16 are called every 62 µs, 250 µs, 1 ms, 4ms, 16ms. The code in these procedures should not be very time consuming. These locations are ideal for some PLC polling features.
Example:
PROGRAM PLC4 OUTPUT1 := FLAG1 & FLAG2 ; END_PROGRAM
This program will be executed every 4ms and will serve OUTPUT1 with internal data.
ERRORnn Exceptions
The user error handling procedure ERRORnn (nn=01..32) will be called if ERRORnn occurs. The user can place some fast emergency stop routines in these procedures.
Example:
PROGRAM ERROR04 OUTPUT1 := 1 ; END_PROGRAM
This program will set Output1 in case of Error 04.
Note: These are the same as the standard error codes displayed on the drive's front display.
PLCMAIN
The user application program should be stored in the background task PLCMAIN. Here even slow routines will not disturb the S300/S700 multitasking. Terminal or Display Communication should be done within this task.
Example:
PROGRAM PLCMAIN BYTE VAR; DO WHILE ...; END_WHILE; END_PROGRAMBack to top