Acquire Digital Data Using a Shared Clock

This example shows how to share the clock with the analog input subsystem on your device with the digital subsystem and acquire automatically synchronized clocked data. You do not need any physical connections to share the clock. For information on automatic synchronization see Automatic Synchronization.

Create a session and add a line from port 0 line 2 on Dev1.

s = daq.createSession('ni');


Not all devices support clocked (hardware timed) digital I/O operations with startForeground and startBackground. For these devices you can use software timed operations with inputSingleScan and outputSingleScan.

Devices that support clocked digital I/O operations might not support them on all ports. Check your device specifications.

Add an analog input channel to your session.

ans =

Data acquisition session using National Instruments hardware:
   Will run for 1 second (1000 scans) at 1000 scans/second.
   Number of channels: 2
      index Type Device   Channel   MeasurementType      Range       Name
      ----- ---- ------ ----------- --------------- ---------------- ----
      1     dio  Dev1   port0/line2 InputOnly       n/a
      2     ai   Dev1   ai0         Voltage (Diff)  -10 to +10 Volts

Plot the acquired digital data.

dataIn = startForeground(s);

Related Topics