Chapter 6. Program OrganizationGFK-2816F August 2015 105Creating UDFB InstancesYou create an instance of a UDFB by calling it in your logic and assigning an instance namein the function properties.In the following LD example, the first rung creates two instances of the UDFB, Motors. Theinstance variables associated with the instances are motors.motor1 and motors.motor2. Thesecond rung uses the two instances of the internal variable temp in logic.Instance Data StructuresA variable with the format function_block_name.instance_name isautomatically created for each instance of a UDFB. The instance datamakes up a single composite variable that is of a structure type. Theexample to the right shows the variable structures associated with twoinstances of the UDFB named Motors. Each instance variable haselements corresponding to parameters In1, Out1, and Y0, and internalvariables modelno, speed, and temp.Instances are created as symbolic variables, never as mappedvariables. This ensures that instance data is only referenced by theinstance name and not by a memory address, which means that noaliases can be created for the UDFB data elements. The indirectreference operator cannot be used on an instance variable becauseindirect references are not permitted on symbolic variables.UDFBs and ScopeUnlike 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 thelogic inside the UDFB. They cannot be read or written by any external logic or by thehardware configuration. An internal variable can be made visible outside the UDFB bychanging its scope to global. Logic outside the UDFB can read but cannot write to internalvariables whose scope is global.Note: If you give internal variables global scope, your application will not conform to IECrequirements.