Example Code

Synchronize Correlated Digital Output with Analog Input Using NI-DAQmx

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Hardware

  • Data Acquisition (DAQ)

    Software

  • LabVIEW

    Driver

  • NI DAQmx

Code and Documents

Attachment

Overview:
This example uses DAQmx to synchronize finite generation and acquisition of Correlated Digital Output with an Analog Input Task respectively.

Descriptions:
Correlated I/O enables synchronization of on board digital I/O lines to a clock reference. Digital and Analog samples can be synchronized in time by sharing the AI clock as the source of your digital I/O clock. You may also use the Counter Output pulse as the Source of Digital Timing. Hence, set the Source for Digital Timing as ai/SampleClock.This  example will work on any device that uses DAQmx and supports Correlated  Digital I/O. To perform Correlated Digital I/O on 9172 Chassis,  you need a Correlated Module in slot 1-4 of the chassis.

Requirements:
  1. LabVIEW 2012 or compatible.
  2. NI-DAQmx 15.5.1 or compatible.


Steps to Implement or Execute Code:

  1. Set all the control values on the front panel corresponding to the physical channel to be used on the DAQ device.
  2. Run this VI.
  3. Monitor the analog input voltage measured and ramp signal generated from specified channels.


Block Diagram Steps:

  1. Creates channels to measure voltage and to generate digital signals  
  2. Sets the source of the Sample Clock, the rate of the Sample Clock, and the number of samples to acquire or generate.
  3. Generates an array containing a ramp pattern and write to digital output lines.
  4. Transitions the tasks to running state to begin measuring and generating data.
  5. Reads the waveform from the analog input channel and waits for the digital output generation to complete.
  6. Clears the tasks.
  7. Displays any error occurs.

Front Panel.PNG

 

Block Diagram.PNG

**This document has been updated to meet the current required format for the NI Code Exchange.**
John Passiak

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.