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
s = daq.createSession('ni'); addDigitalChannel(s,'Dev1','Port0/Line2','InputOnly')
Not all devices support clocked (hardware timed) digital I/O
startBackground. For these devices you can
use software timed operations with
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); plot(dataIn(:,1))