Study notes-STM32 camera OV7725 (1)

Introduction to OV7725
Among all kinds of information, images contain the most abundant information. As a core component in the field of machine vision, cameras are widely used in security, exploration, and license plate detection. It can be divided into digital and analog cameras according to the type of output signal, and can be divided into CCD and CMOS according to the material composition.

The photosensitive device of the analog camera is generally maintained at around 752(H)*582(V) pixel index.

Since the pixels of the CCD are composed of MOS capacitors, it is necessary to use a two-phase/three-phase/four-phase timing pulse signal with a relatively large voltage (at least 2V) to read the charge signal to effectively transfer the charge. Therefore, in addition to multiple power supplies for the CCD imaging system, its peripherals also consume considerable power. The CMOS photoelectric sensor only needs to use a single power supply of 5V/3V, which consumes very little power. It is only 1/8~1/10 of CCD, and some CMOS imaging systems only consume 20-50mW of power.

CCD sensor device production technology started early, using PN to form the SIO2 isolation layer, so it has low noise and good imaging. Compared with CCD, CMOS has the disadvantages of high noise and low sensitivity. However, with the continuous development of CMOS circuit noise reduction technology, it provides good conditions for the production of high-density and high-quality CMOS sensor devices. Nowadays CMOS sensors have occupied most of the market, and mainstream SLR cameras and smart phones have become common. Adopt CMOS sensor.

The next thing I learned is the Binghuo OV7725 produced by Wildfire. This is a CMOS camera with a resolution of 300,000 pixels. It consists of a lens, an image sensor, an on-board circuit and a signal pin below.

A lens assembly comprising a lens holder and rotatably adjustable distance lens, the focal length can be adjusted by rotating, timing
when normally used, the lens holder light-shielding cover on the circuit board, only the light transmitted through the lens to the center of the image sensor, which
capture Light signal, the collected data is buffered in the FIFO buffer on the back of the camera, and then the external device
obtains the captured image data through the signal pin below .
If we disassemble the camera base, we can see a square device on the PCB board directly below the camera. It is the
core component of the camera , the model is OV7725 CMOS type digital image sensor. The sensor supports a maximum output of 300,000
pixels of the image (640x480 resolution), its small size, low operating voltage, supports VGA timing output data image
data, output image data format supported YUV (422/420), YCbCr422 and RGB565 format. It can also
compensate the captured images and support basic processing such as gamma curve, white balance, saturation, and chroma.

The chip schematic diagram of OV7725 is as follows:
Insert picture description here

RSTB System reset pin, active low
PWDN Power-down power saving mode (active high)
HREF Line sync signal
VSYNC Field sync signal
PCLK Pixel clock
XCLK System clock input port
SCL Clock line of SCCB bus
SDA Data line of SCCB bus
D0~D9 Pixel data port

The functional block diagram of OV7725 is as follows: It is divided into four parts in total
Insert picture description here

(1) Control register

标号1处的是 OV7725 的控制寄存器,它根据这些寄存器配置的参数来运行,而这些参数是由外部控制器通过 SCL 和 SDA 引脚写入的,SCL 与 SDA 使用的通讯协

The SCCB is very similar to I2C. In STM32, we can directly use I2C hardware peripherals to control it
.

(2) Communication, control signal and clock

The label 2 contains the communication, control signals and external clock of the OV7725, among which PCLK, HREF and
VSYNC are the pixel synchronization clock, the line synchronization signal and the frame synchronization signal, which
are very similar to the VGA signal in the LCD screen control . When the RSTB pin is low, it is used to reset the entire sensor chip, and PWDN is
used to control the chip to enter low power consumption mode. Note that the last XCLK pin is completely
different from PCLK . XCLK is the clock signal used to drive the entire sensor chip and is the
signal input to the OV7725 externally ; while PCLK is the synchronization signal when the OV7725 outputs data. The signal output by OV7725.
XCLK can be externally connected to a crystal oscillator or provided by an external controller. To compare XCLK to OV7725, it is equivalent
to the relationship between the HSE clock input pin and the STM32 chip. The PCLK pin can be analogous to
the SCL pin of the I2C peripheral of STM32 .

(3) Photosensitive matrix

The place marked 3 is the photosensitive matrix, where the optical signal is converted into electrical signals, and after various processing, these signals are stored as digital images represented by individual pixels.

(4) Data output signal

The label 4 contains the DSP processing unit, which will do some basic image processing
operations according to the configuration of the control register . This part also contains the image format conversion unit and compression unit. The converted data is finally
output through the D0-D9 pins. Generally speaking, we use 8 data lines for transmission. At this time, only D2-D9
pins are used.

SCCB timing

The configuration parameters of the external controller to the OV7725 register are transmitted through the SCCB bus, and the SCCB bus is very similar to I2C, so the on-chip I2C peripheral can be directly used to communicate with it in the STM32 driver.

The difference between SCCB and standard IIC protocol is that it can only write or read one byte of data per transmission. The IIC protocol supports burst reading and writing, that is, multiple bytes of data can be written in one transmission. .

The start signal, stop signal and data validity of SCCB are exactly the same as I2C.

Start signal: When SCL (SIO_C in the figure) is high, SDA (SIO_D in the figure) has a falling edge, and SCCB starts to transmit.

Stop signal: When SCL is high, when SDA appears a rising edge, SCCB stops transmitting.

Data validity: In addition to the start and stop states, during data transmission, when SCL is high, the data on SDA must be stable, that is, the level change on SDA can only occur when SCL is low When the SDA signal is collected when SCL is high.
The following is the timing diagram of SCCB:
Insert picture description here

The main controller uses the SCCB protocol to read and write its registers when controlling the OV7725, while it uses VGA/QVGA timing when outputting images, where VGA is used when the resolution is 480 640, QVGA is Quarter VGA, and its output resolution is 240 320, OV7725 When the image is output, it is output in one frame, generally from left to right and from top to bottom.
Insert picture description here
Okay, I will write here today. The next content is FIFO timing, AL422B and the driving principle of the camera.

Guess you like

Origin blog.csdn.net/weixin_41679822/article/details/102518107