Reading Linear Scaled Process Values in WinCC Runtime

David Krause18 min read
HMI / SCADASiemensTutorial / How-to
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

Reading Linear Scaled Process Values in WinCC Runtime

Linear scaling in WinCC maps a raw PLC value to an engineering value at the HMI tag boundary. Once configured in Tag Management > Tag Properties, the transform is applied transparently to every read and write of the tag in runtime. An I/O field bound to a scaled tag displays the engineering value, and any value the operator enters is converted back to the raw value before being written to the PLC. The same applies to VBScript and C script access when the script is bound to the scaled tag, not to a raw tag you have re-implemented by hand.

This article documents the scaling equation, configuration in WinCC V7/V8 and TIA Portal (WinCC Comfort/Advanced/Professional), runtime access via I/O fields, VBScript, and C scripts, the manual inverse conversion you must apply if you bypass the tag, and the verification procedure that proves the mapping is correct before commissioning.

Engineering intent vs. tag value. In this document raw value is the integer in the PLC DB/MW, process value is the engineering unit (e.g., 0.0–100.0 °C) shown to the operator, and scaled tag value is the value the WinCC tag exposes after the linear transform. Operators work with the process value; control code in the PLC works with the raw value. WinCC's role is to bridge the two without you writing a custom conversion in every screen.

Linear Scaling Fundamentals

WinCC's linear transform implements the affine equation:

y = a · x + b

where:

  • x = raw value from the PLC (integer in PLC engineering units, e.g., 0–27648 for a S7 analog input normalized to the SIMATIC range)
  • y = scaled process value exposed to WinCC, in the engineering unit (e.g., degrees Celsius, bar, liters per minute)
  • a = slope (gain). WinCC calls this the gradient or factor.
  • b = offset. Optional; defaults to 0 in most dialogs.

For the common case described in the field report (data divided by 10 to display as tenths), the factor is a = 0.1 and the offset is b = 0, giving y = 0.1 · x. A raw PLC value of 235 becomes a displayed value of 23.5. If the operator must be able to enter a value, the I/O field binds to the same scaled tag, and WinCC applies the inverse automatically on every write.

To reverse the transform when the operator types a new value into an I/O field, WinCC computes the inverse:

x = (y − b) / a

If the user types 23.5 into the I/O field, the tag writes 235 back to the PLC. There is no rounding step inside the dialog-based transform; if the displayed value and the raw integer both have fractional precision, the conversion goes through the floating-point representation of the tag and is only rounded to the PLC's data type at the boundary.

Direction matters. Linear scaling in WinCC is a bidirectional transform on a single tag. The same factor and offset are used for both read (PLC → HMI) and write (HMI → PLC). If you need an asymmetric transform (e.g., a square-root on read but linear on write), use a separate internal tag and a script instead of the dialog-based linear scaling.

Configuring Linear Scaling in WinCC Tag Management

Open the tag properties and switch to the Properties tab. Under Linear scaling, tick Active and enter the end points of the mapping. WinCC will derive the slope and offset from the two end points, but you can also enter a and b directly when you have them pre-computed.

Field Example: S7 AI → 0.0–100.0 °C Example: S7 AI → 0.0–10.0 bar Example: Counter 0–1000 → 0–100 %
PLC value range start (x₁) 0 0 0
PLC value range end (x₂) 27648 27648 1000
HMI / process value start (y₁) 0.0 0.0 0.0
HMI / process value end (y₂) 100.0 10.0 100.0
Derived slope a = (y₂−y₁)/(x₂−x₁) ≈ 0.003617 ≈ 0.000362 0.1
Derived offset b = y₁ − a·x₁ 0 0 0

For S7 analog inputs the PLC range end should be 27648 (or 27649 on older CPUs), not the raw 16-bit count 32767. Using 32767 introduces a 2.38× scale error because the S7 normalizes the input to 0–27648 by design and uses 27649–32767 for the over-range and overflow diagnostic values described in the S7 analog module manuals.

You can override the computed a and b with explicit values when you need a non-linear mapping through a single linear segment (e.g., a 4–20 mA input mapped to a 0.0–10.0 bar process range with a 4 mA zero suppression), or when the PLC range is wider than the operating window (e.g., mapping 0–27648 → 0–150 °C, then clamping at the dialog limits so that values above 150 °C are reported as out-of-range rather than scaled up).

