LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you increase the sampling rate in this VI?

Solved!
Go to solution

Hello everyone,

 

I recently inherited this mess of a VI, and cant figure out how to increase the sampling rate. I tried altering the "ms to wait' clock, but it didn't add many more data points. Attached is the main VI, as well as the subVI that contains a Daq Assistant for a load cell and LVDT. Any ideas on how to improve sampling frequency without a complete overhaul would be greatly appreciated!

 

Thanks in advance!

Download All
0 Kudos
Message 1 of 6
(4,375 Views)

Okay if we are just talking about making the speed of the while loop faster there are a few things that can be done.  Obviously my previous comments still hold.  I think a re-write from professionals is best.  But second best is to hack it in there.  With the subVI and DAQ Assistant I can see a little more about what is going on.

 

So in your loop you setup a DAQ task to read 100 samples, on two channels, at 1KHz each, in a continuous mode.  This will take 100ms based on the definition of 1Khz rate and 100 samples.  But what comes out of that VI is a single sample.  You are throwing away 99 samples, and reading one sample every 100ms or about 10Hz.

 

The easiest way to improve speed, is instead of reading 100 samples and throwing them away, read one sample, if  you really only want one sample.  Double click the DAQ Assistant and under Acquisition Mode change it to 1 Sample On Demand.  Speed could likely be improved by not using DAQ Assistant and replacing it with DAQmx code but what ever.

 

Also as mentioned offline, you are opening and closing that file reference every iteration of the loop.  You can have a producer consumer else where logging, or at the least just open once, and close once.

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

Changing the setting of the Daq Assistant did greatly increase the number of data points collected. However, I still think I may need to have more. How do I go about opening and closing the reference file only once instead of at every point?

0 Kudos
Message 3 of 6
(4,350 Views)

I don't know how much more speed improvement you'll see, and I don't know your current requirements.  Any faster and it might be better to take N samples and display all N at once, and log all N at once.  Again another reason it should be re-designed.

 

Still here is the logging technique I was talking about.  I back saved it to 8.2 but no idea how it looks because I don't have that version to test on.

 

The VI is broken but it is just meant to show how the code can work with the Open on the outside of the loop, the writes on the inside, and then the close on the outside again.

0 Kudos
Message 4 of 6
(4,338 Views)

This improved it as well! I think at this point, and discrepancy in the data I am receiving is due to mechanical issues and not the VI. Thanks so much for the help!

0 Kudos
Message 5 of 6
(4,323 Views)
Solution
Accepted by topic author BennyD

If you are greatful, feel free to give kudos, and marking the topic as solved.

Message 6 of 6
(4,314 Views)