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: 

Continuous Measuring and Logging on Windows OS at High Sample Rate

Hallo,

I am trying to implement a simple program to read an analog input continuously while at the same time storing the logging the data into the computer, also I would like the measures to have a rather high sampling rate (above 20kHz). My DAQ is a NI cDAQ 9174 with a module NI-9222. 

Being an extreme beginner with LabView, I had some look around on examples and existing codes, but I still have problems. 

From what I've understood, for having a high sample rate acquisition on a Windows OS, you would have to use a producer/consumer design pattern. 

 

I tried to implement it, having a while-loop for reading data and one for writing it, using a FIFO queue (as explained here: http://www.ni.com/tutorial/3023/en/). Though I still find myself being unable to save the continuous measurements in a text file. At the moment it looks like it saves me only the amount of samples I've specified at the specified frequency and then it goes into an error state. Also the execution seems to not be stopping when an error is triggered.

 

Looking for solutions I've saw that the usage of "Express" boxes is not suggested, but as I needed a quick solution I thought I could avoid going into the details and using the NI DAQmx blocks.

 

Could you help me out in fixing this code (see attachments)? 

 

Thanks,

Davide

 

0 Kudos
Message 1 of 3
(1,692 Views)

Hi Davide,

 

I'm not sure if you already solved this problem, since it's been a while, but here goes in case you haven't...

 


@freyda wrote:

From what I've understood, for having a high sample rate acquisition on a Windows OS, you would have to use a producer/consumer design pattern. 


Producer/Consumer design is indeed a good choice for this kind of thing (although 20kHz should be fine, it's not all that fast, and "above 20kHz" could be anything, so no guarantees 😉 ).

 


@freyda wrote:

I tried to implement it, having a while-loop for reading data and one for writing it, using a FIFO queue (as explained here: http://www.ni.com/tutorial/3023/en/). Though I still find myself being unable to save the continuous measurements in a text file. At the moment it looks like it saves me only the amount of samples I've specified at the specified frequency and then it goes into an error state. Also the execution seems to not be stopping when an error is triggered.

 

Looking for solutions I've saw that the usage of "Express" boxes is not suggested, but as I needed a quick solution I thought I could avoid going into the details and using the NI DAQmx blocks.


The code you uploaded (from the point of view of a P/C structure) seems basically fine - you create a Queue, enqueue in the producer and dequeue in the consumer, then log there.

As a result, I'd strongly suspect your problems come from the Express VIs, or more accurately the "Dynamic Data Type" (blue wire), which hides all sorts of information and generally causes unexpected results.

 

The DAQmx nodes aren't that difficult to get started with - you might find this guide useful: Learn 10 Functions in NI-DAQmx and Handle 80 Percent of Your Data Acquisition Applications

 

For your application, you're probably looking at using the Create Virtual Channel, DAQmx Timing, DAQmx Read and DAQmx Stop + Clear.

You can take a look at the built-in example file for some tips, see Help > Find Examples... > search for "Voltage - Continuous input".

This example has a bit more complexity than you really need, but also demonstrates the use of "DAQmx Logging", which might obviate the need for a P/C structure (although I'd suggest you're more flexible sticking with the Producer Consumer as you have now, in case of future changes, but it's up to you).


GCentral
0 Kudos
Message 2 of 3
(1,663 Views)

Hi!

 

Yes at the end I solved using exactly that example in LabView which worked perfectly fine.

Thank you very much anyway for your inputs on the code 🙂

 

Best

0 Kudos
Message 3 of 3
(1,660 Views)