How Can I syncronize between two NI USB-4431 devices?

2 次查看(过去 30 天)
I tried "demo_synchronize_PCI_using_RTSI.m" in the daq example files in the Data Acquisition Toolbox.
% % 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'|.
addTriggerConnection(s,'Dev1/RTSI0','Dev2/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|.
addClockConnection(s,'Dev3/RTSI1','Dev4/RTSI1','ScanClock');
But, I found out that NI USB-4431 doesn't support RTSI(?) option.
But when I look up the
s=daq.createSession('ni')
variables, I found out that there's an option with "AutoSyncDSA", whose default value is "0".
So, I tried using below after addAnalogInputChannel.
s.AutoSyncDSA=1
But there's an error as below.
"" Add channels from NI's Dynamic Signal Analyzers devices before setting the AutoSyncDSA property. ""
What is that meaning? I already added channels, but there's still an error like that.
Below is edited version of "demo_synchronize_PCI_using_RTSI.m"..
%% 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(R) 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.
% Copyright 2011-2014 The MathWorks, Inc.
%% Create Session and Add Analog Input Channel
%
% Create a session, and add analog input channels with the |Voltage|
% measurement type, using National Instruments(R) PCI-6251 and
% NI PCIe-6363.
s = daq.createSession('ni');
addAnalogInputChannel(s,'Dev1', 2, 'Accelerometer');
addAnalogInputChannel(s,'Dev2', 2, 'Accelerometer');
%% Acquire Data without any Synchronization Configuration
%
% Use the |startForeground| command to start the acquisition.
s.Channels(1,1).Sensitivity=0.1;%volt/g
s.Channels(1,2).Sensitivity=0.1;%volt/g
s.AutoSyncDSA=1;
[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(R) (Real-Time System Integration) cable
% and register it in Measurement & Automation Explorer(R). 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'|.
% addTriggerConnection(s,'Dev1/RTSI0','Dev2/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|.
% addClockConnection(s,'Dev3/RTSI1','Dev4/RTSI1','ScanClock');
%%
% For a quick summary of the connections type
s.Connections
%% 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.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simultaneous and Synchronized Operations 的更多信息

标签

产品


版本

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by