01-28-2020
10:04 AM
- last edited on
03-27-2025
10:54 AM
by
Content Cleaner
Hi!
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: https://www.ni.com/en/support/documentation/supplemental/21/producer-consumer-architecture-in-labvie...). 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
01-28-2020 10:10 AM
You'll get a higher response if you "save to previous" (15, 16, 17 or even 18). We're not all enabled to use the newest version...
01-28-2020 10:18 AM
I suggest you look at the DAQmx examples, such as <LabVIEW>\examples\DAQmx\Analog Input\Voltage - Continuous Input.vi
Note that DAQmx is already a "Producer Consumer", the DAQmx "Task" is a Producer, and your code is the Consumer, so it may be redundant to write your own Producer-Consumer structure.
01-28-2020 11:07 AM
I would recommend using the examples that include "xyz And Logging" to have DAQmx do the logging for you.
For what it's worth, I've run acquisitions at 2 MHz for days at a time with no issues, though I wasn't logging every sample.
01-28-2020 03:05 PM - edited 01-28-2020 03:06 PM
Sorry, I didn't though about that. Attached you find the version for Labview 15.
Also thank you very much for the suggestion of examples to look into.
01-28-2020 03:46 PM
@freyda wrote:
Sorry, I didn't though about that. Attached you find the version for Labview 15.
Also thank you very much for the suggestion of examples to look into.
Your best bet are the examples, in the example finder. Specifically, use normal DAQmx functions, no assistants, and use the DAQ logging VIs directly. Note the logging function saves files as TDMS, if this doesn't work for you you have two options: (1) Write your own converter for TDMS to whatever you want, (2) don't use the logging function, and then use a producer consumer type architecture. I highly suggest 1, it is extremely efficient. I have been able to log at 32MB/s to a external Thunderbolt disk no problem use the logging functions.
mcduff
01-29-2020 02:53 AM
@freyda wrote:
Sorry, I didn't though about that. Attached you find the version for Labview 15.
Also thank you very much for the suggestion of examples to look into.
In the attached VI, you have configured "Multiple Files" in the express VI.
You've configured the multiple files to make a new file every 10000 samples.
I can't run the code (no DAQmx installed), but if you want one file, that doesn't seem right.