Provide overall solution for camera module
Get A Free Quote

The implementation of ov7620

1. Function control of OV7620

The OV7620 is controlled using the SeriaICameraControlBus (SCCB) protocol. SCCB is a simplified I2C protocol, SIO-l is a serial clock input line, SIO-O is a serial bidirectional data line, respectively equivalent to SCL and SDA of I2C protocol. The bus timing of SCCB is basically the same as that of I2C, and its response signal ACK is called the 9th bit of a transmission unit, which is divided into Don't Care and NA. The Don 'tcare bit is generated by the slave machine. The NA bit is generated by the host. Since SCCB does not support multi-byte read and write, the NA bit must be high. In addition, SCCB has no concept of repeated start, so in the SCCB read cycle, the host must send the bus stop condition after sending the on-chip register address. Otherwise, the slave will not be able to generate a Don 'tCare response signal when the read command is sent.

Due to some subtle differences between I2C and SCCB, the SCCB bus is simulated by GPIO. The pins connected to SCL are always set to output mode, while the pins connected to SDA dynamically change the input/output mode of the pins during data transmission by setting the value of IODIR. The write cycle of SCCB directly uses the write cycle timing of I2C bus protocol. The SC-CB read cycle adds a bus stop condition.

The addresses of the OV7620 function registers are 0x00 ~ 0x7C (many of them are reserved registers). By setting the corresponding registers, the OV7620 can be made to work in different modes. For example, to set OV7620 to continuous scanning and RGB raw data 16-bit output mode, you need to perform the following Settings:

I2CSendByte () is a register write function, its first parameter OV7620 is the chip address 0x42 defined by the macro, the second parameter is the on-chip register address, and the third parameter is the corresponding register setting value.

2. OV7620 clock synchronization

The OV7620 has four synchronization signals: VSYNC (vertical synchronization signal), FODD (odd-field synchronization signal), HSYNC (horizontal synchronization signal) and PCLK (pixel synchronization signal). When continuous scanning is adopted, only three synchronization signals, VSYNC, HSYNC and PCLK, are used, as shown in Figure l. The HREF level reference signal is also introduced to detect the effective size of the OV7620 scan window.

The three external interrupt pins of the LPC2210 are used as inputs to the three synchronization signals, and the corresponding interrupt service programs are Vsync_IRQ (), Hsync_IRQ (), and Pclk_IRQ (). A two-dimensional array is defined in memory to store image data, and one dimension is represented by variable y, which is used for horizontal synchronization signal counting. Two dimensions are represented by variable x, which is used for pixel synchronization signal counting. The basic process of image acquisition is as follows: after OV7620 is initialized with SCCB, enable the corresponding interrupt of VSYNC, and determine whether a frame of data has been obtained in the interrupt service program of Vsync_IRQ (). If so, the data is processed in the cycle body of the main program. If not, enable the interrupt corresponding to HSYNC and set y to O. In the Hsync_IRQ () interrupt service program, determine the valid level of the HREF. If it is valid, y is increased by 1, x is set to O, and the interrupt corresponding to PCLK is enabled. In the Pclk_IRQ () interrupt service program, the valid level of the HREF is determined, and if it is valid, the z is increased, and the image data of a pixel is collected.

3, image data output speed matching

Among the three synchronization signals of OV7620, PCLK has the shortest period. When the OV7620 uses a 27MHz system clock, the default PCLK cycle is 74ns. The interrupt response time of LPC2210 is much greater than this value. The maximum interrupt delay of LPC2210 is 27 processor instruction cycles, the minimum delay is 4 instruction cycles, plus the interrupt service time, the field recovery time, etc., the time to complete an interrupt response is greater than 7 to 30 instruction cycles. When the LPC2210 uses the maximum system frequency of 60MHz, its interrupt response time is much higher than that of O. 2 ~ 0, 6μs, so the PCLK of OV7620 can only be reduced. By setting the clock frequency control register, the period of PCLK can be set to about 4μs.

