This example shows how to acquire digital data in the foreground by using an external scan clock.
You can use a function generator or the on-board clock from a digital circuit. Here, a function generator is physically wired to the terminal PFI9 on device NI 6255.
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.
Set the rate of your session to the expected rate of your external scan clock.
s.Rate = 1000
Importing an external clock does not automatically set the rate of your session. Manually set the session’s rate to match the expected external clock frequency.
Add an external scan clock to your device on terminal
For more information see
ans = Scan Clock is provided externally and will be received by 'Dev1' at terminal 'PFI9'. Source: 'External' Destination: 'Dev1/PFI9' Type: ScanClock
Acquire clocked data and plot it.
dataIn = startForeground(s); plot(dataIn)