LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Program execution speed to slow, below 20Hz I need at least 100Hz

I am trying to get a while loop to itterate as fast as possible and I cant seem to get it to go faster than about 20Hz (20 readings per second)

I have several express VI's inside the while loop. I am intending to hook the VI upto a data aquisition system that returns voltages. For this excercise though I am just using a random number generator and storing the numbers in an ARRAY. Once the program completes 10 seconds worth of itterations I download the values into a file.

I need to be getting upto 100Hz.

0 Kudos
Message 1 of 5
(3,060 Views)

Basically you should know, that an express vi, although it is very easy to use and sometimes practical, also contains overhead and you can very often do the same thing using less vis and less wires, or let's say more optimised.

File access also needs a lot of time, as you have hardware involved.

So if you application is to slow, try to simplify.

Maybe you could also post your vi, so we can give you advice on improvements.

Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
Message 2 of 5
(3,055 Views)
Hi, sir_scotty.

Becktho is right; Express VI's are designed to accomplish common complex tasks easily, and not for high-speed optimization. I recommend taking a look at your Express VIs and searching on the Functions palette for similarly-titled VIs that can accomplish the same task. Opening and closing files in particular can really slow down an application, so switching to the lower-level file I/O VIs on the Functions>>Programming>>File I/O Palette can really make a difference. (If you do make that change, just put the Open and Close VIs before and after the while loop (respectively) and leave the reading and writing VIs inside.)

Good luck! Let us know if you're still having problems.
Sarah K.
Search PME
National Instruments
0 Kudos
Message 3 of 5
(3,030 Views)
Hi,

Thanks for your very quick response.

OK, so I have attached my 'working' VI, i have modified it to calculate the number of iterations that are performed in 10 seconds so that I know at what frequency (per second) it is peforming calculations.

My calculations shouldn't be that hard to peform? I just want to find the period and amplitude of a wave form generated from a wave tank. I will be collecting voltages from probes that are in the water measuring a change in voltage as the wave passes over them. I will need to get recordings of about 50Hz - 80 HZ, which is the upper limit of the DAQ device that I am using (100Hz). First though I need to get the computer running fast enough with the code.

I have attached my code that is generating random numbers, these are being put into the amplitude and period caculator VI's. Yes I know that this generates errors because random numbers arn't an ideal waveform, but it will do for calculating the loop frequency.

My thoughts around this problem are as follows:

I need to record the values from the DAQ device at 80Hz but I dont need to perform the calculations that fast, so i am trying to develop a sequence that will only perform a calculation on the waveform every 500ms but record values into the waveform every 10ms. Is this possible? I have tried a timed loop outside the sequence and inside the sequence niether of these options work. Your help would be much appreciated.

Cheers,

Scott Kelly



0 Kudos
Message 4 of 5
(3,023 Views)
 

Hi, Scott.

From the description of your application it sounds like you might want to implement a producer/consumer architecture instead of worrying about the complex timing of this one loop. A producer/consumer architecture is a structure in which you have two parallel while loops -- one which acquires data and the other which processes the data -- and each can run at its own speed. It's a really useful way of solving problems like yours, and it sounds like it will be much easier for you to implement than the timing we've been discussing.

Here are a few links that you might find helpful:

Application Note: Application Design Patterns: Producer/Consumer
KnowledgeBase: What is a Queue?

Take a look at these and let me know if you have any more questions. Have a nice weekend!

 
Sarah K.
Search PME
National Instruments
0 Kudos
Message 5 of 5
(2,996 Views)