LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Increasing the sampling frequency of a VI code including a while loop

I am using a LabView code (attached) for real data logging. The maximum attainable sampling frequency is about 25 Hz which is much less than what is expected. As inferred from the loopt ime indicator, the lowest reachable loop time is about 25 ms (when the sampling frequency is set to 25 or higher)  that seems too long for such a simple code. I would like to add that the data acquisiton boared used ( PCI-DAS6013)  is able to acquire data up to 200 KS/s. 

 

Any help and technical guidance is much appreciated. 

 

Farzam

0 Kudos
Message 1 of 19
(4,095 Views)

A few quick comments:

 

1.  There is no need to have 7 different tasks set up for this. Acquire all your channels in one task!

2. You can always move your "Write to measurement file" in to a separate loop. That will speed up your acquisition.

3. You can always acquire more than 1 sample at a time to get the correct acquisition rates if your loop is running slow.

4. You are limiting your loop iteration rate by adding "Wait until next ms multiple" in to it. There is no reason I can see to have it in your loop.

0 Kudos
Message 2 of 19
(4,088 Views)

5.  Don't create the virtual channels on every iteration of the while loop.  Besides slowing down your code, you are bleeding away resources and your code could eventually crash.  You should create the tasks/channels before the while loop, read them in teh while loop, and close them after the while loop which you failed to do here.

6.  You don't need a separate numeric indicator with each chart.  Right click on the chart, Visible Items, digital display.  Now you can delete the extra indicators.

7.  The Save Data button should be inside the while loop.  Right now it is only read once immediately after you start the VI.

0 Kudos
Message 3 of 19
(4,058 Views)

Bowen M: I really appreciate your constructive somments. Regarding the 3th point, I wonder how I can acquire more than one sample at a time and how this trick can control the loop rate. I would also like to know how one can reach the desired sampling frequency without using  "Wait until next ms multiple" or any similar command. 

 

Thanks again for any help. 

0 Kudos
Message 4 of 19
(3,990 Views)

Ravens Fan: Many thanks for the comments. I am trying to apply them and see how they will decrease the loop time. 

0 Kudos
Message 5 of 19
(3,989 Views)

@Farzam wrote:

Bowen M: I really appreciate your constructive somments. Regarding the 3th point, I wonder how I can acquire more than one sample at a time and how this trick can control the loop rate. I would also like to know how one can reach the desired sampling frequency without using  "Wait until next ms multiple" or any similar command. 

 

Thanks again for any help. 


 

Just use the DAQ assistant.   This article answers all of your questions:

 

http://www.ni.com/white-paper/4656/en/

0 Kudos
Message 6 of 19
(3,970 Views)
No, that cannot be done. The DAQ Assistant is only for NI devices that user DAQmx. The DAS 6013 is from Measurement Computing. There are functions in their driver to set a sample rate and to acquire multiple samples, though.
0 Kudos
Message 7 of 19
(3,959 Views)

@Dennis_Knutson wrote:
No, that cannot be done. The DAQ Assistant is only for NI devices that user DAQmx. The DAS 6013 is from Measurement Computing. There are functions in their driver to set a sample rate and to acquire multiple samples, though.

 

Oh.  You are right... I looked at his VI again and realized those were not DAQmx drivers he was calling - and I don't have the package installed.  Sorry!

0 Kudos
Message 8 of 19
(3,948 Views)

BowenM and Dennis: Thanks for your comments. Yeah, it is not as stright forward as DAQ assistant and for the same reason it seems that using "Wait until next ms multiple" is unavoidable to contro the sampling frequency. 

 

BowenM: I wonder how a separate while loop can boost the sampling rate. Applying all recomended comments but No 2,  the sampling frequency reached 100 Hz, however , it is not high enough.  Thanks

0 Kudos
Message 9 of 19
(3,944 Views)
No, the wait is not at all appropriate. You don't use it at all when you specify a sample rate and multiple samples. The 1 sample mode forces you to use software timing. Change it to N samples after adding the timing function. Isn't there an example of that? There certainly is with the NI functions so maybe you should look at those for such a basic task.
0 Kudos
Message 10 of 19
(3,937 Views)