This example shows how to acquire digital data in the foreground by importing 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 0 line 2 on Dev1.
s = daq.createSession('ni'); addDigitalChannel(s,'Dev1','Port0/Line2','InputOnly');
Set the rate of your session to the expected rate of your external scan clock.
s.Rate = 1000
Note: 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 PFI9. For more information see Terminals property.
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)