How-to
EasyBuilder Pro animation loop needs an address-driven position
Short answer
Set the Animation object's position source to controlled by address, then write its position word yourself: a periodic macro or a PLC timer counter increments the point index while the run bit is ON and wraps to zero after the last path point. One pass takes the point count times the macro period, and the switch simply gates the counter.
On this page
The switch cannot start the Animation object by itself, because the object runs its built-in path sequence on its own timing. To start, stop and loop it from a switch, set the object's position source to controlled by address and drive the position word yourself: a periodic macro increments the point index while the run bit is ON and wraps to zero after the last path point. The switch then only gates the counter and never touches the object. This page builds that counter on a Weintek cMT X series panel in EasyBuilder Pro V6.09.01.556 with no PLC attached, using Local HMI memory, and sizes the loop from the point count times the macro period.
Why the switch cannot start the built-in animation #
The Animation object moves an image along the path points you draw on the screen, and it takes its current point in one of two ways. In the predefined mode it steps through its points on its own timing whenever the screen is displayed; the only runtime handle you get is visibility, which hides the object but can never start, stop or reset the motion. In the controlled-by-address mode the object reads a word that holds the index of the point to show and moves only when that word changes. Whoever writes the word owns the start, the stop, the speed and the loop.
A switch-started, looping flow is a start/stop job plus a wrap-around job, so it belongs in the logic that writes the index, not in the object. EasyBuilder Pro has no built-in cycling value for this, the way some HMI platforms ship a system blink tag, so you build the cycle yourself: a periodic macro on the panel, or a counter in the PLC when a controller owns the run command. One caution for real plant: if the pipe carries product, treat the moving dot as decoration and indicate actual flow with real inputs.
Build the switch-gated position counter #
- Draw the Animation object along the pipe centreline and space the path points evenly, through the bends as well; uneven spacing shows up as the particle speeding up and slowing down. Count the points and call the total N.
- Set the object's position source to controlled by address and point it at a free block of Local HMI words that nothing else in the project writes.
- Place a switch object that writes one free Local HMI bit; that bit is the run bit.
- Write the macro that counts and wraps; the logic is in the next section.
- Set the macro's trigger to periodic execution and enter the period. The worked example below uses 250 ms.
- Compile and download: every later change to the macro, the point count or the period needs a fresh download before the panel runs it, as in why an HMI edit needs a new runtime download.
If the PLC owns the run command, build the increment there and drop the macro: the same add-one-and-wrap runs as compare-and-add logic on a timer instruction, pointed at the register the Animation object reads, and the loop keeps running when nobody touches the screen.
The macro that counts and wraps #
The manual's macro example reads one value from local memory as GetData(var, "Local HMI", LB, 0, 1): Local HMI is the device, LB the local bit area, 0 the bit offset and 1 the count. Read the run bit that way, then write the index back with the matching SetData call against the word address the object reads. Between the read and the write sit three lines of logic:
// illustrative variables; reads and writes go through GetData and SetData
int step = 0 // position word, starts at the inlet
bool run_bit = 0 // run bit written by the switch object
const int N = 20 // path points on this object
if run_bit == 1 then
step = step + 1
if step >= N then
step = 0 // wrap: this line is the loop
write step to the position word
// run_bit OFF: write nothing, the particle freezes where it is
With the run bit OFF the macro leaves the word alone and the particle freezes in the pipe; to make the switch park the particle back at the inlet instead, write 0 while the bit is OFF.
Speed follows straight from the settings: one pass takes N times the macro period. Change the period to change the speed, and if the motion looks steppy, add path points and recompute the period from the same relation rather than shrinking the period alone. Some versions read more than one consecutive word for the effect, a state word beside the position word; the Animation object chapter of the EasyBuilder Pro user manual gives the exact word layout for the version you run, so reserve the block it needs.
Timing a 20-point pipe path for a 5 second pass #
The values below are illustrative, chosen to show the sizing; they are not measured results.
- N = 20 path points: an example count for a straight run with two bends drawn at even spacing; count the points on your own object.
- T = 5 s target time for one full pass: an example value picked so a single dot reads as a particle rather than a blur.
- k = 4 offset particles: an example count for a continuous-flow look.
Rule: set the macro period to the target pass time divided by the point count, period = T ÷ N, and offset each extra particle copy by N ÷ k points.
Arithmetic: 5 s = 5000 ms, so the period is 5000 ms ÷ 20 points = 250 ms per point. The offset per copy is 20 ÷ 4 = 5 points, so copy i takes the index (step + 5 × i) mod 20. Dots then arrive at any fixed point on the pipe every 5 points × 250 ms = 1250 ms, one dot every 1.25 s.
Result and decision: set the macro's periodic execution to 250 ms. One full pass then takes 20 × 250 ms = 5000 ms = 5.0 s, with a dot arriving every 1.25 s. If that reads slow on the screen, halve the period to 125 ms first, which takes the pass to 20 × 125 ms = 2500 ms = 2.5 s, and leave the point count and the offsets alone.
Turn one dot into a continuous flow #
A single particle reads as a ball, not a flow. Place k copies of the object on the same path, give each copy its own position word, and write (step + i × N ÷ k) mod N to copy i from the one macro; the copies stay evenly spaced and loop together. Stack the copies above the pipe graphic in the layer order, or they run hidden underneath it.
For complicated pipe routing, skip the Animation object: place a row of fixed dot images along the pipe as lamps and light each one when the step counter matches its index modulo a spacing value. That stays in sync on one word and needs no drawn path.
A rising level in a tank or pipe is a different effect and needs none of this; a fill animation covers it, as in how to animate a tank level graphic on an HMI screen.
Prove the loop before you trust it #
- Put a numeric display object on the position word next to the pipe. With the switch ON, watch it count from 0 to 19 and back to 0; that is the test that proves the counter and the wrap.
- If the number counts but the object stands still, the object is reading a different address or the wrong word of its block; compare the object's position address against the address your macro writes, word for word.
- Toggle the switch OFF mid-pipe and confirm the behaviour you chose: frozen in place, or parked at the inlet if you wrote that variant.
- Leave the screen and come back: the flow resumes from the counter's current value.
- Time one full pass on the panel against the calculation, N × period. If the panel lags the simulation, the period is shorter than the panel's workload allows; lengthen it.
Traps that stall the animation #
- Using visibility as the start and stop: hiding a predefined animation never gives a clean start at the inlet. Switch the mode to controlled by address instead.
- Wrapping against a guessed maximum: past the last point the object has no point to show and the particle parks or disappears. Compare against N.
- Editing the path without updating N: add two points and the loop skips the tail of the pipe or overruns it. Keep N in one place, a constant in the macro or a word you maintain.
- Periods short enough to load the panel: a macro that fires more often than it can finish degrades every object on the screen, the same overscheduling failure a PLC shows when a periodic task period is shorter than its execution time.
- Addresses pointed at a controller that is not connected: keep the run bit and the position word in Local HMI memory while you learn on the bench, because a word that lives at a missing PLC station never updates and nothing moves.
Questions asked
Can the PLC run the counter instead of the HMI macro?
Yes, and prefer it once a controller owns the run command. Build an increment-and-wrap in the PLC: add one to a counter word on a self-resetting timer, compare against the point count and wrap to zero. Point the Animation object at that PLC register over the existing link. The update rate then follows the timer base, and the animation stops by itself when the link to the PLC drops.
The position word counts but the object does not move, why?
The object is reading a different address than the macro writes, or it is reading the wrong word of its block. Open the object's position setting and compare it against the address in your SetData call word for word. The Animation object chapter of the EasyBuilder Pro manual for your version lists the exact word layout, including any extra words your version uses beside the position word.
How do I run the flow in the opposite direction?
Decrement instead of increment. Start the position word at N minus 1, subtract one each macro pass, and wrap to N minus 1 when the value goes below zero. The period and the pass time stay the same, so a 20 point path at a 250 ms period still takes 5 seconds per pass, just from the outlet end back to the inlet.
Does the switch have to be an object on the HMI?
No. The run bit is an ordinary bit, so anything that can write it can start the flow: a PLC output, an interlock or a real flow switch. When a real input owns the run command, let the controller write the run bit and keep the counter local on the panel, so the picture keeps working even if the switch object is never touched.
Can two animated screens share one counter word?
Give each one its own word block. If two screens each write the same position word, the two counters overwrite each other and the particles jump. Run one periodic macro per counter word, and place each screen's copy of the counter in its own reserved block of Local HMI memory. One macro can still drive all the copies of the object on a single screen through their offset words.