02-06-2013 01:23 PM
I have a PCIe-1433 camera link board, with a Basler camera. I found that I can set the gain and exposure times directly in the camera using the serial link and serial commands. This works very well. I'm doing this programmatically using the CLAllSerial.DLL.
The serial commands take too long to send in my application due to the default baud rate of 9600, so I was able to send a command to the Basler camera to up its baud rate, then change the baud rate of the camera link serial com port to match it. The result is that I can talk very quickly to the camera. Sweet so far.
However, with both the Basler camera and the camera link com port set to the higher baud rate, I can no longer acquire images using the IMAQ imgXXX commands. I get a timeout from the serial commands that IMAQ must be using to control the camera for image acquisition. Essentially the IMAQ driver doesn't know about the baud rate change. I cannot see how I can tell the IMAQ driver what baud rate to use either. NI MAX also becomes unusable in this situation.
How can I, through the IMAQ driver, increase the baud rate of the serial commands to the camera over the camera link?
Cheers,
Wayne
Solved! Go to Solution.
02-07-2013 07:42 AM
Hi Wayne,
You are able to change the baud rate directly in the camera file generator.
The link below descripes how to do it.
http://digital.ni.com/public.nsf/allkb/97E3CA926175C9F3862574B30080D22A?OpenDocument
Hope this helps,
Elmar
02-07-2013 09:42 AM
Elmar,
I had actually tried to use the NI Camera File Generator to change the baud rate. I tried once again. The problem is, once I change the the baud rate in the Serial Settings, I can no longer Grab images using either NI Camera File Generator or NI Max, so it is like those programs don't operate with the new baud rate properly.
I have to be missing something here, and I'm sure I don't understand everything there is to know about how the driver uses these serial commands during normal operation. I have saved an .icd file with the new baud rate to disk, then gone into NI Max and opened that .icd file. If I try to Grab images, I get a serial command timeout. If I uncheck the Enable Serial Commands in NI Max, I can Grab images, but then I cannot set Gain, etc, because, I suppose, it uses serial commands for that. Maybe this could work in my application, as I can just set these camera attributes directly into the camera via the serial link. Maybe. If I knew how, using the driver imgXXXX calls, to tell the driver not to use serial commands, like NI Max appears to do, I could do the same. Is this even possible?
What am I missing here? I just want to speed up the baud rate of the serial link to the camera to perhaps 115200. Seems fairly simple, but the driver seems to get in the way.
I appreciate any help.
Cheers,
Wayne
02-10-2013 09:50 AM
So, I thought I'd close this out and post the solution. To increase the serial communications baud rate over camera link, you must:
- Use the NI Camera File Generator to edit the camera file (or simply edit it directly, since it is text file).
- Run NI MAX, and connect to the camera using the new camera file. MAX won't be able to talk to the camera as yet, because the camera baud rate has not yet been changed.
- In your application, first set the serial link baud rate to 9600, so you can talk to the camera. Now change the baud rate in the camera itself, using whatever register changes, etc. are required for the camera you are connected to. Lastly, change the serial link baud rate back to the baud rate you selected in the camera file. (It goes without saying that the serial link baud rate and the camera baud rate must match.)
Now, both the NI driver AND the camera are at the new baud rate. You can exit your application and use NI MAX to access your camera.....until you power off the camera....at which point it (at least the Basler I'm using) the baud rate reverts to 9600. Works great!
Cheers,
Wayne
02-28-2014 12:04 PM
Wayne,
I am trying to communicate to a camera link camera (JAI) via serial to control camera parameters using Labwindows CVI.
Have only just come across the CLAllSerial.DLL but have not been able to find much in the way of documentation and examples.
Could you possibly post your code as an example of how to use the DLL to control exposure time, gain etc. ?
Cheers,
David
03-04-2014 01:55 PM
David,
I'll try to help if I can. Keep in mind that I'm using a stub into the DLL using Delphi as my development platform. That should not matter.
The DLL I'm tapped into is the IMAQ.DLL for the camera calls to get/set exposure time, gain, etc. The best reference I found for this is the NI-IMAQ help files that get installed with the normal NI install. There are important string constants that you need, to talk to the interface. I can't recall how I found these, but below are mine, in Delphi:
{ These are Basler camera attribute names we care about. }
BaslerCameraGainControlAttributeString = 'Gain'; { string result }
BaslerCameraGainValueAttributeString = 'Gain Value'; { numeric result }
BaslerCameraBitDepthAttributeString = 'Bit Depth'; { string result }
BaslerCameraExposureControlAttributeString = 'Exposure Control'; { string result }
BaslerCameraExposureModeAttributeString = 'Exposure Mode'; { string result }
BaslerCameraExposureTimeAttributeString = 'Exposure Time'; { numeric result }
BaslerCameraMaximumHeightAttributeString = 'Maximum Height'; { numeric result }
BaslerCameraPowerOverCameraLinkAttributeString = 'Power Over CameraLink'; { string result }
{ These are Basler camera attribute values we care about. }
BaslerCameraManualGainAttributeValue = 'Manual';
BaslerCamera12BitDepthAttributeValue = '12-bits';
BaslerCameraMaximumHeightAttributeValue = 2048;
BaslerCameraExposureControlFreeRunAttributeValue = 'Free Run';
BaslerCameraExposureControlTriggeredAttributeValue = 'Triggered';
BaslerCameraExposureModeAttributeValue = 'Manual';
BaslerCameraExposureTimeAttributeValue = 5;
BaslerCameraPowerOverCameraLinkAttributeValue = 'On';
BaslerCameraGainValueAttributeValueMinimum = 33;
BaslerCameraGainValueAttributeValueMaximum = 512;
MaxAttributeStringLength = 100;
The following code snippets, get and set gain and exposure times (I called it shutter speed), in Delphi:
{*****************************************************************************}
function TNiVision.GetGain : double;
var
TheGain : double;
begin
if GetCameraAttributeNumeric( BaslerCameraGainValueAttributeString, TheGain ) then
Result := TheGain
else
Result := BaslerCameraGainValueAttributeValueMinimum;
end;
{*****************************************************************************}
procedure TNiVision.SetGain( TheGain : double );
begin
SetCameraAttributeNumeric( BaslerCameraGainValueAttributeString, TheGain );
end;
{*****************************************************************************}
function TNiVision.GetShutterSpeed : double;
var
TheSpeed : double;
begin
if GetCameraAttributeNumeric( BaslerCameraExposureTimeAttributeString, TheSpeed ) then
Result := TheSpeed
else
Result := 1;
end;
{*****************************************************************************}
procedure TNiVision.SetShutterSpeed( TheSpeed : double );
begin
SetCameraAttributeNumeric( BaslerCameraExposureTimeAttributeString, TheSpeed );
end;
{*****************************************************************************}
These then call into the DLL functions imgGetCameraAttributeNumeric and imgSetCameraAttributeNumeric. There is a formatting interface between the above and the actual DLL functions I didn't show that just reforms the Delphi strings attribute names into C null terminated char arrays.
I hope this helps. I've now moved on to using Pylon with GigE cameras, which is a much cleaner interface, but very different code.
Cheers,
Wayne