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 OV5642 camera I2C 8-bit slave address is fixed to 0x78. With 16bit regsiter address, and 8bit register value.
There is two product ID register (0x300A and 0x300B) which can help diagnose if the I2C bus is accessable and determine the camera models.
|Product ID Register||Value|
You need a basic settings to bring up the sensor and make it working in normal streaming mode.
The OV5642 is a SOC sensor, which support auto white balance, auto exposure and auto gain. Sometimes you might need to disable these auto functions to set manual control.
|VTS||0x3503 Bit: VTS manual |
1: Manual, 0: Auto
|AEC||0x3503 Bit = exposure control|
1: Manual, 0: Auto
|AGC||0x3503 Bit: AGC auto/manual control selection |
1: Manual 0: Auto
Manual Exposure Control
Once the AE is disabled, the exposure time is adjustable manually.
|0x3500||Long Channel Exposure Output Bit[3:0]: Exposure[19:16]|
|0x3501||Long Channel Exposure Output Bit[7:0]: Exposure[15:8]|
|0x3502||Long Channel Exposure Output Bit[7:0]: Exposure[7:0]|
To manually change exposure value, you must first set both 0x3503 and 0x3503, where 0x3503 enables manual exposure control and 0x3503 enables manual frame length – the number of lines in each frame or maximum exposure time, which is defined by registers 0x350C and 0x350D. In auto exposure mode, the maximum exposure values in registers 0x350C/0x350D automatically change. In manual exposure mode, these registers will not automatically change. The manually set exposure in registers 0x3500~0x03502 must be less than the maximum exposure value in 0x350C/0x350D. The exposure value in registers 0x3500~0x3502 is in units of line*16 – the low 4 bits (0x3502[3:0]) is the fraction of line, the maximum value in 0x350C/0x350D is in unit of line. If the manually set exposure value is less than one pre-defined frame period (e.g., 1/15 second in 15fps), there is no need to change 0x350C/0x350D. If the exposure value needs to be set beyond the pre-defined frame period; in another words, if the frame period needs to be extended to extend exposure time, then the maximum frame value in 0x350C/0x350D needs to be set first, then the exposure can be set in registers 0x3500~0x3502 accordingly.
Manual Gain Control
To manually change gain, first set register bit 0x3503 to enable manual control, then change the values in 0x350A/0x350B for the manual gain. The OV5642 has a maximum of 64x gain.
|0x350A||Gain Output to Sensor Bit: Gain high bit|
|0x350B||Gain Output to Sensor Bit[7:0]: Gain low bits|
JPEG Compression Ratio
OV5642 JPEG quality is adjustable through the quantization scale register.
|0x4407||Bit[5:0]: QS Quantization scale|