Multiple-Device Synchronization Using USB or PXI Devices
You can synchronize multiple devices in a DataAcquisition using a shared scan clock and shared start trigger. You can synchronize devices using either PFI or RTSI lines.
Requirement
You must register your RTSI cable using the National Instruments™ Measurement & Automation Explorer.
Acquire Synchronized Data Using USB Devices
This example shows how to acquire synchronized voltage data from multiple devices using a shared start trigger and a shared scan clock. Analog input channels on all three devices are connected to the same function generator.
Create a DataAcquisition and add one voltage input channel from each device:
NI USB-6211 with device ID
Dev1
NI USB 6218 with device ID
Dev2
NI USB 6255 with device ID
Dev3
d = daq("ni"); addinput(d,"Dev1",0,"Voltage") addinput(d,"Dev2",0,"Voltage") addinput(d,"Dev3",0,"Voltage")
Choose terminal PFI4
on Dev1
as the start trigger
source. Connect the trigger source to the destination terminals PFI0
on
Dev2
and PFI0
on Dev3
.
addtrigger(d,"Digital","StartTrigger","Dev1/PFI4","Dev2/PFI0") addtrigger(d,"Digital","StartTrigger","Dev1/PFI4","Dev3/PFI0")
Choose terminal PFI5
on Dev1
as the scan clock
source. Connect it to destination terminals PFI1
on
Dev2
, and PFI1
on Dev3
.
addclock(d,"ScanClock","Dev1/PFI5","Dev2/PFI1") addclock(d,"ScanClock","Dev1/PFI5","Dev3/PFI1")
Acquire data and assign it to dataIn
.
dataIn = read(d,350,"OutputFormat","Matrix");
Plot the data.
plot(dataIn)
All channels are connected to the same function generator, so the plot displays overlapping signals, indicating synchronization.
Synchronize Counter Outputs from Multiple Devices
This example shows how to synchronize the start trigger of counter output operations from two channels on different devices.
d = daq("ni"); addoutput(d,"Dev1","ctr0","PulseGeneration") addoutput(d,"Dev2","ctr0","PulseGeneration") addtrigger(d,"Digital","StartTrigger","Dev1/PFI0","Dev2/PFI0") start(d)
This example uses two USB or PCI devices, but could be modified for channels across
CompactDAQ or PXI chassis. If you have counter output CompactDAQ modules in the same chassis, it
is not necessary to call addtrigger
; but it is required for multiple
modules in the same PXI chassis.
Synchronize DSA PXI Devices Using AutoSyncDSA
This example shows how to acquire synchronized data from two Dynamic
Signal Analyzer (DSA) PXI devices, NI PXI-4462 and NI PXI-4461, using the
AutoSyncDSA
property.
Create a DataAcquisition and add one voltage analog input channel from each of the two PXI devices
d = daq("ni"); addinput(d,"PXI1Slot2",0,"Voltage") addinput(d,"PXI1Slot3",0,"Voltage")
Acquire data in the foreground without synchronizing the channels:
[data,time] = read(d,seconds(1),"OutputFormat","Matrix"); plot(time,data)
The data returned is not synchronized.
Synchronize the two channels using the AutoSyncDSA
property:
d.AutoSyncDSA = true;
Acquire data in the foreground and plot it:
[data,time] = read(d,seconds(1),"OutputFormat","Matrix"); plot(time,data)
The data is now synchronized.
Acquire Synchronized Data Using PXI Devices
This example shows how to acquire voltage data from two PXI devices on the same chassis, using a shared start trigger to synchronize operations within your DataAcquisition. PXI devices have a shared reference clock that automatically synchronizes scan clocking. You need to add only start trigger connections to synchronize operations in your DataAcquisition with PXI devices. Analog input channels on all devices are connected to the same function generator.
Create a DataAcquisition and add one voltage input channel from each NI-PXI 4461 device
with IDs PXI1Slot2
and PXI1Slot3
.
d = daq("ni"); addinput(d,"PXI1Slot2",0,"Voltage") addinput(d,"PXI1Slot3",0,"Voltage")
Add a start trigger connection to terminal PXI_Trig0
on
PXI1Slot2
and connect it to terminal PXI_Trig0
on
PXI1Slot3
. PXI cards are connected through the chassis backplane, so you
do not have to wire them physically.
addtrigger(d,"Digital","StartTrigger","PXI1Slot2/PXI_Trig0","PXI1Slot3/PXI_Trig0")
Acquire data and assign it to dataIn
.
dataIn = read(d,seconds(1),"OutputFormat","Matrix");
Plot the data.
plot(dataIn)
All channels are connected to the same function generator and have a shared reference clock. The signals overlap, indicating synchronization.