Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to speed up this vi program?

I've attached a snapshot of the vi program I implemented in labview 8.5, the hardware is USB-6251. Basically I'm using the DAQ card to acquire an analog voltage at 1M samples/sec and the data acquisition is externally triggered. For each trigger 350 samples are saved in an array and after simple signal processing an output is calculated.

 

I use "for loop" to repeat the above procedures 256 times, and 256 outputs are saved in a 16 by 16 array, which is used to reconstruct a gray image. The problem I noticed is that the labview program is not running fast enough because I have to wait for very long time to get one image. Is it because of the "for loop" running slowly between two consecutive iterations? Is there any way I can speed up this program? Is using a faster computer gonna help? Thanks in advance and I'm looking forward to any advice.

 

Jerry 

0 Kudos
Message 1 of 9
(4,284 Views)
There's not enough information to say anything. All that you have done is show an image of a for loop with a subVI. It's what's inside the subVI that's important. If you are doing DAQ, one source of unnecessary time would be if you are creating/starting/stopping the task inside the subVI. You also say that it is not running fast enough. That's very vague. Exactly how fast is it running now and how much faster do you want (and please you some actual numbers and not 'running slow' and 'run faster'). Also since it depends on an external trigger, how often does the trigger occur?
0 Kudos
Message 2 of 9
(4,274 Views)

Hi Jerry,

 

It looks to me as though the problem may be to do with the amount of tasks you are performing for every iteration of the for-loops. I'm assuming that you have all of your DAQmx VIs (eg. DAQmx Create Virtual Channel, DAQmx Read etc.) contained within the 'Acquire Data' subVI. Could you please confirm that? If that is the case then that could be very processor-intensive and hence could be why your application is running slowly. As a rule of thumb, it is best to keep everything possible outside of the loops, and hence perform each task once only. Many examples of how to do this may be found by selecting Help>>Find Examples from the LabVIEW pull-down menu, before navigating to Hardware Input and Output>>DAQmx>>Analog Measurements>>Voltage. Most of the examples concerning continuous acquisition (those beginning in 'Cont Acq') will give a good idea of what should be placed inside and outside of iterative loops.

 

Hope this helps, don't hesitate to ask if you need anything clarified. Let me know if it has any affect on the speed of running your application and if not, then I can assist you further.

 

Regards

Jeremy T
Technical Marketing
NI
0 Kudos
Message 3 of 9
(4,263 Views)

Hi Dennis,

 

I'm sending you the vi file, sorry I didn't make it clear enought, the top level vi is acquire.vi, I'm using labview 8.5.

In the front panel, the sampling rate is set to 1M samples/sec, number of samples is 350.

Right now I have to wait 10 to 15 seconds to get one image, but my external trigger (from FPGA) is 2KHz, which means the frame rate should be 2000/256, which is around 8fps. Thanks in advance.

 

Jerry 

Download All
0 Kudos
Message 4 of 9
(4,262 Views)

Hi Jeremy,

 

Thanks for you reply. Do you have time to take a look at my vi's which are attached in my second post and point me some directions?

 

Jerry

0 Kudos
Message 5 of 9
(4,260 Views)
As Jeremy and I both mentioned, you are doing too much in the subVI. There is a shipping example called Acq&Graph Voltage-Int Clk-HW Trig Restarts.vi that I think you should look at. This uses an analog trigger instead of a digital but that can be easily modify. What is key is configuring the task outside the loop. In your case, that would mean placing the majority of the code outside your for loops.
0 Kudos
Message 6 of 9
(4,256 Views)
Thanks for your reply. I think the DAQmx read block has to reside inside the for loop, but what about the stop task and clear task blocks? I can't put then outside the loop, there will be data type error, but if I put them inside the loop then for the next iteration I'll have to recreate task inside the loop. Can you give me any idea how to just keep the data acquisition block inside the loop? I took a look at the examples, they all have while loops, but in my case I need for loops to accurately control over the number of iterations to run.
0 Kudos
Message 7 of 9
(4,233 Views)

Of course you can place them outside the for loop. You seem to not understand that by default, a for loop will automically auto-index any wire entering or leaving the loop. You can simply right click on your exit tunnel and select 'Disable Indexing'.

 

p.s. A while loop can run an exact number of iterations just like a for loop. You just have to compare the iteration count to a stop condition (i.e. Greater/Equal to a number).

0 Kudos
Message 8 of 9
(4,231 Views)

Jerry,

 

If you disable auto-indexing, you will want to check for the status of the error at each iteration of the loop (similar to "Cont Acq&Graph Voltage-Int Clk.vi" shipping example).  If an error occurs in the middle of your iteration count, you should abort the loop, or else you will lose the error information.  An alternative would be to use a shift register (right click on the tunnel and click replace with shift register).  A shift register will pass the value at the output back to the input for each iteration, thus saving information from each iteration.  Either option should do the job.

 

ck.x 

 

 

0 Kudos
Message 9 of 9
(4,201 Views)