Writing or Reading Digital Data Using an External Clock in C Series Modules

Updated Apr 6, 2026

Environment

Hardware

  • C Series Digital Module

Driver

  • NI-DAQ™mx

C Series Digital Modules can write digital data in its digital lines by indicating in the software when to output a logic 0 or 1. With some of them, it is also possible to read digital data.  However, there are applications that require changing the state of a line or read data according to an external signal used as a sample clock. This is also useful to output a predetermined pattern of bits. 


This article explains what considerations you need to make this work, using the NI-9401 C Series Digital Module as an example. 

1. Check the specifications of your device to find the number of Input/Output buffers available. For example, the NI-9401 has two buffers (DIO 0 to 3 is a buffer and DIO 4 to 7 is another buffer). 
buffers.png

  • If your device has more than 1 buffer (like the NI-9401), you can use one buffer to read the external clock and any additional signals (Digital Input). The other buffer can be utilized for your Digital Output. Notice if you use one buffer to read the external clock (for example DIO0:3), you will be able to use only the channels of the other buffers as outputs (for example DIO4:7). 
  • You can also use a PFI input on your cDAQ chassis to connect your external sample clock. 
  • For both cases, make sure the specifications of your external clock match the PFI input capabilities of your Digital module or the cDAQ PFI input. 

2. Modify the DAQmx Timing function to use your PFI as the Sample Clock Source of your Digital Output Task. 

  • If you are using LabVIEW, you can use the Digital - Continuous Output.vi, Digital - Finite Output.vi, Digital - Continuous Input.vi, and Digital - Finite Input.vi examples as a guide. If you are using a text-based environment, you can use the equivalent examples: NI-DAQmx Example Locations for LabVIEW and Text-Based in Windows). 
  • Make sure you select the PFI terminal properly according to the line where you connected the external sample clock:


pinmap.png

3. Continue developing your code based on the operation (read or write) you are looking to implement. Note: To output a pattern of bits, there are different ways. One of them is to create a waveform constant with the pre-defined sequence of bits and modify the DAQmx Write to Digital Waveform 1 Channel N Samples. In LabVIEW this will look like this: 
digitalwaveform.png

The C Series Module will be able to sample or read digital data using a finite or continuous digital input or output task, using an external clock as a sample clock.