Skip to main content

Function Block — Calling Functions or Methods with External Implementation

A runtime system can include the implementation of a function block, function, or method (for example, from a library). If you create a POU in your application with the same name by using the External implementation without an implementation, then you can execute the existing implementation. Note here that you declare local variables only in an external function block. External functions and methods must not contain local variables.

When the application is downloading, CODESYS searches for and links the associated implementation in the runtime system for each external POU.

Tip

Objects with the property External implementation are postfixed with (EXT) after the object name in the Devices or POUs view.

For more information, see: Build

Creating POUs with external implementation

  1. Click Project → Add Object → POU.

  2. Activate Function block, Method, or Function and specify the name of the associated implementation of the runtime system. Close the dialog by clicking Add.

    The runtime system POU is created in the POUs view. The name is postfixed with (EXT).

  3. Right-click the POU and select Properties.

    The dialog opens.

  4. Click the Build tab.

  5. Select the External implementation (Late link in the runtime system) option.

    The POU is declared and you can implement a POU call.

Creating methods with external implementation

  1. Select a function block in the device tree or in the POU view.

  2. Select Add Object → Method and specify the name of the associated implementation of the runtime system. Click Add to exit the dialog.

    The method is created.

  3. Right-click the method and select Properties.

    The dialog opens.

  4. Click the Build tab.

  5. Select the External implementation (Late link in the runtime system) option.

    The method is declared and you can implement a method call. The method name is postfixed with (EXT) in the Devices or POUs view.