Configuration in TIA Portal (WinCC Comfort / Advanced / Professional)

In TIA Portal, open the HMI tag's properties and expand Linear scaling. Per the Siemens Support entry ID 109054417 (STEP 7 Basic V13.1, applying linear scaling to a tag):

"To apply linear scaling to a tag, you must specify one value range on the HMI device and one on the PLC. The value ranges will be mapped to each other linearly."

Enter the PLC range in PLC and the HMI range in HMI; the tool stores the resulting a and b on the tag. The transform runs at runtime and is visible to I/O fields, faceplate tags, alarm limits, and any script that reads the tag symbolically. TIA Portal also writes the scaling to the device's runtime file, so the same configuration is loaded when the panel boots from the project.

Configuration in WinCC V7 / V8 (Classic)

In WinCC V7/V8 (the classic, non-TIA generation), open the Tag Management editor, double-click the tag, and switch to the Properties tab. Tick Linear scaling and enter the two end-point pairs. Per the Siemens Support entry ID 109780723 (scaling a process value in WinCC V7/V8):

"Here you must read the value of the PLC variable, divide it by the scaling factor (1000, for example) and pass it as a process value."

WinCC stores the slope and offset with the tag in the project's database. The transform is applied at the HMI runtime layer, so a faceplate, an archive tag, and a script reading the same tag all see the scaled value without further conversion.

Where the transform lives. The scaling coefficients are stored on the HMI tag, not on the PLC tag. This means a change to the scaling range takes effect only after a recompile and a download of the HMI project; the PLC program does not need to be touched.

Runtime Data Flow

S7 PLC DB1.Temp_Raw (Int) WinCC Tag Temperature_Process HMI / Script I/O field, VBS, C x (raw) y = a·x + b y (process) x = (y-b)/a S7 PLC DB1.Temp_Raw updated WinCC Tag Temperature_Process Operator enters 75.0 °C Read path (top, blue): PLC raw value → WinCC tag → HMI. Write path (bottom, red): Operator → WinCC tag → PLC raw value. For a 0–27648 → 0.0–100.0 °C scale, raw = 20736 maps to y = 75.0 °C and back.

Reading and Writing Scaled Values in I/O Fields

Bind an I/O field to the scaled tag, not to the raw PLC variable:

  1. In the Graphics Designer (WinCC V7/V8) or the screen editor (TIA Portal), drag an I/O field onto the picture.
  2. Open Configuration > Tag (WinCC V7/V8) or Properties > General > Tag (TIA Portal).
  3. Select the scaled WinCC tag (the same tag you configured linear scaling on). Do not select the raw PLC tag.
  4. Set the data format to match the engineering unit: Float32 for fractional values (tenths, hundredths), Decimal for integer counts, Long Integer for large counter values.
  5. Set the field type to Input/Output if the operator must be able to change the value at runtime; Output if the value is read-only.
  6. Set the field length to a value wide enough to display the full range (e.g., 6 characters for 0.0–100.0 °C, 8 characters for 0.000–100.000).

At runtime, the I/O field shows the engineering value (e.g., 23.5). When the operator types a new value (e.g., 24.0) and confirms, WinCC applies the inverse transform and writes the raw value (240) to the PLC. No script is required.

Do not bind to the raw tag. A common mistake is to bind the I/O field to the original PLC tag and re-implement the scaling in a script. This duplicates the transform, and any change to the configured factor must be made in two places. Always bind the I/O field to the scaled tag.

Accessing Scaled Values via VBScript

VBScript reads and writes the scaled value when the script is bound to the scaled tag. The script never sees the raw integer unless you deliberately read the underlying PLC tag.

Read scaled process value

' "Temperature_Process" is a scaled HMI tag with linear scaling enabled
Dim pv
pv = HMIRuntime.Tags("Temperature_Process").Read
HMIRuntime.Trace "Process value: " & pv & " °C"

Write scaled process value

' Operator entered 75.0 °C in a popup; write it back through the scaled tag
Dim newPv
newPv = 75.0
HMIRuntime.Tags("Temperature_Process").Write newPv

Read raw value (diagnostics only)

