Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Camera link protocol implementation on FPGA

Hi,

 

I want to configure the Basler camera parameters like exposure time, frame rate, Gain value etc. through 7966R FlexRIO & 1483 Camlink adapter module. But on FPGA there is no option to configure these parameters through .icd file or MAX. So I have to implement the Camera Link protocol in FPGA to configure these parameters of camera.

 

I found that camera link has 4 controls lines (CC1 to CC4) but I am not able to find how these lines works to control the parameters of camera. If anyone knows how these control lines work then please tell me or share any document to describe their operation. Or any other information through which I can implement the algorithm on FPGA to control the parameters of camera.

 

Any help will be appreciate

 

Regards

 

0 Kudos
Message 1 of 14
(8,486 Views)

Look at the examples.  They include reading the data using Camera Link, and there is a routine for sending messages to the camera to adjust shutter, frame rate, etc.  You could probably just copy the examples and switch the pixel configuration and have a working program.

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 2 of 14
(8,479 Views)
The "Serial Sever" component in the 1483 examples is designed to interface with 3rd-party camera software like Basler's Pylon to configure the camera settings. As long as it is running, Pylon should see the camera.
0 Kudos
Message 3 of 14
(8,470 Views)

Thanks to both of you for the reply.

 

@Bruce Ammons

 

I have check all the four examples shipped in example finder of LabVIEW 2014 for 1483 camera adapter module. But I did not find any signal used for configuring the camera parameters.

 

In the project of example codes of 1483, it is showing all the four control lines of camera link. But they have not demonstrate how to use these control lines to configure the camera parameter.

If you have that example which is using CamLink to adjust the shutter value & other parameters then please post that code or give me the link  so that I can access that example.

 

@ BlueCheese

 

I understood your point. But I am developing an application on LabVIEW which can directly configure the parameters of camera. So I have to configure these parameters through my application only. 

 

Is it possible to understand how the pylon software works to configure these parameters then I can implement that algorithm on LabVIEW.

 

 

Message 4 of 14
(8,449 Views)

It might be good to understand what your needs are. Do you need to configure all settings dynamically or just one or two? How fast do you need to control these settings? What OS will the system run, Windows?

 

CameraLink uses a standard serial UART connection over the wire between the camera and framegrabber. The protocol itself is camera-specific. There is an CameraLink-defined software plugin layer (clallserial) that lets software from the camera vendor (Pylon) see and configure the camera using a 3rd-party frame grabber (NI) from within the camera vendor's software. The 4 CC lines are just digital I/O's that go between the framegrabber and camera and are not used for configuration. However, they can be often used by cameras for triggering or exposure time control.

 

Additionally, some framegrabbers (like NI's PCIe-1433 and others) have a system of camera files (or similar) that give them some knowledge of some set of features on the camera and how to interface with them over the serial port. The IMAQ driver ships with a set of these that includes many current Basler cameras.

 

However, the 1483 card is a specialized FPGA-interfaced framegrabber that does not use the IMAQ driver. Thus it has no camera file mechanism.

 

Some possible options you could try are:

- Write serial port commands (see Basler manual) directly from the FPGA code (could be used for very tight control loops)

- Leverage serial port infrastructure in examples to interface with serial port from host-side code (still need to consult Basler manual for commands)

- Interface with Pylon via its .NET interface in LabVIEW

 

Eric

Message 5 of 14
(8,444 Views)

Hi eric, thanks for the reply

 

I will configure the settings to freeze the setup position (to capture the proper image) after that I will change the settings rarely.

 

I think third possible option can work & other than this I have to talk technical support of basler.

 

Regards

Rahul

0 Kudos
Message 6 of 14
(8,412 Views)

I ran into multiple issues with the Serial Server running through the 1483/7966.  I was never able to reliably get the serial server to operate through the MAX NI Vision CLSerNat function.  It seems the 1483 is just not well supported in Max in any way.  This prevents the use of Pylon as your serial command/status tool.  Those work great with other frame grabbers like the 1433, but the 1483 leaves you having to implement the entire capability yourself.

 

So, I wound up having to write my own serial driver for the BBPI protocol and message processors for the various standard message types the Basler ACE cameras respond to.

 

Though I can't provide code, if you need to write your own protocol stack and have questions on the Basler interface, I'm worked through many of the issues.

 

One issue you may encounter is with the serial server itself.  It operates in byte mode.  I was never able to understand the reasons, but between a VI running on a host PC interacting through the stock serial server running on an FPGA (7966) through a RT target (PXI-1082) byte mode inserted very large inter-character delays.  Often so large as to cause the Basler camera to claim a timeout and terminate the command.  I had to modify the serial server to operate in a one-shot FIFO mode for transmit data as follows:

 

In the FPGA serial_interface.vi (For non byte-mode)

 

  • Increase the FIFO to 64 bytes to accomodate the largest Basler message
  • Add a "Transmit now" control to trigger a full FIFO output
  • Add a "Transmit length" control to control the number of bytes transmitted

 

In the upper level serial_server.vi

 

  • Modify the transmit loops to better detect bytes to transmit from the Ethernet interface and to direct the transmit data to the new WriteBytes vi

 

In the FPGA_UART.llb library

 

  • Add an FPGA_UART_WriteBytes.vi to handle the non byte-mode modification and to 'chunk' up transmit data into 64 byte (max) pieces.  In the BBPI and Basler protocols, this has not been seen since all the messages are small.

With these modifications, I could then write a state machine to handle the basler BBPI protocol.  States I chose for this were:

 

  • Idle
    • When a command is queued, it is fed to the serial server in its entirety.  The serial interface sends it to the camera as a complete message with no inter-character gaps)
  • Wait for ACK
    • Every command must have an ACK/NACK
    • Go back to idle if sending a write or command message
  • Wait for BFS (Only if sending a read request)
  • Wait for FTF
  • Wait for the data lengthbyte
  • Wait for BFE (Goes back to idle once all bytes received)

