In this article, we discuss how to use the Background Application feature, which allows the user to run more than one application at the same time.
An asynchronous application enables the cobot to execute two or more independent logic threads concurrently. This is particularly useful when certain events or conditions must be monitored continuously, even while the main program is executing. With a single-thread setup, the robot must finish the entire foreground program before evaluating conditions again, making real-time reactions difficult or impossible.
Check whether a package is present at a specific location
Stop the conveyor when the package arrives
Remove the package from the conveyor and place it on a shelf
Restart the conveyor until the next package arrives
In the previous implementation, the cobot could not check for Package B until it finished all instructions for moving Package A to the shelf. This meant the conveyor could not restart or be monitored until the entire pick-and-place cycle was completed.
This limitation can be resolved by separating the package-detection logic from the package-removal logic. By running the detection logic in a Background Application, the cobot can continuously monitor for new packages while the foreground application handles movement, gripping, and other tasks.
Typically, the cobot runs:
A foreground application — the main LUA script used for pick-and-place or general robot motion.
One or more background applications — additional scripts that run asynchronously with independent logic.
(For example, you can run both logic_A_background and logic_B_background simultaneously.)

The logic running in the background will continuously monitor the proximity sensor.
Assuming your proximity sensor is Digital Input 2 (Responsible for detecting the package arrival), you can follow this structure:
If DI2 = 1 (a part is present):
→ Stop the conveyor
→ Set a global user variable (e.g., SetUserVal(uservar1,1))
If DI2 = 0 (no part present):
→ Set the global user variable to (e.g., SetUserVal(uservar1,0))
→ Turn the conveyor back on (DO0 = 1)
→ Keep it running until a new part arrives
Save the script and run it from the Background Applications tab.
Note that background applications continue running even if the robot is not in automatic mode or is temporarily stationary.
To start the background application, simply select your script from the list and click Run.
