Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

read data into 2D array using USB6251

Hi Everyone,

 

I have written the following .vi to readout analog voltage into a 2D array to reconstruct a 31 by 31 image. Here is my setup:

 

1. The USB6251 ai0 is connected to the analog voltage output of my external circuit, and the PFI0 is connected to a trigger output of my circuit.

2. The PFI0 is configured as falling edge trigger, after the trigger the DAQmx read.vi  reads 10 samples from analog input ai0 channel and the rms value is stored as one element.

3. I have contructed 2 for loops with 31 iterations for each loop. Then the above step 2 is performed within the for loop for 961 times and the final 31*31 array is displayed as an image.

 

The problem I have is that I want to increase the frame rate by increasing the external trigger signal frequency. Right now it's only 100Hz and for a complete image reconstruction I need to wait for 10seconds. If I increase the frequency to 1KHz the speed doesn't seem to improve. Can someone take a quick look at my vi and tell me what is wrong? Is the speed limited by software?

 

Thanks

 

Jian

 

0 Kudos
Message 1 of 3
(3,037 Views)

Here are a few thoughts:

 

1. Right now you're using "Build Array" functions inside your For loops that could probably be converted to auto-indexing output tunnels that are likely to run faster.

 

2. You are reconfiguring your trigger repeatedly inside your inner loop.  Such configs should move outside the loop (though I'll steer you away from the trigger entirely in a minute).

 

3. You are updating a graph in your innermost loop.  Bad Karma.  You are also updating images and writing to file in your outer loop.  This will slow down your ability to iterate from one image to the next, but you'll need to judge the importance of that issue.

 

4. You are never calling DAQmx Start.vi.  Thus, each DAQmx Read call will cause an implied Start->wait for data->Read->Stop sequence.  You should try to Start one time before the main loops so the hardware and driver can handle all the speed work.

 

5. Refer to this thread I remembered.  Configure your task to specify 10 repeats of your 1 AI channel.  You're kinda lying to DAQmx and saying you have a 10-channel task, but you'll know that a single sample of those 10 channels is *really* the 10 samples of 1 channel you want to average.

 

6.  After doing #5, you could get rid of both For loops and replace them with something like this:

 

faster raster.png

 

Note that the 2 transpose options are only there b/c I don't have a good way to verify

whether they're needed or not.  Get rid of them if they aren't necessary.

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 2 of 3
(3,030 Views)

Hi Kevin,

 

Thank you very much for some very useful advice. I will give it a try as soon as I can and let you know how it works. Thanks again.

 

Jian

0 Kudos
Message 3 of 3
(3,027 Views)