set gain ceiling

Dear all,

I try to understand how works the gain in the OV7725 camera, and i stopped on the gain ceiling.

To set the gain ceiling there is 2 ways in python :

  • sensor.set_gainceiling(4)
  • sensor.set_auto_gain(True, gain_db_ceiling=4)
    which both write at the COM9 register but the c language codes do it in 2 different ways.

Here is the test code :

import sensor
sensor.reset()                      # Reset and initialize the sensor.
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 500)
sensor.set_gainceiling(4)
print("set_gainceiling : ", hex(sensor.__read_reg(0x14)))
sensor.set_auto_gain(True, gain_db_ceiling= 4)
print("set_auto_gain : ", hex(sensor.__read_reg(0x14)))

The result for 4db is ;

  • set_gainceiling : 0x11 (this is right)
  • set_auto_gain : 0x1 (this is not right)

Do i miss something ?
Thanks

set_gainceiling takes multipliers not db. So 4 means 4x the value is the max gain.

well, i see

  • set_gainceiling : 2, 4, 8, 16 or 32 for x2, x4, x8, x16 or x32
  • set_auto_gain : 2 to 32db

But i dont still understand teh relationship between gain and register ?
Thanks,

I think it’s explained some where in an appnote.

The ceiling is how much the auto algorithm goes up too.