This example illustrates the typical connection of a three-stage enable switch S1 to the safety-related SF_EnableSwitch function block. The two signals resulting from the enable switch are connected to input terminals 1.1 and 2.1 of the safety-related input device PSDI 1.
- The signal of the safety-related input terminal 1.1 of the safety-related input device PSDI 1 is assigned to the global I/O variable SwitchControl1_In. This global I/O variable is connected to the S_EnableSwitchCh1 input of the function block for evaluation.
- Likewise, the following applies to the second channel of the enable switch: the signal of the safety-related input terminal 1.1 of the safety-related input device PSDI 1 is assigned to the global I/O variable SwitchControl2_In. This global I/O variable is connected to the S_EnableSwitchCh2 input of the function block for evaluation.
The function block is perpetually activated by the TRUE constant at the Activate input.
A restart inhibit is set via S_AutoReset. This inhibit becomes active after a valid signal sequence returns at the function block inputs S_EnableSwitchCh1 and/or S_EnableSwitchCh2. The Reset button S2 for removing the restart inhibit is connected to input terminal 1.1 of the standard input device DI 1.
Note
Typically, you set the operating mode at input S_SafetyActive by means of a mode selector switch in conjunction with the safety-related SF_ModeSelector function block, as shown in the second application example. If it can be ensured that the operating mode is active without a confirmation, you can apply a constant SAFETRUE signal to input S_SafetyActive instead. |
Note
In the example, the enable signal at the S_EnableSwitchOut output controls the removal of safeguarding. To this end, the S_EnableSwitchOut enable output is connected to other safety-related function blocks or functions. |
S2 | Reset |
 | See second note above the illustration. |
The IEC 61131-3 standard defines function block instantiation. Instantiation means, a function block is defined once and can be used (instantiated) several times. This applies to all FBs (user-defined POUs as well as library FBs, such as IEC standard FBs, firmware FBs, user library FBs).
Why instantiation?
A function block has an internal memory where it stores its own processing data (local variables). As a consequence, the output values calculated by the FB depend on the internally stored values. The same input values applied to an FB instance do not necessarily deliver the same results in another FB instance.
Therefore, it is necessary to store the internal data of the FB to a separated memory area each time the function block is processed, i.e., for each FB instance. To uniquely identify each FB instance and to clearly separate its memory area, instance names are used.
The instance name of the function block has to be declared in the 'Variables' table of the POU where the FB is going to be used.
The following applies:
- Function blocks can be instantiated in other function blocks or in program POUs. Calling FBs in function POUs is not possible.
- Functions are called without instantiation because they do not have an internal memory.
Safety-related and standard (non-safety-related) code is strictly distinguished in PLCnext Engineer. If a Safety PLC is included in your project, the following applies:
- Safety-related FBs can only be instantiated in safety-related POUs but not in standard (non-safety-related) POUs.
- User-defined standard FBs can only be instantiated in standard POUs. They cannot be called in safety-related POUs.
- Particular standard firmware FBs can be instantiated in both safety-related and standard POUs.
Note
When inserting a standard FB into a safety-related SNOLD network, the rules for implicit type conversion (safety-related to standard) apply. |
Example for the instantiation of a user-defined function block
The user-defined function block 'TLC' ("Two Level Controller") is added to the 'Functions & Function Blocks' category (COMPONENTS area). It shall be called twice in the program POU 'Container' to control the filling level and the temperature of a boiler.
For both FB instances, an instance name declaration is added to the 'Variables' table of the calling program POU 'Container': TLCTemperature and TLCLevel. Thus the 'TLC' function block can be called twice in the code worksheet of the calling POU by means of these instance names.
Both FB instances have been inserted into the 'Container' code worksheet, each instance with different variables connected to its input and output formal parameters ('Level...' and 'Temperature...').