Chapter 2. Program Organization
12
PACSystems* RX7i, RX3i and RSTi-EP CPU Programmer's Reference Manual
GFK-2950C
Creating UDFB Instances
You create an instance of a UDFB by calling it in your logic and assigning an instance name in the
function properties.
Figure 4: Creating a User-Defined Function Block
In the following LD example, the first rung creates two instances of the UDFB, Motors. The instance
variables associated with the instances are motors.motor1 and motors.motor2. The second rung
uses the two instances of the internal variable
temp
in logic.
Figure 5: Use of User-Defined Function Block in Ladder Logic
Instance Data Structures
A variable with the format
function_block_name.instance_name
is
automatically created for each instance of a UDFB. The instance data
makes up a single composite variable that is of a structure type. The
example to the right shows the variable structures associated with two
instances of the UDFB named Motors. Each instance variable has
elements corresponding to parameters
In1, Out1
, and
Y0
, and internal
variables
modelno, speed,
and
temp
.
Instances are created as symbolic variables, never as mapped variables.
This ensures that instance data is only referenced by the instance name
and not by a memory address, which means that no aliases can be
created for the UDFB data elements. The indirect reference operator
cannot be used on an instance variable because indirect references are
not permitted on symbolic variables.
Figure 6: Display of
Instance Data
Structures
UDFBs and Scope
Unlike a parameterized subroutine, a UDFB has its own %L memory.
By default, internal variables of a UDFB have local scope, making them visible only to the logic inside
the UDFB. They cannot be read or written by any external logic or by the hardware configuration. An
internal variable can be made visible outside the UDFB by changing its scope to global. Logic outside
the UDFB can read but cannot write to internal variables whose scope is global.
Note:
If you give internal variables global scope, your application will not conform to IEC
requirements.
Summary of Contents for PACSystems RSTi-EP
Page 357: ......
Page 466: ...Chapter 9 Diagnostics GFK 2950C February 2018 451 ...