4. Access of image data

When the OV7620 is operating in master device mode, its YUV channel will continuously output data to the bus. If the YUV channel of OV7620 is directly connected to the DO ~ D15 data bus of LPC2210, the data bus will be interfered with, so that LPC2210 can not run normally; If the method of using 74HC244 and other isolation and time-sharing data bus will greatly reduce the running speed of the system, so that LPC2210 can not take the data on the bus in time, resulting in incomplete image data. Since the data bus width of LPC2210 is 32 bits, and Flash and SRAM only occupy the low 16-bit data line D0 ~ D15, the method in Figure l can be used to set the idle high 16-bit data line D16 ~ D31 as GPIO for collecting the 16-bit image data output from OV7620.

5. Recovery of image data

When OV7620 adopts 16-bit output mode, the data output formats of Y channel and UV channel are listed in Table l. As you can see from Table l, each row of Y channels and UV channels alternately outputs duplicate data from the previous row and new data from this row. Within a row, B data appears only in odd columns and R data appears only in even columns.

The following takes a 5×5 pixel lattice as an example to introduce the recovery of image data in detail.

First, define a 5×15 byte array to read 5×5 pixel image data in Pclk_IRQ () interrupt service program; Then the image data is interpolated, and the odd points are stored in the three consecutive bytes of the array B, G, 0, and the even points are stored in O, G, R; Finally, the RGB value of the current row can be calculated by averaging each byte of the current row with each byte of the corresponding column of the next row. In each row, the R data of odd-numbered points and the B data of even-numbered points can be obtained by averaging the R and B data of the two points on either side.

In this way, an image is restored. It can be directly saved into binary files (this system uses serial port output to PC for display), or add BMP bitmap file header information and save into DIB bitmap file with biBitCouNt=24; LPC2210 can also be used for further processing of this image data, such as fingerprint recognition.

Ov7620 hardware connection

The Ov7620 has 16 pins

Here's what they mean

Gray signal output interface Y0-Y7

SCCB Data interface SDA

SCCB Data Clock SCL

Line interrupt signal HREF

Field interrupt signal VSYN

Operating voltage 5V vcc

Pixel synchronization Signal PCLK (also known as TCLK)

Operating voltage 0V

Analog signal output interface VTO

Of these 16 pins, you need to connect the "operating voltage 5V" to the positive of the power supply, and the "operating voltage 0V" to the ground of the power supply. This must not be reversed!! Or burn the camera! Then the analog signal output interface VTO and the power supply of the ground two wires connected to the TV, you can use the lotus head, or any two wires connected to the TV video input can be. This is when the TV can produce pictures.

Here only explains the pins that may be needed, the analog camera is nothing more than these signals, it is important that the signal line of the analog camera needs to be separated, which will of course bring avoidable interference to the image acquisition.

Other different cameras have similar pins and they're all the same. Here are the hardware connections:

1. Pay attention to line field interruption If the connection is correct, the first small light on the system board will flash once every second.

How do I connect cables to ov7620? _ov7620 Hardware Connection

image.png

2. The vcc of the camera is connected to 5v power, gnd ground, do not connect wrong!

3. The core board leads ps0 to the rxd on the usb adapter and one is a common ground wire. All right, you can see the image.

Camera module sensor

20MP Camera Sensor

48MP Camera Sensor

50MP Camera Sensor

60MP Camera Sensor

4MP 2K Camera Sensor

3MP 1080P Camera Sensor

2MP 1080P Camera Sensor

1MP 720P Camera Sensor

0.3MP 480P Camera Sensor

16MP 4K Camera Sensor

13MP 4K Camera Sensor

12MP 4K Camera Sensor

8MP 4K Camera Sensor

5MP 2K Camera Sensor

REQUEST INFORMATION, SAMPLE, OR A QUOTE CONTACT US

John Doe

Typically replies within a day

Powered by WpChatPlugins