03-22-2022 02:39 PM
I'm using a NI USB 6251 to generate a raster scan with galvos and then collect the fluorescence signal point-to-point. The problem is that I can seem to be able to run the scan speed -almost- as fast as I want, but as soon as I try to add AI reading for filling a matrix (sync is done by using timing and onboard clock on both AO and AI) with the read data, it gives me this error. I need to set the read rate so low that it takes minutes to make a single scan (512x512 points), which is not good.
If I use DAQmx instead, I don't get the error, but it looks like te reading can't keep up with scan speed, even if it's not too high (like 10kpps): it keeps restarting scanning the frame many and many times until it gets all the matrix values form the PMT.
I think my DAQ should be able to handle this easily with its sampling speed, so what's the problem?
Any suggestions?
03-22-2022 04:33 PM
Synchronizing AI and AO is definitely possible on your hardware. The problem is the usage of DAQAssistant, I would recommend learning and using DAQmx drivers instead, that gives you a lot of flexibility.
BTW, please attach the VI in LV2016 version - this allows most of the forum members to open the VI
03-22-2022 05:07 PM
Hi, thank you for your answer.
I usually don't use DAQAssistant and my actual approach is the following, but it doesn't seem to work. The scan speed exceeds the AI speed at which the image matrix is being filled. So the scan restart many times from the beginning until the image array has been filled with all the values (which goes very slowly).
I saved the VIs in a compatible format for 16.0.
03-22-2022 07:45 PM
The two most urgent bits of advice I can give:
1. To avoid the -200279 buffer overflow error, read more samples at a time from your AI task. A good rule of thumb is 1/10 second worth. At your 40 kHz sample rate, that'd be 4000 samples per read instead of 5.
2. Your AO and AI tasks are *not* sync'ed. Because you use the same device for both tasks, a simple way to sync them is to configure the AO task for triggering, specifically a start trigger on the terminal "/Dev3/ai/StartTrigger". And then make sure you call DAQmx Start for the AO task *before* calling it for the AI task.
There are many other improvements possible after you take care of these 2, but these 2 should be your first priority.
-Kevin P
03-23-2022 09:54 AM
Followup: when you're ready, there's a more flexible way to sync AO and AI that lets you account for a little bit of system response time. Let me try to dig up an old posting that illustrates.
<time passes...>
Ok, have a look over here. A few details of that example are specific to that other thread, but most of what you see would carry over.
-Kevin P
03-27-2022 06:30 AM
Thank you for your suggestions!
I think I finally solved the problem of syncing, but maybe with a different approach, by looking at one of the proposed examples in labview:
I now build an array containing the total number of points I want to scan. If I want to acquire and average 5 samples for each scan point, I just build a scan array with all the points repeated 5 times. Then I sync the AO and AI and acquire all the samples at once in a single dimension array.
After this I build the image with a series of operations on that array. The problem now is that those operations are TERRIBLY slow (takes minutes if there are 2-3 million samples in the array) to perform and I'm stuck again. It also seems that lines of the image are shifted of a number of pixels that varies with the scan rate I set and with the number of samples I want to average. I don't know why this happens, but I need to fix these.
03-27-2022 01:30 PM - edited 03-27-2022 01:56 PM
Your array processing can easily sped up by orders of magnitude. It looks like you keep deleting elements from the front of the array as your method to work on the data a few samples at a time.
There are much better ways to access that data! In fact, I'm hard pressed to think of a worse one. Unless LabVIEW does some smart optimizations under the hood (and your minutes of processing time suggest that it doesn't), each time you do the deletion, you have to then copy all the remainding elements from their original memory location to a new location "N" places earlier. It's a very wasteful repeated operation. You might be copying and moving some of those later elements 10's of thousands of times!
Instead, use "Array Subset". For each loop iteration "i", take a subset a subset of N points that start at index N*i. This will be *much* faster.
-Kevin P
03-27-2022 01:53 PM
Thank you very much for the idea, I will try it and let you know how it goes! ^^
03-27-2022 02:22 PM
This is super! I Changed it as you suggested and now it works great! After the scansion ends, I get the image almost immediatly!
Great!
Now I only have one issue left: every second line in the image is shifted a number of pixel compared to the adjacent line. The number of pixels the image is shifted is not fixed and seems to vary with the scan speed (rate) and number of samples I read and average per point. Need to fix this now.