Thread Subject: synchronizing multiple daq boards

Subject: synchronizing multiple daq boards

From: S.J.

Date: 25 Jul, 2008 04:37:02

Message: 1 of 7

I am trying to synchronize two National Instruments daq
boards (NI DAQPad-6251) without success. I tried using
Solution 1-196NJ from the Mathworks solutions lists, but it
doesn't work. I cannot use a HW trigger (I am collecting
pre-trigger data) and performing set(ai,'ClockSource',
'External'); is not a valid option for NI boards. If I try
to use another option, e.g., ExternalSampleCtrl, the command
can be performed, but the data do not seem to be logged
(i.e., getdata does not retrieve data from one of the two
boards).

I'd welcome some new suggestions!

Subject: synchronizing multiple daq boards

From: Sherryl Radbil

Date: 25 Jul, 2008 12:31:03

Message: 2 of 7

Sychronizing devices is a common task that users of Data
Acquisition routinely do.

Clocksource External is supported for NI boards as
described in the help:
http://www.mathworks.com/access/helpdesk/help/toolbox/daq/c
locksource.html

What versions of MATLAB and NI-DAQmx drivers are you using?

Post your code snippet that shows what you mean
by "getdata does not retrieve data from one of the two
boards" along with the error messages so we can see the
actual problem.

Sherryl

Subject: synchronizing multiple daq boards

From: S.J.

Date: 25 Jul, 2008 13:40:19

Message: 3 of 7

Good news that this is hopefully an easy fix. I am away
from my daq computer so I can't answer your specific
questions about versions (I will add that in a couple of hours).

In the meantime, if I set "ai.ClockSource = 'External'" I
receive an error message that this is not a valid option.
When I look at all the settings and options for this board,
External is not on the list (the other NI parameters as on
the ClockSource help page are options, e.g., ExternalScanCtrl).

In terms of the getdata problem, I just get a timeout error.

Am I thinking about this the right way? I thought that all
I needed to do is hook up the PFI0 pin connectors to each
other from the two boards and read the clock from one board
to the other. Because I can't do a HW digital trigger due to
my need to collect pretrigger data, I think this is my only
option.

Subject: synchronizing multiple daq boards

From: Sherryl Radbil

Date: 25 Jul, 2008 13:57:25

Message: 4 of 7

While your posting code and specific error messages also
post the output of the command:
daqsupport

Note that it is lengthy and you may delete the path
information as it is highly unlikely that it is effecting
what you're seeing.

I'm especially curious to see the error message when setting
ClockSource to External.

Sherryl

Subject: synchronizing multiple daq boards

From: S.J.

Date: 25 Jul, 2008 18:09:08

Message: 5 of 7

Okay, here's the info.

Matlab 2008a 7.6.0.324
NidaqMX 8.5.0f5

When I execute the following code (to set up the first board):
ai2= analoginput('nidaq','Dev1');
addchannel(ai2,0);
addchannel(ai2,1);
dur = 5;
set(ai2,'InputType','SingleEnded');
ai2.Channel.InputRange=[-10 10];
ai2.SampleRate = 5000;
set(ai2,'SampleRate', 5000);
ActualRate=get(ai2,'SampleRate');
set(ai2,'SamplesPerTrigger', ActualRate*dur);
set(ai2,'TriggerType','Manual');
set(ai2,'TriggerDelay',-5);
set(ai2,'ClockSource', 'External');

I get the following error message:
??? Error using ==> daqdevice.set at 259
The 'External' name is ambiguous.




output from daqsupport

----------General Information ----------

Current Time & Date:
25-Jul-2008 10:59:45

Operating System:
Microsoft Windows [Version 6.0.6000]


MATLAB version:
7.6.0.324 (R2008a)