It's up to you if you want to handle the checksum capability of the BBPI protocol.  It's surprisingly tricky.  I hsould have saved myself the headache and just worked entirely in non-checksumming mode.

 

Once I got that all working, I could then write message handlers for each of the basic Basler message types:

 

Enum

String

Bitfield

Scalar

etc..

 

followed by specific message handlers for each of the messages I wanted to deal with.  My usual technique is to perform a mass serial configuration as soon as I fire up the FPGA.  I haven't tried to use the trigger port signals (CC1 etc) but those can all be configured and controlled through the serial port once you get a message passing capability in place.

Message 7 of 14
(8,398 Views)
Hi xl600,

Thanks for the very informative post! I can elaborate on a few things:
-clsernat is not used for the 1483/serial server. We have a separate DLL called clsernif instead. It might be possible there are installation issues preventing it from being found (especially if you need a 64-bit version - I'm not sure if that is currently installed)
-We have only ever tested the serial server connected through localhost loopback (in fact, clsernif currently hardcodes this, so you can't use it today to an RT target). In local mode it does work well with Pylon-configured Basler cameras. It does seem like their could be some timing issues we never noticed when run over the network.
-You may have already noticed this, but the 1483 is definitely intended for a differnt type of user than the 1433. It is more geared today to the user that just wants raw access to the cameralink protocol on the FPGA as opposed to a high-level framegrabber
0 Kudos
Message 8 of 14
(8,391 Views)

I certainly have noticed that Smiley Wink

 

The major issue with the clsernif is the hardcoding of localhost.  So the only way to get things to work would be to host the serial server on my Wondows host.  I tried that but couldn't get it to work (Perhaps there's an installation issue... I don't know).  When I scoped the serial output when trying to use Pylon like that, that's where I saw the large delays  Certainly, there should have been some sort of indication that things weren't working correctly if clsernif was not found (There's no mention of how that works in any documentation).

 

Regardless, I did wind up writing my own protocol drivers since I have to use the 1483.  My frame grabber needs require some very specific high speed capabilities that the 1433/1435 can't provide.  It'll be a more flexible design as a result since I don't have to integrate Pylon.  I can do everything from a vi and just fire up the correct FPGA and host VI pair to kick off ny tests.

0 Kudos
Message 9 of 14
(8,386 Views)

Hi xl600,

 

Thanks for the very useful information. Definitely I will require your help to modify the code accoding to my application. I am using 1-Tap 8-Bit Camera with Centroid.lvproj example for the reference. I have Basler ACE 340 km NIR camera for my application. I have listed my doubt below regarding communication with the camera:

 

1. If you have any document for the Basler Protocol then please share it. It will be very helpful for me to understand the BBPL protocol working.

 

2. What is the baud rate I should use to communicate with the camera?

 

3. As you mentioned to increase the FIFO size to 64 bytes on FPGA serial interface.vi. I did not find any FIFO on serial interface.vi

 

4. As I want to configure the parameters of camera like gain value, exposure time, binning etc. What are the commands should be use to configure these parameters & how to send these cmds through UART.Tx Data array.

 

Please share any other document which is helpful to configure these parameters of camera. 

0 Kudos
Message 10 of 14
(8,274 Views)