Application Case 6—Hardware-Timed Simultaneously Updated I/O Using the Timed Loop

Requirement

"My I/O needs to be hardware-timed. All output values need to simultaneously update at the arrival of the sample clock edge. However, I would also like to use the Timed Loop in my application."

Solution

Use the DAQmx Create Timing Source VI to create a timing source that drives a Timed Loop that contains the I/O operations and the control algorithm.

Advantages

Restrictions

Sample Application

An example of this kind of application is an analog control loop that reads samples from a specific number of analog input channels, processes the data using a control algorithm (such as PID), and writes the new control values to the analog output channels.

You can create such an application with the Control Loop From Task timing source. The Control Loop From Task timing source uses the sample clock signal from the analog input task, which allows strict lateness-checking of all tasks associated with that sample clock.

The Control Loop From Task timing source also allows you to specify a delay between the time the sample clock event is handled and the time the Timed Loop starts executing. This delay, or sleep time, keeps the Analog Input Read VI inside the Timed Loop from using 100% of the CPU time available while waiting for the analog input samples to be multiplexed and digitized.

Sample Timing Diagram

Sample Implementation

Sample Block Diagram

Notes

The following diagram shows, for multiple channel configurations, the effect of the amount of sleep over the maximum achievable rate and the amount of work lower-priority threads can execute at such rates.

*See benchmark configuration below.

The graph shows that, when acquiring 8 channels using a specific hardware and software configuration, the maximum achievable rate decreases as soon as the amount of sleep time increases from 0 to 5 µs. This is not, however, the case for the 12- and 16-channel configurations, for which increasing the amount of sleep up to 10 and 15 µs respectively has no visible effect on the maximum achievable I/O rates. In the 12- and 16-channel case, the additional sleep interval allows other threads to execute more work (refer to definition below) without affecting the overall I/O rate of the application.

Benchmark Configuration

Hardware Configuration:

Software Configuration:

Benchmark details: