1. Application Overview
This reference describes how to drive a continuously moving graphic object on a Siemens WinCC Flexible runtime panel so that the object travels horizontally, freezes the instant a digital sensor input becomes active, and resumes its trajectory once the sensor releases. The pattern is reusable for any indication where a process flag should pause a visual cue without affecting the underlying PLC state machine: conveyor visualization, dancer position, agitator sweep, valve travel, and similar animation use cases.
Two valid implementation paths are documented:
- Horizontal Movement dynamization - one PLC tag carries a 0..N integer; the HMI object binds its X-coordinate to that tag through the Animation dialog.
- Visibility-stacked layers - three identical objects occupy the same coordinates; tag range windows toggle which layer is visible. Useful when pixel-level motion is not required.
The two paths can also be combined: a moving object (method 1) plus a stationary body that appears only inside a defined range (method 2). Both methods run on WinCC Flexible 2008 SP2 through SP5 and remain valid after project migration to TIA Portal WinCC via the Project Converter.
2. Prerequisites
- WinCC Flexible 2008 SP2 or later (SP5 recommended, last released update per Siemens Entry ID 36435786).
- A supported runtime panel: OP 73 / OP 77, TP 177 / TP 177A, MP 177 / MP 277 / MP 377 or a PC Runtime for offline commissioning. Comfort Panels require TIA Portal WinCC; WinCC Flexible targets the legacy panel line.
- PLC: SIMATIC S7-200, S7-300, S7-400, or LOGO! with an MPI/PROFIBUS/Ethernet connection configured in the WinCC Flexible project.
- STEP 7 V5.5 (for S7-300/400) or STEP 7 Basic / Professional in TIA Portal V13+ (for S7-1200/1500) if you author the PLC code.
- One digital input wired to the sensor and configured in the PLC hardware (HW Config or device configuration).
3. System Architecture and Tag Flow
The PLC owns the position counter; the HMI is a thin display client. Only the integer position and a small set of control bits traverse the bus. This keeps the HMI cycle budget unaffected by motion speed because the counter increment is performed inside OB1 on the PLC, not inside the HMI runtime.
4. PLC Program: Continuous Motion with Sensor Pause
The counter is updated only when the sensor is clear. The simplest implementation uses a cyclic timer (TON) in OB1 that increments an integer every N ms while bRun is true. bRun is the boolean AND of the master enable and the negation of the sensor input.
4.1 SCL for S7-1200/1500 (TIA Portal)
// FB_MoveBlock - tag-driven horizontal animation source
FUNCTION_BLOCK "FB_MoveBlock"
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
VAR_INPUT
iSensor : BOOL; // TRUE = pause motion
bEnable : BOOL; // FALSE = freeze at current pos
iMaxPos : INT; // pixel range upper bound
iCycle_ms : INT; // update period, e.g. 100
END_VAR
VAR_OUTPUT
oPosition : INT; // bind to HMI tag
oAtMax : BOOL; // optional diagnostic
END_VAR
VAR
statTimer : TON;
statPos : INT := 0;
END_VAR
BEGIN
// Hold position while sensor is active OR enable is false
"statTimer".IN := "bEnable" AND NOT "iSensor";
"statTimer".PT := DINT_TO_TIME(INT_TO_DINT("iCycle_ms"));
"statTimer"();
IF "statTimer".Q THEN
"statTimer".IN := FALSE;
"statTimer"();
IF "statPos" >= "iMaxPos" THEN
"statPos" := 0; // wrap to start
END_IF;
"statPos" := "statPos" + 1;
END_IF;
"oPosition" := "statPos";
"oAtMax" := ("statPos" >= "iMaxPos");
END_FUNCTION_BLOCK
4.2 Equivalent STL for S7-300/400 (STEP 7 V5.5)
// OB1 - cyclic increment, sensor pause
A I 0.0 // sensor NC
AN M 10.0 // master enable
= M 20.0 // bRun (effective run)
L MW 102 // iCycle_ms (e.g. 100)
SD T 1 // pulse timer 100 ms
A T 1
A M 20.0
JC INC
JU DONE
INC: L MW 100 // iPosition
L MW 104 // iMaxPos
>=I
JC WRAP
L MW 100
+ 1
T MW 100
JU DONE
WRAP: L 0
T MW 100
DONE: NOP 0
4.3 Cycle-Time Selection
The visual smoothness on a 6" panel is acceptable at 80-150 ms per increment; faster updates do not render between screen paint cycles and waste bus bandwidth. Use the table below as a starting point:
| iMaxPos (px) | iCycle_ms | Traversal (s) | Visual effect |
|---|---|---|---|
| 400 | 100 | 40 | Steady march |
| 400 | 50 | 20 | Brisk march |
| 400 | 25 | 10 | Fast sweep |
| 800 | 75 | 60 | Long conveyor, low load |
5. HMI Tag Configuration in WinCC Flexible
- Open the project, expand "Tags" in the project tree, double-click to add a new tag.
- Set Name =
HMI_Position, Data type = INT (signed 16-bit, range -32768..32767). - In Connection, point to the connection that targets your PLC (e.g.,
S7-300/400with addressDB1,DBW0orM100). When using S7-1200/1500 in TIA Portal, use the optimized DB symbol or absolute address%MW100. - Set Acquisition cycle to 250 ms (default for slow-changing values; raise to 100 ms if you raise the PLC cycle to match).
- For the sensor itself, add a tag
HMI_Sensorof type BOOL, acquisition 100 ms, so the runtime can also drive a status lamp from the same source if desired.
6. Configuring Horizontal Movement Dynamization
- Open the screen that holds the graphic (e.g.,
Screen_1). - Insert a rectangle or graphic view (Insert > Simple Objects > Rectangle, or insert an SVG/PNG).
- Right-click the object, choose Properties > Animations.
- In the Animations dialog, click Add and select Horizontal Movement (some builds label this Dynamization > Movement Horizontal).
- Configure:
- Tag:
HMI_Position - Source range minimum =
0 - Source range maximum =
400(must match PLCiMaxPos) - Target range minimum =
0pixels - Target range maximum =
400pixels (screen width minus object width)
- Tag:
- Confirm with OK. The object X-coordinate is now animated.
At runtime, the object increments one pixel every PLC cycle (e.g., 100 ms), wraps at iMaxPos, freezes when the sensor tag is TRUE, and resumes when the sensor releases. Because the PLC holds the last value during the pause, the screen does not snap backwards.
7. Alternative: Visibility-Layered Animation
When pixel-accurate motion is unnecessary (e.g., coarse state indication), three layered objects each cover the path and become visible inside a defined range window. This was the originally suggested method in the engineering discussion.
- Place three identical objects at the same X/Y (stack them in z-order).
- For each object, open Properties > Animations > Add > Visibility.
- Configure each Visibility entry with a range tag and limits:
| Object | Tag | Visible range | Behavior |
|---|---|---|---|
| Layer_1 | HMI_Position | 0..9 | Stationary indicator at left |
| Layer_2 | HMI_Position | 10..19 | Mid-path indicator |
| Layer_3 | HMI_Position | 20..29 | End-of-path indicator |
Combine with Horizontal Movement dynamization on Layer_1 only to obtain a moving object that additionally reveals a static body when the counter is inside its window.
8. Edge Detection and Sensor Debounce
Mechanical sensors chatter. Run the input through a debounce block before it gates motion:
// IEC debounce timer, SCL
FUNCTION_BLOCK "FB_Debounce"
VAR_INPUT
iRaw : BOOL;
iTime_ms : INT := 30; // 30 ms typical
END_VAR
VAR_OUTPUT
oStable : BOOL;
END_VAR
VAR
statTON : TON;
END_VAR
BEGIN
"statTON".IN := "iRaw";
"statTON".PT := DINT_TO_TIME(INT_TO_DINT("iTime_ms"));
"statTON"();
"oStable" := "statTON".Q;
END_FUNCTION_BLOCK
Feed oStable into iSensor of the motion FB. For sub-millisecond response on a clean 24 V PNP sensor, set iTime_ms := 5. For mechanical limit switches, use 50-100 ms.
9. Bouncing Motion and Direction Reversal
For true back-and-forth motion (e.g., a shuttle), replace the wrap with a direction flip:
// inside FB_MoveBlock, replace the wrap section:
IF "statPos" >= "iMaxPos" THEN
"statPos" := "iMaxPos";
"statDir" := FALSE; // reverse
ELSIF "statPos" <= 0 THEN
"statPos" := 0;
"statDir" := TRUE; // forward
END_IF;
IF "statDir" THEN
"statPos" := "statPos" + 1;
ELSE
"statPos" := "statPos" - 1;
END_IF;
Publish statDir to the HMI as HMI_Direction (BOOL) if you want the sprite to flip horizontally. Drive a graphic view's Mirror property from this tag via Direct connection.
10. Verification and Runtime Commissioning
- Compile the PLC program and download to the controller. Add the FB instance to a cyclic OB (OB1, OB35, or OB200 for S7-1200/1500).
- In WinCC Flexible, use Tools > Simulation > Start Runtime with the simulator enabled to verify without a panel.
- Watch the position tag in the WinCC Flexible tag simulator; force it to 0, then to mid-range, then to iMaxPos. Confirm the object jumps to the correct X-coordinate in each case.
- Force the sensor input to TRUE in PLCSIM or on the live PLC. The object must freeze at its current pixel position. Force the input back to FALSE; motion resumes from the same pixel.
- Cycle through the full range at least three times to verify the wrap condition.
- Confirm that the HMI tag's acquisition cycle is shorter than or equal to the PLC cycle.
11. Migrating the Project to TIA Portal WinCC
When the panel reaches end of life, migrate via the TIA Project Converter (menu Project > Migrate project). Mapping summary:
| WinCC Flexible | TIA Portal WinCC | Notes |
|---|---|---|
| Tags > INT/BOOL | HMI tags > Int/Bool | Automatic mapping |
| Animation > Horizontal Movement | Animations > Horizontal Movement | Same dialog structure |
| Animation > Visibility | Animations > Appearance | Renamed but functionally identical |
| S7-300/400 connection | HMI connection with PLC of same family | Re-enter slot/IP |
| S7-1200/1500 connection | Native, no converter step | Use TIA-author project from start |
The PLC SCL in section 4.1 is already TIA-syntax and requires no conversion. The STL in section 4.2 can be auto-translated by the SCL/STL converter built into TIA Portal if you want to consolidate.
12. Troubleshooting Matrix
| Symptom | Likely cause | Corrective action |
|---|---|---|
| Object stays at pixel 0 | HMI tag acquisition cycle longer than PLC cycle, or wrong address | Verify tag address matches DB/MW; lower acquisition cycle to 100 ms |
| Object teleports in jumps of 10+ pixels | HMI cycle too slow for PLC update | Raise PLC cycle to 250 ms or drop HMI cycle to 100 ms |
| Object does not pause on sensor | Sensor tag inverted (NC vs NO) | Verify polarity in PLC; for NC contact use iSensor := NOT %I0.0
|
| Object pauses but does not resume | Master enable bit stuck low | Check bEnable source tag in tag list |
| Object visible at wrong X on screen load | Initial value of HMI tag not 0 | Set tag start value = 0 in WinCC Flexible tag properties |
| Wrap point shows wrong pixel | iMaxPos mismatch between PLC and HMI source range | Re-enter identical numeric values in both places |
| Object invisible | Visibility layer rule hides it | Temporarily disable the Visibility animation to isolate |
| Compile error "tag type mismatch" | PLC writes WORD but HMI expects INT | Change PLC variable to INT, or change HMI tag to WORD and convert |
| Runtime error 1001 / connection lost | Wrong PLC IP, subnet, or PROFINET name | Re-check connection parameters; verify PG/PC interface assignment |
| Sensor flag shows on lamp but does not pause motion | Sensor tag not wired to FB input on PLC | Inspect FB call in OB1; cross-compile to confirm |
Which WinCC Flexible version adds the Horizontal Movement animation?
Horizontal Movement has been present since WinCC Flexible 2004. The current baseline for legacy panels is WinCC Flexible 2008 SP5. See Siemens Entry ID 36435786 for the SP5 download and release notes.
What HMI tag type should I bind the object position to?
Use INT (signed 16-bit). The PLC increments a small counter that fits comfortably within 0..32767. Avoid BOOL (single bit) - it toggles the object between two pixels only.
How do I prevent the object from snapping back when the sensor activates?
Do not zero the position in the PLC when the sensor trips. Only stop the increment. In the SCL sample this is achieved by gating the TON instance: statTimer.IN := bEnable AND NOT iSensor;. The last written value stays in statPos, so the HMI continues to render the freeze frame.
Can I run this on a Comfort Panel without TIA Portal?
No. Comfort Panels are programmed exclusively in TIA Portal WinCC. The dynamization API is identical, so the PLC code and the Animation dialog mapping translate one-to-one after migration.
What is the maximum number of simultaneous Horizontal Movement animations on a panel?
TP 177 and MP 177 panels comfortably handle 20-30 animated objects at a 100 ms acquisition cycle. MP 277/MP 377 extend this to several hundred because of the higher CPU clock. If you exceed this, drop the acquisition cycle to 250 ms or move the position logic to the PLC and refresh only on change.