To read the raw integer directly, reference the underlying PLC tag, not the scaled HMI tag:

' "DB1_Temp_Raw" is the unscaled PLC tag in the tag list
Dim raw
raw = HMIRuntime.Tags("DB1_Temp_Raw").Read
HMIRuntime.Trace "Raw value: " & raw

Use the raw read only for diagnostics or for control logic that needs the integer form (e.g., comparing against a bit pattern). For operator dialogs, faceplate displays, and any value that the operator can change, always use the scaled tag.

Tag name resolution. HMIRuntime.Tags(...).Read looks up the tag by its symbolic name. The runtime resolves the name to the underlying data manager entry, applies the linear scaling, and returns the scaled value. The symbol is case-insensitive in the project file but is conventionally spelled as defined in the tag list.

Accessing Scaled Values via C Script

C scripts in WinCC V7 use the GetTag / SetTag family. Like VBScript, the script reads the scaled value when bound to a scaled tag.

Read scaled process value

// "Temperature_Process" is a scaled HMI tag
float pv = 0.0f;
GetTagFloat("Temperature_Process", &pv);
printf("Process value: %f °C\r\n", pv);

Write scaled process value

float newPv = 75.0f;
SetTagFloat("Temperature_Process", newPv);

Manual inverse calculation (only when bypassing the tag)

If you must read the raw PLC variable and convert it yourself, apply the inverse of the configured transform. The general form is:

processValue = (rawValue − b) / a

For the source example (raw divided by 10, i.e., a = 0.1, b = 0):

// C script reading a raw integer and computing the engineering value
int raw = 0;
GetTagSDWord("DB1_Temp_Raw", &raw);
float pv = raw / 10.0f;        // (rawValue - 0) / 0.1 == raw * 10
printf("Process value: %f\r\n", pv);

For the write direction:

rawValue = round( (processValue − b) / a )

// C script writing a process value back to a raw integer
float pv = 75.0f;
int raw = (int)((pv - 0.0f) / 0.1f + 0.5f);   // round to nearest integer
SetTagSDWord("DB1_Temp_Raw", raw);

Per the Siemens Support entry ID 109780723, when the script bypasses the scaled tag you must perform this conversion explicitly: read the PLC variable, divide by the scaling factor, and pass the result as a process value.

Avoid float → int rounding drift. When converting a process value back to a raw integer, add 0.5 before truncation (positive values) or subtract 0.5 (negative values). Floating-point drift on values like 0.1 can otherwise produce off-by-one errors in the PLC (e.g., 749 instead of 750).

Where to Apply the Scaling: HMI Tag vs. PLC

Linear scaling can live on the HMI tag, in the PLC (using the S7 SCALE / UNSCALE FCs from the Standard Library, or the new SCALE_X / NORM_X / SCALE instructions in S7-1500), or in both. The right place depends on who consumes the value:

Consumer Recommended location Reason
Operator HMI only HMI tag (WinCC linear scaling) Single point of configuration; no PLC code change when the range changes
Multiple HMIs / SCADA / OPC UA clients PLC (scaled REAL in the DB) Every consumer reads the engineering value directly; no client-side conversion
PLC control logic needs both raw and engineering PLC keeps raw integer; HMI scales Control loops prefer integer math; HMI shows the engineering value
Recipe / setpoint value written by HMI and consumed by PLC math PLC (scaled REAL); HMI tag uses linear scaling for display Recipe data is stored in engineering units; the PLC reads REAL directly

Mixing both is acceptable but requires discipline: keep the HMI scaling and the PLC scaling in lockstep, and document both in the tag comment. A mismatch (e.g., HMI scaled twice, or PLC scaled and HMI scaled again) is the single most common source of off-by-a-factor-of-10 errors at commissioning.

Numeric Format and Data Type Considerations

The scaled tag value's data type is determined by the tag definition, not by the configured scaling. If the raw tag is a 16-bit integer and you scale it to a 0.0–100.0 °C range, the scaled value is still a 16-bit integer internally (multiplied by 10 in WinCC's internal storage as 0–1000 tenths). I/O fields configured as Float32 will show one decimal place; I/O fields configured as Decimal will show an integer.

For S7 analog inputs, use the following mapping convention:

