LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

image acquisition vi runs fine, but errors as a sub VI

Solved!
Go to solution

Hi,

 

Not sure how to title this so any feed back is welcome. I am using the attached VI to extract a 1280x1024 image from a thorlabs DCC1645C camera, and save it as a BMP. (It also displays the image but I do not need this).

 

As a VI on its own, this runs just fine, and can run hundreds of times in a row (if the filenames are changed), however when I call this as a sub VI it works the first time it is called, then the second time it returns a black image but no error, then the third time it returns "Error 3" with no other information. Im completely stuck other than perhaps it is a problem with how the memory is allocated? 

 

Thanks for any help.

p.s all I am trying to do is quickly save a frame from the camera as a .tiff or .bmp so any alternative code is most welcome.

0 Kudos
Message 1 of 3
(1,713 Views)
Solution
Accepted by topic author md12g12

Without the drivers there's not much debugging we can do, but I'd suggest probing the subVI to see which specific function is throwing the error.

 

If I had to guess it's to do with the initialization and memory allocation being auto-handled. You're initializing the camera each time you call this VI. When run as a subVI, it initializes each time, and LabVIEW automatically deinitializes the memory each time the VI stops. As a subVI, the memory/dll/whatever is being initialized won't automatically unreserve the memory since the top level VI is still running.

 

I would redo this to not call the initialization functions except for the first time you call the camera, then don't close the references until the end of the run. That, or just make sure you actually deinitialize the camera properly during the subVI.

 

Basically I'm guessing your DLL is holding values or something and is throwing an error when you try to initialize something that's already initialized.

0 Kudos
Message 2 of 3
(1,694 Views)

Yes I think you were right, running the initialisation and close separately (in a state machine) worked great. Thanks

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