Need help with ov5640 exposure timing

davecazz
Posts: 1
Joined: Tue Apr 18, 2023 7:57 pm

Need help with ov5640 exposure timing

Postby davecazz » Tue Apr 18, 2023 8:37 pm

Hello, I am trying to debug an issue with how exposure works for my application.

in order to gather information and better understand how the camera timings work. I’m trying to calculate the actual time of exposure and math just doesn’t seem to line up with real world measurements.

my registers are set as follows

AEC is in auto mode - reg 0x3503 = 0x00
actual exposure value - reg 0x3500 - 0x3502 = 0x3750 (highest exposure under poor lighting)
total horizontal width - reg 0x380c - 0x380d = 0x080c (2060)
binning is on - reg 0x3821 = 0x07
pixel clock is 8,000,000 - reg 0x3034 = 0x1a
the final output resolution of the camera is low = 96x96. mainly being used for ML.

here is information about our clock settings

XVCLK: 16,000,000 Hz, - provided by esp32
REFIN: 16,000,000 Hz, - input to pll
VCO: 320,000,000 Hz, - voltage controlled oscillator, part of the pll
PLL_CLK: 128,000,000 Hz, - pll output frequency
SYSCLK: 32,000,000 Hz, - camera system clock
PCLK: 8,000,000 Hz - pixel clock

raw timing registers
0x3000: 0x20, 0x3001: 0x08, 0x3002: 0x1C, 0x3003: 0x00, 0x3004: 0xFF, 0x3005: 0xF7, 0x3006: 0xC3, 0x3007: 0xFF, 0x3008: 0x02, 0x3009: 0x01, 0x300a: 0x56, 0x300b: 0x40, 0x300c: 0x22, 0x300d: 0x00, 0x300e: 0x58, 0x300f: 0x00, 0x3010: 0x00, 0x3011: 0x00, 0x3012: 0x00, 0x3013: 0x00, 0x3014: 0x00, 0x3015: 0x07, 0x3016: 0x00, 0x3017: 0xFF, 0x3018: 0xFF, 0x3019: 0xF0, 0x301a: 0x00, 0x301b: 0x00, 0x301c: 0x00, 0x301d: 0x00, 0x301e: 0x00, 0x301f: 0x00, 0x3020: 0x00, 0x3021: 0x00, 0x3022: 0x00, 0x3023: 0x00, 0x3024: 0x00, 0x3025: 0x00, 0x3026: 0x00, 0x3027: 0x00, 0x3028: 0x00, 0x3029: 0x00, 0x302a: 0xB0, 0x302b: 0x00, 0x302c: 0xC3, 0x302d: 0x10, 0x302e: 0x00, 0x302f: 0x02, 0x3030: 0x0B, 0x3031: 0x00, 0x3032: 0x00, 0x3033: 0x03, 0x3034: 0x1A, 0x3035: 0x11, 0x3036: 0x14, 0x3037: 0x01, 0x3038: 0x00, 0x3039: 0x00, 0x303a: 0x00, 0x303b: 0x19, 0x303c: 0x11, 0x303d: 0x30

the equation for calculating actual time during exposure should be as follows
Exposure time = exposure value (regs 0x3500-02) * total horizontal size (0x380c-0d) / pixel clock (in our case it’s 8,000,000 hz).

exposure = 0x3750 (14160) = 885 scanlines
total width = 2060
pixel clock = 8,000,000
scanline time = 0.0002575 seconds = 0.2575 ms
exposure time = 227.8 ms = 4 frames per second

when I calculate the actual camera fps using an external timing strobe I get 16hz. Which is much higher than the 4 frames per second I calculated using the equation above.

Do you know if there is something missing here? Could it be possible that exposure could possibly be longer than the time it takes to capture an actual frame?
how does binning affect timing (with binning on, is the timing for each scanline actually 2060 / 2)?

Second question was I was considering using FREX global reset to capture the entire frame. If I trigger FREX from an i2c register (0x3b08) do you know if it needs an external shutter to work? Or if the shutter built into the ov5640 itself is used?

FBMinis
Posts: 15
Joined: Sun Jan 17, 2021 1:08 pm

Re: Need help with ov5640 exposure timing

Postby FBMinis » Fri Feb 02, 2024 3:05 pm

Did you develop your application any further? I'm trying to understand how to control exposure time in order to use the OV2640 in dark conditions

Who is online

Users browsing this forum: No registered users and 25 guests