How-to
Simulate Robot Conveyor Tracking Without an Encoder
Short answer
Yes: configure linear conveyor tracking to take its tick count from script, then advance a counter in a parallel thread and push it to the tracking setup with set_conveyor_tick_count(). The tracked offset moves at the tick update rate divided by the configured ticks per meter, so you choose the simulated belt speed and verify it before any conveyor hardware exists.

On this page
- Can a robot track a conveyor with no encoder connected?
- How do you set up linear tracking to take its count from script?
- How do you run the parallel thread that advances the count?
- How fast does the tracked offset move for a given tick rate?
- Does a higher ticks-per-meter setting make the robot track faster?
- How do you prove the simulated speed is what you calculated?
- What changes when you replace the simulation with a real encoder?
- Questions asked
You can make a robot track a conveyor that does not exist. Configure linear conveyor tracking to take its encoder count from script, then run a parallel thread that advances a counter and pushes it to the tracking setup with set_conveyor_tick_count(). The tracked frame then moves along the configured conveyor direction at a speed you control: the tick update rate divided by the configured ticks per meter. No fieldbus encoder, no Modbus device, no belt. This article gives the setup, the code pattern, the speed arithmetic with a worked example, and the check that proves the simulation before you build anything around it.
Can a robot track a conveyor with no encoder connected? #
Yes. Linear tracking consumes exactly one live input: the encoder tick count. When the tracking setup is configured to expect that count from a script function rather than from a fieldbus encoder, a counter you increment yourself supplies everything the tracking math uses.
The controller documentation describes the function in one line: it sets the count value of the encoder. The tracking math never asks where the count came from. It multiplies the count by the distance one tick represents and shifts the tracked frame accordingly, whether a physical encoder, a Modbus device, or your own loop produced the number.
This makes the simulation legitimate rather than a workaround: you are using the documented input path, with a script-generated source in place of hardware. When the real conveyor arrives, only the count source changes.
How do you set up linear tracking to take its count from script? #
Set the tracking up exactly as you would for a real line, with one difference: the encoder configuration must be the variant that expects the tick count to be updated from script, not the one that polls a Modbus encoder. The steps, in order:
- Define the conveyor's direction and the frame the parts travel along, as for a real installation.
- Set the resolution in ticks per meter; for example 1,000. This is the only number tying counts to distance, so write it down before anything else.
- Select the encoder source that waits for tick counts from the script function, so the setup stops asking for a Modbus address.
- Write or load the tracking program: the pick move that starts linear tracking on that conveyor.
- Start the simulating thread before the tracking move begins, so the count is already advancing when tracking starts.
Steps 1 and 4 are the same work you would do for a real conveyor, which is the point: the simulation rehearses the real program, not a stripped-down version of it.
How do you run the parallel thread that advances the count? #
Start a parallel thread before the tracking move, and in its loop add a fixed step to a counter, pass the counter to set_conveyor_tick_count(), then sleep for a fixed period; the thread keeps running while the robot tracks. The pattern below is pseudocode: the only controller identifier in it is the documented function name, and every other name is this example's own variable.
# Illustrative variables, not controller identifiers:
# sim_ticks : int, the simulated encoder count, starts at 0
# step : int, ticks added on each update, 10 in this example
# period : float, seconds between updates, 0.1 in this example
sim_ticks = 0
step = 10
period = 0.1
run in a parallel thread, loop forever:
sim_ticks = sim_ticks + step
set_conveyor_tick_count(sim_ticks)
sleep(period)
Two things matter in that loop. First, the count must keep changing while tracking runs, which is why it lives in a parallel thread rather than in the tracking program itself; a blocked or finished thread means a belt that stopped. Second, the step and the period together set the simulated speed, as the next section shows.
How fast does the tracked offset move for a given tick rate? #
The simulated belt speed is the tick update rate divided by the resolution, and each single tick moves the tracked point by one divided by the resolution, in meters. Write it as v = R / T, where R is the update rate in ticks per second and T is the configured resolution in ticks per meter.
| Ticks per meter | Update rate | Offset per tick | Simulated velocity |
|---|---|---|---|
| 1,000 | 1 tick/s | 1 mm | 1 mm/s |
| 10,000 | 1 tick/s | 0.1 mm | 0.1 mm/s |
| 1,000 | 100 ticks/s | 1 mm | 100 mm/s |
Worked example, calculated for the inputs above and not a measured result. The thread adds step = 10 ticks every period = 0.1 s, so the update rate is R = 10 ticks / 0.1 s = 100 ticks/s. With T = 1,000 ticks/m, the simulated speed is v = 100 ticks/s / 1,000 ticks/m = 0.1 m/s, which is 100 mm/s. Over a 5 s tracking run the count rises by 100 ticks/s × 5 s = 500 ticks, so the tracked frame should advance 500 ticks / 1,000 ticks/m = 0.5 m along the conveyor direction. That last number is the one to check against the robot, because it is a distance you can measure.
Does a higher ticks-per-meter setting make the robot track faster? #
No. If the thread keeps adding the same number of ticks each second, a higher resolution makes the tracked offset move more slowly, because each tick now stands for a shorter distance. At one tick per second, raising the resolution from 1,000 to 10,000 ticks per meter drops the offset speed from 1 mm/s to 0.1 mm/s.
To make the simulated belt faster, change the thread: add more ticks per update, or shorten the sleep period. Both raise R, and speed follows R directly once T is fixed. There is a practical ceiling on how fast a script loop can push counts, so when you need high simulated speed, prefer a larger step over a tiny period.
The resolution itself has its own limits on the real system, separate from this simulation; the article What Limits Counts per Meter in Robot Conveyor Tracking covers where that ceiling comes from.
How do you prove the simulated speed is what you calculated? #
Run the tracking move with the robot unloaded, read the tracked position at two known times, and compare the distance traveled against the expected distance from the count rate and resolution. The comparison is arithmetic you already did: expected distance equals R times elapsed time divided by T.
Do the check in this order:
- Note the count and the robot's position along the conveyor direction at the start of tracking.
- Let it track for a measured window, then note both again.
- Divide the measured travel by the window to get the observed speed, and compare it with the calculated one.
If the direction is wrong, the configured conveyor direction is the first thing to fix, before anything in the thread. If the speed is wrong, check the two numbers in the thread, step and period, and then confirm the resolution actually configured matches the one you calculated with. A wrong sign or rate shows up only as motion you did not expect, so run the first test at reduced speed with the cell clear: the arm is chasing a belt that carries nothing, and nothing in the scene tells a bystander where it will go.
What changes when you replace the simulation with a real encoder? #
Only the count source changes: stop the simulating thread, connect the encoder to the controller's encoder input, and keep the same resolution, direction and tracking frame, so the program you rehearsed runs unchanged. The setup step that selected the script-fed count source is reverted to the fieldbus or hardwired encoder variant at the same time.
The physical side has its own checklist, covered in Robot Conveyor Tracking: Wire the Encoder to the Controller. If the whole line is still ahead of you, What a Conveyor Tracking Retrofit Needs Beyond an Encoder lists what else the installation requires before the first real part moves.
That is the decision, case by case. Learning or testing tracking with no hardware: configure the script-fed encoder source, run the parallel thread, and size the speed with v = R / T. Doubting the numbers: measure the tracked travel over a timed window and compare. Commissioning: disable the thread, wire the real encoder, and change nothing else.
Questions asked
How do you make the simulated conveyor stop or run backwards?
Set the step to zero and the count freezes, so the tracked frame stops while the robot keeps tracking a stationary belt. A negative step decrements the count and the offset moves opposite the configured conveyor direction. Ramping the step up from zero at start also lets you rehearse how a pick behaves while the belt accelerates.
Can the simulation run while a real encoder is connected?
No. The script function sets the encoder count value directly, so a simulating thread and a physical encoder would overwrite each other's counts and the tracked frame would jump. Choose one source: run the thread only while the encoder input is unused, and disable the thread before commissioning the real line.
How do you change the simulated belt speed without touching the setup?
Change the thread, not the configuration. Doubling the ticks added per update doubles the simulated speed, and halving the sleep period does the same at the cost of more script cycles per second. Once the resolution is fixed, the ratio of step to period alone sets the speed, so adjust that ratio first.