Manual Exposure for OV2640

Overview

ArduCAM all given examples are using auto exposure for easy use of the camera. But somethings user want to control the exposure more precisely. This article will cover how to do manually exposure for OV2640 camera.

How does Rolling Shutter Sensor Exposure

All rolling shutter image sensors including OV2640 are doing exposure by line basis. They do exposure line by line, so all pixels in a line are exposed at the same time, but different pixels from different line are exposed at different time.

In this case, the minimum exposure time is 1 Line Time, and the maximum exposure time is one Frame time. Basically it equals to total vertical resolution times 1 Line Time, but sometimes there are one or more dummy lines added to the frame.

The OV2640 Timing

The following figure is the OV2640 UXGA (1600 x 1200) resolution timing diagram.

1 Line is composed by 1600 pixels and 322 clock horizontal blanking, Tline = 1922 pclk in total.

1 Frame is composed by 1248 lines including the active 1200 lines and 4 lines + 44 lines of vertical blanking.

Given the pixel clock is 36MHz by default, the 1 Line time is 53.39us. The calculated frame time is 66.63ms. So the minimum exposure time is 53.39us and maximum exposure time is 66.63ms if no additional dummy pixels and dummy lines added.

How to Set Manual Exposure with OV2640

In order to enable OV2640 manual exposure, we have to disable the AEC bit from register 0x13 in the register Bank 1. Don’t forget to switch to the register Bank 1 by writing 0x01 to 0xFF register.

The exposure register is spreaded in 3 registers 0x45, 0x10, 0x04 in the register Bank 1. Write correct value in line basis to these register will change the exposure of the target images.

More Control Over the Exposure

The maximum exposure time is limited by the Frame time. If we want to over exposure of a image when at night, we have three other ways to do it.

  • Change the Pixel Clock

Write 0x11 register in the register Bank 1 will adjust the pixel clock speed, and in turn change the Line time accordingly.

  • Add dummy pixels to a line

Write 0x2A and 0x2B register in the register Bank 1 will add dummy pixels to a Line, and in turn change the Line time accordingly.

  • Add dummy lines to a frame

Write 0x2D and 0x2E register in the register Bank 1 will add dummy Lines, and in turn change the Frame time accordingly.

Testing Result

Here we set different exposure value to AEC register at the same light enviroment. The exposure values are 200, 400, 800, 1024 which is in lines basis, and corresponding  to 10.7ms, 21.4ms, 42.7ms and 54.7ms.

 

Frequent Asked Questions

Q: Where can I order camera modules and ArduCAM shield?

A: Please order from our distributor www.uctronics.com

Q: Where can I find the source code and schematic of ArduCAM shield?

A: Please download source code from Download section, schematic can be found Rev.C and Rev.B.

Q: What kind of Arduino boards will be support?

A: The ArduCAM shield Rev.C support all families of Arduino boards including DUE. It has been tested on the following Arduino boards:

Index
Arduino Boards
1 UNO R3
2 MEGA2560 R3
3 Leonardo R3
4 Nano
5 DUE

Q: What is the max resolution will be support?

A: The resolution is depend on the max frame buffer size. Now the ArduCAM has build in 3Mbit FiFo, it support following resolution:

Width Height Format
320 240 RGB565,YUV
600 320 RGB565,YUV
640 600 RGB Raw, Mono 8bit
1600 1200 JPEG
1920 1080 JPEG

 

Q: What kind of camera modules does ArduCAM support?

A: The following list shows the support of camera modules, we will add support for more camera modules in the future.

Resolution Camera modules Part No. Support
0.3MP OV7670, OV7675 Yes
1.3MP OV9650,OV9655 No
1.3MP MT9M111,MT9M112,MT9M001 No
2MP OV2640,MT9D111 Yes
2MP MT9D112 No
3MP OV3640 Yes
3MP MT9T112 No
5MP OV5642 Yes
5MP MT9P013 No
10MP MT9J001 No

 

Q: Can I connect OV7670 directly to Arduino board without ArduCAM shield?

A: The OV7670 data speed is about 6MHz~24MHz, the Arduino board is too slow to catch up with the camera data stream’s speed. So user has to use extra hardware like ArduCAM shield to buffer a full frame, then read out the image byte by byte with fairly low speed.

 

Q: How can I customize settings on it using register values (brightness, exposure, speed)?

Yes, we can help you with the brightness, speed , exposure level settings

A: Please contact us for the customized settings.

 

Q: My lab is interested in building large numbers of x-ray detectors using consumer-grade CMOS

sensors. Do you have some kind of camera modules for that?

 

A: Yes, the MT9M001 module is monochrome image sensor which is used in Xbox360 and suitable for image processing.

 

Q: I’m working on a project where I need to trigger 15 digital photo cameras simultaneously.

Is it possible to daisy chain these camera shields to trigger multiple cameras?

A: It is no problems to trigger multi-cameras in parallel or daisy chain. There is external trigger input in ArduCAM shield, user can connect them together and trigger them simultaneously.

 

Q: How can I make the LCD display brighter.

A: The LCD back light is controlled by R6 and RN7.You can reduce the value of these two resistors to make the backlight much brighter.