Logic Program

Description

PolyScope X applications can include a Logic Program that runs continuously in the background, independently of the main robot program. Use it for tasks that must keep running when the arm is powered off, the main program is paused or stopped, or you have entered a safeguard area.


Typical uses include maintaining fieldbus communication (Modbus, Ethernet/IP, PROFINET, Socket, XmlRPC), reacting to external sensor inputs, reporting robot state to a production PLC, and controlling external equipment when the main program stops.

Logic Program cannot use functions that directly move the robot arm.

Examples of applications with Logic Program

  1. Active response to external sensor input while the robot is in a stop mode, such as Safeguard Stop, Protective Stop, or Emergency Stop, and the main program is paused or stopped, or before the robot arm is powered on.

  2. Fieldbus communication (Modbus, Ethernet/IP, PROFINET, Socket, XmlRPC) is maintained even if the robot arm is powered off and the program is not running.

  3. Continuous cell logic operation while the main program is interrupted by the operator.

  4. Robot status reported to the production control software (production PLC).

  5. Controlled stop of external equipment, such as a welding machine, conveyor, or glue dispenser, when the main program stops or pauses.

  6. Operator input is captured before the program starts.

  7. Customized recovery after fault conditions. You can decide what to do after you resume the main program.

  8. Replacement of external PLC controller in small robot cells.

License

Logic Program requires a license. You can purchase it through the customer portal.

 

 

Controlling the Logic Program

On the Program page, select Logic program on the sidebar. The expanded sidebar shows the controls for navigating the different parts of the Logic Program. You can also start, pause, stop, and reset the program.

Logic Program Screen

 

 

The program control icon changes to either Run Program or Stop Program, depending on the state of the Logic Program. It is a shortcut for the program control actions in the Logic Program context menu.

Run Program icon in Logic Program Stop Program icon in Logic Program

The four Logic Program indicators show the current state of the program. They also indicate whether the program is configured to start automatically when an application is loaded.

 

Command nodes in Logic Program

You can use the Frame, Payload, and TCP command nodes in a Logic Program.

Command nodes in Logic Program

 

Logic Program structure

A Logic Program has the same structural sections as a main program:

  • Main program body — runs continuously until you stop it manually, with a halt instruction, or by a runtime error.
  • Before Start — runs once when the Logic Program starts.
  • Modules — functions and threads, organized the same way as in the main program. Thread functions execute only once by default; enable the Loop option to run a thread continuously.

The robot program and the Logic Program each have their own set of global variables, an independent thread pool, and an independent execution lifecycle. Starting, stopping, or faulting one program does not stop the other. A halt or pause instruction affects only the program in which it is executed.

Logic Program tree

 

 

In the Before Start section, the program runs only once.

Before Start in Logic Program tree

 

The Modules section lists the functions and threads available for the program.

Module in Logic Program tree

 

Exchanging data with the robot program

The primary way to communicate between the robot program and the Logic Program is through Application Variables. You can set and read these variables from both the robot program and the Logic Program.

This example counts items entering the robot cell's input buffer and displays the count in the robot program. The counter continues to increment even while the robot arm is powered off.

Program tree in Logic Program using Application Variables

 

Reading the robot state

The robot state is available through built-in RTDE variables. Read these variables with the script function get_rtde_value(). For a full list of available RTDE fields, see the RTDE Guide.

The following example shows how to check if Safeguard Stop is active:


safety_status = get_rtde_value("safety_status")
# check for Safeguard Stop and Automatic Mode Safeguard Stop
is_safeguard_stop_active = (safety_status == 5 or safety_status == 12)

 

The following example checks if the robot program is paused:

is_program_paused = get_rtde_value("runtime_state") == 4

The URScript Control API also wraps this functionality.

 

Automatically starting Logic Program

You can start a program automatically when an application is loaded. When you select the Autostart option, the Logic Program starts immediately after the application is loaded.

Autostart in Logic Program

 

You can also automatically start the Logic Program when the robot controller is powered on and the last application is loaded.

The Autostart function works regardless of the operational mode or robot arm status. When Autostart is triggered on load, a snackbar notification confirms that the Logic Program has started.

 

 

The sidebar badge on the Logic Program icon always indicates the program's current state, whether it is running or stopped.

Logic Program icon
It is your responsibility to ensure that the Logic Program is safe when the robot is powered on and when different applications are loaded.

Logic Programs can activate and deactivate external equipment using wired or PLC connections (Modbus, PROFINET, Ethernet/IP, Socket, direct outputs, or other interfaces).

 

Modules and threads

You can organize Logic Program functionality in functions, the same way as in the robot program.

You can mark each function as a Thread. By default, threads execute only once.

Thread function in Logic Program

 

Sharing resources

The robot program and the Logic Program execute independently, each with its own pool of threads and variables, but they share the same hardware resources. This imposes a few limitations that you should be aware of:

  • Logic Program threads execute on the same CPU as the robot program. The execution time of all Logic Program threads adds to the execution time of all robot program threads. In extreme cases, this can lead to a “Runtime too much behind” violation.

  • Some communication resources, such as Modbus signals or general-purpose registers, are shared. Writing to the same register at the same time produces unexpected results. The currently observed behavior can also change when the underlying implementation is optimized.

  • Modbus — One Modbus client is shared. Signals created in either program are visible in both.

  • Ethernet/IP flexible adapter — Each program opens its own reader or writer handle to the same instance. Handles must not write the same data fields.

 

Limitations

  • Only a subset of URScript instructions is available in the Logic Program.

  • Program execution indicators and breakpoint-based debugging are not supported for the Logic Program.

  • Interpreter mode is not supported in Logic Programs. You can still start interpreter mode in the robot program while the Logic Program is running.