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. Please make sure 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.

Note

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

See also

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 box 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 box opens.

  4. Click the Build tab.

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

    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 POUs view.

  2. Select Add Object ‣ Method and type the name of the associated implementation of the runtime system. Click Add to close the dialog box.

    The method is created.

  3. Right-click the method and select Properties.

    The dialog box opens.

  4. Click the Build tab.

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

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