×
Siemens Industry Online Support
Siemens AG
Entry type: FAQ Entry ID: 79161565, Entry date: 10/31/2016
(3)
Rate

How do you process 64-bit power counter values with a SIMATIC S7-300/S7-400 controller without information loss?

  • Entry
  • Associated product(s)
Using 64-bit power counter values

Description
The 7KM PAC3200 and 7KM PAC4200 measuring devices deliver a 64-bit REAL (floating point) power counter value. Since the SIMATIC controllers of the S7-300 and S7-400 product family are each based on a 32-bit technology, this counter value cannot be processed directly.
The existing options for data type conversion however lead to information loss as of a specific counter value.

In order to use the 64-bit power counter values, download the library for SIMATIC STEP7 V5.5 SP2 available in this entry.

Instructions
The attached block library includes a block that splits the 64-bit REAL counter value into two counters.
Copy the block into your project. Make sure you use a free FB number.
To correctly interconnect the block you simply switch the High DWORD of the 64-bit REAL number to the input parameter "id_hdword" and the Low DWORD of the 64-bit number to the input parameter "id_ldword".


Fig. 01: Splitting of the 64-bit REAL number into a high and low DWORD

The two counters are then available at the output interface.

  • The "FINE" output signal is the fine counter with a value range of 0 to 109 Wh.
  • The "RAW" output signal is the fine counter with a value range of 0 to 109 kWh.

At the end of their value range both counters roll over and start to count again from the beginning.
Since the counter values of the FB64 are many times greater than the maximum counter value you can neglect the roll-over of the SENTRON PAC counter.

Download
The download includes the "64Bit_Converting" library.
Copy the "64Bit_Converting.zip" file into a separate directory and then start the file with a double-click. You can then use STEP 7 to open and utilize the library.

64Bit_Converting.zip (26 KB)

Note
The block can only be used up to an LREAL value of 1012.

Background information
The cause of this information loss is the different structure of a 64-bit REAL number and a 32-bit REAL number.

64-bit REAL number:
- 1 bit sign
- 11 bits exponent field
- 52 bits mantissa
- Value range: ± 2.2 x 10-308 ... 1.8 x 10308


Fig. 02: Structure of a 64-bit REAL number

32-bit REAL number:
- 1 bit sign
- 8 bits exponent field
- 23 bits mantissa
- Value range: ± 1,17 * 10-38 .. 3,4 * 1038


Fig. 03: Structure of a 32-bit REAL number

The exponent field specifies how many bits are to the left of the period. However, the exponent is given with an offset. For a 32-bit REAL number this is 127 and for a 64-bit REAL number it is 1023. In order to obtain a number from this representation a leading 1 is added to the mantissa.
Example: 32-bit REAL number with 23 bits left of the period


Fig. 04: Example

1111 1111 1111 1111 1111 1111 - 16.777.215 Wh
1 0000 0000 0000 0000 0000 0000 - 16.777.216 Wh
1 0000 0000 0000 0000 0000 0001 - 16.777.216 Wh
(1 Wh lost, actually 16.777.217 Wh)
1 0000 0000 0000 0000 0000 0010 - 16.777.218 Wh
1 0000 0000 0000 0000 0000 0011 - 16.777.218 Wh
(1 Wh lost, actually 16.777.219 Wh)
1 0000 0000 0000 0000 0000 0100 - 16.777.220 Wh

In the case of REAL numbers that need a mantissa greater than 23 bits all the bits that are outside the mantissa have the value 0. This is where important counter value information is lost. The greater the counter value, the greater the value of the lost Wh.

11 0000 0000 0000 0000 0000 0000 - 50.331.648 Wh
11 0000 0000 0000 0000 0000 0011 - 50.331.648 Wh
(3 Wh lost, actually 50.331.651 Wh)

Note on security
Caution
The functions and solutions described in this entry are predominantly limited to the realization of the automation task. When linking your system to other system components, to the company network or to the internet, appropriate industrial security measures must be taken. Further information about this is available in Entry ID 50203404.

Additional Keywords
Sentron, powerrate, Data type, Conversion, Power counter, LREAL, 64 bit


Security information
In order to protect technical infrastructures, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art IT security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about cyber security, please visit
https://www.siemens.com/cybersecurity#Ouraspiration.