Writting Digital Data Using an External Clock in C Series Modules

Updated Nov 23, 2022

Environment

Hardware

  • C Series Digital Module

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. However, there are applications that require changing the state of a line 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 the other buffer 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 or Digital - Finite Output.vi examples. 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. 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 digital data using a finite or continuous digital output task, using an external clock as a sample clock.