From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error 1172: using thorlab CMOS DCC1545M camera to continuously take pictures

Solved!
Go to solution

Hi, 

I have no experience to .net so I hope I am stuck with a simple problem to experienced labview coders...

I am trying to modify the VIs provided by thorlab, which is related to file named "uc480DotNet.dll', to coordinate with my actuator then take pictures at different position. 

But now I am stuck in making the thorlab camera to take a few pictures in a for loop.

The VI will work all right if I only ask it to take 1 picture, but more than that will pop up a message box showing " error code 3".

Then the error box will show error 1172 with text as :"Invoke Node System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
Inner Exception: System.NullReferenceException: Object reference not set to an instance of an object. <append><b>System.NullReferenceException</b> in Camera take 1 pic with auto path call.vi"

And another one as :" Property Node (Arg :1) Error accessing property uc480.Types.CameraInfo.SerialNumber, (System.ArgumentNullException: Key cannot be null.
Parameter name: key) <append><b>System.ArgumentNullException</b> in uc480_SubVI_Example_MemoryAllocation.vi->Camera take 1 pic with auto path call.vi"

 

The code is attached below.

I guess this is something about .net memory leak but I don't really understand it well enough to fix it.

Any help is appreciated. 

Thank you!

0 Kudos
Message 1 of 7
(4,650 Views)

I don't have LabVIEW 2016 installed (just 15...) so I can't look at your VI but typically that error is caused by a bad reference.  Is there a chance that you're re-using an old reference that was closed and freed, or that you're using a "default" reference or one from a block diagram constant somewhere?

 

If you probe the reference wire going into the nodes that cause problems, you can often tell if it's bad if you see just zero as the probe value instead of 8 random hex characters.

0 Kudos
Message 2 of 7
(4,640 Views)

I use a different camera but the same dll.  Below is a few images form a single LOOONG VI that take a single frame.  You initialize the camera, allocate memory, set the xposure and framerate, aquire, then exit.  

 

To take images continuously just break it up, and just keep doing the 'aquire' part.  Don't forget to initialize and exit only once and at the right time.

 

112233

0 Kudos
Message 3 of 7
(4,620 Views)

Hi Kyle,

 

I tried to use the save for the previous version. I am not sure if you can open this one.

For the camera reference, actually I am quite confuse about it. 

The VI will ask for the camera number and output buffer, then I just choose 0 for both. That work out for only 1 shot.

I probably shall look into that as you said.

Thanks!

0 Kudos
Message 4 of 7
(4,602 Views)

 

 

 

0.jpg1.jpg

 

Hi Adam,

 

Thanks for your image! I will refer to your code.

I also put up mine here.

Hope I can figure it out soon.

0 Kudos
Message 5 of 7
(4,599 Views)

You have a huge amount of "close reference" nodes.  You should get rid of all of them that are inside the loop, and just leave the one that's outside the loop.  They aren't needed because when you finally close the "Camera" reference at the end, all other references that you got from it close when the top-level nodes close.

 

Additionally, the "Close" node for the PictureBox control should go outside of the loop as well.

 

I suspect that will clear up your issues, but if not please post here again.  Or try copying some of the code Adam posted.

0 Kudos
Message 6 of 7
(4,594 Views)
Solution
Accepted by topic author Doraemon214

Thanks for your advice!

I somehow make it work by moving the camera initialization VI out of the loop.

I have no idea why... 

This is contrary to my experience working with Keithley SMU.

I guess that really depends on the communication protocol.

0 Kudos
Message 7 of 7
(4,578 Views)