3 to_bool, 4 time_to / time_of_day, To_bool – Lenze DDS v2.3 User Manual

Page 295: Time_to / time_of_day, Drive plc developer studio

Advertising
background image

Drive PLC Developer Studio

IEC 61131-3 Standard functions

14-3

l

DDS EN 2.3

14.1.3

TO_BOOL

Converting from any type to BOOL

The result is TRUE if the operand is not 0 and FALSE if the operand is 0.

With type STRING the result is TRUE if the operand is TRUE, otherwise the result is FALSE.

Examples
IL

LD 213
BYTE_TO_BOOL
ST b (* b=TRUE *)

LD 0
INT_TO_BOOL
ST b (* b=FALSE *)

LD T#5ms
TIME_TO_BOOL
ST b (* b=TRUE *)

LD ’TRUE’
STRING_TO_BOOL
ST b (* b=TRUE *)

ST

b:=BYTE_TO_BOOL(2#11010101);
b:=INT_TO_BOOL(0);
b:=TIME_TO_BOOL(T#5ms);
b:=STRING_TO_BOOL(’TRUE’);

(* b=TRUE *)
(* b=FALSE *)
(* b=TRUE *)
(* b=TRUE *)

FBD

14.1.4

TIME_TO / TIME_OF_DAY

Converting from TIME or TIME_OF_DAY to another type

Internally, the time is saved as a DWORD in milliseconds (with TIME_OF_DAY from 00:00 o’clock). This
value is converted.

With type STRING, the result is the time constant.

Conversion from higher- to lower-order types may result in information loss.

Examples
IL

LD T#12ms
TIME_TO_STRING
ST str

LD T#300000ms
TIME_TO_DWORD
ST dw

LD TOD#00:00:00.012
TOD_TO_SINT
ST si

ST

str:=TIME_TO_STRING(T#12ms);
dw:=TIME_TO_DWORD(T#5m);
si:=TOD_TO_SINT(TOD#00:00:00.012);

(* str=’T#12ms’ *)
(* dw=300000 *)
(* si=12 *)

FBD

Show/Hide Bookmarks

Advertising