Drive plc developer studio – Lenze DDS v2.3 User Manual

Page 264

Advertising
background image

Drive PLC Developer Studio

IEC 61131-3 Data types

10-8

l

DDS EN 2.3

Library CheckRange.lib

The library CheckBounds contains the global variable

g_bErrorCheckRange.

Open the library management with Window

WLibrary Manager.

Insert the library from the library folder. Via the menu command Insert

WAdditional Library,

you can select the library and insert it into the actual project.

Select the library in the library management. On the index card Global Variables, the
variable and additional information are listed.

Note!

The global variable

g_bErrorCheckRange monitors critical and not to be processed value ranges.

The library function CheckRange recognizes that the target system has reached a critical value
range.

The global variable

g_bErrorCheckBounds is set to TRUE.

The status TRUE is not set back during runtime. If the status = TRUE, at least once a critical
value range has been reached.

CheckRangeSigned and CheckRangeUnsigned

In order to use these function, the library CheckRange.lib must be linked.

The function CheckRangeSigned and CheckRangeUnsigned must be added to enable runtime
range limit checks and to prevent range infringements (by clipping the value or error flag).
CheckRangeSigned and CheckRangeUnsigned are called up implicitly if a variable is written to. This
variable is of a subrange type generated from a signed or unsigned type.

In the case of a variable of a signed subrange type (var:i1 or i2 listing above), the process calls up
the function CheckRangeSigned. Programming might look as follows to clip the value to the
permitted range.

FUNCTION CheckRangeSigned : DINT
VAR_INPUT

value, lower, upper: DINT;

END_VAR

IF (value < lower) THEN

CheckRangeSigned := lower;

ELSIF(value > upper) THEN

CheckRangeSigned := upper;

ELSE

CheckRangeSigned := value;

END_IF

Caution!

If the two functions CheckRangeSigned and CheckRangeUnsigned do not exist, the subrange
types will not be type-checked at runtime! Variables i1 or i2 could then assume any value between
-32768 and 32767!

Show/Hide Bookmarks

Advertising