1 type conversion functions, 1 converting between integer number types, 2 bool_to – Lenze DDS v2.3 User Manual
Page 294: Converting between integer number types, Bool_to, Drive plc developer studio

Drive PLC Developer Studio
IEC 61131-3 Standard functions
14-2
l
DDS EN 2.3
14.1
Type conversion functions
Implicit conversions from a ” higher-” type to a ” lower-order” type are not permitted (such as from
INT
to BYTE or from DINT to WORD). Special type conversion functions must be applied to do so.
Conversions from any elementary type to any other elementary type are possible on principle.
Syntax:
14.1.1
Converting between integer number types
Conversion from an integer number type to another number type
Conversion from higher- to lower-order types may result in information loss.
•
Where the number to be converted exceeds the range limit, the first bytes of the number will
not be considered.
Examples
IL
ST
FBD
LD 4223
INT_TO_SINI
ST si
si:=INT_TO_SINT(4223);
(* si=127 *)
If the integer 4223 (16#107f in hexadecimal writing) is saved as SINT variable, that variable will be
assigned the number 127 (16#7f in hexadecimal writing).
14.1.2
BOOL_TO
Converting BOOL into another type
•
With number types, the result is 1 if the operand is TRUE, and 0 if the operand is FALSE.
•
With type STRING, the result is TRUE or FALSE.
Examples
IL
LD TRUE
BOOL_TO_INT
ST i
LD TRUE
BOOL_TO_STRING
ST str
LD TRUE
BOOL_TO_TIME
ST t
LD TRUE
BOOL_TO_TOD
ST tof1
LD FALSE
BOOL_TO_DATE
ST dat
LD TRUE
BOOL_TO_DT
ST dandt
ST
i:=BOOL_TO_INT(TRUE);
str:=BOOL_TO_STRING(TRUE);
t:=BOOL_TO_TIME(TRUE);
tof1:=BOOL_TO_TOD(TRUE);
dat:=BOOL_TO_DATE(FALSE);
dandt:=BOOL_TO_DT(TRUE);
(* i=1 *)
(* str=’TRUE’ *)
(* t=T#1ms *)
(* tof=TOD#00:00:00.001 *)
(* dat=D#1970-01-01 *)
(* dandt=DT#1970-01-01-00:00:01 *)
FBD
Show/Hide Bookmarks