LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Image Acquisition and Digital I/O timing issues

Hey all,

 

I am using labview (8.2 or 8.6) to control two components, an NI-9472 and a firewire (IEEE 1394) camera.  My image acquisition vi's work pretty well, and can capture/store may data at an acceptable rate (~500msec per frame).  However, I need to cycle the state of my NI-9472 at a much faster rate (~100Hz).  This I am also able to do on its own.  When I try and do both at the same time, I get stutters in the write out to the 9472.  It cycles at the appropriate rate, during the acquisition, but then either as the acquisition starts or finishes, there is like a mini pause in the actuation of the 9472.  At lower cycle speeds going to the 9472 (less than 5 Hz), the glitch obviously goes away.  

 

They way my code is setup right now (I'll post it tomorrow), I have 3 parallel while loops.  One controls the timing of the signals being sent to the 9472.  It basically writes a change to the output array at a fixed time interval, and generates a notifier that the array has been changed.  A parallel while loops waits for notifications then sends the updated array to the module.  This second loop (the one that actually sends data to the 9472) is the one that is getting delayed (as evidenced by the fact that the stutter doesn't just cause a delay in the execution of the sequence, but an actual skipping of elements, which means the first loop is generating the apporpirate changes, they just aren't being written).

 

Image acquisitoin is being done in yet another parallel while loop.  Each iteration takes about 500 msec (create image buffer, expose image (5msec exposure time), Read image buffer, flush image buffer, convert RGB image to 3, 12-bit grayscale images, stream image data to disk, compute crude image statistics (avg intensity on a small ROI)).  I am totally fine with this frame rate, even though I know it could be done faster, my problem is that it screws up timing of my other hardware.

 

I know I am probably looking at a complete architectural overhaul, but I am kind of self-taught and only know how to do, what I already know how to do.  So any advice, examples people could point we to would be very much appreciated.

 

Thanks All

Matt

 

 

0 Kudos
Message 1 of 6
(3,446 Views)

Hi Matt

 

If you could post a screen shot of your code it may help us further diagnose the problem. I believe what may be causing a problem here is the simple overhead in sending commands over the USB. If you are acquiring off the camera device and using this to perform software timed responses on the USB you may see some lag when cycling the state. This lag time is inherit in the time it takes to send commands to the USB driver itself and restructuring the software may not provide a performance increase.


Thank You
Eric Reid
National Instruments
Motion R&D
0 Kudos
Message 2 of 6
(3,417 Views)

Sorry about the delay in posting the vi's.  Here they are.  Thank you so much for taking a look and giving me advice...


0 Kudos
Message 3 of 6
(3,400 Views)

Hi Matt

 

I took a look at your code, however the architecture makes it a little bit hard to see the source of the problem.  I did however see several individual calls out to the usb device which would be slowed down by the overhead inherent in the driver. If you can direct me to a specific loop and explain its functionality, I could look there and see if anything could be optimized.


Thank You
Eric Reid
National Instruments
Motion R&D
0 Kudos
Message 4 of 6
(3,369 Views)

So here is a rundown of what is happening:

 

All the action is in frame 2 of the large stacked sequence.

 

There are 5 parallel while loops

Starting from top to bottom:

 

The first loop captures user input onto the GUI, mostly, changes to hardware configuration that occur only during thstartup phase of the software, or ar irregular, non-critical times throughout.  I am not worried about the impact here, because while I am trying to drive my system at high speeds, this loop is basically hitting the time out even over and over.  It is possible fo the user to change a control that would fire an event (events 5, 6, 7, and 9) in this loop that would impact the lower loops.  In these events, the use is requesting a change in at least one of the eight members of a boolean array to be written to the NI9472.  This generates a notifier, which brings us to the second loop.

 

The second loop waits for notification that something needs to change in the output array, and then sends the new array to the 9472 (!Valveit!_MC.vi).  With the exception of initialization (in frame 2) and shutdown (in frame 4), this is the only place that I actually send signals to the 9472.

 

The third and fourth loop have the same function (as each other).  When triggered, (P1on = T for loop 3, or P2on = T for loop 4), the loop advances through a pattern of values for three of the elements of the control array.  Each step is timed using the Labview's "wait" function.  Each change generates a notifier, which triggeres action in loop 2.  These are separated into distinct loops so that the two sets of three valves can actuate as independent units.

 

The final loop is camera control.  This loop is truely parallel, which no communication with the other loops.  This loop controls a firewire camera (previously initialized).  It allows for live imaging ("CLive"=T", images captured and displayed on the front panel, but not stored in memory) or for the recording of images to disk (direct streaming to hard disk as a binary). In the live mode the loop continuously uses "GetSingleRBGIMage_2_CCpAP.vi" to acquire an image from the camera which is then displayed on the front panel.

 

In the live mode, there is jitter in the display on the front panel, but there does not appear to be jitter in the actual actuation of the valves.  In the data streaming mode, there is some jitter in both. In the recording mode, the same sub-vi ("GetSingleRBGIMage_2_CCpAP.vi") is again used to snap a sinlge image, but rahter than outputing the image, it outputs three structures (one for each color channel of the image) which consist of a 1D array of pixel values, and an average value over a region of interest.  Each 1D array is streamed to a binary on hard disk. 

 

Since my initial post, I modified the '!ValveIt!_MC.vi' to output a tick count every time it executes, and see that it is executing at the correct rate, except for at either the start or finish of an image capture (probably the finish).  (Remeber, theoutput to the 9472 is changing many times during a single image acquisition).  And at that point, there is one cycle that takes longer than it shouldfollowed by a cycle that is much shorter than it should be.  So it catches up.

 

Hope that clears it up, and allows you to make any suggestions you think would be helpful.

M

 

 

0 Kudos
Message 5 of 6
(3,350 Views)

Hi Munson

 

One thing you could try is taking small time stamps and subtracting them in the different loops to see if one loop is taking longer than the others. It looks like you are on the right track with using notifiers to monitor your loop performance. We also may want to look at your systems performance for this as both data acquisition from the camera and the 9472 would be disk drive intensive.  


Thank You
Eric Reid
National Instruments
Motion R&D
0 Kudos
Message 6 of 6
(3,336 Views)