SK91USB3-WIN  5.5.0
Functions
Gain / Offset

Explanations about gain and offset control. More...

Functions

int SK_SETGAIN (int CamID, int gain, int channel)
 Gain control. More...
 
int SK_SETOFFSET (int CamID, int offset, int channel)
 Offset control. More...
 
int SK_SETGAINCOUPLING (int CamID, int enable)
 Coupling of gain channels. More...
 
int SK_GETGAIN (int CamID, int channel)
 Returns the current gain value of a ADC channel. More...
 
int SK_GETOFFSET (int CamID, int channel)
 Returns the current offset value (black level) for the defined ADC channel. More...
 
int SK_GETNROFCHANNELS (int CamID)
 Returns the camera specific number of ADC channels. More...
 

Detailed Description

Explanations about gain and offset control.

The line scan camera is provided with correctly adjusted gain / offset. Only if necessary, these settings should be changed. This must be done carefully.

The number of channels for gain and offset is sensor specific and depends on the number of ADCs inside of the camera. The number of channels is returned by the function SK_GETNROFCHANNELS. The setting range for gain is 0 to 1023 (0 db to 24 db), the offset setting range is 0 to 255.
Note: Too low gain values (< 80) can reduce the signal dynamic by limiting the input range of the ADC. Very high gain values increase the noise.

Re-Adjustment principle

Normally, to re-adjust the gain / offset setting use the SKLineScan program with the manual for SKLineScan.
If this is not possible, here is an example to display the oscilloscope signal with the library OpenCV:

1. Offset (using the SK2048U3PD)
The zero baselines of the video signal 1 and 2 must be adjusted and balanced. To do this, totally block the incident light and execute the function SK_SETOFFSET(m_CamID, 0, 0) and SK_SETOFFSET(m_CamID, 1, 0).
Minimize any differences using the function SK_SETOFFSET.
A slight signal noise should be visible in the zero baseline.

Adjust_Offset.png

2. Gain (using SK2048U3PD)

Illuminate the sensor with a slight over exposure to identify the maximum clipping. Use the function SK_SETGAIN(m_CamID, 0, XX) (XX = gain value) to adjust the maximum output voltage for the first channel. Adjust the signal intensity with the function SK_SETGAIN(m_CamID, 1, XX) (XX = gain value) to minimize the difference between channels 0 and 1.

Notes for gain adjustment:

Adjust_Gain_1.png
Adjust_Gain_2.png

Function Documentation

◆ SK_GETGAIN()

int SK_GETGAIN ( int  CamID,
int  channel 
)

Returns the current gain value of a ADC channel.

Remarks
The number of ADC channels is camera specific and can be inquire by SK_GETNROFCHANNELS.
Parameters
CamIDid of camera from 0 ... n - 1, 0 = 1st camera
channelADC channel
Returns
gain value, else see Error Code Table

◆ SK_GETNROFCHANNELS()

int SK_GETNROFCHANNELS ( int  CamID)

Returns the camera specific number of ADC channels.

Parameters
CamIDid of camera from 0 ... n - 1, 0 = 1st camera
Returns
number of ADC channels, else see Error Code Table

◆ SK_GETOFFSET()

int SK_GETOFFSET ( int  CamID,
int  channel 
)

Returns the current offset value (black level) for the defined ADC channel.

Remarks
The number of ADC channels is camera specific and can be inquire by SK_GETNROFCHANNELS.
Parameters
CamIDid of camera from 0 ... n - 1, 0 = 1st camera
channelADC channel
Returns
offset value, else see Error Code Table

◆ SK_SETGAIN()

int SK_SETGAIN ( int  CamID,
int  gain,
int  channel 
)

Gain control.

This function sets the gain value for the defined ADC channel.

The number of ADC channels is camera specific and can be inquire by SK_GETNROFCHANNELS or the camera manual.

Note
Range of values: 0 ... 1023, 1023 = 24 dB
Parameters
CamIDid of camera from 0 ... n - 1, 0 = 1st camera
gaingain value
channelADC Channel
Returns
SK_RESULT_OK on success, else see Error Code Table

◆ SK_SETGAINCOUPLING()

int SK_SETGAINCOUPLING ( int  CamID,
int  enable 
)

Coupling of gain channels.

This function is suitable for cameras with more than one ADC channel. Once adjusted, all gain channels can be coupled and will be controlled together by channel 0 only. The differences between the channels before coupling are changed proportionally.

Remarks
Together with SK_NOSAVINGEEPROM with enable = false this function is usable for a very fast changes of gain adjustment. While Continuous Grabbing all parameter settings are blocked normally. A backdoor for gain setting between two frames is SK_SETCOMMAND(CamID, "Gnnnn", NULL, 1), wherein all gain channels should be coupled.
Calculation of proportional changing of gain channel differences inside the camera: before coupling: gain channel 0: G0= 108, gain channel 1: G1= 110
new gain G' with coupled channels
camera revision < 1.22: G0'= 212, G1'= G0' + (G1 - G0) = 214
camera revision >= 1.22: G0'= 212, G1'= G0' * G1/G0 = 216
Parameters
CamIDid of camera from 0 ... n - 1, 0 = 1st camera
enable1 = gain coupling is active
0 = gain coupling is not active
Returns
SK_RESULT_OK on success, else see Error Code Table

◆ SK_SETOFFSET()

int SK_SETOFFSET ( int  CamID,
int  offset,
int  channel 
)

Offset control.

This function sets the offset value for the defined ADC channel.

The number of ADC channels is camera specific and can be inquire by SK_GETNROFCHANNELS or the camera manual.

Note
Range of values: 0 ... 255
Parameters
CamIDid of camera from 0 ... n - 1, 0 = 1st camera
offsetOffset value
channelADC channel
Returns
SK_RESULT_OK on success, else see Error Code Table