12-04-2020 02:34 PM
I was using the DAQmx Express VI inside a while loop, but in order to speed up the operation, I generated the DAQmx code to replace the express VI. But as with this stripped-down example, the with just the DAQmx read operation it is still taking about 1.2 seconds per iteration. I was hoping the DAQmx read would take just a few ms. What am I doing wrong?
The attached example is just a stripped-down version of what I'm trying to do -- but operates the same as in my more involved code.
Solved! Go to Solution.
12-05-2020 02:39 PM
What DAQ module are you using?
I don't see any thing in your DAQmx code that sets timing. And your DAQAssistant version is set for 1 sample (On Demand), so I believe every time a data point is read, it takes time for the DAQ task to start the channels, read the points, then stop the read.
If you set up a timer and set it to 1 sample HW Timed, it should keep the task running and return as sample as soon as they are available.
12-05-2020 03:01 PM
@RavensFan -- Thank you for the reply! I'm using a cDAQ with a 9211 4-channel thermocouple module.
I'll try the 1 sample, hardware timed option when I get to the lab Monday -- thanks for the suggestion. The DAQmx code was generated from the Express VI, so presumably has the same 1 sample (on demand) setup.
12-05-2020 04:08 PM
Yes. The DAQ Assistant was also 1 sample on Demand.
12-05-2020 08:03 PM
Nice work finding the Generate Code right-click!
Now figure out how fast temperature really changes compared to other noise sources in a system. A thermocouple does not generate a very large change in Voltage per degree Centigrade ( and RTDs don't have a large change in resistance per degree Centigrade either) so these really need to be very precise measurements. Of course, since temperature is a measurement of energy per unit of mass... temperature does not change quickly and slow, precise measurements are actually desirable.
Seam to be a theme going on with temperature measurements lately...another class assignment taking a wrong turn? It happens now and then.
12-15-2020 08:49 AM
Looking at LabVIEW's example VIs was the most helpful with this problem. In LV2018, I looked at:
Example Finder > Hardware Input and Output > DAQmx > Analog Input > Thermocouple - Continuous Input.vi
Adding a DAQmx start task and end task block outside of the loop (as shown below) reduced the loop time from 1.2 sec down to 0.28 sec.
Adding those blocks solved this particular question. To optimize my larger code, I still need to move the DAQmx task to a separate loop from the measurements I want updated at a higher frequency... but that will require a much larger overhaul.