Write Digital Data Using DAQmx API in LabVIEW

Updated Aug 3, 2023

Environment

Software

  • LabVIEW

Driver

  • NI-DAQmx

  • I am trying to write a DC output to a port on my DAQ device but DAQ Assistant is no longer working. How do I write a Boolean output by using NI-DAQmx code?
  • How can I use the NI-DAQmx driver to write to a hardware channel?
  • I want to write data to a NI-DAQmx supporting device. How can I do this?
  • How can I create a digital output signal using my NI-DAQmx supporting device?

LabVIEW is shipped with some example VIs that demonstrate how to write data using the DAQmx API.
For most LabVIEW projects, especially when you are new to LabVIEW, it is beneficial to start from a working example and modify the code to fit your needs.

See the following locations for the Digital Output shipping examples in NI Example Finder:
  • Hardware Input and Output --> Digital Output:
    1. Digital - Finite Output.vi - Generate a finite amount of digital data based off of a sample clock.
    2. Digital - Continuous Output.vi - Generate a continuous amount of digital data based off of a sample clock.
    3. Digital - SW-Timed Output.vi - Generate digital output data based on software timing or user inputs. (Some of this code can be seen below).

Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.

Additional Information

The DAQmx Write VI is capable of handling Boolean and Numeric data, including arrays. However, the data that you write must be in the units of generation.