WinCC Tag Scaling: Convert Integer PLC Values to Float Tags
Siemens WinCC Tag Logging archives the value present in the internal WinCC tag. When the source PLC tag is an integer and the application requires one-decimal precision (for example, scaling 254 to 25.4), configuring the WinCC tag as Integer and applying linear scaling causes the archived value to be rounded to 25 rather than stored as 25.4. The fix is to switch the WinCC tag data type from Signed 16/32-bit to Float 32-bit, apply linear scaling with a gain of 0.1, and constrain the display precision with an I/O field output format string such as 99.9. This guide details both WinCC V7.x and WinCC Professional (TIA Portal) configuration paths, explains the IEEE 754 floating-point representation that produces the 25.7999992370605 artifact, and provides a VBScript action reference for projects that still need script-based scaling inside cyclic tag logging.
Overview
Integer PLC tags are widely used for analog values when the field device returns scaled counts (for example, 0-5000 representing 0.0-500.0 °C). When WinCC Tag Logging records these values with acquisition type On Change, an action (VBScript or C) cannot be assigned at the archive level to transform the value before storage. The only mechanism that runs for every change without an action is the linear scaling parameter built into WinCC Tag Management. Linear scaling itself does not round values; the rounding occurs only when the destination WinCC tag is configured as an integer data type, because integers have no fractional bits. Promoting the WinCC tag to Float 32-bit (or Float 64-bit for high-precision loops) preserves 25.4 in the archive while the PLC retains its native INT / DINT representation.
Problem Statement: Integer Tags Round After Linear Scaling
Consider a S7-1500 PLC exposing "ProcessValue" : INT with raw counts 0-1000 representing 0.0-100.0 %. The standard WinCC V7.x project maps this tag to a WinCC tag of type Signed 16-bit with linear scaling enabled:
| Parameter | Value |
|---|---|
| WinCC tag name | ProcessValue_Scaled |
| Source address |
DB1.DBW0 (S7-1500) |
| WinCC data type | Signed 16-bit |
| Linear scaling | Enabled |
| Gain (AS-OS) | 0.1 |
| Offset | 0.0 |
When the PLC value is 254, the linear scaling engine computes 254 * 0.1 = 25.4, but because the destination tag is an integer, the result is truncated to 25 before it ever reaches the Tag Logging archive. Tag Logging therefore records 25 instead of 25.4 for every change event. The issue is identical in TIA Portal WinCC Professional when the HMI tag is configured as Int or DInt.
Prerequisites
- WinCC V7.4 SP1, V7.5, V7.5 SP1, or V7.5 SP2 (project loaded on the engineering station)
- OR WinCC Professional V16 / V17 / V18 inside TIA Portal
- AS-OS connection configured (S7-MPI, S7-TCP, named connection, or OPC UA)
- Source PLC tag defined as
INT,DINT, orWORD - Tag Logging archive created with acquisition type On Change or Cyclic
- User rights to edit Tag Management and Tag Logging in WinCC Explorer / TIA Portal
Root Cause: Why Integer Tags Round After Linear Scaling
WinCC performs linear scaling through the formula Output = (Input × Gain) + Offset at the I/O layer of the tag driver. The scaled result is then written to the internal tag buffer using the tag's declared data type. When the declared data type is an integer variant (Signed 16-bit, Unsigned 16-bit, Signed 32-bit, Unsigned 32-bit), the runtime truncates the fractional portion of every scaled value because integer storage allocates zero bits for the decimal component. Truncation in WinCC follows round-toward-zero, so 25.4 becomes 25, and 25.9 becomes 25 (not 26). Linear scaling is therefore not at fault; the data type of the destination tag is.
Float 32-bit IEEE 754 single precision or Float 64-bit IEEE 754 double precision can hold decimal values for Tag Logging.Solution: Configure WinCC Tag as Float 32-bit with Linear Scaling
The solution is a one-property change in Tag Management: change the WinCC tag's data type from Signed 16-bit to Float 32-bit (or Float 64-bit for high-resolution loops). The linear scaling configuration remains identical, and Tag Logging automatically consumes the new data type. The S7 PLC side does not need any modification; the integer raw value continues to be read over the AS-OS connection and converted by WinCC.
Linear Scaling Formula in WinCC
WinCC V7.x and WinCC Professional both implement:
OutputValue = (RawValue × Gain) + Offset
// Examples for the scenario above
Gain = 0.1
Offset = 0.0
RawValue = 254 → OutputValue = 25.4
RawValue = 1000 → OutputValue = 100.0
RawValue = 7 → OutputValue = 0.7
The Gain and Offset fields are the only two parameters required. WinCC does not store the raw PLC value at this point - all consumers of the tag (HMI screens, Tag Logging, archives, scripts) read the scaled float value.
Step-by-Step: WinCC V7.x Configuration
- Open WinCC Explorer on the engineering station and load the project in Open Project mode.
- Right-click Tag Management and choose Open.
- Select the desired driver (for example,
SIMATIC S7-1200, S7-1500 Channel) and locate the existing integer tag (e.g.ProcessValue). - Right-click the tag and choose Properties.
- On the General tab, change Data Type from
Signed 16-bittoFloat 32-bit. - On the same dialog, switch to the Linear Scaling section and enable the checkbox.
- Enter Gain = 0.1 and Offset = 0.0. (Equivalent: Value range start = 0, Value range end = 1000 in PLC units mapped to 0.0 to 100.0 scaled units.)
- Click OK to apply.
- Open Tag Logging, expand the archive, and confirm the tag is listed. The archive column now shows the float data type.
- Save the WinCC project and trigger a recompile.
Step-by-Step: WinCC Professional (TIA Portal) Configuration
- Open the TIA Portal project containing the HMI device.
- Expand HMI Tags in the project tree and double-click the tag (e.g.
ProcessValue). - In the tag properties, change the Data type drop-down from
IntorDInttoReal(Float 32-bit) orLReal(Float 64-bit). - In the Linear scaling group, enter Gain = 0.1 and Offset = 0.0. The linear scaling dialog also accepts Endianness and bit-packing fields for advanced use cases.
- Compile the HMI station and download to the runtime.
- Open the HMI Tags table in the runtime and verify the value
25.4for a PLC value of254.
INT or DINT. The HMI tag type is independent of the PLC tag type; WinCC converts during the read cycle.IEEE 754 Floating-Point Artifacts: 25.7999992370605 Explained
After switching to a float data type, engineers frequently observe artifacts such as 25.7999992370605 instead of 25.8. The artifact is not a bug in WinCC, the PLC, or the linear scaling engine - it is a fundamental property of IEEE 754 binary floating-point arithmetic.
Why 25.8 Becomes 25.7999992370605
The IEEE 754 single-precision (32-bit) format stores numbers as (-1)sign × 1.mantissa × 2exponent. The mantissa field has 23 explicit bits plus one implicit leading bit, giving 24 bits of precision, equivalent to approximately 7 decimal digits of significance. The double-precision (64-bit) format has a 52-bit mantissa, giving approximately 15 decimal digits of significance. The decimal value 25.8 cannot be expressed as a finite sum of negative powers of two; its nearest IEEE 754 single-precision representation rounds to a value roughly 5.96 × 10-8 below 25.8, which the runtime prints as 25.7999992370605. WinCC is therefore displaying the closest float representation - the user's intended 25.8 literally does not exist in the IEEE 754 single-precision world.
| Format | Bits | Mantissa bits | Decimal precision | Example artifact for 25.8 |
|---|---|---|---|---|
| IEEE 754 single | 32 | 23 (+1 implicit) | ~7 digits | 25.7999992370605 |
| IEEE 754 double | 64 | 52 (+1 implicit) | ~15 digits | 25.799999999999997 |
| Decimal (BCD / string) | n/a | n/a | Exact for 25.8 | 25.8 |
For more detail, see the IEEE 754 standard and the Single-precision floating-point format reference.
I/O Field Output Format Strings
WinCC I/O fields and trend views accept a Output Format string that constrains the decimal display. The format specifier uses Microsoft .NET-style placeholders. To display the scaled value with one decimal place, use:
Output Format: 99.9
or with thousands separator: n1
or fixed-width zero-padded: 000.0
With the format string 99.9, the value 25.7999992370605 is rendered to the operator as 25.8. The underlying float is unchanged; only the textual display is rounded. For two-decimal precision, use 99.99; for engineering notation, use 0.00E+00.
| Output Format | Raw float value | Operator display |
|---|---|---|
99.9 |
25.7999992370605 |
25.8 |
99.99 |
3.14159274101257 |
3.14 |
n2 |
1234.5 |
1,234.50 |
0.00E+00 |
12345.678 |
1.23E+04 |
Float 32-bit and apply rounding inside a separate calculated tag or use a Function trigger in the archive.Tag Logging Acquisition Types and the Action Constraint
WinCC Tag Logging supports three acquisition types per archive column:
| Acquisition type | Action available? | Use case |
|---|---|---|
| Cyclic (e.g. 500 ms) | Yes - VBScript or C action can be assigned to compute the value | Time-series at fixed sample rate |
| On Change | No - the archive simply stores the new tag value | Event-driven capture when the process changes |
| On Command | No - only stored when a script calls the archive API | Manual snapshot from a button |
This is exactly the constraint the source scenario describes: an On Change archive cannot host an action to divide the integer by 10. Linear scaling on the WinCC tag itself is the correct mechanism because the scaling happens before the value reaches the archive, so it applies to every acquisition type transparently.
VBScript Action for Cyclic Tag Logging (Reference)
For projects that nevertheless use a VBScript action on a cyclic archive, the canonical pattern is to read the raw integer tag, divide, and write to a separate float tag that the archive consumes. The raw tag stays as integer, the scaled tag is float. WinCC V7.x VBScript:
' VBScript action attached to a cyclic Tag Logging trigger (1 s)
Dim rawValue, scaledValue
rawValue = HMIRuntime.Tags("ProcessValue_Raw").Read
scaledValue = rawValue / 10.0
HMIRuntime.Tags("ProcessValue_Scaled").Write scaledValue
For the C script variant in WinCC V7.x, use GetTagFloat / SetTagFloat from the stdlib include:
// C script inside a cyclic Tag Logging action (WinCC V7.x)
#include "apdefap.h"
BOOL _main(char* lpszPictureName)
{
DWORD rawValue = 0;
float scaledValue = 0.0f;
rawValue = GetTagDWord("ProcessValue_Raw");
scaledValue = (float)rawValue / 10.0f;
SetTagFloat("ProcessValue_Scaled", scaledValue);
return TRUE;
}
The same pattern applies in TIA Portal WinCC Professional using JavaScript inside an HMI script: HMIRuntime.Tags("ProcessValue_Scaled").Write(rawValue / 10.0);
Verification Procedure
- Force the PLC value to a known integer (for example, set
DB1.DBW0 = 254in the S7 watch table). - Open WinCC Explorer > Tag Management and double-click the scaled tag. The Current Value indicator should display
25.4, not25and not25.799999…. - Open Tag Logging, select the archive, and click Display & Acknowledge. Confirm the most recent value is
25.4. - Export the archive to CSV via Tag Logging > Archive > Export and inspect with Notepad or Excel. The CSV cell must contain
25.4(or the underlying IEEE 754 value); the human-readable trend view applies the Output Format string. - Add an I/O field on a screen bound to the scaled tag and set the Output Format to
99.9. The field must render25.8when the PLC value is258. - Force a sequence of test values (0, 1, 25, 254, 1000) and confirm none of them is truncated.
Troubleshooting Matrix
| Symptom | Likely cause | Fix |
|---|---|---|
| Archive always shows integer (e.g. 25 instead of 25.4) | WinCC tag data type is still integer | Change Data Type to Float 32-bit in Tag Management |
| Archive shows float (e.g. 25.7999992) but I/O field shows 25 | Output Format string is missing or set to integer placeholder | Set Output Format to 99.9 on the I/O field |
| Trend view shows artifacts (25.7999992) but I/O field shows 25.8 | Trend curve does not apply Output Format; the curve plots the raw float | Configure trend value axis labels with one-decimal precision or use a Tag with rounding |
| Scaled value is wildly wrong (e.g. 2540000 instead of 25.4) | Gain entered as 10 instead of 0.1 (multiply vs. divide) |
Set Gain = 0.1 to divide, or use 1/Gain in formula |
| Tag in alarm state (quality = bad) | Float tag is bound to a non-existent or wrong-typed PLC address | Verify the AS-OS connection online; confirm PLC address and data block structure |
| Cyclic archive missing values during step changes | Cyclic cycle time is too long; acquisition is "On Change" | Switch acquisition type to Cyclic with a cycle ≤ 100 ms, or accept that "On Change" archives only on edge |
| Linear scaling checkbox is greyed out | Tag data type is binary, text, or raw | Change to a numeric data type first, then enable scaling |
Output Format 99.9 still shows 25.7999992 |
The I/O field is bound to a tag of type String containing the raw float text |
Bind to the float tag directly; format applies to numeric tag only |
| TIA Portal V17: scaled value flickers between 25.4 and 25 | Two HMI tags are bound to the same PLC address with different scaling | Delete the duplicate tag; keep one float tag with linear scaling |
Field-Proven Tips
- For control loops with setpoint precision better than 0.01, use
Float 64-bit(LReal / double) on both the HMI tag and the PLC tag to avoid cumulative rounding in long archives. - When using linear scaling with negative gains (e.g. for inverted signals), add a Limit Value monitor to detect overflow into the engineering range.
- If the scaled value is used in a WinCC OnlineTrendControl, configure the Value Axis > Decimal Places explicitly. Trends do not inherit the I/O field's Output Format string.
- For redundant WinCC servers, linear scaling parameters are part of the project and replicate automatically; do not set scaling on a runtime tag in C scripts, as runtime-side scaling does not persist across restart.
FAQ
Why does my WinCC tag show 25 instead of 25.4 after linear scaling?
The WinCC tag is configured as an integer data type (Signed 16-bit, Signed 32-bit, etc.). Linear scaling computes 25.4 correctly, but the integer storage truncates the fractional portion to 25. Change the Data Type in Tag Management to Float 32-bit (or Float 64-bit); linear scaling then stores 25.4 in the archive.
How do I display 25.7999992370605 as 25.8 in an HMI I/O field?
Set the Output Format property of the I/O field to 99.9 (for one decimal), 99.99 (for two decimals), or n1 (with thousands separator). The format string only affects the textual display; the underlying float value in Tag Logging remains unchanged.
Can I attach a VBScript action to a Tag Logging archive with acquisition type "On Change"?
No. WinCC Tag Logging only allows actions on cyclic acquisition types. For "On Change" archives the only available scaling mechanism is the Linear Scaling parameter on the WinCC tag itself, which applies before the value reaches the archive and works for every acquisition type.
What is the exact Gain value to divide an integer by 10 in WinCC linear scaling?
Use Gain = 0.1 and Offset = 0.0. The internal formula is Output = (Input × 0.1) + 0.0, so a raw integer of 254 becomes 25.4, 1000 becomes 100.0, and 7 becomes 0.7. Make sure the WinCC tag data type is Float 32-bit or Float 64-bit, otherwise the result is truncated.
Do I need to change the PLC tag to REAL in the S7-1500 data block?
No. The HMI/WinCC tag data type is independent of the PLC tag data type. WinCC reads the integer raw value over the AS-OS connection, applies linear scaling, and stores the float in the Tag Logging archive. Leave the PLC tag as INT or DINT unless the control algorithm in the PLC itself requires fractional precision.
Is 25.8 representable exactly in IEEE 754 single precision?
No. The decimal value 25.8 has no finite binary representation; the closest IEEE 754 single-precision value is approximately 25.7999992370605. The displayed value 25.8 is purely a function of the I/O field's Output Format string rounding the textual representation. The archive will always store the underlying float.