Conversion between integral number types, L-force | plc designer – Lenze PLC Designer PLC Designer (R3-1) User Manual

Page 1069

Advertising
background image

L-force | PLC Designer

Programming Reference

DMS 4.1 EN 03/2011 TD29

1067

Examples in FBD:

( *Result is TRUE *)

(* Result is FALSE *)

(* Result is TRUE *)

(* Result is TRUE *)

Examples in St:

b := BYTE_TO_BOOL(2#11010101);

(* Result is TRUE *)

b := INT_TO_BOOL(0);

(* Result is FALSE *)

b := TIME_TO_BOOL(T#5ms);

(* Result is TRUE *)

b := STRING_TO_BOOL('TRUE');

(* Result is TRUE *)

Conversion between Integral Number Types
Conversion from an integral number type to another number type.
Syntax for the conversion operator:
<INT data type>_TO_<INT data type>
When you perform a type conversion from a larger to a smaller type, you risk losing
some information. If the number you are converting exceeds the range limit, the first
bytes for the number will be ignored.
Beispiel in ST:

si := INT_TO_SINT(4223); (* Result is 127 *)

If you save the integer 4223 (16#107f represented hexadecimally) as a SINT variable, it
will appear as 127 (16#7f represented hexadecimally).
Beispiel in AWL:

Beispiel in FUP:

Advertising