Signal PLC range (x) Typical process range (y) Slope a
4–20 mA, 0–10 V (S7 AI normalized) 0–27648 0.0–100.0 °C 100.0 / 27648 ≈ 0.003617
4–20 mA, 0–16 bar pressure 0–27648 0.0–16.0 bar 16.0 / 27648 ≈ 0.000579
RTD / thermocouple via TI module 0–27648 −50.0 to +200.0 °C 250.0 / 27648 ≈ 0.009041
Counter, 0–65535 pulses 0–65535 0.0–100.0 % 100.0 / 65535 ≈ 0.001525

The 4 mA zero suppression on a 4–20 mA input is implemented in the PLC analog module (or the channel configuration in TIA Portal) by setting x₁ to the value the module returns at 4 mA, typically 0 for a Siemens AI8 module, not by adjusting the WinCC linear scaling.

Faceplate, Archive, and Alarm Considerations

The same scaled tag should be reused across faceplates, archive configurations, and alarm limits. Mixing scaled and raw references in the same faceplate is a common source of operator confusion: one label shows 23.5 °C and another shows 235, and the operator cannot tell which is the engineering value.

For tag logging, the archive configuration references the scaled tag directly. WinCC stores the scaled value in the archive; no further conversion is applied on read-back, and the historical trend displays the engineering value. If you accidentally reference the raw tag in the archive, the trend will show 0–27648 (or 0–65535) instead of the engineering range, and a downstream report will need to scale the values before plotting.

For alarm limits, define the limit values in engineering units (e.g., HH = 95.0 °C, H = 80.0 °C, L = 5.0 °C, LL = 0.0 °C) on the scaled tag. WinCC applies the limit comparison after the linear transform, so a raw PLC value of 26266 (≈ 95.0 °C) trips the HH alarm. Defining the same limits on the raw tag would require 26266 instead of 95.0, which is unreadable in the alarm log.

Runtime Verification Procedure

Confirm the scaling is correct before commissioning:

  1. Open the WinCC project in Runtime and navigate to the picture with the I/O field.
  2. Force the underlying PLC tag to three known raw values: zero (0), midpoint (13824 for a 0–27648 range), and full scale (27648).
  3. Read the I/O field. It must show 0.0, 50.0, and 100.0 respectively for the 0–100 °C example.
  4. Type a new engineering value (e.g., 75.0) in the I/O field and confirm. Watch the raw PLC tag in the STEP 7 / TIA Portal watch table; it must hold the raw integer (e.g., 20736 for 75.0 °C on a 0–27648 → 0.0–100.0 °C scale).
  5. Trigger a tag trace (WinCC V7/V8: Tag Logging > Tag Simulation; TIA Portal: Tools > Tag trace) on both the raw and scaled tags to confirm the linear relationship over the full range.
  6. Verify the boundary behavior: type a value above the configured maximum (e.g., 150.0) and confirm the write is clamped to the configured end-point, or rejected, depending on the tag's overflow configuration.
  7. Verify the inverse path on a write: type a fractional value (e.g., 23.7) and confirm the raw integer is rounded to the nearest representable value (237 in the divide-by-10 case).
Audit the tag comment. Store the configured mapping in the tag's comment field in the tag list (e.g., "Linear: 0–27648 → 0.0–100.0 °C, a=0.003617, b=0, last verified 2024-03-15"). The commissioning audit trail can then confirm the scaling without re-deriving the coefficients from the project tree.

Troubleshooting Matrix

