From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2 different USB DAQ boards in parallel

Solved!
Go to solution

Hi,

I have 2 x USB 6210 on 2 x USB ports on my laptop.   (Windows 7, Labview 2010). My goal is to syncronize these two boards.

I put the same sinus (50Hz) voltage signal on their first input channel (AI0), to have and to see them in the same graph, and synchronised.

I put code in 2 different while loops. I tried with daq assistant, and daqmx (see attachements).

I hopped "DAQmx Start trigger" to do something good, but no luck.

 

But there is always a delay between them, some miliseconds on graph. And never the same delay, if ai run the program again.

 

If I light the yellow bulb when running, i see one of the "while" loop running, and then the other one, not in parallel.

 

Is there a way to have them synchronised, immediately, after I run the .vi ?

 

Thanks.

 

 

 

 

Download All
0 Kudos
Message 1 of 15
(3,764 Views)

First of all, one big problem with your VI is that you use an infinite loop, moreover you init and stop the DAQmx task at EVERY iteration. This is silly to do. Move the init and stop parts out of the loop, see example below.You specify a single physical channel, so why do you use the DAQmx Read function as "NChan NSamp", use "1Chan".

 

Did you have a look at the many DAQmx examples shipped with LV? Also, you do not use the error wires, which is not good. First understand the basic DAQmx things, and after that you can start to deal with syncing (in your VI you just have simply two totally independent parallel loops, how do you expect that the DAQmx tasks will be synced?).

I modified you VI to have first only one loop properly setup. Give me some time, I look for some example how to sync two USB DAQ boards...

 

edit1: I have changed the "Finite samples" to "Continuous samples"

 

daq mx_example1_BD.png

0 Kudos
Message 2 of 15
(3,744 Views)

I have found an example but I think this is not applicable for your hardware (only PCI and PXI stated in the help).

Anyway, give it a try, there are different modes for different HW in this VI, try the M-series option first, lets see if it works (i guess it will not). I try to find USB device specific method to do such task, I post again if I find one...

 

So, for the example, go to LabVIEW main window --> Help --> "Find Examples..." --> Type "synchronization" into the search field, and hit enter.

Double click on the first example ("Analog Input - Synchronization.vi"):

 

examplefinder_sync1.png

0 Kudos
Message 3 of 15
(3,736 Views)

Have a look at this example too:

https://www.youtube.com/watch?v=g_8jiKuKeDI

0 Kudos
Message 4 of 15
(3,724 Views)
Solution
Accepted by topic author dsasorin

Based on the video, I have created this example VI. Could you test it? Do not forget, you need to connect the PFI0 to PFI0 and PFI1 to PFI1 BNC terminals with BNC cables between the two modules (you can chose other PFI connectors depending on your terminal devices, but then you need to change the corresponding PFI channels in the VI too).

 

daq mx_example1_BD.png

0 Kudos
Message 5 of 15
(3,719 Views)
If you want the data exactly in synchronization you need to be using a common sample clock, and only one channel per box. The first problem to face is that there is a small but finite delay between channels on the same box. In addition, depending on input scaling there can be varying settling time between channels.

Next, you need to provide an external sample clock that drives both boxes. Without that input each box will be using its own internal clock but those clocks won't be synchronized.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 6 of 15
(3,709 Views)

mikeporter, the VI above your post does fulfil your description? I am just asking since I never tried such method. I have right now an USB-6212 device, but only one, so I cannot try to technique...

0 Kudos
Message 7 of 15
(3,705 Views)
Actually, I haven't even gotten as far as the LabVIEW code. First you need to set up the hardware (providing an external clock) then you set you the initialization logic to use that clock -- and probably a common hardware trigger as well.

Now in your LabVIEW code you can start both acquisitions but nothing happens until the trigger is received by both boards in parallel. When triggered both boards will be sampling in parallel using the common sample clock so data will be clocked into their onboard buffers at the same time.

The result is that your LabVIEW code is completely out of the loop (no pun intended) in terms of enforcing synchronization. As long as you read the data fast enough to prevent buffer overflow you can pretty much read the data at your leisure and in any way you like -- though for readability sake I usually prefer keeping the logic for the two devices is separate error streams.

Your last code is close, but with hardware synchronization you only need one loop to read both devices.

The thing to remember is that all of NIs acquisition devices are smart and when you use the DAQ setup VIs you can think of it as defining a little program that will run on that smart hardware.

Even with just one box you can try out the basic configuration process of using an external trigger and sample clock. Once you are comfortable with it you will find many places where it is useful. I once had an application where we needed to measure the pressure in multiple compression chambers but have those readings correlated to the crank position
Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 8 of 15
(3,695 Views)
Oops, wrong button...

The way I accomplished this was to use an encoder on the end of the crankshaft. I used the once per degree pulse as my sample clock and the once per rotation pulse as my trigger.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 9 of 15
(3,692 Views)

Hmm, I am not sure if mikeporter sees my posts? Did you reply to my question, or at all to this particular post? It seems you cross-mixed some different posts?

0 Kudos
Message 10 of 15
(3,689 Views)