Data Acquisition Toolbox version:
       Name: 'Data Acquisition Toolbox'
    Version: '2.12'
    Release: '(R2008a)'
       Date: '23-Jan-2008'


 ----------Memory Information: ----------
       MemoryLoad: 50
        TotalPhys: 2.1368e+009
        AvailPhys: 1.0518e+009
    TotalPageFile: 4.2950e+009
    AvailPageFile: 3.3423e+009
     TotalVirtual: 2.1474e+009
     AvailVirtual: 1.4783e+009
          UsedDaq: 929792


 ----------MATLAB root directory: ----------
C:\Program Files\MATLAB\R2008a

 ----------Data Acquisition Toolbox directory: ----------
c:\program files\matlab\r2008a\toolbox\daq

 ----------MATLAB path: ----------


 ----------Available hardware: ----------

          ToolboxName: 'Data Acquisition Toolbox'
       ToolboxVersion: '2.12 (R2008a)'
        MATLABVersion: '7.6 (R2008a)'
    InstalledAdaptors: {3x1 cell}


 ----------Adaptor List ----------

    'nidaq'
    'parallel'
    'winsound'


 ----------nidaq adaptor: ----------

 ----------Registering adaptor: nidaq ----------

Successfully registered nidaq adaptor

 ----------Adaptor Information for adaptor nidaq ----------


adaptorInfo =

           AdaptorDllName: [1x68 char]
        AdaptorDllVersion: '2.12 (R2008a)'
              AdaptorName: 'nidaq'
               BoardNames: {'USB-6251' 'USB-6251'}
        InstalledBoardIds: {'Dev1' 'Dev3'}
    ObjectConstructorName: {2x3 cell}


 ----------Adaptor DLL Name ----------

C:\Program
Files\MATLAB\R2008a\toolbox\daq\daq\private\mwnidaqmx.dll

 ----------Adaptor Name ----------

nidaq

 ----------Object Constructor Names ----------

analoginput('nidaq','Dev1')
analoginput('nidaq','Dev3')
analogoutput('nidaq','Dev1')
analogoutput('nidaq','Dev3')
digitalio('nidaq','Dev1')
digitalio('nidaq','Dev3')

 ----------Additional Adaptor Information for adaptor nidaq
----------

NIDAQ Traditional is not installed.

 ----------Creating analoginput('nidaq','Dev1') object for
adaptor nidaq ----------

Display Summary of Analog Input (AI) Object Using 'USB-6251'.

  Acquisition Parameters: 1000 samples per second on each
channel.
                           1000 samples per trigger on each
channel.
                           1 sec. of data to be logged upon
START.
                           Log data to 'Memory' on trigger.

      Trigger Parameters: 1 'Immediate' trigger(s) on START.

           Engine status: Waiting for START.
                           0 samples acquired since starting.
                           0 samples available for GETDATA.

AI object contains no channels.



ans =

                AdaptorName: 'nidaqmx'
                       Bits: 16
                   Coupling: {'DC'}
                 DeviceName: 'USB-6251'
            DifferentialIDs: [0 1 2 3 4 5 6 7]
                      Gains: [1 2 5 10 20 50 100]
                         ID: 'Dev1'
                InputRanges: [7x2 double]
              MaxSampleRate: 1250000
              MinSampleRate: 0.6000
             NativeDataType: 'double'
                   Polarity: {'Bipolar'}
                 SampleType: 'Scanning'
             SingleEndedIDs: [0 1 2 3 4 5 6 7 8 9 10 11 12
13 14 15]
              SubsystemType: 'AnalogInput'
              TotalChannels: 16
    VendorDriverDescription: 'National Instruments NIDAQmx
driver'
        VendorDriverVersion: '8.5'


 ----------Creating analogoutput('nidaq','Dev1') object for
adaptor nidaq ----------

Display Summary of Analog Output (AO) Object Using 'USB-6251'.

       Output Parameters: 1000 samples per second on each
channel.

      Trigger Parameters: 1 'Immediate' trigger on START.

           Engine status: Waiting for START.
                           0 total sec. of data currently
queued for START.
                           0 samples currently queued by
PUTDATA.
                           0 samples sent to output device
since START.

AO object contains no channels.



