PLC

Object POUs for implicit checks

 

Object Create POU for implicit checks

1.
Select a folder in the PLC project tree.
2.
In the context menu select the command Add > POU for implicit checks...
The dialog Add POU for implicit checks opens.
3.
Activate the desired functions.
4.
Click on Open.
The selected POUs are inserted in the PLC project tree.
5.
Open the POUs in the editor.
6.
Adapt the implementation proposal to your requirements.

In order to prevent multiple integration, a monitoring function that may already have been integrated is no longer available for selection in the dialog Add POU for implicit checks.

 
Do not change the declaration part
To maintain the functionality of the monitoring functions, the declaration part must not be modified. The only exception is to add local variables.
No online change possible
After removing implicit monitoring functions, such as CheckBounds, from the project, online change is no longer possible, only a download. A corresponding message is issued.
Implicit checks for function blocks from source libraries
TwinCAT does not perform implicit checks on function blocks from libraries. However, you can use the compiler definition "checks_in_libs" to extend the check to function blocks from source libraries (* .library). To do this, enter the compiler definition "checks_in_libs" from the PLC project properties in the Compiler defines field, which you can find in the Compile category. However, this only affects source libraries (*.library), not protected libraries (*.compiled-libraries).
Excluding individual POUs from the check
You can disable the checking of special POUs in the project with the attribute 'no_check‘.
 
 

Dialog Add POU for implicit checks

Available functions

Monitoring function
Type
CheckBounds
Bound checks:
Appropriate treatment of field bound violations (e.g. by setting an error flag or by changing the field index).
CheckDivDInt
Division checks:
Monitoring of the divisor value, to avoid division by 0.
CheckDivLInt
CheckDivReal
CheckDivLReal
CheckRangeSigned
Range checks:
Monitoring of the range bounds of a subrange type at runtime. Applies to the data types DINT/UDINT
CheckRangeUnsigned
CheckLRangeSigned
L range checks:
Monitoring of the range bounds of a subrange type at runtime. Applies to the data types LINT/ULINT
CheckLRangeUnsigned
CheckPointer
Pointer checks:
For this function you have to complete the entire implementation code yourself. See the help page for POU CheckPointer. The purpose of the function is to monitor whether the transferred pointer points to a valid memory address, and whether the orientation of the referenced memory area matches the type of variable to which the pointer points. If both conditions are met, the pointer itself is returned. Otherwise, CheckPointer should perform appropriate troubleshooting. In the same way, CheckPointer also monitors variables of type REFERENCE TO
 

See also:

Reference Programming: Attribute 'no_check'
Additional information
POU CheckBounds
POU CheckDivDInt
POU CheckDivLInt
POU CheckDivReal
POU CheckDivLReal
POU CheckRangeSigned
POU CheckLRangeSigned
POU CheckRangeUnsigned
POU CheckLRangeUnsigned
POU CheckPointer