From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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: 

Data logging of multiple standalone usb instruments

Solved!
Go to solution

Hi All,

 

I'm new to LabView and looking for example code for data logging of multiple standalone usb instruments. There are examples for single instruments but I can't seem to find example code where multiple instruments are used. For my application I was envisaging logging data from multiple instruments in a test environment (e.g. Lake Shore 336, Agilent N8731A, Keysight 34461A, Tektronix PA3000 etc) at say 1 sec intervals. I was thinking of connecting the standalone instruments via a USB hub into a PC running labview. Most instruments we're using appear to have LV VIs available. If anyone has developed a similar application or can point me to some examples to assist me that would be great!

 

Thanks in advance.

0 Kudos
Message 1 of 7
(3,060 Views)
Solution
Accepted by topic author pob@qut

If you have an example involving a While loop or similar for one instrument, and then you have multiple instruments, and you want them to run at the same rate, you can just put them all side by side (or probably more clearly, on top of each other) in the same While loop.

 

The important point here would be that they need to each take the same amount of time in the While loop - for example, if Instrument A reads 1000 samples at 1kHz, and Instrument B reads 10 samples at 10Hz, then you're fine - they both want to loop at a 1Hz rate.

 

If InstrA wants to read 100 samples at 10kHz continuously, and InstrB reads 10 samples at 10Hz, you'll want two separate loops - B's loop will iterate much more slowly than A's for continuous acquisition, which could easily lead to problems like buffer overflow in Instrument A's code.

 

You could consider using Producer/Consumer with one producer per instrument, if you wanted - this is a more detailed architecture than a simple example but allows you to 'easily' (?) extend your code with future instruments. The key benefit with Producer/Consumer is usually that any post-processing can be done outside of the loop acquiring the data, which can help when acquisition rates are high.

 

Try to avoid reading a single sample in a loop running very fast - you'll usually have a better time reading 100 samples at 1/100th of the speed.


GCentral
0 Kudos
Message 2 of 7
(3,048 Views)

Hi pob,

 

what happens when you place two or three VIs next to each other to request values of 2 or 3 devices and start them all?

Sometimes it can be simple like that to start datalogging from different DAQ devices…

 

(I still recommend to develop a better approach to handle several devices in parallel!)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 7
(3,046 Views)

Thanks for your help. Cheers.

0 Kudos
Message 4 of 7
(2,981 Views)

Thanks again for your help.

0 Kudos
Message 5 of 7
(2,958 Views)

Hi,

If I use a while loop as a simple framework to start with for my application do I initialize and close communications to each instrument within the while loop (or outside the loop)? I am using a single USB on my laptop to communicate to 3 instruments via a 3 port USB 3.0 hub.

0 Kudos
Message 6 of 7
(2,973 Views)

Hi pob,

 

If I use a while loop as a simple framework to start with for my application do I initialize and close communications to each instrument within the while loop (or outside the loop)?

Let me compare this with a real-life example:

What would you do if you want to read a book? Would you open and close the whole book for each new paragraph? Or would you open the book once before reading and close it, when you have finished the chapter?

 

Usually it makes no sense to re-init a device within a loop with each iteration. Sometimes it even enforces erranous behaviour!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 7
(2,970 Views)