ans =

                AdaptorName: 'nidaqmx'
                       Bits: 16
                 ChannelIDs: [0 1]
                   Coupling: {'DC'}
                 DeviceName: 'USB-6251'
                         ID: 'Dev1'
              MaxSampleRate: 2860000
              MinSampleRate: 0.6000
             NativeDataType: 'double'
               OutputRanges: [2x2 double]
                   Polarity: {'Bipolar'}
                 SampleType: 'SimultaneousSample'
              SubsystemType: 'AnalogOutput'
              TotalChannels: 2
    VendorDriverDescription: 'National Instruments NIDAQmx
driver'
        VendorDriverVersion: '8.5'


 ----------Creating digitalio('nidaq','Dev1') object for
adaptor nidaq ----------

Display Summary of DigitalIO (DIO) Object Using 'USB-6251'.

         Port Parameters: Port 0 is port configurable for
reading and writing.
                           Port 1 is port configurable for
reading and writing.
                           Port 2 is port configurable for
reading and writing.
                           
           Engine status: Engine not required.

DIO object contains no lines.



ans =

                AdaptorName: 'nidaqmx'
                 DeviceName: 'USB-6251'
                         ID: 'Dev1'
                       Port: [1x3 struct]
              SubsystemType: 'DigitalIO'
                 TotalLines: 24
    VendorDriverDescription: 'National Instruments NIDAQmx
driver'
        VendorDriverVersion: '8.5'


 ----------Creating analoginput('nidaq','Dev3') object for
adaptor nidaq ----------

Display Summary of Analog Input (AI) Object Using 'USB-6251'.

  Acquisition Parameters: 1000 samples per second on each
channel.
                           1000 samples per trigger on each
channel.
                           1 sec. of data to be logged upon
START.
                           Log data to 'Memory' on trigger.

      Trigger Parameters: 1 'Immediate' trigger(s) on START.

           Engine status: Waiting for START.
                           0 samples acquired since starting.
                           0 samples available for GETDATA.

AI object contains no channels.



ans =

                AdaptorName: 'nidaqmx'
                       Bits: 16
                   Coupling: {'DC'}
                 DeviceName: 'USB-6251'
            DifferentialIDs: [0 1 2 3 4 5 6 7]
                      Gains: [1 2 5 10 20 50 100]
                         ID: 'Dev3'
                InputRanges: [7x2 double]
              MaxSampleRate: 1250000
              MinSampleRate: 0.6000
             NativeDataType: 'double'
                   Polarity: {'Bipolar'}
                 SampleType: 'Scanning'
             SingleEndedIDs: [0 1 2 3 4 5 6 7 8 9 10 11 12
13 14 15]
              SubsystemType: 'AnalogInput'
              TotalChannels: 16
    VendorDriverDescription: 'National Instruments NIDAQmx
driver'
        VendorDriverVersion: '8.5'


 ----------Creating analogoutput('nidaq','Dev3') object for
adaptor nidaq ----------

Display Summary of Analog Output (AO) Object Using 'USB-6251'.

       Output Parameters: 1000 samples per second on each
channel.

      Trigger Parameters: 1 'Immediate' trigger on START.

           Engine status: Waiting for START.
                           0 total sec. of data currently
queued for START.
                           0 samples currently queued by
PUTDATA.
                           0 samples sent to output device
since START.

AO object contains no channels.



ans =

                AdaptorName: 'nidaqmx'
                       Bits: 16
                 ChannelIDs: [0 1]
                   Coupling: {'DC'}
                 DeviceName: 'USB-6251'
                         ID: 'Dev3'
              MaxSampleRate: 2860000
              MinSampleRate: 0.6000
             NativeDataType: 'double'
               OutputRanges: [2x2 double]
                   Polarity: {'Bipolar'}
                 SampleType: 'SimultaneousSample'
              SubsystemType: 'AnalogOutput'
              TotalChannels: 2
    VendorDriverDescription: 'National Instruments NIDAQmx
driver'
        VendorDriverVersion: '8.5'


 ----------Creating digitalio('nidaq','Dev3') object for
