LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx read runs slow, even after generating DAQmx Code from express VI

Solved!
Go to solution

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.

 

 

Message 1 of 6
(2,239 Views)

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.

0 Kudos
Message 2 of 6
(2,196 Views)

@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.

0 Kudos
Message 3 of 6
(2,192 Views)

Yes.  The DAQ Assistant was also 1 sample on Demand.

0 Kudos
Message 4 of 6
(2,186 Views)

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.


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 6
(2,176 Views)
Solution
Accepted by topic author d-thomas

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.

 

tc_reader_DAQmx_code_revised.PNG

0 Kudos
Message 6 of 6
(2,145 Views)