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

Page 265

Advertising
background image

Drive PLC Developer Studio

IEC 61131-3 Data types

10-9

l

DDS EN 2.3

Parameterizing the function

value

Is given the value to be assigned to the range type.

lower

The lower range limit.

upper

The upper range limit.

return value

The actually assigned value for the range type.

In this example, the following assignment is implicitly generated from an assignment i := 10*y;:
i := CheckRangeSigned(10*y, -4095, 4095);

If y has e.g. the value 1000, i will only have the value 4095 in accordance with this assignment.

Function CheckrangeUnsigned requires function name and interface to be correct.

FUNCTION CheckRangeUnsigned : UDINT
VAR_INPUT

value, lower, upper: UDINT;

END_VAR

Functions CheckRangeSigned and CheckRangeUnsigned are available in library CheckRange.lib.
Use the Library Manager Insert

WAdditional Library to insert the library into the project.

Tip!

If a function CheckRangeSigned or CheckRangeUnsigned is implemented as shown above, use of
the subrange type in a FOR loop may result in an endless loop. This occurs if the range specified
for the FOR loop is equal to or greater than that of the subrange.

VAR

ui : UINT (0..10000);

END_VAR

FOR ui:=0 TO 10000 DO
...
END_FOR

The FOR loop is not exited as ui cannot exceed 10000.

Observe the content of the CheckRange functions when using incrementation values in the FOR
loop!

Show/Hide Bookmarks

Advertising