This page describle the basic control over the sensor registers using Arducam camera breakout board, it might not be able to cover all the detail register operations, but give you an insight how to adjust these settings.
Sensor I2C Slave Address
The MT9P031 camera I2C 8-bit slave address is fixed to 0x90. With 8bit regsiter address, and 16bit register value.
There is a ” model_id ” register (0x00) which can help diagnose if the I2C bus is accessable and distinguish the camera models.
|Camera Model||model_id register ( 0x00 )|
You need a basic settings to bring up the sensor and make it working in normal streaming mode. Here is the sample config for the Window GUI.
|MT9P031_2592*1944 ( Color )|| MT9P031_2592x1944.cfg|
Manual Exposure Control
The nominal exposure time, t EXP, is the effective shutter time in ERS modes, and is defined by the shutter width, SW, and the shutter overhead, SO, which includes the effect of Shutter_Delay. Exposure time for other modes is defined relative to this time. Increasing Shutter_Delay (SD) decreases the exposure time. Exposure times are typically specified in units of row time, although it is possible to fine-tune exposures in units of t ACLKs (where t ACLK is 2 * t PIXCLK).
t EXP = SW × t ROW – SO × 2 × t PIXCLK
SW = max(1, (2 * 16 × Shutter_Width_Upper) + Shutter_Width_Lower)
SO = 208 × (Row_Bin + 1) + 98 + min(SD, SDmax) – 94
SD = Shutter_Delay + 1
SDmax = 1232; if SW < 3 1504,
otherwise The exposure time is calculated by determining the reset time of each pixel row (with time 0 being the start of the first row time), and subtracting it from the sample time. Under normal conditions in ERS modes, every pixel should end up with the same exposure time. In global shutter release modes, or in row binning modes, the exposure times of individual pixels can vary.
|R0x008||15:0||Shutter Width Upper (RW) |
The most significant bits of the shutter width, which are combined with Shutter_Width_Lower (R9).
|R0x009||15:0||Shutter Width Lower (RW)|
The least significant bits of the shutter width. This is combined with Shutter_Width_Upper and Shutter_Delay
for the effective shutter width. If set to zero, a value of “1” will be used.
RegAddr = 0x009, Value = 0x0E5
RegAddr = 0x009, Value = 0x1E5
RegAddr = 0x009, Value = 0x2E5
Manual Gain Control
Gain settings are like the ISO settings in most digital cameras. The gain is divided into analog and digital gain, and there are separate gain settings for four color-specific gains. There is also global gain setting to change all the four color-specific gains.
|R0x035||15:0||Global Gain (WO)|
Here we demonstrate how to change the gain through the Global Gain register (0x035).
RegAddr = 0x035, Value = 0x0018
RegAddr = 0x035, Value = 0x1018
RegAddr = 0x035, Value = 0x2018
White Balance Control
The MT9P031 sensor output is RAW bayer format, each RGB channel gain is controlled by corresponding gain regsiter.
There are 5 registers related to color gain settings which can be used for control white balance.
|R0x02B||15:0||Green1 Gain (RW)|
|R0x02C||15:0||Blue Gain (RW)|
|R0x02D||15:0||Red Gain (RW)|
|R0x02E||15:0||Green2 Gain (RW)|
|R0x035||15:0||Global Gain (WO)|
The global gain is used to set all color gain value at one time. The other 4 registers control GR, R, B, GB respectively.
Tips: GR, GB should be set equally, and Red, Blue gain can be set higher than GR/GB gain to get better color represent. Automatic software whtie balance is also possible with proper AWB algorithm to set these gain settings automatically.