Camera Reference/Guide

Fall 2023

You are not logged in.

Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.

Reference Links

Intro to OV5640

The OV5640 sensor is a camera capable of capturing

Register-setting Communication

The behavior of the OV5640 is determined by its settings registers, which can be set externally via the SCCB protocol. SCCB is a near clone of the more common I2C protocol; a module you've built to communicate over I2C will very likely also work over SCCB. However, there are a few differences worth noting:

  • The "ACK" bit of I2C is replaced with a "Dont-Care" bit--peripheral devices on SCCB may or may not acknowledge each byte sent. However, it seems like typically the OV5640 does anyway.CITATION NEEDED
  • The SCCB protocol only allows one to write one byte of data at a time; following the addressing of the peripheral device and the addressing of the relevant register, only one "write" byte is permitted.
  • For the OV5640 specifically, the address of each register is 2 bytes long, transmitted as 2 data frames, for the high byte and low byte of the address.

The default (7-bit) address of the OV5640 is 0x3C. Below is an example of a transmission writing to an OV5640 register, specifically writing to the 0x503D register which controls the test pattern generator, and setting it to 0xC0 which enables a rolling color-bar test pattern (OmniVision Datasheet, page 43).

Example SCCB bus assertions made by a controller to the OV5640. The mid-range lines between 0 and 1 indicate high-impedance, when the line will be pulled up unless a peripheral device asserts a 0 value, such as the optional acknowledge bit. The clock speed of SCL is 100kHz, much slower than a typical FPGA clock.

Register Sequence for startup

In order to turn the camera on and get it to start capturing image data, many registers need to be set to values. Most of them can be found and learned about in the datasheet, but a few registers must be set beyond what the datasheet specifies. This has been implemented in a couple microcontroller libraries to get reasonable quality images out of the sensors. (esp32-camera for ESP32, adafruit_ov5640 for others using CircuitPython). I've created a python script which emulates these libraries and builds a list of register writes to issue over SCCB to get the camera up and running, with some modifications to make the settings fit the FPGA use case better. It'll provide you with a BRAM that stores a sequence of (16-bit) register addresses and (8-bit) write values, which can be sent to the camera via your SCCB (I2C) module.

Image Data Transmission

There are two protocols the camera can use, the MIPI-CSI2 protocol and the DVP (Digital Video Port) "protocol". MIPI CSI-2 is an industry standard protocol with a licensing feeCITATION NEEDED that transmits data at high speeds with a differential seralized signal (not unlike HDMI). DVP is not really a properly published protocol with a specification, but is described in the OV5640 datasheet--it has lower throughput, but transmits image data bytes in an easy to process parallel format. It uses 8 wires to send a full byte in parallel, alongside a clock signal, an HSYNC and a VSYNC signal. More details about the signal format are included in the Camera DVP lab.

Wiring connection to FPGA

Kiran's Open Questions/Todos

  • Does does the OV5640 reliably ACK, even if SCCB doesn't require it?
  • Build a YAML system for the startup_bytes script (rename from whatever mess it is named now)
  • Put the polished startup_bytes script on here