04-28-2006 04:38 PM
04-28-2006 05:10 PM
Chris,
You are correct. The problem appears to be corrected by the new drivers. The only problem we have left is the missing lines.
In looking at the problem we are missing a small but random number of lines. Unfortunately, the missing lines ar also blank so when they are apparent, they are also noticable. Statistically, we are missing less than 20 lines out of 2000. This is less than 1% of the total. In talking with NI, the card was not made for this purpose & I tend to agree with them.
I think the a solution lies in masking the problem by copying the previous line. I made a vi that does this after the image is stored but it takes a loneg time to add the entire array then replace the line: 5 min. with a P3:1 GHZ. I have tried to look at an array subset but this takes even longer.
Have a good weekend.
Earl
05-01-2006 08:48 AM
05-01-2006 09:58 AM
I think what Kevin was getting at was...
Yep, that was exactly what I was getting at. It sounded like there was a need to do Retriggerable AI with Finite Sampling on each trigger. I knew the counters could be setup to generate the sampling clock and no DAQmx Start / Stop's would be needed inside the AI loop.
However, I didn't realize that simply "commit"-ing the task before the AI loop could make the overhead just about negligible. Cheers for the DAQmx task state model! Given the performance and the simplicity of the change, I'd heartily endorse your approach rather than messing around with counters.
As altenbach pointed out, there doesn't appear to be a good mechanism to sync the Digital data (from some type of external circuit) with the Analog data. I *do* understand that the counter is counting a hw signal, apparently the same signal that should be the AI trigger. However, there's still no control over whether the software call to Read the Digital Port is reading the count value that truly corresponds to the analog data being pulled out of the queue.
I suspect this lack of correlation contributes to the missing lines. Let's suppose the lower loop gets bogged down on a particular iteration. My top 2 candidates are "IMAQ ArrayToImage" and the "Contrast Brightness" vi, both of which are probably doing a lot more array handling than strictly necessary. IMAQ is converting an entire 2d pixel array to an image rather than converting a single 1D row array. Contr/Bright takes a 2d floating point input and produces a 2d integer output. Unless very carefully constructed, the memory allocation functions are liable to get tickled pretty often.
Anyhow, let's suppose that the i_th iteration of the lower loop starts in sync with the i_th line of AI data. However, the memory allocation functions have to do some extra work this time, so while the lower loop's i_th iteration continues, the upper loop completes both loops i+1 and i+2. Next, the lower loop finishes and starts iteration i+1. It gets the queued AI data representing line i+1, but when it does the Digital Read, it gets the "right now snapshot" data representing line i+2. So AI data for line i+1 gets put into the 2d array as row i+2. The lower loop now speeds around again since the Dequeue doesn't require any waiting. It now reads AI data for line i+2 and again reads the Digital data representing line i+2. So it overwrites the same row of the 2D array that it just got done overwriting the previous iteration. This time however, it actually writes the data that belongs there.
However, row i+1 of the 2D array NEVER gets overwritten with AI data. The initial 0 values are still there, hence blank lines.
An M-series board would let you perform hw-clocked, buffered digital reads. With proper config and programming, you could guarantee to keep the AI and DI in sync. Your need to hw-reset the external counter value tends to dictate for continuing to use an external counter circuit rather than using the onboard counters. There IS a somewhat convoluted method that's pretty likely to work for an M-series counter, but it would be much nicer if the NI counters would support the simple type of reset you can easily accomplish with your chip.
-Kevin P.
05-01-2006 10:30 AM
05-01-2006 11:51 AM