Explainer
Why a WinCC Flexible Script Will Not Run Every 2 Seconds
Short answer
WinCC flexible cannot schedule a script faster than the Scheduler's one-minute floor, and a Switch on a clock memory bit only fires when the trigger tag is acquired cyclic continuous with the script on the tag's own Change event. For a two-second cadence, wire the script to a PLC clock bit's tag event; if no PLC bit is available, use a data log overflow with ClearLog. For CPU-to-CPU data, bypass the panel with a DP/DP coupler.

On this page
A WinCC flexible script cannot be run cyclically at a two-second cadence by any built-in timer. The Scheduler's smallest selectable interval is 1 minute, and a Switch bound to a PLC clock memory bit stays silent unless the trigger tag is acquired cyclic continuous and the script hangs on the tag's own Change event. The decision: for one execution every 2 seconds, use a clock memory bit whose tag is read cyclic continuous, with the script on that tag's Change event. If no PLC bit is available, use a data log overflow as a last resort. If the script exists only to copy data between two CPUs, remove the panel from that path entirely.
The Scheduler stops at one minute #
The documented automatic executor is the Scheduler: Device Settings -> Scheduler, add a new job, set the event to 1 Minute and bind the script to it. That is the whole answer the Scheduler can give, because the smallest interval the dialog accepts is 1 minute — no sub-minute value exists in the editor. A job set this way runs every 60 s and nothing you configure in the project changes that.
For context when planning a migration: WinCC Runtime Professional under TIA Portal documents cycle values as small as 100 and 125 ms for tag triggers. That is a different runtime with a different trigger model, and it does not retroactively help a WinCC flexible project, but it is the reason a panel replacement is worth considering when the cadence requirement itself will grow.
Anything faster than the Scheduler floor in WinCC flexible must come from one of three places: a tag event driven by the PLC, the data log overflow event, or logic moved out of the panel altogether.
Why the switch on the clock bit never fires #
Three conditions must all hold, and the failure is almost always in one of them:
- The trigger tag's acquisition mode must be cyclic continuous. A tag read only on demand, or only while a screen uses it, is not sampled between screen updates, so the runtime never observes the bit's edges and the Change event cannot occur.
- The tag's acquisition cycle must be shorter than the time the bit holds each state. A state that lasts a couple of seconds but is sampled once a minute is invisible, even in cyclic continuous mode.
- The script must sit on the tag's Change event, in the tag's own properties, not on the event of a Switch object placed on a screen. Object events exist only while that screen is displayed; a tag event runs in runtime regardless of which screen is open. A switch that works on its own page and stops after a screen change is this exact fault.
If the script must react to every single edge, not just detect activity eventually, read up on whether an HMI script can count PLC bit changes reliably (article:can-an-hmi-script-count-plc-bit-changes-reliably) before trusting it as a counter. The panel samples the tag; it does not see the PLC scan. The sampling behavior that bounds acquisition rates is also why WinCC flexible cannot acquire 1000 samples per second (article:why-wincc-flexible-cannot-acquire-1000-samples-per-second), and the same mechanism sets how tight a tag-driven cadence can be.
Worked example: one execution per clock edge #
Take an S7 CPU clock memory bit that changes state every 2 seconds — the bit turns on, holds, turns off, holds, so its full period is 4 s and it produces one Change event per state change.
Configuration:
- Trigger tag: the clock memory bit, acquisition mode cyclic continuous.
- Acquisition cycle: 1 s.
- Script: bound to the tag's Change event.
The arithmetic:
- Each state is held for 2 s and sampled every 1 s, so every state is seen at least twice: 2 s ÷ 1 s = 2 samples per state. No edge can be missed.
- Worst-case detection delay after a real edge is one acquisition cycle, 1 s.
- The bit produces 2 state changes per 4 s period, so the script executes 2 ÷ 4 s = one run every 2 s — exactly the target cadence, driven by the CPU clock and immune to screen changes.
If the cadence must be tighter, pick a faster clock bit and shorten the acquisition cycle to match; the rule stays the same: acquisition cycle at most half the state time.
The data log overflow workaround, as a last resort #
When no PLC bit can be provided, the logging system can be made to generate the beat. It is not designed as a timer, and it should be the fallback, not the plan:
- Create an internal tag and set it to update cyclic continuous at 1 s.
- Create a data log with 2 records per log, logging that internal tag.
- Enable the Raise Event option, and set log handling at restart to reset the log — otherwise a full log after a power cycle stalls the timer permanently.
- On the log's Overflow event, bind two actions in order: the ClearLog system function for that log, then the script.
The cycle arithmetic: each overflow needs the log filled, so the interval is 2 records × 1 s tag cycle = 2 s between overflow events. Want a slower beat? Add records — 5 records at 1 s gives 5 s. The floor is about one event per second; below that the runtime can drop events under load, because the overflow handler, the ClearLog and the script must all finish before the next record is due, and on a WinCE panel they compete with screen updates for the same runtime thread.
Take the panel out of the loop for CPU-to-CPU data #
When the script's whole job is copying a tag from one CPU to another, the panel is the wrong carrier: the machine's data path now depends on an operator terminal, and a runtime download, a fault or a power cycle silently cuts it. The direct fix on Profibus is a DP/DP coupler (order number 6ES7 158-0AD01-0XA0) between the two masters, exchanging up to 244 bytes in each direction with no HMI traffic at all. One safety rule applies to either design: interlocks and sequence data belong in the PLCs, never in an HMI script loop that stops with the panel.
Prove the trigger before blaming the script #
Before changing anything else, establish whether the script runs at all:
- Put a system alarm or a trace line on the script's first line. An alarm proves execution; silence means the event never fired.
- Display the trigger tag in an I/O field on the active screen. If the value toggles on screen and no alarm appears, the event binding is wrong — the tag event versus the object event distinction above.
- Keep the script free of loops. A waiting loop inside a script holds the runtime thread and delays every tag, screen and event on the panel, which shows up as sluggish page changes long before anyone suspects the script.
Decision summary: one-minute cadence — Scheduler job, done. Cadence of seconds with a PLC available — clock memory bit, cyclic continuous tag, script on the tag's Change event. No PLC bit available — data log overflow with ClearLog, knowing it is a workaround. Data exchange between CPUs — DP/DP coupler, and the panel goes back to being a display.
Questions asked
Can the data log trick run the script faster than once per second?
No, not dependably. One second is the practical floor. The overflow event has to run ClearLog and then the script before the next record is due, and on a WinCE panel the runtime can drop events under load below that cadence. For anything faster, generate the trigger in the PLC and hand the HMI only the result, or move the logic itself into the PLC program.
Why does the same script always work on a button but never on the trigger?
A button Press or Click event comes from the panel's local input queue, so it fires no matter how the tags are configured. The cyclic path depends entirely on tag acquisition over the communication link. When the button works and the trigger does not, the script is not at fault: check the tag's acquisition mode, its acquisition cycle against the bit's state time, and that the script hangs on the tag's Change event rather than a screen object's event.
Does the overflow event work the same way in WinCC flexible SMART?
Yes. The Overflow event with the Raise Event option is documented for WinCC flexible SMART V5 SP1 as well: when the log is completely full, the Overflow event fires and a function list bound to it runs. The same restrictions apply, including resetting the log at restart and treating the method as a workaround rather than a timer feature.
How much data can two CPUs exchange through a DP/DP coupler?
Up to 244 bytes in each direction through one coupler. Each Profibus DP master is configured with its own transfer areas in the hardware configuration, and the coupler maps matching input and output slots across the boundary. The exchange then runs at network speed with no panel involved, so a runtime download or a failed HMI cannot interrupt it.

