LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to reduce the process time in a while loop

i am collecting data at 50 samples per second rate for 15 secs and processing it taking each data point. the process time is very long. the data is processed in a while loop. while loop executes more than 200k times per second then why is it taking so much time to process 750k samples? do i need to consider anything while creating the while loop. are there any stnadard ways to increase the speed of processing data in a loop?
0 Kudos
Message 1 of 9
(3,884 Views)
The best way to decrease the time for processing is to reduce the processing that you do. If you've got computationaly intense processing, you may have to consider doing it after the program completes, doing it differently, or reducing the sample size. You don't say what exactly that you're doing. Without that information, it's really hard to say. Also, you say it's taking too much time to process 750K samples but at the beginning you say you take 50 samples/sec for 15 seconds. That works out to 750 samples. If you could attach the program (include all subVIs) that would be a great help.
Message 2 of 9
(3,884 Views)
HI mudda

This will probably sound a little crazy but if you are not putting in some type of wait function into your loop then you could be seding you processor to 100% therefore slowing down the process. this will free upi some processor time. i do this in all my applications because it allows the end user to shake the mouse or do different functions also if you put in enough time. Try it and if this doesn't work post you VI and we will take a look.



Joe.
"NOTHING IS EVER EASY"
0 Kudos
Message 3 of 9
(3,884 Views)
that was a good answer alot better than mine was but I tried. I guess that why I'm still a newby



Joe.
"NOTHING IS EVER EASY"
0 Kudos
Message 4 of 9
(3,884 Views)
The while loop will only process as fast as everything that you are doing within the loop. Without seeing your code it is difficult to determine what might be causing your slowdown. I suspect that the problem is likely with your array handling. If you'll post your code you will receive more help in analyzing your problem.

Is there some reason that you are using a while loop instead of a for loop for this application? If you feed the array of data to a for loop and use autoindexing then it will execute the required 750k times and end. This works very well if you're processing on a point by point basis.
0 Kudos
Message 5 of 9
(3,884 Views)
In my program I am collecting the dta from four channels. hall pulses, current and voltage. first I am reading the signals storing them in a binary file taking the data processing it and displaying it on a graph. I know this is not an efficeint way of programming but that was what I made. The reason for storing the data as a binary file is to take small memory for storage. In my for loop what I do is I take the hall pulses digitize them and calculate th speed of the motor. For current data I multiply it by 1000 cause I am using a .001 shunt. I am attaching my main VI and sub VI's.
0 Kudos
Message 6 of 9
(3,884 Views)
Okay, I can now see that it's the precessing time itself and not trying to process while doing daq that's the issue. The first thing to do is to turn on the profiler (Tools>Advanced) and see where the time is being spent. Once you've done that, you can focus on the areas using the most time. The other thing to do is get rid of the value property nodes. It is always faster and more effecient to use a wire and not a local variable or property node.
0 Kudos
Message 7 of 9
(3,884 Views)
Dennis,
The solution you said has just worked fine. The program which used to take 10 minutes to process is now taking only splits of seconds. I got rid of all property nodes in side my for loop and that increased the processing speed a lot. I have one more question could you tell me how do I use Profiler. thanks for the reply.
0 Kudos
Message 8 of 9
(3,884 Views)
It's pretty simple. Under Tools>Advanced, you have the selection Profile VIs. When the Profile screen opens, click the Start button and then run the VI.
0 Kudos
Message 9 of 9
(3,884 Views)