Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Any Examples for setting Exposure Time using cwimaq.ocx?

Hi, everyone.

I am using the cwimaq.ocx base and Viewer controls in an app.  I am using snap mode, and can acquire the images just fine.  My problem is that I can query the exposure time OK,

MsgBox ImCtrl.CameraAttribute("Exposure Mode")
MsgBox ImCtrl.CameraAttribute("Exposure Time")

but when I try to set them,

ImCtrl.CameraAttribute("Exposure Time") = "1/80000"

It does not seem to work.  Illegal values (i.e. not in the camera file) will throw an error, so it is doing some error checking.  And when I query the exposure time again is has been updated.  It just does not change anything about the acquisition.

Are there any examples of setting the exposure time in code?  I am using VB6 and a PCI-1428 with IMAQ version 3.1.1, and have a Cohu 7800CL camera.

thanks,
Jonathan
0 Kudos
Message 1 of 3
(3,228 Views)

Hello Jonathan,

I was not able to find any example code that modifies camera attributes in VB (there were plenty for LabVIEW and CVI). I did find a knowledgebase called "IMAQ Camera Attribute Function In Visual Basic", but it did not provide anything more than syntax information (which you are already familiar with).

One thing to consider is that when you modify the camera attribute, it will not affect an acquisition that is currently in progress. For instance, if you change an acquisition parameter after initializing a grab, you will modify the camera file, but subsequent grabs will continue to use the old settings. Only if you reinitialize the board for a new grab acquisition will it use the updated camera attributes.

Also, I would make sure that manually changing the camera file changes the acquisition the way you think it should. If it does not, you may want to get that working first.

If you need to be able to change the attributes of a camera's acquisition while it is in the middle of one, you may be able to use the serial functions that the IMAQ driver provides to communicate directly with the camera through the Camera Link connection. The IMAQ function is called "imgSessionSerialReadBytes". I hope this information helps. Take care!

Regards,

Aaron B.
National Instruments
0 Kudos
Message 2 of 3
(3,210 Views)
Thank you, Aaron.

The note about setting attributes while it was acquiring was helpful.  The imgSessionSerialReadBytes or Write does not seem to be implemented at the ocx level.  If there is a workaround I'd love to hear it.

I am running into a problem with setting
CameraAttributes in general: when I do so it destroys my SessionID.  When I begin and initialize, I end up with a session ID of 0.  I can perform and externally triggered acquisition just fine (by calling .Start()).  As soon as I set any CameraAttribute, it sets my SessionID to a huge negative number (looks random to me).  Then as soon as I call a .Start() to arm the capture board, it errors out with a message saying that the Interface or Session was invalid.  And of course the SessionID _had_ just changed to some weird value.  I can not just read SessionID before hand and then reset it afterward because the property is ReadOnly.

Does anyone know what is going on?

Jonathan


0 Kudos
Message 3 of 3
(3,189 Views)