Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Communication using Camera Link API

I am writing a C utility to control my device.  The device is connected to a NI IMAQ 1428 Camera Link framegrabber.  I want to control it using the standard Camera Link serial API. 
 
The clGetPortInfo call succeeds, and the clSerialWrite call succeeds, but the clSerialRead call always returns 0 bytes with a timeout error (error code -100004).
 
I have the Camera Link dll clallser.dll in my System32 folder.  My registry defines CLSERIALPATH in the HKEY_LOCAL_MACHINE / SOFTWARE / cameralink registry key.  In CLSERIALPATH folder, I have the clsernat.dll.
 
Why am I able to enumerate the port, but I am unable to read from it?
 
Thanks,
--steve
0 Kudos
Message 1 of 5
(9,609 Views)

Steve,

This seems like it could have several different causes:

1. Camera Commands – Take a look at the commands your camera accepts.  Make sure that you are sending the appropriate commands and that everything is case correct.  You might be able to find specific step by step instructions in the manufacturer’s manual for the camera.  Make sure to follow these precisely.

2. Termination Characters – Find out if the camera requires any termination characters that you may not be sending.  It may not respond until it receives on of the termination characters.

3. Delay – Try increasing the delay before reading in order to give the camera a chance to respond to the command you have sent.

Please let us know how things go and if you have any further questions or concerns.

Regards,
Luke H

0 Kudos
Message 2 of 5
(9,585 Views)
Thanks for the reply, Luke. Those are good suggestions.

After looking some more at this, I suspect the problem may be related to the baud rate. The camera has a fixed baud rate of 115200 and the IMAQ PCI-1428 has a max baud rate of 56000 according to the user manual.

My code calls the Camera Link API clSetBaudRate() to set the baud rate to 115200. I'm surprised that did not return a baud-rate-not-supported error. But I can't think of anything else that could cause clSerialRead to fail. The same code works with the same camera on a different frame grabber, so I feel confident that your suggestions are not the cause.

--steve
0 Kudos
Message 3 of 5
(9,578 Views)

Steve,

 

What kind of camera are you using and what camera attributes are you trying to set?  The reason I ask is that serial communication with Camera Link cameras is normally taken care of in the camera file.  

 

You are probably aware of this, but a camera file maps a standard set of IMAQ functions to any number of vendor-specific camera commands. In other words, the camera file tells NI-IMAQ how the camera organizes the pixels, what attributes the camera supports and how to change them. You can also download camera files from our web-site via ftp at the following address: https://download.ni.com/#support/imaq/camera_support/camera_files/.

 

In order to support as many cameras as possible, the IMAQ driver uses a specific camera file for each camera. NI is constantly working on creating new camera files, but it is impossible to include every camera-specific command in every camera file. If there is a special or undocumented serial command that you wish to use with your camera, you may consider updating the existing camera file with the new command using the NI Camera File Generator.

 

The other option that you may be able to use would be to use the NI-IMAQ driver imgSessionSerialWrite/Read functions.  I’m not sure if any of this matters at all with the baud rate barrier you seem to be encountering, but hopefully it helps.

 

Regards,
Luke H

0 Kudos
Message 4 of 5
(9,561 Views)
Luke,

I'm testing a camera that is under development. We want to read and write camera registers on the fly. I had the hardware engineer change the camera's baud rate to match the baud rate of the IMAQ 1428 frame grabber, and now my code works OK.

This is all new to me, so thanks for info about mapping commands, and the link to the Camera File Generator. If you have other pointers to resources for camera developers, I'd appreciate that too.

--steve
0 Kudos
Message 5 of 5
(9,558 Views)