Using FB_Code to create device templates

If there are several identical devices, FB_Code can be used to create a template. Multiple instances of the generated FB can be accessed via the device instance number of the peer device.

In the following sample, the generated FB has been renamed to represent a more general FB implementation. It is recommended to use the refactoring function of TwinCAT to avoid naming conflicts.

Three instances are declared in MAIN and called cyclically.

Using FB_Code to create device templates 1:

Please note that you call the adapter FB only once!

Sample:

Rename FB_Code

Using FB_Code to create device templates 2:

Cyclic calls in MAIN:

Using FB_Code to create device templates 3: