Data Acquisition Toolbox

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 National Instruments® PCI-6251 and to Channel 0 of NI PCIe-6363. Both the channels are given the same sine wave to verify synchronization. Perfectly synchronized channels would show zero phase lag between the two acquired signals.

Create Session and Add Analog Input Channel

Create a session, and add analog input channels with the Voltage measurement type, using National Instruments® PCI-6251 and NI PCIe-6363.

s = daq.createSession('ni');
s.addAnalogInputChannel('Dev3', 0, 'Voltage');
s.addAnalogInputChannel('Dev4', 0, 'Voltage');

Acquire Data without any Synchronization Configuration

Use the startForeground command to start the acquisition.

[data,time] = s.startForeground();
plot(time, data)

There is a small phase lag between the two channel inputs. The session starts the two channels close together, but the devices are not sharing any clock and trigger information and therefore will not be perfectly synchronized. In this case the acquisitions are near-simultaneous acquisition. To synchronize them perfectly share clock and trigger information.

Setup Hardware Connections

Connect PCI devices using a RTSI® (Real-Time System Integration) cable and register it in Measurement & Automation Explorer®. To synchronize acquisition share a scan clock and start trigger between the two devices.

Choosing 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, we choose Dev3 as the Source device and Dev4 as the Destination device.

Add Start Trigger Connections to Session

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

Add a start trigger connection to the session using addTriggerConnection. In this example, set the source as 'RTSI0/PFI3' and the destination as 'RTSI0/Dev4'.

s.addTriggerConnection('Dev3/RTSI0','Dev4/RTSI0','StartTrigger');

Add Scan Clock Connections to Session

Similarly use the RTSI1 terminal connection between the two devices to share the scan clock. Add scan clock connection to the session using addClockConnection.

s.addClockConnection('Dev3/RTSI1','Dev4/RTSI1','ScanClock');

For a quick summary of the connections type

s.Connections
ans = 


Connections added to session.
   index     Type       Source   Destination
   ----- ------------ ---------- -----------
   1     StartTrigger Dev3/RTSI0 Dev4/RTSI0
   2     ScanClock    Dev3/RTSI1 Dev4/RTSI1

Acquire Data with Synchronization

Use startForeground to start the acquisition.

[data,time] = s.startForeground();
plot(time, data)

The two sine waves are overlapping with zero phase lag confirming that your devices are completely synchronized.