Baumer GK473 User Manual

Page 26

Advertising
background image

Manual_GK473_S7_Profibus_EN.doc 26/32

Baumer IVO GmbH & Co. KG

04.05.11

Villingen-Schwenningen,

Germany

4.4 FC 1 - ASCII Number (6 Byte) in real numbers

This function is required by FC10, FC11, FC12 and FC13 to convert the SPA data received into a real
number (with floating point according to IEEE-754).
Incoming data in ASCII format are being read off a DB (in the example it is DB20) and converted to be
depicted as real numbers with floating point.
First the ASCII sign is converted into an integer number and multiplied by 10. Same applies to the
following ASCII sign that is then added to the previous result, again multiplied by 10 and so on up to
the latest number which is only added and instead of being multiplied divided by 100 in order to end up
with two decimals.

Example: (positive value)

0x31 Æ 1

multiplied by 10 -> 10

0x32

Æ

2 + 10 = 12 multiplied by 10 Æ 120

0x33

Æ

3 + 120

= 123 multiplied by 10 Æ 1230

0x34

Æ

4 + 1230

= 1234 multiplied by 10 Æ 12340

0x38

Æ

8 + 12340

= 12348 multiplied by 10 Æ 123480

0x36

Æ

6 + 123480

=123486 divided by 100 Æ 1234,86


Analog with negative sign:

0x2d Æ - (negative sign, read 5 numbers only)

0x34

Æ

4

= 4 multiplied by 10 Æ 40

0x33

Æ

3 + 40

= 43 multiplied by 10 Æ 430

0x32

Æ

2 + 430

= 432 multiplied by 10 Æ 4320

0x38

Æ

8 + 4320

= 4328 multiplied by 10 Æ 43280

0x36

Æ

6 + 43280

= 43286 divided by 100 Æ 432,86

Negate number due to negative sign Æ -432.86

A negative number makes the function run in another sub-program than a positive number. Similar to
the SPA display the range is limited, for positive numbers. 9999.99 max, for negative numbers.–999.99
max.


4.5 FC 5 – Real number in ASCII

FC13 requires this function to convert the target received in real format into ASCII format by using data
block 97 where the target in ASCII format is written after conversion. The conversion is realized as
follows:
First the target is multiplied by 100 to eliminate the digits after the point. The floating point number can
be converted without rounding error into an integer number that is now converted into BCD (Binary
Coded Decimal). Since loading 4 bytes only ( i.e. BCD number) under AWL (STL-Statement List) is not
possible, always 8 bytes i.e. 2 numbers must be loaded and treated separately by shifting operations
and outmasking. The numbers are successively written into DB97 in ASCII format by adding the offset.

Example: Target 123,45:
First the target is multiplied by 100: 12345
Readout in BCD:

BYTE BYTE BYTE

0 1 2 3 4 5


Access byte by byte for example will make the last two figures load into the battery( 01000101 binary).

4 5

010

0

010

1


To achieve number 4 the bits must be shifted by 4 digits to the right in order to eliminate number 5. The
following bits are filled by zeroes.

Advertising