IMDTouchKnowledge BaseShop main store

Explainer

Does One Shared Script Speed Up WinCC Screen Animations

HMI and touchscreens Published 6 min read

Short answer

No for screen changes: opening a picture loads graphics, dynamic bindings and initial tag values, and consolidating animation scripts into one does not reduce that. Yes for steady-state runtime, but only when the grouped animations share one frame rate and phase, the trigger is scoped to the picture, and the shared counter has exactly one writer. Expect the visible running cycle to be three times the trigger interval.

On this page
  1. Which WinCC runtime you are scripting
  2. What the shared action does on each execution
  3. Why fewer scripts do not speed up picture changes
  4. Where sharing actually pays
  5. Trigger scope and counter ownership
  6. Worked example: frame cycle and tag traffic at a 1 s cyclic trigger
  7. The decision
  8. Questions asked

No — not for screen switching. Consolidating every animation on a picture into one C action does not make picture changes measurably faster, because opening a picture loads its graphics, dynamic bindings and initial tag values, and animation actions are a small share of that work. The consolidation is still worth doing, for a different reason: one shared frame counter removes duplicated increment work and holds grouped objects in phase. Do it per picture, not project-wide. Scope the action's trigger to the picture, keep exactly one writer for the shared counter, and read the visible running cycle as three trigger intervals while screen-open time stays where it was.

Which WinCC runtime you are scripting #

The #include "apdefap.h", the gscAction entry point and the GetTagByte, SetTagByte and GetTagBit calls identify the ANSI-C action interface of classic WinCC. WinCC Unified uses a different scripting environment, so this action is rebuilt to equivalent logic there rather than copied. Within the SIMATIC WinCC range, Runtime Advanced and Runtime Professional do not even share communication drivers and differ in how much data they manage, so confirm which runtime the station actually runs before tuning it. For how the engineering and runtime pieces fit together, see what WinCC does in an HMI and SCADA system.

What the shared action does on each execution #

Each execution reads the stored frame from auxiliar2, an unsigned 8-bit tag, so the frame value survives between executions. It increments the value, wraps it with the test rem > 3 back to 1, and writes it back. It then reads the two running bits and writes the frame value, or 0, into the two animation tags. Comments in scripts of this shape often claim the counter runs 1 to 4; the comparison rem > 3 actually produces a three-frame sequence, 1 → 2 → 3 → 1, so map the status display states to 1, 2 and 3 and do not configure a fourth frame nobody will see.

Identifier Role
auxiliar2 Unsigned 8-bit stored frame counter
sf1 Conveyor running bit
rem_sf1 Conveyor animation state, 0 or 1 to 3
aspa1 Fan running bit
Rem_vent1 Fan animation state, 0 or 1 to 3

Because both animation tags receive the same frame in the same execution, the two objects animate in phase: correct when they should look alike, wrong when one needs its own pace. When the frame number selects an image through a graphic list, the same counter drives it, as covered in animating four images with a graphic list in WinCC RT.

Why fewer scripts do not speed up picture changes #

The hope behind the merge — fewer scripts, less data to load when switching pictures — does not survive the arithmetic of what a picture load contains. Opening a picture loads its graphics, its dynamic bindings, its tag access and its initialization. Consolidating five animation actions into one leaves the graphic count and the dynamic bindings exactly where they were; you save configuration clutter, not load time. If opening is slow, measure the navigation-to-usable-display time separately from the recurring action time, repeat the navigation because a first opening and a cached opening exercise different resources, and then cut graphic content and per-object dynamics in the offending picture. Decide on that basis, not on script count.

Where sharing actually pays #

The honest saving is duplicated execution work. Twenty animated objects sharing one counter need one read-increment-write chain per cycle instead of twenty, and they all step together, which is usually what a mimic should look like. Two conditions gate the merge: the grouped animations must want the same frame rate, and they must be acceptable in phase. Where one object needs a different speed or a staggered start, split it into its own group rather than forcing everything through one universal action. Keep each execution short regardless: a long action stalls the picture that hosts it, which is why an HMI screen freezes until a script finishes.

Trigger scope and counter ownership #

The WinCC scripting documentation, "WinCC: Scripting (VBS, ANSI-C, VBA)", describes scheduling actions by cyclic or acyclic timers or by a tag change. A frame counter needs the cyclic timer: a running bit that stays true produces no new event, so nothing else will advance the animation. The same documentation separates picture-independent actions from picture dynamics — dynamics configured on objects of a picture execute only while that picture is open, while global actions execute regardless. That distinction is the whole performance argument: one project-wide action for every screen's animations keeps doing work for pictures nobody is watching. Configure the action as dynamics of the picture it serves, then navigate away and confirm the counter tag stops advancing. To verify which picture context an action executes in, use the technique of displaying the current WinCC picture name in a static text.

Ownership is the second half. Give auxiliar2 exactly one writer. Two actions that each read, increment and write the same byte will interleave and skip visible frames. Where several displays must share one sequence, let a single central action advance the counter and let the other displays only read it.

Worked example: frame cycle and tag traffic at a 1 s cyclic trigger #

Inputs: three distinct running frames, 1, 2 and 3, from the wrap test rem > 3; the cyclic trigger interval T configured in the action's trigger dialog, which the project material does not state, so 1 s is the stand-in for the arithmetic; and six tag operations per execution counted straight from the action — reads of auxiliar2, sf1 and aspa1, writes of auxiliar2, rem_sf1 and Rem_vent1.

Rule in words: one full running cycle takes one execution per distinct frame, and steady-state tag traffic equals the operations per execution times the execution rate.

The arithmetic:

  • Cycle: 1 → 2 → 3 → 1 is 3 executions, so 3 × 1 s = 3 s per visible run cycle.
  • Traffic: 6 operations × 1 execution/s = 6 tag operations per second while the picture is open.
  • The unshared alternative, one action per object with its own counter: each does 4 operations (counter read, counter write, bit read, animation write), so 2 × 4 = 8 operations per execution pair. Sharing saves 8 − 6 = 2 operations per second, a 25% cut.

Result and decision: the shared action is the right call at any object count — it costs nothing and keeps the pair in phase — but its measurable effect here is 2 tag operations per second, negligible next to picture loading. The lever that matters is the interval. At 1 s the run cycle reads as 3 s; if that looks sluggish on the floor, set the cyclic trigger to 500 ms, which gives 3 × 0.5 s = 1.5 s per cycle at 6 × 2 = 12 tag operations per second — still trivial load for one station.

The decision #

  • Merge animations into one shared action only when they share a frame rate and a phase; split groups that need different speeds.
  • Scope the action's cyclic trigger to the picture it animates, and never promote it to a global action serving every screen.
  • Keep exactly one writer for auxiliar2.
  • Set the cyclic interval to the frame step you want, and read the run cycle as 3 × that interval.
  • Expect no improvement in picture-open time; attack graphics and dynamic bindings for that, and measure navigation-to-usable time before and after any change you make.

Questions asked

Will merging animations into one script make my pictures open faster?

No. Opening time is set by the graphics, dynamic bindings and initial tag values the picture loads, and a merged action changes almost none of that. To speed up opening, cut graphic content and per-object dynamics in the slow picture and let repeated openings run from cache. The merge only trims steady-state execution work while the picture is displayed.

Why do the conveyor and fan step their frames together?

Both animation tags receive the same counter value in the same execution, so they are in phase by design. That is what you want when the machines should look identical. Give an object its own counter and its own action when it needs a different speed or a staggered start, rather than fighting the shared sequence.

What happens if two actions both increment the shared counter?

Each writer reads, increments and writes the same byte, so interleaved executions skip frames or make the visible cycle irregular. Keep exactly one owning action, and make every other consumer read-only.

Does this C action run in WinCC Unified?

No. The calls shown here belong to the ANSI-C action interface of classic WinCC only. Unified projects use a different scripting environment, so the action has to be rebuilt there to the equivalent logic rather than copied across.

How do I confirm the action stops when I leave the picture?

Open the picture and note the animation stepping, navigate away, then watch whether the counter tag keeps advancing in tag monitoring or a trace. If it still changes with the picture closed, the action is configured globally; move it into the picture's object dynamics or re-scope its trigger so the work stops with the display.

Keep reading

  • Troubleshooting

    Why a WinCC Faceplate Script Does Not Auto-Refresh

    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.

    HMI and touchscreens

  • How-to

    How to calculate daily flow totals and midnight rollover in WinCC

    Yes — no archive query is needed. One C action in the Global Script editor, on a several-second cyclic trigger, keeps today's running total; a time-based trigger at 00:00 rolls it, so yesterday takes today's value and today restarts at zero. Compute each day as a totalizer difference when the meter reads cumulative mass, or as flow × elapsed seconds ÷ 3600 when it reads a rate, and give the calculation one owner: the PLCs, or one designated server.

    HMI and touchscreens

  • Troubleshooting

    Fixing WinCC C Script Memory Growth From String Buffers

    Yes - writing a database field through a pointer aimed at a string literal is undefined behavior and a buffer overrun into 10 bytes of read-only storage, and it is not the leak. Days of script.exe growth come from database objects acquired per call and never released. Fix both: pass a caller-owned buffer with its capacity, copy at most bufferSize - 1 bytes, terminate explicitly, and release every acquired object on every exit path.

    HMI and touchscreens