1. Overview: OnlineTrendControl and Percentage Scaling
The Siemens OnlineTrendControl is the standard ActiveX/.NET control shipped with WinCC V7.x, WinCC Professional (TIA Portal) and WinCC Unified for plotting real-time and archived process data. In many process applications the underlying tag value represents an engineering unit (e.g. pressure in mbar, flow in l/min, count in pieces), but the operator should see a normalized 0-100% trend that maps the live value against an active setpoint.
The required scaling is the classic linear normalization:
Percentage = (ProcessValue / SetPoint) * 100
For example, with SetPoint = 200 and ProcessValue = 40, the control must draw the trend line at 20%. OnlineTrendControl cannot perform this division internally; the percentage must either be computed in the PLC and shipped to WinCC as a third tag, or it must be computed inside WinCC using a Global Action (WinCC V7) or a scripted tag (WinCC Unified) that writes into an internal HMI tag which is then archived by TagLogging.
This article covers both engineering paths and the matching OnlineTrendControl configuration steps for V7.x and for WinCC Unified V20. The official Siemens documentation for the online configuration of the trend control is maintained at the WinCC Unified V20 - Online Configuration of the Trend Control page and the WinCC V8.0 Information System - Operating Online Trend Control in Runtime entry.
2. Prerequisites and Engineering Environment
Before configuring percentage scaling, confirm the following items are present in the project.
| Item | WinCC V7.5 / V8.0 | WinCC Unified V20 (TIA Portal) |
|---|---|---|
| HMI engineering tool | WinCC Explorer / WinCC Configuration Studio | TIA Portal V20 with WinCC Unified option |
| Trend control | OnlineTrendControl (ActiveX, OCX) from WinCC Controls palette | TrendControl (WinCC Unified, .NET-based) from Controls toolbox |
| PLC connection | SIMATIC S7-1200/1500, S7-300/400 via S7DOS / TCP | S7-1200/1500 only, via integrated PLC interface |
| PLC tag data type | INT, REAL, DINT, WORD | Int, Real, DInt, Word |
| Scripting language | VBScript for Global Actions | JavaScript / VB-like Unified Scripting |
| Archiving | TagLogging RT / SQL | Logging tags (Unified Log) backed by SQLite / SQL |
3. Architecture Decision: PLC vs. HMI Calculation
WinCC global actions and WinCC Unified scripts run event-driven on the HMI's C/CPU scheduler, not cyclically at the PLC scan rate. When the number of tags or update frequency is moderate (a few dozen tags at 1 s update), WinCC-side calculation is acceptable. When you have hundreds of percentage values, fast update cycles (< 250 ms), or require deterministic behavior, move the calculation into the PLC.
| Criterion | Calculate in PLC (recommended) | Calculate in WinCC (Global Action) |
|---|---|---|
| Execution speed | PLC scan (1-10 ms typical) | WinCC scheduling (250-1000 ms typical) |
| Number of percentage tags | Unlimited | Up to ~50 per trigger |
| Source of truth | PLC (consistent with control logic) | HMI only (drift risk vs. PLC) |
| Coding language | SCL / STL / LAD / FBD | VBScript (V7) / JavaScript (Unified) |
| Network traffic | SetPoint + ProcessValue + Result (3 tags) | SetPoint + ProcessValue (2 tags, computed HMI-side) |
| CPU load on HMI | Minimal | Higher with many tags / events |
4. Method 1 - PLC-Side Percentage Calculation (Recommended)
The PLC owns the SetPoint and the ProcessValue; it should also own the normalized percentage. The result is shipped to WinCC as a third tag.
4.1 SCL Implementation (S7-1200 / S7-1500)
Add the following SCL block to your project. The function is reusable for any SetPoint / ProcessValue pair.
FUNCTION_BLOCK "FB_PercentScale"
VAR_INPUT
i_rProcessValue : REAL; // Tag2 - live process value
i_rSetPoint : REAL; // Tag1 - current setpoint
i_rMaxPercent : REAL := 100.0;
END_VAR
VAR_OUTPUT
q_rPercent : REAL; // Tag3 - 0..100 % result for WinCC
q_bDivZero : BOOL; // diagnostic flag
END_VAR
BEGIN
// Guard against setpoint = 0 to avoid DIV_BY_ZERO exception
IF ABS(i_rSetPoint) < 1.0e-6 THEN
q_rPercent := 0.0;
q_bDivZero := TRUE;
RETURN;
END_IF;
q_bDivZero := FALSE;
q_rPercent := (i_rProcessValue / i_rSetPoint) * i_rMaxPercent;
// Optional: clamp the display range so a noisy PV above SP
// does not draw a trend above 100 %
IF q_rPercent > 100.0 THEN q_rPercent := 100.0; END_IF;
IF q_rPercent < 0.0 THEN q_rPercent := 0.0; END_IF;
END_FUNCTION_BLOCK
Instance DB layout (WinCC side address these symbols directly):
| Symbol | Type | WinCC address example | Comment |
|---|---|---|---|
i_rProcessValue |
REAL | DB20.DBD0 | Tag2 - ProcessValue |
i_rSetPoint |
REAL | DB20.DBD4 | Tag1 - SetPoint |
q_rPercent |
REAL | DB20.DBD8 | Tag3 - scaled 0-100 result |
q_bDivZero |
BOOL | DB20.DBX12.0 | Diagnostic flag |
4.2 Ladder Equivalent (S7-300/400 or LAD-only projects)
For installations still on STEP 7 V5.x or S7-300, the same result is achievable with two networks:
// Network 1 - DIV / R (divide REAL by REAL)
A "DB_Process".SetPointNotZero // user-defined safe-bit
JCN DIV0
L "DB_Process".ProcessValue // Tag2
L "DB_Process".SetPoint // Tag1
/R
L 1.000000e+002 // 100.0
*R
T "DB_Process".PercentOut // Tag3
JU ENDOK
DIV0: L 0.0
T "DB_Process".PercentOut
ENDOK: NOP 0
4.3 WinCC V7 Tag Configuration for the PLC Path
- Open WinCC Explorer > Tag Management.
- Create three tags, all on the same S7 channel / connection:
| Tag name | Data type | PLC address | Length |
|---|---|---|---|
| Tag_SP_SetPoint | REAL | DB20.DBD4 | 4 bytes |
| Tag_PV_ProcessValue | REAL | DB20.DBD0 | 4 bytes |
| Tag_PCT_Percentage | REAL | DB20.DBD8 | 4 bytes |
- Set the acquisition cycle of
Tag_PCT_Percentageto 1 s (or match your PLC OB1 cycle). For an OB35 cyclic interrupt, use 1000 ms or 500 ms as the WinCC acquisition cycle. - Verify the value round-trip: in the WinCC tag simulator, force
Tag_PV_ProcessValue= 40 andTag_SP_SetPoint= 200. ConfirmTag_PCT_Percentagereads 20.0.
5. Method 2 - WinCC V7 Global Action for Percentage Calculation
When the SetPoint is read-only on the HMI and the number of percentage tags is small, do the math in WinCC.
5.1 Create the Internal Tag
- In WinCC Explorer, right-click Tag Management > Add new tag.
- Name:
Tag3_Percentage. Type: Direct (no PLC address). Internal data type: FLOAT (32-bit IEEE 754). - This tag lives entirely in WinCC memory; it will not poll the PLC.
5.2 Build the Global Action
- Open Global Script > C Editor (ANSI-C) or use a VBScript action. The VBScript approach is simpler and event-driven.
- Create a new action named
act_CalcPercentage. - Set the trigger to the
Tag2_ProcessValuetag (the variable that changes most often). WinCC will fire the action on every value change of that tag.
' --- VBScript Global Action: act_CalcPercentage ---
Option Explicit
Dim sp, pv, pct
sp = HMIRuntime.Tags("Tag1_SetPoint").Read ' e.g. 200
pv = HMIRuntime.Tags("Tag2_ProcessValue").Read ' e.g. 40
If Abs(sp) < 0.000001 Then
pct = 0
Else
pct = (pv / sp) * 100
End If
' Clamp to 0..100
If pct > 100 Then pct = 100
If pct < 0 Then pct = 0
HMIRuntime.Tags("Tag3_Percentage").Write pct
5.3 ANSI-C Equivalent (lower-overhead variant)
/* act_CalcPercentage (C) */
#include "apdefap.h"
BOOL _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
float sp = GetTagFloat("Tag1_SetPoint");
float pv = GetTagFloat("Tag2_ProcessValue");
float pct;
if (fabs(sp) < 1e-6f) {
pct = 0.0f;
} else {
pct = (pv / sp) * 100.0f;
}
if (pct > 100.0f) pct = 100.0f;
if (pct < 0.0f) pct = 0.0f;
SetTagFloat("Tag3_Percentage", pct);
return TRUE;
}
1s_Tick) instead of the process value tag.5.4 WinCC Unified JavaScript (TIA Portal V20)
In WinCC Unified the trend control and the scripting host are .NET-based. The equivalent of the V7 global action is a Scheduled task or a Tag trigger with JavaScript:
// Unified Script - scheduled tag trigger on Tag2
export function Percentage_Calc() {
const sp = Tags("Tag1_SetPoint").Read();
const pv = Tags("Tag2_ProcessValue").Read();
let pct;
if (Math.abs(sp) < 1e-6) {
pct = 0;
} else {
pct = (pv / sp) * 100.0;
}
if (pct > 100) pct = 100;
if (pct < 0) pct = 0;
Tags("Tag3_Percentage").Write(pct);
}
Bind this script to a tag trigger on Tag2_ProcessValue or schedule it at 1 s on a Unified Scheduled task.
6. Configuring OnlineTrendControl Value Range (0-100)
Whether you computed the percentage in the PLC or in WinCC, the OnlineTrendControl must now draw the 0-100 range. Two parameter groups control the visual scale: value axis range and Y-axis scaling.
6.1 WinCC V7 - Static Axis Configuration
- Insert the OnlineTrendControl from the Controls palette onto the picture.
- Right-click the control > Configuration dialog > tab Trends > Add.
- Configure the trend:
| Parameter | Setting |
|---|---|
| Name | Percentage |
| Tag name / archive |
Tag3_Percentage (or its TagLogging archive) |
| Color | Operator-defined (green / blue typical) |
| Line type | Solid, 2 px |
- Switch to tab Value axes and add or edit the axis that drives the Percentage trend:
| Axis parameter | Value | Notes |
|---|---|---|
| Selection | Value axis left / right | Pick a clean side |
| Begin value | 0 | Hard 0 % lower bound |
| End value | 100 | Hard 100 % upper bound |
| Scaling type | Linear | Default; do not use logarithmic |
| Decimal places | 1 | Displays 20.0 % etc. |
| Label | % | Axis caption |
| Auto-range | Off | Mandatory for fixed 0-100 |
- Click Apply, close the dialog, and rebuild the project. Activate Runtime to verify the axis is locked to 0-100.
6.2 WinCC V7 - Dynamic Axis via Property Linking
Sometimes the SetPoint is not a constant: the operator may enter it. To dynamically scale the axis to 0-SetPoint while keeping a 0-100 % trend, expose two extra tags and bind them with a VB script that rewrites the ValueAxisBegin / ValueAxisEnd properties of the control.
' Set dynamic axis: 0 .. current SetPoint
Dim sp
sp = HMIRuntime.Tags("Tag1_SetPoint").Read
Dim objTrend
Set objTrend = ScreenItems("Control1")
objTrend.GetTrend("RawValue").ValueAxis = 0 ' left axis
objTrend.GetTrend("RawValue").ValueAxisBeginValue = 0
objTrend.ValueAxisEndValue = sp ' raw range 0..SP
objTrend.ValueAxisLabel = "Raw " & CStr(sp)
For the percentage trend, keep the axis fixed at 0-100 as in section 6.1 so the operator's eye sees a consistent normalized plot.
6.3 WinCC Unified V20 - TrendControl
The Unified trend control exposes the same parameters via the Properties pane:
- Drag TrendControl from the toolbox onto the screen.
- In Properties > Trend areas > [index], set
Source= the logging tag forTag3_Percentage. - In Properties > Axes, set the Y-axis to Manual range with
Min = 0,Max = 100,Scale = Linear. - For runtime adaptation, follow the WinCC Unified V20 online configuration page to enable Online configuration so operators can adjust the axis without an engineering rebuild.
7. TagLogging Configuration
The trend will only persist historical data if Tag3_Percentage is added to a TagLogging archive. Otherwise the curve is drawn live but cannot be reviewed past the buffer window.
7.1 WinCC V7 TagLogging
- Open Tag Logging in WinCC Explorer.
- Right-click Archives > Add new archive (e.g.
ProcessArchive) or use the default system archive. - Inside the archive add Tag3_Percentage:
| Archive parameter | Recommended value |
|---|---|
| Acquisition cycle | 1 s (match PLC update) |
| Archiving cycle | 1 s (1:1) or 5 s for long retention |
| Compression | None / swinging door for slow archives |
| Storage location | Default database (SQL Server Express for V8.0) |
| Retention | Project requirement (e.g. 30 days) |
- Bind the trend in OnlineTrendControl to TagLogging archive instead of the raw tag. The control will then offer both Online (live) and Archive (history) display modes.
7.2 WinCC Unified V20 Logging
- In TIA Portal, open HMI tags, select
Tag3_Percentage, and enable Logging. - Set Logging cycle = 1 s and Logging mode = Cyclic continuous.
- The trend control's data source becomes the log automatically.
8. Online Configuration in Runtime
WinCC's online configuration lets operators tune the trend without restarting Runtime. The unified manual describes this in detail; the V7/V8 documentation entry 109818193 covers the V8 runtime path.
8.1 Enable Online Configuration at Design Time
- Select the OnlineTrendControl in the Graphics Designer.
- In the configuration dialog's Miscellaneous tab, set Online configuration = On.
- Rebuild the project and start Runtime.
8.2 Runtime Operator Actions
- Right-click the trend > Online configuration...
- Change axis begin/end, time range, color, line type, or trend selection.
- Click OK to apply. Changes persist for the Runtime session; they are saved on Stop Runtime via the project settings if Persist online configuration is enabled.
9. Verification and Commissioning Tests
Run these checks before sign-off:
| Test # | Procedure | Expected result |
|---|---|---|
| 1 | Force PV = 0 | Trend draws at 0.0 % |
| 2 | Force PV = SP | Trend draws at 100.0 % |
| 3 | Force PV = 0.5 * SP | Trend draws at 50.0 % |
| 4 | Force PV = 1.1 * SP (overshoot) | Trend clamped at 100.0 % (if clamp enabled) |
| 5 | Force SP = 0 (zero divide) | Tag3 reads 0.0, div-zero flag = TRUE, no exception logged |
| 6 | Change SP live from operator panel | Percentage trend recomputes within one acquisition cycle |
| 7 | Stop / Start Runtime | Archive history preserved, online buffer re-initializes |
| 8 | Open trend from historical archive (V7) or history view (Unified) | Historical curve matches live curve at the same time stamp |
10. Performance and Update Cycle Considerations
Several parameters interact and determine the perceived latency of the trend:
- PLC scan / OB1: 5-20 ms typical. If the percentage block runs in OB1 with 5 ms, Tag3 will update every 5 ms in the PLC image.
- PLC -> WinCC acquisition: configured per tag. 250 ms, 500 ms and 1000 ms are the three common production values. Below 250 ms the load on the S7 connection rises sharply.
- WinCC archive cycle: should equal the acquisition cycle to avoid dropped samples. A 1 s acquisition with a 500 ms archive cycle causes double-write, while a 2 s archive with a 1 s acquisition causes apparent lag.
- Global action trigger frequency: if you compute in WinCC, the trigger rate is the bottleneck. Triggering on a 1 s timer tag is more deterministic than triggering on the process value change tag, which can burst when the PLC updates a block of related values.
- CPU and memory on the HMI: 100 percentage tags at 1 s generate ~8.6 million samples per day. SQL Express 2017 / 2019 can handle this; below SQL Express, defragment the archive periodically.
11. Troubleshooting Matrix
| Symptom | Likely cause | Fix |
|---|---|---|
| Trend always shows 0 % | PLC block not called or q_rPercent not mapped | Verify FB call in OB1 and WinCC tag address (DB20.DBD8) |
| Trend shows flat line at 100 % | PV >> SP and clamp not enabled; or global action overwriting | Disable clamp and verify raw PV; enable logging on raw tag to compare |
| Trend shows NaN or empty | SetPoint = 0 reached during operator entry | Add div-zero guard in PLC or WinCC script (sections 4.1, 5.2) |
| Trend is stale by several seconds | Acquisition cycle too long | Reduce WinCC acquisition to 1 s; verify PLC scan cycle |
| Online configuration grayed out | Online configuration disabled at design time | Set Online configuration = On in control properties |
| Historical view empty | Tag3 not added to TagLogging archive | Add Tag3 to an archive and re-arm the trend data source |
| Curve jumps wildly | Real-time tag jitter from cyclic OB inconsistent with archive | Align OB1 cycle, WinCC acquisition cycle and archive cycle |
| WinCC Unified compile error "Undefined Tag3" | Tag scope mismatch (Local vs. Global) | Move Tag3 from Local to Global HMI tags |
12. Summary
OnlineTrendControl cannot normalize a process value against a setpoint internally. The percentage must be computed upstream and delivered as a third tag. Prefer the PLC-side calculation for performance and consistency; use the WinCC global action / Unified script approach for small projects where the math should remain inside the HMI. Lock the Y-axis to 0-100 for a clean normalized trend, add the result tag to TagLogging for historical review, and enable online configuration so operators can adapt the view at runtime. The official Siemens references for the runtime behaviour of the trend control are the WinCC Unified V20 trend control documentation and the WinCC V8.0 Information System entry 109818193.
13. Frequently Asked Questions
Can OnlineTrendControl divide one tag by another tag internally?
No. OnlineTrendControl plots the value of the source tag directly. To display a percentage, you must compute (ProcessValue / SetPoint) * 100 in the PLC or in a WinCC script and provide the result as a third tag, which OnlineTrendControl then plots against a 0-100 axis.
Which is faster, calculating in the PLC or in a WinCC global action?
Calculating in the PLC is faster and more deterministic. PLC scan cycles are typically 1-10 ms while WinCC global actions run event-driven on the HMI scheduler at 250-1000 ms. For more than ~50 percentage tags or update cycles below 1 s, use the PLC path.
How do I lock the Y-axis to 0-100 in OnlineTrendControl?
In the control's configuration dialog, open the Value axes tab, set Begin value = 0, End value = 100, set Scaling type = Linear and disable Auto-range. In WinCC Unified, set the Y-axis Min = 0 and Max = 100 in the Properties pane under Axes.
What happens when the setpoint is zero?
A direct division produces a division-by-zero exception. Guard the calculation in the PLC with an IF check on the setpoint magnitude and write 0.0 to the output when SP is approximately zero. The same guard belongs in VBScript or JavaScript if you compute in WinCC.
Why is the trend empty when I look at historical data?
The percentage tag must be added to a TagLogging archive (V7) or marked as Logging in TIA Portal (Unified). The OnlineTrendControl only displays history for tags that are actually being archived; if Tag3_Percentage is not archived, only the live buffer is shown and it disappears on Runtime restart.