![]() |
APIs, concepts, guides, and more
|
PREMIUM FEATURE BETA
Leverage Real-Time Tasks (RTTasks) alongside RMP firmware to execute deterministic user logic, motion control, and I/O operations without specialized real-time programming expertise.
Real-Time Tasks (RTTasks) provide a powerful framework to run functions that use RapidCode alongside the RMP firmware that simplifies real-time programming for industrial automation. This feature enables machine builders and software developers to write and run deterministic user logic, motion control, and I/O operations without requiring specialized expertise in real-time operating systems.
Every sampling interval, the RTTaskManager firmware executes scheduled RTTasks with precise timing guarantees, making them ideal for applications where consistent, predictable execution is critical to system performance.
Real-Time Tasks consist of several key components:
RTTasks solve several critical challenges in industrial automation development:
Traditional real-time programming requires expertise in:
RTTasks eliminate these complexities by providing:
RTTasks guarantee consistent execution timing, critical for:
Safe communication between real-time tasks and non-real-time client applications is achieved through a shared memory structure called GlobalData. This structure contains variables that can be accessed by both real-time tasks and client applications.
The GlobalData mechanism provides a structured way to exchange information between:
GlobalData
structure containing shared variables using the RSI_GLOBAL
macroREGISTER_GLOBAL
macroTo create shared variables, define them in your GlobalData structure using the RSI_GLOBAL
macro and register them with the REGISTER_GLOBAL
macro:
Method | Description | Parameters | Return Value |
---|---|---|---|
GlobalNamesGet | Retrieves names of all registered global variables | Optional library name and directory | Vector of variable names |
GlobalValueGet (by name) | Reads a global variable's value by its name | Variable name, optional library name and directory | FirmwareValue containing the value |
GlobalValueSet | Sets a global variable's value | New value, variable name, optional library name and directory | None |
GlobalTypeGet (by name) | Reads a global variable's type by its name | Variable name, optional library name and directory | RSIDataType of the global |
In real-time task code:
In application code:
Global variables provide:
The Real-Time Tasks API provides comprehensive interfaces for creating, managing, and monitoring deterministic user-defined tasks that execute alongside the RMP firmware.
Class | Description |
---|---|
RTTaskManager | Manages real-time tasks firmware including creating, scheduling, and controlling multiple tasks |
RTTask | Controls and monitors an individual real-time task |
Category | Methods | Description |
---|---|---|
Creation | Discover, Get, Create | Methods to create or discover task manager instances |
Task Management | TaskSubmit, TasksGet | Submit new tasks and retrieve existing tasks |
Global Data | GlobalNamesGet, GlobalValueGet, GlobalValueSet, GlobalTypeGet | Manage shared data between tasks and applications |
Control | Shutdown | Control manager lifecycle |
Information | StatusGet, InfoGet, IdGet | Retrieve manager status and information |
Category | Methods | Description |
---|---|---|
Control | Stop, TimingReset | Control task execution and reset timing statistics |
Status | StatusGet, ExecutionCountAbsoluteWait, ExecutionCountRelativeWait | Monitor task status and wait for execution events |
Information | InfoGet, IdGet | Retrieve task configuration and identification |
Structure | Description |
---|---|
RTTaskCreationParameters | Defines how a task should be created and configured |
RTTaskInfo | Provides configuration information about a task |
RTTaskStatus | Provides execution status and timing statistics for a task |
RTTaskManagerCreationParameters | Defines how a manager should be created and configured |
RTTaskManagerInfo | Provides configuration information about a manager |
RTTaskManagerStatus | Provides status information about a manager |
State | Description |
---|---|
RTTaskManagerState::Dead | Task manager is not initialized or has been terminated |
RTTaskManagerState::Running | Task manager is running |
RTTaskManagerState::Stopped | Task manager is not running, but is initialized |
State | Description |
---|---|
RTTaskState::Dead | Task is not initialized or has been terminated |
RTTaskState::Disabled | Task is initialized but not currently executing |
RTTaskState::Waiting | Task is waiting for its next scheduled execution time |
RTTaskState::Running | Task is currently executing |
Learn how to create and manage real-time tasks for deterministic execution.
This sample demonstrates how to create a simple RTTask that runs every sample interval.
This is the code that will be running cyclically in the RTTask. All it does is increment a global counter
.
These are the RTTaskManagerCreationParameters we will be using. The required parameters are different depending on whether the task manager is going to run in Windows, INtime, or Linux.
This the is application code, which creates the RTTaskManager, submits the Increment
RTTask, and examines the counter
global.
This sample demonstrates how to use RapidCode objects inside an RTTask.
Before using and RapidCode objects inside of RTTasks you need to initialize the pointers inside the RTTaskManager by calling InitializeRapidCodeObjects()
inside an RTTask. After doing so the RapidCode object pointers will be accessible like normal "C-style" global variables (not GlobalData).
*controller
is a MotionController*axes[i]
is an Axis*multiAxes[i]
is a MultiAxis*networkNodes[i]
is a NetworkNodeHere is an example RTTask that initializes the RapidCode object pointers.
In the application code, we submit the Initialize
task as follows.
Here is an example of a task function that uses a RapidCode object. It randomly increments the average
global, and moves the axis to it. It is important to check that the axis pointer exists before attempting to use it, otherwise it could cause a segmentation fault inside the task manager.
Here is the application code that puts it all together, submitting the Initialize
task first and then submitting the RandomWalk
task.