Bit-/byte functions, L-force | plc designer – Lenze PLC Designer PLC Designer (R2-x) User Manual
Page 662

L-force | PLC Designer
PLC Designer Libraries
660
DMS 3.2 EN 02/2011 TD29
Examples in ST:
i:=BCD_TO_INT(73); (* Result is 49 *)
k:=BCD_TO_INT(151); (* Result is 97 *)
l:=BCD_TO_INT(15); (* Output -1, because it is not in BCD
format *)
INT_TO_BCD_
Provided by util.lib.
This function converts an INTEGER value into a byte in BCD format:
The input value of the function is type INT, the output is type BYTE.
The number 255 will be outputted where an INTEGER value should be converted
which cannot be converted into a BCD byte.
Examples in ST:
i:=INT_TO_BCD(49); (* Result is 73 *)
k:=BCD_TO_INT(97); (* Result is 151 *)
l:=BCD_TO_INT(100); (* Error! Output: 255 *)
19.2.2
Bit-/Byte Functions
EXTRACT
Provided by util.lib.
Inputs to this function are a DWORD X, as well as a BYTE N. The output is a BOOL
value, which contains the content of the N
th
bit of the input X, whereby the function
begins to count from the zero bit.
Examples in ST:
FLAG:=EXTRACT(X:=81, N:=4); (* Result : TRUE, because 81 is
binary 1010001, so the 4th bit is 1 *)
FLAG:=EXTRACT(X:=33, N:=0); (* Result : TRUE, because 33 is
binary 100001, so the bit '0' is 1 *)