Troubleshooting
Why a WinCC Faceplate Script Does Not Auto-Refresh
Short answer
The script never auto-refreshes because the event you configured offers the standard actions but no script call on this runtime target. Trigger it from the HMI tag's "Value Change" event with "cyclic continuous" acquisition, promote each presence-AND-sensor result to its own internal tag, write both true and false, and evaluate once at screen load — or compute the Bools in the PLC and bind visibility directly.
On this page
- Why does the script run on a button click but never on its own?
- Why can't the visibility field take presence AND sensor?
- How do I trigger the script without any clock bit?
- If I keep bit_cadence, why did the 1 Hz heartbeat never fire?
- How does each result reach its own faceplate instance?
- What stops the indication sticking on after the pallet leaves?
- How fresh are the values the script actually reads?
- Are scheduled tasks or cyclic triggers an option at one second?
- Should the visibility be computed in the PLC instead?
- Questions asked
A WinCC script runs only when an event calls it, and in a project configured with TIA Portal V13 the value-change event you wired on the faceplate attribute offers the standard function set but no script call. Move the trigger one level up: give the tag "cyclic continuous" acquisition, open its "Value Change" event in the HMI tag table, and call the script there. Then give every presence-AND-sensor condition its own internal tag, because a script fired from a tag event runs in global scope and cannot write a faceplate's block-local variables. The wiring, the timing arithmetic and the decision against computing in the PLC follow.
Why does the script run on a button click but never on its own? #
Because a script executes only when an event invokes it, and in this TIA Portal V13 project the event you used — the value change of the interface attribute — offers the predefined functions but not script invocation; the call belongs on the HMI tag's own "Value Change" event.
An event is a notification, and the actions offered on it depend on where the event lives and on the configured runtime target. The working button proves the target executes scripts: its click event lists the script call. The attribute's value change lists only the predefined functions, so no amount of reconfiguring that one event will launch the script. Read the observations in order:
- The button computes the correct visibility: the Boolean logic and the result binding are right, and only the automatic trigger is missing.
- The heartbeat's value change runs predefined actions such as incrementing a variable: the event path itself works on this target.
- The script is absent from that action list: the event context cannot call it, so the trigger has to move to the tag table.
Before choosing any trigger, record the configured HMI device and runtime type. The version of the engineering software alone says nothing about which events offer script execution.
Why can't the visibility field take presence AND sensor? #
Because the visibility animation on this runtime accepts exactly one operand — a standalone bit, a bit taken out of a word, or a word value compared against a range — so a two-bit AND has to be computed into a single Bool before it reaches the object.
The condition for the first sensor at the first position is a logical specification, not executable script syntax:
sensor_visible = presence_palette_en_1 AND capteur_1_actif
| presence_palette_en_1 | capteur_1_actif | sensor indication |
|---|---|---|
| 0 | 0 | hidden |
| 0 | 1 | hidden |
| 1 | 0 | hidden |
| 1 | 1 | visible |
Only the one-and-one row shows the sensor. The bridge between this logic and the animation is one Bool per condition, and it belongs in the HMI: an internal tag is a display result, the PLC program stays untouched, and the documented faceplate pattern is exactly this — an interface property of BOOL data type driving the object's visibility animation. Test the four rows with the working button, then repeat on a second instance and confirm it follows its own presence bit rather than the first instance's. If the object is a symbol-library object rather than a plain graphic and it still ignores a correct tag, the fault is in that object's animation wiring — see animating WinCC symbol library objects in TIA Portal.
How do I trigger the script without any clock bit? #
Call one global script from the "Value Change" event of every operand tag, each set to "cyclic continuous" acquisition, and the indication follows every real input change with no heartbeat bit at all.
The operands are the presence bits — presence_palette_en_1 through presence_palette_en_4 — and the sensor bits — capteur_1_actif through capteur_4_actif. The script then runs exactly when an input moved, with all operands current, and nothing runs in between; the documented guidance for these scripts is to prefer variable triggers over cyclic ones precisely to keep runtime load low. One script evaluates every condition in a single pass, so wire the same script call to each operand tag's event instead of maintaining per-condition scripts.
If I keep bit_cadence, why did the 1 Hz heartbeat never fire? #
Two independent faults: the event was configured on the attribute, whose action list never offers the script call on this target, and the tag's acquisition can alias the clock — the heartbeat changes state every 500 ms, and sampling at the same period can read the same state every time.
Run the arithmetic on the second fault. bit_cadence at 1 Hz spends 500 ms at 1 and 500 ms at 0. Acquired every 1 s, its samples land on whole seconds, and one second ÷ 0.5 s = 2 — an even number of half-periods — so every sample catches the same state and the tag never reports a value change, whatever is attached to the event. The rule is acquisition cycle ≤ half the heartbeat period. Check which acquisition cycles your target actually offers before committing; if the fastest available still equals the heartbeat period, slow the heartbeat to 0.5 Hz and accept the slower refresh. A correctly acquired heartbeat gives two value changes per second, so expect two script passes per second. Treat the heartbeat as the fallback for operands you cannot trigger on, not as the default.
How does each result reach its own faceplate instance? #
Through one internal tag per condition, because a script called from a tag event runs in global scope with no instance context and cannot write the block-local variables the button-driven version used; each faceplate instance binds its own internal tag through its interface.
The button-driven script ran inside the faceplate, in the instance's own scope, so it could write its local variables. A global script has no way to address "the instance currently on screen", which is why the results move out to internal tags. Build the design in this order:
- Create one internal Bool per sensor-per-position combination: 4 positions × 4 sensors = 16 on this machine.
- Write one global script that evaluates all of them per pass, assigning 1 for presence AND sensor and 0 otherwise.
- Attach that script call to every operand tag's value-change event.
- Bind each faceplate instance's Bool interface attribute to the internal tag of its own position-and-sensor pair, and the object's visibility animation to that attribute.
- Call the same script once from the screen's open event, so instances with already-true inputs display immediately.
One shared result tag across instances is the mistake to avoid: every instance's calculation would overwrite the value the others display.
What stops the indication sticking on after the pallet leaves? #
Writing both outcomes on every execution: the internal Bool is set to 1 only in the one-and-one row of the specification and to 0 in the other three, because a script that only ever sets 1 latches the last true state until something else clears it.
Clear either operand after the indication appears and the next execution writes 0 and hides the object; with operand triggers that next execution is the clearing edge itself. An operator trusts a lit sensor icon, so verify all four input combinations before release and keep any interlock in the PLC — the display is indication, never protection. The remaining staleness window is the initial one: after the screen opens or the runtime restarts with inputs already true, no value change occurs and nothing triggers. The screen-open call closes that window; a correctly acquired heartbeat closes it on its next edge.
How fresh are the values the script actually reads? #
No fresher than each operand tag's acquisition cycle makes them, because a script pass only re-reads what acquisition already delivered — cadence and freshness are two separate settings on the tags.
Calculated example, with the operand tags acquired every 1 s:
- Operand-triggered: a PLC change becomes visible to the HMI within that cycle, and the arrival is itself the trigger. Worst-case indication lag equals the acquisition cycle.
- Heartbeat acquired correctly: add the wait for the next edge, up to one half-period — 1 s + 0.5 s = 1.5 s worst case — for a fixed two script passes per second instead of one per actual change.
- Heartbeat faster than the operand acquisition: no further gain, because the extra passes recompute identical stale inputs.
If the target offers acquisition modes tied to screen usage, set the operands to the continuous mode: a tag-event script is not a screen, and screen-dependent values stop updating exactly when the script needs them. Verify freshness directly by watching the HMI-side values of presence_palette_en_1 and capteur_1_actif while the PLC bits are forced.
Are scheduled tasks or cyclic triggers an option at one second? #
No: in TIA Portal V13 a scheduled task fires no faster than once per minute — 60 s ÷ 1 s = 60 times too slow for a 1 s refresh — and the documented guidance is to prefer variable triggers over cyclic ones anyway to keep runtime script load low.
Repeated execution has one more cost to check: a script that rebuilds string buffers on every pass grows runtime memory over days of cycling, and the failure pattern and its fix are covered in fixing WinCC C script memory growth from string buffers. The contrast is WinCC Unified V20, which does expose cyclic script triggers from a 100 ms minimum with 500 ms recommended — but that is a different runtime target with its own panels and engineering, a migration decision rather than a setting in a V13 project.
Should the visibility be computed in the PLC instead? #
If the PLC program is yours to change, yes: the AND results — 4 positions × 4 sensors = 16 — cost the controller nothing, visibility binds to one PLC bit per condition, and the entire trigger, scope and staleness machinery above disappears.
The decision rule is ownership. With the PLC program frozen or owned by another team, build the HMI-side design above — internal Bool per condition, "Value Change" trigger, both outcomes written, one evaluation at screen open — and accept a worst-case indication lag equal to the operand acquisition cycle. With the PLC program open to you, compute the 16 results in the controller, bind each visibility to one PLC bit, and the trigger, scope and staleness work all disappear; that is the better engineering whenever it is available.
Questions asked
How many internal HMI tags does this design need on a bigger machine?
One per condition, and the count is positions times sensors: 4 x 4 = 16 on this machine, 6 x 8 = 48 on one with six positions and eight sensors. They live in the HMI only, so the PLC program and its data areas stay untouched. Past a few dozen conditions the PLC-side computation wins on maintainability, because one code block replaces dozens of individually wired tags.
What happens to the indications after a runtime restart or power cycle?
Internal HMI tags are recreated at their initial values, so every indication is wrong until the first script execution clears it. A correctly acquired heartbeat clears it on the next edge; halving the heartbeat rate doubles that wait. With operand triggers it takes a real input change or the screen-open call, which is why that call belongs in the design. Test it by restarting the runtime with a pallet already standing in a position.
Does a faster heartbeat give fresher indications?
No. Freshness is bounded by the operand tags' acquisition cycle, not by script cadence: once the script runs more often than the operands are acquired, the extra passes recompute the same stale inputs and change nothing. Raising bit_cadence only helps if operand acquisition is raised with it; otherwise the worst-case lag stays where the arithmetic in the article puts it.
Does WinCC Unified have the same limitation?
No. Unified V20 exposes cyclic script triggers, and that runtime is built to react to value changes instead of continuously monitoring them. It is a separate runtime target with its own panels and engineering, not an option inside a V13 project — but the operand-trigger design carries over unchanged.