10-31-2023 01:34 PM
Hello,
Hoping someone can enlighten me on an issue I've been struggling on for days. I'm vaguely familiar with LabVIEW and by no means an expert by any stretch of the imagination.
I've been stumped on attempting to record data as fast as the hardware will allow (~60 Hz I believe). I'm using 9189 chassis with a cDAQ 9214 thermocouple module. Just running a simple program that logs data (TC readings and timestamp) onto a TDMS file and plots the data in real time. Only using one cDAQ module with one TC input as this will lay a foundation as a base program to build upon (will eventually use several cDAQs for data acquisition). The program uses two loops with the first loop capturing data and the second loop graphing data. The program executes without errors but I can only capture data at a max rate of ~5 Hz. Can someone point me in the right direction? How can I capture data at the maximum rate the hardware will allow? Thank you.
Machine Specs: windows 10 pro 64-bit, 2.9 GHz processor, 32 GB ram
Solved! Go to Solution.
10-31-2023 01:38 PM
Try separating your Acquisition and logging into separate loops connected by a Channel Wire (Producer/Consumer)
10-31-2023 03:14 PM
Why don't you use the built-in DAQmx logging feature?
You can refer to the shipping examples at Help >> Find Examples... >> Hardware Input and Output >> DAQmx >> Analog Input >> Voltage - Continuous Input.vi and combine it with Thermocouple - Continuous Input.vi
11-01-2023 08:52 AM - edited 11-01-2023 08:53 AM
I just did some massive cleaning up of your code.
1. Use the DAQmx Timing VI to set the sample rate for the DAQ and set the task to be Continuous Samples. This allows the DAQ to perform the sampling at the rate (hardware timed) instead of relying on software timing. With this, I changed the sample rate to a constant of 60.
2. With #1, you can get rid of all waits in your code. For the DAQmx read, change the polymorphic to Analog->Single Channel->Multiple Samples->Waveform (Samples). I would recommend then reading 6 samples per read. This would have the read complete every 100ms, a general rule of thumb when dealing with DAQs.
3. Before the loop, use the DAQmx Configure Logging. This tells DAQmx to log the data as it reads. This is way more efficient than you can possibly make with a Producer/Consumer as it bypasses software layers.
4. With #3, you can get rid of the whole second loop.
5. Change the graph to a Chart and wire the output of the DAQmx read straight to the terminal. The chart keeps a history and the timestamp is included with the waveform data type.
11-01-2023 12:50 PM
Thanks everyone for the for the feedback, especially Crossrulz for pointing out the flaws in the labVIEW script.
The acquisition rate (in real time) was day and night difference on the new script! It seems I still have a long path in front of me to fully understand data management in LabVIEW. Very surprised to see an issue that was taking days of research on my end to be resolved in mere seconds while pointing out my deficiencies in the process. Thank you again!
11-01-2023 01:00 PM
@LVenthusiast434 wrote:
It seems I still have a long path in front of me to fully understand data management in LabVIEW. Very surprised to see an issue that was taking days of research on my end to be resolved in mere seconds while pointing out my deficiencies in the process.
It took me years to get to this point. Lucky for you, there is a lot better information out there now than when I was figuring this out. The first reference we normally point to is Learn 10 Functions in NI-DAQmx and Handle 80 Percent of Your Data Acquisition Applications.