Resolving Incorrect Floating Values in a Siemens S7 Node

David Krause2 min read
Data AcquisitionSiemensTroubleshooting
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

A Siemens S7 node can display a large integer when the PLC value stored at MD10 is not decoded as a floating-point value. Separate data interpretation from decimal formatting: first read the bytes using the node's REAL-equivalent representation, then format the decoded value if required.

Identify the interpretation mismatch

The reported PLC value is 10.1 at MD10, while the receiving node shows a large integer. This indicates that the same underlying data may be interpreted as an integer rather than as a floating-point number. Rounding cannot correct that decoding mismatch.

Observation Engineering conclusion
PLC debug view shows 10.1 Use this as the reference value.
S7 node returns a large integer Check the configured data representation before changing byte order or applying arithmetic.
Reported fix used MR instead of MD Treat MR as node-specific notation unless the node documentation defines it; the evidence does not establish it as a PLC address type.

Configure and verify the S7 read

  1. Confirm that the PLC debug view shows 10.1 at MD10.
  2. Inspect the S7 node configuration for the tag and select its floating-point or REAL-equivalent representation. The reported configuration used MR instead of MD, but verify that notation against the specific node implementation.
  3. Deploy the flow and inspect the unformatted value in the debug node.
  4. Accept the configuration only when the debug value matches the PLC value before rounding.

Format the decoded value

After the node returns the correct floating-point value, format it to two decimal places with JavaScript:

msg.payload.tag = msg.payload.tag.toFixed(2);
return msg;

toFixed(2) produces a two-decimal display value. Apply it only after decoding is correct; otherwise it merely formats the wrong integer. If downstream logic requires a numeric value rather than display text, keep the original decoded value for calculations and format only the displayed field.

Verification criteria

Compare the PLC debug value, the raw S7 node output, and the formatted output. For the reported test, the raw node value must represent 10.1; only then should two-decimal formatting produce 10.10. If the raw output remains a large integer, return to the tag representation rather than adding rounding logic.

FAQ

Why does an S7 node show a large integer for 10.1 at MD10?

The node is likely interpreting the stored bit pattern as an integer instead of a floating-point value. Configure the tag with the node's REAL-equivalent representation and verify the raw result before formatting it.

Should I use MR instead of MD in the Siemens S7 node?

The reported solution used MR instead of MD, but the evidence does not define that notation universally. Confirm that MR selects a REAL value in the documentation for the specific S7 node.

How do I show an S7 floating value with two decimal places?

After correct decoding, use msg.payload.tag.toFixed(2). For a decoded value of 10.1, the formatted result is 10.10.

Back to blog