POUS for Implicit Checks

In the event that you are working on an PAM application and are concerned that one or more functions in your code could return an invalid result and throw the PAC into an error state, there is a fairly simple way to prevent the PAC from crashing and handle the exception.  This can be done using POUs for implicit checks.

To add these into your program, right-click Application > Add Object > POUs for Implicit Checks.  You can select from a list of checks to perform:

pou_list_4653-20240521-001105.png

 

The selected POUs will be executed any time the relevant operation is called, do note that this may cause POU slowdown because of this.  

  • For instance, a divide operation where the divisor is a REAL set to zero will call CheckDivReal.  Note that division checks for DINT also apply to smaller integer datatypes like INT and USINT through implicit type conversion. 

  • Checks are also available for array boundaries, ensuring the application never tries to read or write to an array location that is beyond its boundaries (for instance, location 30 of a 20-index array).

  • Range checking is also available, but this only applies to integer datatypes declared to use less than their typically available data range.  For instance, the variable declaration MyInt : INT (-100..100); creates an integer that rolls over at 100 and -100.  This is useful for creating integers with built-in modulo functions.  The range check POU can cap such values at their specified maxima and minima.

  • There is also a POU to check pointers.  Pointers are likely sources of spontaneous errors because they can point to any memory location.  If the programmer is not careful, they may point to a memory location that is outside of the PAC runtime memory structure or point to a location with restricted access.  Unfortunately, there is no standard way to check for pointer access violations and no standard way to correct them.  It is therefore up to the programmer to either develop a way to check/correct pointers in the implicit POU or to root out any pointer bugs in development.

For more information, please download and try one of the included samples. Select the project that matches your version of Parker Automation Manager:

PAM1.4: POUs_For_Implicit_Checks_PAM1.4

PAM1.2: POUs_For_Implicit_Checks_PAM1.2

A related FAQ about PAC errors and their causes can also be found here.

DC 22APR2016

30OCT18 JD