Symptom Likely cause Remediation
I/O field shows raw integer instead of engineering value Bound to the raw PLC tag, not the scaled HMI tag Re-bind the I/O field to the scaled tag
Operator entry does not change the PLC value Field type is set to Output only, or the tag's access level is set to read-only Set field type to Input/Output; confirm the tag's Authorization in tag properties
Off-by-one error at the high end (e.g., 99.9 instead of 100.0) Integer rounding in the inverse transform, or PLC range end set to 32767 instead of 27648 Round to nearest integer; verify x₂ = 27648 (or 27649); confirm the tag's data type
Scaled value flickers between two values PLC value is updating faster than the tag acquisition cycle, or a/b are wired to internal tags that are being animated Lower the acquisition cycle (TIA Portal: Acquisition cycle; WinCC V7: Update); keep a/b as static configuration
Script shows correct scaled value, but PLC does not receive the write Script uses Read instead of Write, or the tag is configured as Read only Use Write / SetTag*; verify the tag's access level
Linear scaling field greyed out in the dialog Tag is a string, or the tag's data type is a raw pointer / text reference Use a numeric tag type (Int, DInt, Real, Float)
Value at 4 mA reads as 0.0 °C instead of the configured start (e.g., −50.0 °C) PLC analog module is reporting 0 at 4 mA (no zero suppression handled by the module), and the WinCC scaling is not adjusting for the 4 mA offset Add the 4 mA offset to the PLC-side end points in the scaling dialog, or configure zero suppression in the PLC analog module
Negative values shown as very large positives Tag data type is unsigned (Word) but the PLC value is signed (Int) Change the tag data type to Int (16-bit signed) or DInt (32-bit signed)
Process value updates lag the raw value by one or two acquisition cycles Tag is configured as On demand or has a long update cycle Switch to Cyclic continuous with a 100–500 ms cycle for display values
Archive trend shows 0–27648 instead of 0.0–100.0 Archive tag references the raw PLC tag, not the scaled HMI tag Re-point the archive tag at the scaled HMI tag

Best Practices

  • Configure scaling on the HMI tag, not in a script. The transform is then visible to every consumer (I/O field, faceplate, alarm limit, archive) without duplication.
  • Keep a and b as static configuration. If you need different ranges per screen, define separate scaled tags rather than animating the gradient with an internal tag at runtime.
  • Document the configured mapping in the tag's comment field so the conversion is auditable at commissioning.
  • For asymmetric transforms (e.g., square-root extraction on read, linear on write), use a separate internal tag and a script, not the dialog-based linear scaling.
  • For S7 analog inputs, set x₁ / x₂ to the actual S7 normalized range (0–27648) rather than the raw 16-bit count (0–65535) to avoid a 2.38× scale error.
  • Use the same scaled tag in faceplates, archive configurations, and alarm limits. Mixing scaled and raw references in the same faceplate is a common source of operator confusion.
  • Test the inverse path explicitly: type a fractional value, confirm the raw integer, and check for rounding drift.
  • If you must change the scaling range after deployment, recompile and re-download the HMI project; the change is not hot-reloadable from the runtime.
  • For multi-panel deployments, define the scaled tag once in the shared tag list and reuse it on every panel rather than redefining it per device.

FAQ

Can I read a scaled process value from an I/O field in WinCC Runtime?

Yes. Bind the I/O field to the scaled HMI tag (not the raw PLC tag). The linear transform configured in Tag Properties > Linear scaling is applied automatically on every read and write, so the I/O field displays the engineering value and the operator's entry is converted back to the raw value before being written to the PLC. No script is required.

Do I need a VBScript or C script to use linear scaling at runtime?

No. The transform runs inside the tag, not in a script. Scripts are only required when you need to read the raw value for diagnostics, log an out-of-range condition, or implement an asymmetric transform (e.g., square-root on read, linear on write) that the dialog-based linear scaling does not support.

What equation does WinCC apply for linear scaling?

WinCC uses y = a · x + b, where x is the raw PLC value, y is the process value, a is the slope, and b is the offset. The inverse for writes is x = (y − b) / a. If you bypass the tag and read the raw PLC variable directly, you must apply the inverse manually; for a divide-by-10 mapping, divide the raw value by 10 to get the process value and multiply by 10 to go back.

Can I change the linear scaling factor at runtime?

No. The factor and offset are static configuration in tag properties. To change the mapping while the project is running, use an internal tag for the gradient/offset and apply the transform in a script, or define a second scaled tag with the alternate range and switch the I/O field binding via a visibility / property animation.

Why does my I/O field show the raw integer even though I enabled linear scaling?

The most common cause is that the I/O field is bound to the raw PLC tag rather than the scaled HMI tag. Other causes include the linear scaling field being greyed out because the tag is a string or pointer type, or the tag's data type being unsigned (Word) while the PLC value is signed (Int). Re-bind to the scaled tag and confirm the tag's data type is a signed numeric (Int, DInt, Real).

Back to blog