Synchronize NI PCI Devices Using RTSI
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.