Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Control exposure time and gain with FPGA as frame grabber

Hi,

I'm using a Basler acA2000 340kc camera with a PCIe1473R FPGA as frame grabber.

I managed to obtain images succesfully by modifying some of the sample codes. I can also control some of the camera settings thorugh the Pylon software.

 

Nevertheless, I'd like to control the exposure time and gain in   LabView.

Any idea on how to do this?

Thanks

0 Kudos
Message 1 of 12
(6,366 Views)

For this scenario, you would have to consult Basler's camera manual for the details of the serial protocol needed to construct the command to change the feature. Then you would modify the FPGA and host code to let you send a serial command to the camera.

 

You could also take a look at the IMAQ camera file for this camera:

ftp://ftp.ni.com/support/imaq/camera_support/camera_files/digital/basler/Basler%20acA2000-340km.icd

as it has functionality to modify the exposure time and gain for the standard IMAQ framegrabbers (non LabVIEW-FPGA-based). There are some pretty simple lines in there that you could look at to see how the driver programs those values in.

 

Eric

0 Kudos
Message 2 of 12
(6,354 Views)

Sorry,

I think I didn't explained myself properly.

We would like to be able to control gain and exposure time at real time through some control in LabView.

Do we have to program something on the FPGA for this or can we do it directly in the host code?

Thank you.

0 Kudos
Message 3 of 12
(6,349 Views)

Ultimate the serial port on the board is controlled by the code on the FPGA. There are shipping examples that provide the FPGA-side implementation of interfacing the serial port to a host-side interface, which then bridges it to a TCP port, which is bridged to a DLL called "clsernif.dll", which interfaces through the common "clallserial.dll" that Pylon can use to access the camera.

 

Depending on your needs, you could interface at any of these layers.

-If you need to do this with the ultimate in determinism, you could have the FPGA issue these serial commands directly as needed

-If can do it from the host CPU, you could modify the host-side code and send/receive serial traffic to the FPGA code directly

-You could examine the example code that bridges to a TCP port and simple write some host VIs that talk directly to it by opening a TCP session to the socket it uses.


Eric

0 Kudos
Message 4 of 12
(6,346 Views)

Hi, thanks for your help,

Is there some specific example that you could point us to about either using the host-side code or the one bridging to a TCP port?

Thanks a lot

0 Kudos
Message 5 of 12
(6,342 Views)

Take a look at the code installed here:

C:\Program Files (x86)\National Instruments\LabVIEW 2013\examples\Vision-RIO\Common\Serial

 

The SerialServer.vi is the example code that is included in all the examples. It basically connects the TX/RX UART controls to a TCP socket and bridges them (so traffic sent by TCP is sent out the serial port, and received serial data is sent back out via TCP). There is also some command sequence via an escape character to allow commands like changing baud rate to be done. You could simply start this code and then connect to it with the standard TCP VIs in LabVIEW and send/receive traffic over the serial port.

 

 

 

0 Kudos
Message 6 of 12
(6,340 Views)

Thanks, 

 

When going through the example code, we keep seeing a fucntion FPGA_UART_ChangeeBaudeRate, we want to write a similar function for change exposure time, but we don't know how to start to write a UART function because in the code it seems like they reference the function without ever having actually writing it. I'm sure it's there somewhere but we just can't seem to find it, so can you please tell us how to a) write a UART function? b) show us the source code for the FPGA_UART_ChangeBaudeRate?

0 Kudos
Message 7 of 12
(6,338 Views)

That VI is in the LLB included in that folder. The Baud rate stuff is "special" because it isn't a command to the camera, but rather a command to the serial UART on the FPGA. If you don't need to dynamically change the baud rate programatically, you can probably not worry about it.


Eric

0 Kudos
Message 8 of 12
(6,334 Views)

Ok, thanks for clarifying that point.

We don't want to change baudrate, so we just want to know how that function works in order to do something similar with the gain and exposure time.

I think we just want to comunicate with the camera (the way Pylon does).

Do we have just to modify with this the host code, or do we need to create separate VI in the same way it's done with the baud rate?

 

Can we use the IMAQ set atributes VI for that??

0 Kudos
Message 9 of 12
(6,332 Views)

The IMAQ API is only used with traditional IMAQ framegrabbers, like the PCIe-1433. The PCIe-1473R is an entirely different architecture in terms of how you program and access it, as it essentially just exposes the raw FPGA functionality through LabVIEW FPGA. It is designed to be much more low-level and requires user code to do many things the non-FPGA boards do automatically. It generally has a much higher required level of comfort with digging into the guts of how the example code works if you want to use it, unfortunately....

 

I would probably suggest just digging into the SerialServer code and seeing how it interfaces with the UART code running on the FPGA. You could then write your own VI to do this interaction instead of the server. That may be the simplest way I can suggest.


Eric

0 Kudos
Message 10 of 12
(6,328 Views)