Main Content

Acquire Digital Data Using an External Clock via Chassis PFI Terminal

This example shows how to acquire clocked digital data using an external clock provided at the CompactDAQ chassis PFI terminal. It uses a cDAQ 9178 chassis and NI 9402 module with ID cDAQ2Mod3. A digital signal is connected to the module PFI0 terminal to provide a scan clock.

Create a DataAcquisition object and add the digital input line.

d = daq("ni");
addinput(d,"cDAQ2Mod3","Port0/Line0","Digital");

Add a clock specifying source and destination. Then set the DataAcquisition scan rate to match the external clock frequency.

addclock(d,"ScanClock","External","cDAQ2/PFI0");
d.Rate = 100e3;

Acquire and plot the digital input data.

[data,timestamps] = read(d,seconds(1),"OutputFormat","Matrix");
plot(timestamps,data(1:100,1))