Creating Deterministic Applications Using the Timed Loop

Separate deterministic tasks from non-deterministic tasks and place them in different loops in an RT target VI to ensure the deterministic tasks receive enough processor resources. A Timed Loop executes a subdiagram each iteration of the loop at the period and priority you specify. The higher the priority of a Timed Loop, the greater priority the structure has relative to other timed structures on the block diagram. Use deterministic communication methods to share data locally from the deterministic Timed Loop or to share data remotely across a network.

Note When using Timed Loops in RT applications, be careful to avoid jitter.

The following block diagram shows an RT target VI that contains a Timed Loop and a While Loop to control a data acquisition and logging application:

The deterministic loop set to a priority of 100 contains a subVI that performs a data acquisition task every iteration of the loop. The deterministic loop shares the acquired data with the non-deterministic loop using a shared variable, data. Shared variables with the real-time FIFO enabled can share data deterministically from a VI running on an RT target without affecting the determinism of the VI. The non-deterministic loop logs the acquired data that it reads from the shared variable data to disk on the RT target.

Cooperatively Yielding Timed Loop Execution

Because of the preemptive nature of Timed Loops, they can monopolize processor resources. A Timed Loop might use all of the processor resources, not allowing lower priority tasks on the block diagram to execute.

You must configure a deterministic Timed Loop with a period large enough to perform the deterministic task and still have idle time during the iteration to allow lower priority tasks to execute. By timing Timed Loops, you can yield the execution of deterministic tasks and cooperatively relinquish processor resources to lower priority tasks on the block diagram.

Note If you want to run an RT application on a system with multiple CPUs, consider targeting the time-critical Timed Loop to a dedicated CPU.