Skip to main content

Object: POUs for Implicit Checks

You can add these special POUs to an application to provide them with implicit monitoring functions. At runtime, these functions check the limits of arrays or subrange types, the validity of pointer addresses, and division by zero. Note: This option can be disabled for devices that are already equipped with these kinds of monitoring blocks by a special implicit library.

The Add Object → POU for Implicit Checks command is used to add it to the application. The command opens the Add POU for Implicit Checks dialog where you can select a monitoring function type (see table below). Depending on the monitoring function, you have to edit the implementation code or create it yourself from scratch.

To prevent multiple inclusions, monitoring functions that have already been inserted are disabled in the Add POU for Implicit Checks dialog.

For more information, see: Using POUs for Implicit Checks

Important

To get the feature for monitoring functions, do not edit the declaration part. However, you are permitted to add local variables.

After removing an implicit monitoring function (example: Check Bounds) from the project, only a download is possible, not an online change. A corresponding message is displayed.

Tip

By default, CODESYS does not run implicit checks for function blocks from libraries used in the application. However, you can extend the check to the libraries by opening the Properties dialog of the application and specifying the compiler definition checks_in_libs in the Compiler Defines field on the Build tab. This definition affects implementation libraries (*.library) only, not protected libraries (*.compiled-library).

You can use the "no_check" attribute to deactivate the check for special POUs in the project.

Table 62. Available Functions

Monitoring function

Type

CheckBounds

Bound Checks

Appropriate handling of bound violations; such handling includes setting flags or changing field indices

CheckDivDInt

Division checks:

Monitors the divisor value to avoid division by zero

CheckDivLInt

CheckDivReal

CheckDivLReal

CheckRangeSigned

Range checks:

Monitors the range limit of a subrange type in runtime mode

Valid for data types DINT/UDINT

CheckRangeUnsigned

CheckLRangeSigned

L-range checks:

Monitors the range limit of a subrange type in runtime mode

Valid for data types LINT/ULINT

CheckLRangeUnsigned

CheckPointer

Pointer checks

You are responsible for filling in this function completely with implementation code. See the help page for "POU 'CheckPointer'". The function should monitor whether or not the passed pointer references a valid memory address, and whether or not the orientation of the referenced memory area matches the variable type to which the pointer refers. If both conditions are fulfilled, then the pointer is returned. If not, then CheckPointer should complete an appropriate error handling. CheckPointer monitors the same way as variables of type REFERENCE TO.