Table Of Contents

Hardware-Timed Simultaneously Updated I/O

Last Modified: October 17, 2018

  • Requirement—The I/O must be hardware-timed. All output values need to simultaneously update at the arrival of the sample clock edge.
  • Solution—Use the DAQmx Wait For Next Sample Clock function/VI to verify that a new sample clock edge has not yet occurred.

    Advantages

    • The current iteration's output samples are guaranteed to be aligned with the next iteration's input samples.
    • NI-DAQmx returns an error if the DAQmx Wait For Next Sample Clock function/VI does not start before the next sample clock edge occurs.
    • I/O jitter is confined to the jitter of the hardware clock, which is on the order of a few nanoseconds.

    Restrictions

    Read, process, and write operations are confined to the time available between the moment the device starts acquiring data and the moment the next sample clock edge arrives.

Sample Application—Hardware-Timed Simultaneously Updated I/O

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 new control values to the analog output channels.

LabVIEW Example—Hardware-Timed Simultaneously Updated I/O

spd-note-note
Note  

Although this example is written for LabVIEW users, the principles apply if you are using another ADE, such as LabWindows/CVI.

LabVIEW Example

  • Wire the DAQmx Wait For Next Sample Clock VI to one of the hardware-timed tasks. Use dataflow wiring to guarantee that the DAQmx Wait For Next Sample Clock VI executes after the AO Write call.
  • If the DAQmx Wait For Next Sample Clock VI does not start before the arrival of the next sample clock edge, it returns an error.

Sample Block Diagram

spd-note-note
Note  
  • Use only one DAQmx Wait For Next Sample Clock VI within a LabVIEW loop. If you have multiple hardware-timed single-point I/O tasks within the same LabVIEW loop, you can connect the DAQmx Wait For Next Sample Clock VI to any one hardware-timed single-point task within that loop.
  • If, when a cycle overflow occurs, you want to receive a warning rather than an error, set the DAQmx Real-Time»Convert Late Errors to Warnings property to True.
  • The DAQmx Wait For Next Sample Clock VI has two modes of operation: Polling and Wait For Interrupt. To change these values, use the DAQmx Real-Time»Wait For Next Sample Clock Wait Mode property. Wait For Interrupt mode, which is the default, allows lower priority processes to execute while the time-critical loop waits for the next sample clock. Polling mode allows for higher sampling rates, but it prevents lower priority processes in the system from executing while the time-critical loop waits for the next sample clock.
  • The analog instance of DAQmx Read calls have two modes of operation: Polling and Wait For Interrupt. To change these values, use the DAQmx Read»Advanced»Wait Mode property. Wait For Interrupt mode allows lower priority processes to execute while the time-critical loop waits for all the requested samples to be converted. Polling mode allows for higher sampling rates, but it prevents lower priority processes in the system from executing while the time-critical loop waits for the converted analog samples.
  • The specific application shown in this section assumes the use of Wait For Interrupt mode for both the DAQmx Wait For Next Sample Clock VI and the analog instance of the DAQmx Read VI. To change these values, use the DAQmx Read»Advanced»Wait Mode and/or DAQmx Real-Time»Wait For Next Sample Clock Wait Mode properties.

Recently Viewed Topics