How-to
How to Animate an Object Moving in WinCC From a PLC Tag
Short answer
WinCC moves nothing by itself: the S7 program steps a position word (100 counts per floor, floors 0 to 400) with a pulse-gated up/down counter, and an expression on the object's Top property maps counts to pixels with Top = Top_F1 - Cabin_Pos * (Top_F1 - Top_F5) / Pos_max, subtracting because the vertical axis grows downward. Generate motion in the PLC, scale in the picture, and set the tag update cycle equal to the pulse period.
On this page
- One position tag is the whole interface
- Generate the motion in ladder
- Create the WinCC tag on the S7 connection
- Map counts to pixels on the Top property
- Clear the Missing Tags warning before trusting the dialog
- Lamps, calls and doors from the same tag
- Verify the run end to end
- Why not a script loop in the picture
- Questions asked
WinCC does not move anything on its own. The S7 program has to publish a position value that changes step by step, and the picture binds one property of the object to that value. The method: an up/down counter word in the PLC, stepped by a timed pulse while the motor bits run, mapped to the object's Top property in Graphics Designer. The detail that breaks most first attempts is the axis direction: the WinCC Information System documents that the vertical axis points toward the bottom of the screen, so a rising position must be subtracted from Top, never added. The worked case below is a five-floor lift at 100 counts per floor, floors at 0 to 400; the pattern is the same for any object that travels.
One position tag is the whole interface #
Cabin_Pos (an example name) is the only thing the ladder and the picture share. Declare it as an integer word in a data block or memory word, owned by the PLC and only read by WinCC. Decide the resolution before writing any logic: at 100 counts per floor, floors 1 to 5 sit at 0, 100, 200, 300 and 400, and floor-reached logic compares Cabin_Pos against those constants. Add the binary tags the picture needs anyway: Motor_Up, Motor_Down, call buttons, door state.
Force Cabin_Pos from a variable table before touching graphics. The online value must follow the force, and with both motor bits off the program must not write the word. If it does, something else owns that word and every later step inherits the fault.
Generate the motion in ladder #
A simulated cabin has no encoder, so a time base substitutes for travel. Speed is step size divided by pulse period; commit to one count per 100 ms pulse, which is one floor (100 counts) in 10 s, believable for a passenger lift. Confirm the CPU cycle time is far below 100 ms so no pulse edge is lost.
- Create the pulse source: a retriggered on-delay timer with a 100 ms preset, or a clock memory bit.
- Feed a CTUD so the counter output is
Cabin_Pos: up input = pulse ANDMotor_UpAND (Cabin_Pos< 400), down input = pulse ANDMotor_DownAND (Cabin_Pos> 0). The limit terms are not optional; without them the count runs past the shaft and the picture draws the cabin outside the building. - Latch
Motor_UpandMotor_Downwith the sealing pattern of a sealed motor starter rung in STEP 7 ladder, interlocked so both can never run at once. - Preset the counter to 0 at startup or reset, so runtime always opens with the cabin at floor 1.
Bench-check the word before the picture exists: Motor_Up set alone climbs one count per 100 ms, Motor_Down falls at the same rate, and both forced together must not move the count (a count that still moves is an interlock defect). From 0, the floor-2 constant 100 is reached after 10 s and the floor-reached bit sets exactly there. This is the same controller-side technique as simulating a rising liquid level in WinCC runtime, with a counter stepping a position instead of a timer filling a tank.
A simulated position is for the picture only: never let it stand in for real floor sensors or limit switches on a machine that actually moves.
Create the WinCC tag on the S7 connection #
In Tag Management, add the S7 protocol channel connection to the CPU, then create the Cabin_Pos tag with the same 16-bit signed type as the PLC word. A mismatch, signed read as unsigned or a word read as 32-bit, surfaces later as wrong or negative-looking positions. Set the tag's update cycle to 100 ms, equal to the pulse period; a longer cycle delivers several counts per refresh and the object visibly jumps.
In runtime, watch the tag in the diagnostics view while forcing it in the PLC variable table: the values must match, with good quality.
Map counts to pixels on the Top property #
Draw the shaft as one rectangle and the cabin as a separate rectangle or group. Place the cabin exactly on the floor-1 mark and read its Top value (Top_F1); place it on the floor-5 mark and read Top_F5. Both are plain integers read off the property. With Top_F1 and Top_F5 as integer pixel positions, Cabin_Pos a signed 16-bit count from 0 to 400, and Pos_max the constant 400:
Top = Top_F1 - Cabin_Pos * (Top_F1 - Top_F5) / Pos_max
The leading subtraction inverts the axis, because Top is measured downward from the top of the picture.
Worked example with the object as drawn here: Top_F1 = 400 px and Top_F5 = 40 px. Travel = 400 - 40 = 360 px over 400 counts = 0.9 px per count. At Cabin_Pos = 100 (floor 2): Top = 400 - (100 * 360 / 400) = 400 - 90 = 310. At Cabin_Pos = 250 (mid-travel): Top = 400 - (250 * 0.9) = 175. Test by forcing: 0 parks on the floor-1 mark, 100, 200 and 300 on their marks, 400 on floor 5, and 250 exactly halfway. A landing that sits off its mark means one of the two Top readings was taken with the object nudged.
Apply the expression in the dynamic dialog on the object's Top property; the dialog accepts arithmetic over tags. A VBS action returning the computed value works equally well. A direct tag-to-property connection only works if the PLC itself scaled counts to pixels. Do not do that: keeping counts in engineering units in the controller and converting at the display is the same discipline as scaling encoder counts to inches on an HMI display, and it is what lets you re-layout the picture without touching ladder.
Clear the Missing Tags warning before trusting the dialog #
The dynamic dialog raises a Missing Tags warning whenever the expression references a tag it cannot resolve: one typed by hand instead of picked, or masked by a tag prefix. Select the tag from the dialog's tag list so it registers, and never accept the configuration while the warning stands. An unresolved tag means the animation simply does not run, and runtime gives no error to tell you so.
Lamps, calls and doors from the same tag #
Derive floor bits in the PLC by comparing Cabin_Pos to the floor constants, then bind each lamp's visibility to one bit, so ladder and picture can never disagree about where the cabin is. Call buttons write to call tags on press; ladder cancels the call when that landing's floor-reached bit sets. Doors repeat the pattern one level down: a second counter stepped by the door motor, with its own word and limits.
Parts that only snap between fixed pictures rather than travel are lighter with animating four images with a graphic list in WinCC RT; save the position mapping for things that move continuously.
Verify the run end to end #
Give the finished picture the same acceptance pass as testing HMI simulation against a live PLC:
- Start at floor 1: cabin on the floor-1 mark, that lamp on, both motor bits off.
- Press the floor-4 call:
Motor_Upsets,Cabin_Posclimbs at 10 s per floor, the cabin rises without jumps. - Passing floors 2 and 3: each lamp lights only while the position equals its constant, and the cabin does not stop.
- Arrival:
Motor_Updrops exactly at 300, the cabin stops on the floor-4 mark, the call clears. - Press the floor-1 call:
Motor_Downsets, the cabin descends and stops at 0 with no overshoot below the shaft.
Why not a script loop in the picture #
A VBS or VBA loop that reads the motor tags and steps the object does work, and it is often suggested first. It is still the wrong default: a blocking loop freezes every other update in the picture, and the position then exists only on the screen, so ladder cannot use it for floor detection or interlocks. The decision in order: generate the position in the PLC, scale it in the picture, keep the update cycle equal to the pulse period. Use a script only for a visual-only demo with no logic behind it.
Questions asked
What pulse period gives a realistic floor-to-floor time?
Floor time equals pulse period times counts per floor. At 100 counts per floor, a 100 ms pulse gives 10 s per floor and a 50 ms pulse gives 5 s. Choose the floor time first, then divide it by 100 to get the pulse period, and confirm the CPU scan time stays well below that period so no pulse edges are missed.
Why does the cabin jump in steps instead of moving smoothly?
The tag's update cycle is longer than the pulse period, so several counts arrive per refresh and the object snaps between them. Set the update cycle equal to or shorter than the pulse period. If steps still show, raise the counts per floor so each count is a smaller fraction of the travel.
The machine has a real encoder. Do I still need the counter?
No. Scale the encoder count so one floor spans the same number of counts and write it straight into the position word in place of the counter output. The tag, the expression on Top and the floor marks stay exactly as they are; only the source of the number changes.
How do I animate the doors on the same picture?
Repeat the pattern with a second counter and tag: step a door word from 0 to 100 while the door motor runs and drive a Width property or a two-state graphic from it. If the door only needs fully closed, moving and fully open states, a graphic list switched by a discrete tag is simpler than a continuous position.