adaptor nidaq ----------

Display Summary of DigitalIO (DIO) Object Using 'USB-6251'.

         Port Parameters: Port 0 is port configurable for
reading and writing.
                           Port 1 is port configurable for
reading and writing.
                           Port 2 is port configurable for
reading and writing.
                           
           Engine status: Engine not required.

DIO object contains no lines.



ans =

                AdaptorName: 'nidaqmx'
                 DeviceName: 'USB-6251'
                         ID: 'Dev3'
                       Port: [1x3 struct]
              SubsystemType: 'DigitalIO'
                 TotalLines: 24
    VendorDriverDescription: 'National Instruments NIDAQmx
driver'
        VendorDriverVersion: '8.5'


 ----------parallel adaptor: ----------

 ----------Registering adaptor: parallel ----------

Successfully registered parallel adaptor

 ----------Adaptor Information for adaptor parallel ----------


adaptorInfo =

           AdaptorDllName: [1x69 char]
        AdaptorDllVersion: '2.12 (R2008a)'
              AdaptorName: 'parallel'
               BoardNames: {'PC Parallel Port Hardware'}
        InstalledBoardIds: {'LPT1'}
    ObjectConstructorName: {'' ''
'digitalio('parallel','LPT1')'}


 ----------Adaptor DLL Name ----------

C:\Program
Files\MATLAB\R2008a\toolbox\daq\daq\private\mwparallel.dll

 ----------Adaptor Name ----------

parallel

 ----------Object Constructor Names ----------

digitalio('parallel','LPT1')

 ----------Creating digitalio('parallel','LPT1') object for
adaptor parallel ----------

Display Summary of DigitalIO (DIO) Object Using 'PC Parallel
Port Hardware'.

         Port Parameters: Port 0 is port configurable for
reading and writing.
                           Port 1 is port configurable for
reading.
                           Port 2 is port configurable for
reading and writing.
                           
           Engine status: Engine not required.

DIO object contains no lines.



ans =

                AdaptorName: 'parallel'
                 DeviceName: 'PC Parallel Port Hardware'
                         ID: 'LPT1'
                       Port: [1x3 struct]
              SubsystemType: 'DigitalIO'
                 TotalLines: 17
    VendorDriverDescription: 'Win I/O'
        VendorDriverVersion: '1.3'


 ----------winsound adaptor: ----------

 ----------Registering adaptor: winsound ----------

Successfully registered winsound adaptor

 ----------Adaptor Information for adaptor winsound ----------


adaptorInfo =

           AdaptorDllName: [1x69 char]
        AdaptorDllVersion: '2.12 (R2008a)'
              AdaptorName: 'winsound'
               BoardNames: {'Microphone (SoundMAX Integrated'}
        InstalledBoardIds: {'0'}
    ObjectConstructorName: {'analoginput('winsound',0)'
[1x26 char] ''}


 ----------Adaptor DLL Name ----------

C:\Program
Files\MATLAB\R2008a\toolbox\daq\daq\private\mwwinsound.dll

 ----------Adaptor Name ----------

winsound

 ----------Object Constructor Names ----------

analoginput('winsound',0)
analogoutput('winsound',0)

 ----------Creating analoginput('winsound',0) object for
adaptor winsound ----------

Display Summary of Analog Input (AI) Object Using
'Microphone (SoundMAX Integrated'.

  Acquisition Parameters: 8000 samples per second on each
channel.
                           8000 samples per trigger on each
channel.
                           1 sec. of data to be logged upon
START.
                           Log data to 'Memory' on trigger.

      Trigger Parameters: 1 'Immediate' trigger(s) on START.

           Engine status: Waiting for START.
                           0 samples acquired since starting.
                           0 samples available for GETDATA.

AI object contains no channels.



