synchronize ni pci devices using rtsi -凯发k8网页登录
this example shows how to acquire synchronized data from two pci devices. a sine wave is connected to channel 0 of ni pci-6251 and to channel 0 of ni pcie-6363. synchronized operation is verified by demonstrating zero phase lag between the acquired signals.
create dataacquisition and add analog input channel
create a dataacquisition and add analog input voltage input channels from ni pci-6251 and ni pcie-6363 devices.
dd = daq("ni"); addinput(dd,"dev3","ai0","voltage"); addinput(dd,"dev4","ai0","voltage");
acquire unsynchronized data
use the read
command to start the acquisition.
[data,time] = read(dd,seconds(1),"outputformat","matrix"); plot(time, data)
there is a small phase lag between the two channel inputs. the dataacquisition starts the two channels close together, but the devices do not share any clock and trigger information and therefore are not fully synchronized.
set up hardware connections
connect pci devices using a rtsi® (real-time system integration) cable and register it in measurement & automation explorer®. to synchronize the acquisition, share a scan clock and start trigger between the two devices.
choose source and destination devices
the device that provides the control and timing signals is called the source device, and the device that receives these signals is called destination device. in this example, dev3
is the source device and dev4
is the destination device.
add start trigger
the rtsi cable creates a physical connection between the rtsi0
terminal on dev3
and rtsi0
terminal on dev4
. use this connection to share the start trigger between the source and destination devices.
use addtrigger
to add a digital start trigger from 'rtsi0/pfi3'
(source) to 'rtsi0/dev4'
(destination).
addtrigger(dd,"digital","starttrigger","dev3/rtsi0","dev4/rtsi0");
add scan clock
use addclock
to share a scan clock using the rtsi1
terminal connection.
addclock(dd,"scanclock","dev3/rtsi1","dev4/rtsi1");
acquire data with synchronization
use read
to acquire data.
[data,time] = read(dd,seconds(1)); plot(time,data)
the two sine waves are overlapping with zero phase lag, confirming that the devices are fully synchronized.