Scale the value in the PLC, add helpers in ladder or SCL (an archive enable and minute min/max/average), load the tags into WinCC, create a process value archive in Tag Logging with sensible acquisition and archiving cycles or archiving on change with hysteresis, plan segment size and backup, and display it with the OnlineTrendControl and OnlineTableControl.
- Acquisition reads, archiving stores – size both deliberately.
- Compress steady values with archiving on change.
- Let the PLC capture peaks inside each archive interval.
How Tag Logging Is Structured
Tag Logging reads tags at an acquisition cycle, writes values into a process value archive at an archiving cycle (optionally mean, min or max of the interval, or on change), and stores them in time segments that can be backed up. Controls in Graphics Designer then read live and historical values from the archive.
Lab Flow: From Flow Transmitter to WinCC Trend
Every lesson in the Softwell PLC lab manual series follows the same six stages and the same address rule, so the code you write here plugs straight into the HMI lessons.
Stage 1Field Wiring and PLC Tags
| PLC tag | Address | Type | Device / comment |
|---|---|---|---|
FT501_Raw | %IW110 | Int | Flow 4–20 mA = 0 – 20 m³/h |
M501_Running | %I8.6 | Bool | Line running feedback |
Stage 2Input Mapping and Scaling
// FC_InputMapping "DB_IO".FT501_Valid := "FT501_Raw" <= 32511; "DB_IO".FT501_m3h := SCALE_X(MIN := 0.0, MAX := 20.0, VALUE := NORM_X(MIN := 0, VALUE := "FT501_Raw", MAX := 27648)); "DB_IO".M501_Running := "M501_Running";
Stage 3PLC Logic in Ladder and SCL
The same logic in SCL – use whichever your plant standard prefers; both write the same DB members that WinCC reads:
// FB_ArchiveHelper in OB30 (1 s) – min/max/avg over each minute for a compressed archive
// STAT: n : Int; sum, mn, mx : Real; DB_Arch: Avg1m, Min1m, Max1m : Real; ArchiveEnable : Bool;
"DB_Arch".ArchiveEnable := "DB_IO".M501_Running AND "DB_IO".FT501_Valid; // ladder network 1
IF #n = 0 THEN #mn := "DB_IO".FT501_m3h; #mx := "DB_IO".FT501_m3h; #sum := 0.0; END_IF;
#sum := #sum + "DB_IO".FT501_m3h;
#mn := MIN(IN1 := #mn, IN2 := "DB_IO".FT501_m3h);
#mx := MAX(IN1 := #mx, IN2 := "DB_IO".FT501_m3h);
#n := #n + 1;
IF #n >= 60 THEN // every minute
"DB_Arch".Avg1m := #sum / 60.0; "DB_Arch".Min1m := #mn; "DB_Arch".Max1m := #mx;
#n := 0;
END_IF;Stage 4Link PLC Tags to WinCC
In Tag Management add the SIMATIC S7-1200, S7-1500 Channel, create a connection with the CPU IP address, then use AS Symbols to load the PLC symbols and drag the DB members you need into a tag group. The DB members must have Accessible from HMI ticked in TIA Portal. Names and menus can differ slightly between WinCC versions.
| WinCC tag | Data type | Connection / address | Used by |
|---|---|---|---|
DB_IO_FT501_m3h | Floating-point 32-bit | symbolic | Archive PVA_Flow, trend |
DB_Arch_Avg1m / Min1m / Max1m | Floating-point 32-bit | symbolic | Compressed archive |
DB_Arch_ArchiveEnable | Binary | symbolic | Start/stop archiving |
Stage 5Configure Tag Logging and Link the Trend Controls
| Item | Setting |
|---|---|
| Timers | 1 s acquisition, 5 s or 60 s archiving as needed |
| Process value archive PVA_Flow | FT501_m3h: acquisition 1 s, archiving 5 s, mean value; or on change with hysteresis 0.5 m³/h |
| Minute archive | Avg1m, Min1m, Max1m archived every 60 s |
| Archive configuration | Segment size and period, backup path for swapped-out segments |
| Trends.pdl | WinCC OnlineTrendControl with FT501 and the minute values; OnlineTableControl for exact values; time axis 1 h |
The panel version with data logs is in HMI trends and data logs.
Stage 6Perform and Test: Acquisition, Archiving and Compression
The grey line is the real flow; the dark line and dots are what the process value archive keeps. Change the acquisition and archiving cycles or switch to archiving on change, and watch the trade-off between detail and archive size.
Troubleshooting
| Symptom | Likely cause | First check |
|---|---|---|
| Peaks missing in the trend | Archiving cycle too long, value averaged | Use PLC min/max or shorter cycle |
| Archive fills the disk | Too many tags at short cycles | Archive on change, longer cycles, segments |
| Trend flat after restart | Online-only curve or archive not running | Curve source, archive state |
| Old data missing | Segments swapped out | Reconnect backed-up segments |
Hands-On Lab: Build a WinCC Archive and Trend Screen
Hands-on- TIA Portal and WinCC Explorer V8.1
- Estimated time: 75 minutes
Wire and declare FT501
Declare FT501_Raw and M501_Running.
Scale into DB_IO
Scale FT501 to m³/h and set FT501_Valid.
Write the archive helpers in ladder and SCL
ArchiveEnable in ladder; minute min/max/average in SCL in OB30.
Load the tags into WinCC
Load DB_IO.FT501_m3h and DB_Arch members.
Configure Tag Logging and the trend
Process value archive with cycles, compression and segments; OnlineTrendControl and table on Trends.pdl.
Test and size
Compare cyclic and on-change archiving and calculate the yearly size.
The archive keeps the detail you need at a size you planned, peaks survive compression, and the trend shows both live and historical values.
Frequently asked questions
What is the difference between acquisition cycle and archiving cycle?
The acquisition cycle is how often WinCC reads the value; the archiving cycle is how often a value is written to the archive. Archiving is a multiple of acquisition and can use mean, minimum or maximum over the interval.
When should I archive on change instead of cyclically?
For values that are steady for long periods, such as levels or setpoints. With a hysteresis, only meaningful changes are stored, which keeps the archive small without losing events.
How do I keep years of data?
Use segmented archives with a defined segment size and period, swap them out (back up) to a long-term location, and reconnect them when you need to analyse old data.
Why calculate min, max and average in the PLC?
So a one-minute archive record still shows the peaks that happened inside the minute. The PLC sees every scan; WinCC only sees its acquisition cycle.
Which control shows archived values?
The WinCC OnlineTrendControl for curves and the OnlineTableControl for values; both can read process value archives and show live and historical data.
Should the PLC logic be ladder or SCL here?
The enable condition is simple and readable in ladder; the min/max/average over 60 samples is cleaner in SCL. Both are shown.