Can I Use a Mask In DAQmx to Write to a Line in a Port as in Traditional DAQ?

Updated Apr 19, 2023

Reported In


  • LabVIEW Full
  • LabVIEW Base
  • LabVIEW Professional


  • NI-DAQmx

Issue Details

I am working with a digital board and need to control the values of each line (bit) independently in my port. In Traditional DAQ, I can send in a mask to specify exactly which line that I want to control. How can I accomplish this same functionality in DAQmx?


There is no mask functionality in DAQmx as there is in Traditional DAQ. 

In DAQmx, you have the ability to control one line by configuring the DAQmx located on the functions palette at All Functions>>NI Measurements>>DAQmx - Data Acquisition for Digital Bool 1Line 1Point. This is a good solution if you only need to modify the value of the same line on the port. You are not able to modify a different bit on the port with this VI once you have configured it for a specific line.

You can use the DAQmx with the configuration Digital 1D Bool 1Channel 1Sample to modify all bits (lines) on a port. There is a shipping example in LabVIEW called Write Dig that displays this functionality. For convenience, the example is below

This solution may seem most similar to the Traditional DAQ solution, but the DAQmx solution requires you write an array of data to the port at every DAQmx Write function call. Therefore, in order to control one line at a time, you must remember the previous state of the port, logically modify that array, and then write to the port and change the value of a specific line. Keep in mind that you are actually writing to each bit in your array at each loop iteration, whereas traditional DAQ allowed you to mask out bits that you did not want to write anything to.

If you know in advance which lines you will be writing to, you could use the one channel for each line feature of the DAQmx Create Channel function to create one task that write only to your desired lines. To do so, click the dropdown menu of Output Lines on the attached and select Browse. You will be able to select multiple lines by holding <Ctrl>. Make sure to initialize the array to the number of lines you are writing to before running the VI:

Alternatively, you can create parallel digital tasks for each line you want to control. This solution allows you to write to one line at a time without having to remember the previous states of the lines that you do not want to change. The only drawback is that is clutters up the block diagram a little more:

Additional Information

Here is a quick refresher on digital terminology:
  • Line- Individual Bit
  • Byte- Eight Bits
  • Port- A collection of lines (usually 8)
  • LabVIEW refers to a physical port as a channel