NI-XNET Best Practices for High-Priority Loops in LabVIEW Real-Time Applications

Many real-time applications contain at least one loop that must execute at the highest priority. Single-point session modes within NI-XNET are optimized for use within high-priority loops, though you can use other NI-XNET session modes within these loops.

Note Not all NI-XNET communication protocols support single-point session modes.

A high-priority loop typically contains code to read inputs, execute a control algorithm, and then write outputs. The high-priority loop executes at a fast period, such as 500 µs (2 kHz). To ensure that the loop executes within the period, the average execution time (cost) of read and write functions must be low. The execution time also must be consistent from one loop iteration to another (low jitter).

  • NI-XNET single-point session modes are designed for use within high-priority loops. This applies to all four single-point modes: input, output, signal, or frame. The NI-XNET Read and Write functions provide fast and consistent execution time, and they avoid access to shared resources, such as the memory manager.
  • NI-XNET session modes other than single-point modes all use queues to store data. Although you can use queued session modes within a high-priority loop, queued modes use a variable amount of data for each read and write. Variable amounts of data require variable amounts of time for processing, which can introduce jitter to the loop. When using the queued modes, measure the performance of your code within the loop to ensure that it meets your requirements even when bus traffic is variable.
  • When the NI-XNET Read and Write functions execute for the very first loop iteration, they often perform tasks such as starting the session, allocating internal memory, and so on. As a result, the first iteration has higher processing costs compared to any subsequent iteration. As a result, when you measure performance of the NI-XNET Read and Write functions, discard the first iteration from the measurement.
  • Assume that functions other than NI-XNET Read and Write are not designed for use within high-priority loops. Properties are designed for configuration purposes. Functions that change state (for example, NI-XNET Start) require time for hardware or software configuration. Nevertheless, there are exceptions for which certain properties and functions support high-priority use. Refer to the documentation for the specific functionality you want to use within a high priority loop for information on potential exceptions.