ans =

                AdaptorName: 'winsound'
                       Bits: 16
                   Coupling: {'AC Coupled'}
                 DeviceName: 'Microphone (SoundMAX Integrated'
            DifferentialIDs: []
                      Gains: []
                         ID: '0'
                InputRanges: [-1 1]
              MaxSampleRate: 96000
              MinSampleRate: 5000
             NativeDataType: 'int16'
                   Polarity: {'Bipolar'}
                 SampleType: 'SimultaneousSample'
             SingleEndedIDs: [1 2]
              SubsystemType: 'AnalogInput'
              TotalChannels: 2
    VendorDriverDescription: 'Windows Multimedia Driver'
        VendorDriverVersion: '6.0'


 ----------Creating analogoutput('winsound',0) object for
adaptor winsound ----------

Display Summary of Analog Output (AO) Object Using 'Speakers
(SoundMAX Integrated D'.

       Output Parameters: 8000 samples per second on each
channel.

      Trigger Parameters: 1 'Immediate' trigger on START.

           Engine status: Waiting for START.
                           0 total sec. of data currently
queued for START.
                           0 samples currently queued by
PUTDATA.
                           0 samples sent to output device
since START.

AO object contains no channels.



ans =

                AdaptorName: 'winsound'
                       Bits: 16
                 ChannelIDs: [1 2]
                   Coupling: {'AC Coupled'}
                 DeviceName: 'Speakers (SoundMAX Integrated D'
                         ID: '0'
              MaxSampleRate: 96000
              MinSampleRate: 5000
             NativeDataType: 'int16'
               OutputRanges: [-1 1]
                   Polarity: {'Bipolar'}
                 SampleType: 'SimultaneousSample'
              SubsystemType: 'AnalogOutput'
              TotalChannels: 2
    VendorDriverDescription: 'Windows Multimedia Driver'
        VendorDriverVersion: '6.0'


 ---------- ----------End test ---------- ----------

This information has been saved in the text file:
daqtest.txt

If any errors occurred, please e-mail this information to:
support@mathworks.com

Subject: synchronizing multiple daq boards

From: Sherryl Radbil

Date: 19 Aug, 2008 14:37:01

Message: 6 of 7

Hi SJ,

The error you're getting about External being ambiguous is
correct. The USB-6251 has several ClockSource values that
begin with External and you have to continue the word with
the one you want. Notice the legal values for the
ConstraintValue of the ClockSource property below.

>> ai = analoginput('nidaq','Dev2')
Display Summary of Analog Input (AI) Object Using 'USB-6251'.
  Acquisition Parameters: 1000 samples per second on each
channel.
                           1000 samples per trigger on each
channel.
                           1 sec. of data to be logged upon
START.
                           Log data to 'Memory' on trigger.
      Trigger Parameters: 1 'Immediate' trigger(s) on START.
           Engine status: Waiting for START.
                           0 samples acquired since starting.
                           0 samples available for GETDATA.
AI object contains no channels.
>> propinfo(ai,'ClockSource')
ans =
               Type: 'string'
         Constraint: 'enum'
    ConstraintValue: {'Internal' 'ExternalScanCtrl'
'ExternalSampleCtrl' 'ExternalSampleAndScanCtrl'}
       DefaultValue: 'Internal'
           ReadOnly: 'whileRunning'
     DeviceSpecific: 0

The documentation explains each of the values.

Hope this helps.
Sherryl

Subject: synchronizing multiple daq boards

From: S.J.

Date: 21 Aug, 2008 00:40:19

Message: 7 of 7

Thank you for the reply. This turned out to be an easy fix
(once I had the correct options selected), but the
underlying problem remains unsolved. I cannot figure out
how to communicate with the NI board to tell it to send a
clocksource signal out of the PFI line. This particular
board does not have a dedicated clocksource pin.

There doesn't seem to be code in Matlab to do this, and the
code posted through NI's website seems to be based on the
time period when Matlab wasn't supporting NIDAQmx and I
cannot get it to work.

Any ideas?

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
daq S.J. 25 Jul, 2008 00:40:05
synchronization S.J. 25 Jul, 2008 00:40:05
national instruments S.J. 25 Jul, 2008 00:40:05
rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com