Util.lib library, Bcd conversion, L-force | plc designer – Lenze PLC Designer PLC Designer (R2-x) User Manual

Page 661

Advertising
background image

L-force | PLC Designer

PLC Designer Libraries



DMS 3.2 EN 02/2011 TD29

659

19.2

Util.lib library

This library contains an additional collection of various blocks which can be used for
BCD conversion, bit/byte functions, mathematical auxiliary functions, as controller,
signal generators, function manipulators and for analogue value processing.

As some of the functions and function blocks contain REAL variables, an accessory
library named UTIL_NO_REAL exists in which these POUs are excluded.

19.2.1

BCD Conversion

Provided by util.lib.

A byte in the BCD format contains integers between 0 and 99. Four bits are used for
each decimal place. The ten decimal place is stored in the bits 4-7. Thus the BCD
format is similar to the hexadecimal presentation, with the simple difference that
only values between 0 and 99 can be stored in a BCD byte, whereas a hexadecimal
byte reaches from 0 to FF.

An example: The integer 51 should be converted to BCD format. 5 in binary is 0101, 1
in binary is 0001, which makes the BCD byte 01010001, which corresponds to the
value $51=81.

BCD_TO_INT

Provided by util.lib.

This function converts a byte in BCD format into an INT value:

The input value of the function is type BYTE and the output is type INT.

Where a byte should be converted which is not in the BCD format the output is -1.

Advertising