Fairino supports running background programs (LUA scripts that run alongside your main program). They're a powerful concept but come with significant limitations that aren't obvious from the documentation.
What background programs CAN do
- Read sensors, digital inputs, and robot state variables
- Monitor conditions and set flags
- Start and stop the main (foreground) program
- Communicate with external devices (PLC, sensors) via I/O or network
- Run automatically after controller startup — no need to be in automatic mode
- Log data to files
- Use
RegisterVar()for variable monitoring
What background programs CANNOT do
- Move the robot arm — no MoveJ, MoveL, MoveC, or any motion commands whatsoever
- Access or control the teach pendant UI
- Directly modify main program execution flow (only start/stop it)
Critical limitation: background pauses during robot motion
This is the biggest gotcha that multiple users have discovered the hard way: when the robot executes movements in the main program, the background program halts or runs extremely slowly.
This affects:
- Any background loop that polls I/O or sensor values
RegisterVar()monitoring- Communication routines with external devices
This makes background programs nearly useless for real-time I/O communication during motion — which is exactly the use case most people want them for.
Workarounds
Workaround 1: Use physical I/O as intermediary
Instead of direct variable sharing between main and background programs, use digital I/O: the main program sets/reads physical outputs, and the background program (or PLC) reads/writes the other side. The I/O operates at hardware level and isn't affected by the LUA execution pause.
Workaround 2: Use CI (Configurable Input) signals instead
For common operations like starting/stopping the main program, you don't need a background program at all. Use the built-in CI/CO (Configurable Input/Output) system:
- Go to Settings → I/O Configuration
- Assign CI inputs to functions like "Start Main Program", "Stop Main Program", "Manual/Auto Mode Switch"
- Wire your PLC or external buttons to these CI inputs
This is built into the firmware and works reliably without any LUA code.
Workaround 3: Start/Stop function via CI
Fairino has a dedicated Start/Stop function controlled by signal levels: rising edge starts the program, logic 1 = program running, falling edge stops the program. This is configured in the I/O settings and is the recommended way for PLC integration.
Auto-start in Automatic Mode
A common need: have the robot boot up and automatically enter Automatic Mode so it can receive start commands via DI/CI.
The robot does not start in Automatic Mode by default after a reboot. Options:
- Use a physical Manual/Auto mode switch connected to the control box input
- A background program can switch to Auto mode — since mode switching doesn't require arm movement
- Configure a "default program" that starts via the safety box buttons or digital inputs
Setting up a background program
In the WebApp: Programs → Background Programs. Select your LUA script. It will run automatically on controller boot.
Reference: Look for "Background Program" in the manual or in the WebApp help section.