Beckhoff Automation GmbH & Co. KG TX1200 — 2.1 Project Components

A Brief Introduction to TwinCAT PLC Control Function block Instances Reproductions or instances (copies) of a function block can be created. Each instance possesses its own identifier (the Instance name), and a data structure which contains its inputs, outputs, and internal variables. Instances are declared locally or globally as variables, whereas the name of the function block is indicated as the type of an identifier. Example of an instance with the name INSTANCE of the FUB function block: INSTANCE: FUB; Function blocks are always called through the instances described above.

Only the input and output parameters can be accessed from outside of a function block instance, not its internal variables. Example for accessing an input variable: The function block FB has an input variable in1 of the type INT. PROGRAM prog VAR inst1:fb; END_VAR LD 17 ST inst1.in1 CAL inst1 END_PROGRAM The declaration parts of function blocks and programs can contain instance declarations. Instance declarations are not permitted in functions. Access to a function block instance is limited to the POU in which it was declared unless it was declared globally. The instance name of a function block instance can be used as the input for a function or a function block.

All values are retained from one execution of the function block to the next. Therefore, calls of a function block with the same arguments do not always return the same output values! If the function block contains at least one retain variable, the entire instance is stored in the retain area. TX1200 12 Version: 1.3