This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Acquire Digital Data Using an External Clock

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 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.

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 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);

Related Topics