Low-end video surveillance system based on STM32F407 and OV7670

Abstract : This system uses STMicroelectronics' STM32F407 microprocessor as the core, OV7670 as the video acquisition sensor of the monitoring system, and the data collected by the sensor is successfully sent to the liquid crystal module (SSD1289) through the DMA controller. The system runs smoothly and provides a new solution for low-end video surveillance systems.

This article refers to the address: http://

introduction

The system focuses on economical video surveillance system, which can be applied to industrial automation equipment, car safety driving, medical facilities or building water supply, power supply and other systems monitoring, with broad application prospects, low cost and simple system.

1 chip introduction

1.1 Introduction to STM32F407

The processor used in this system is STMicroelectronics' STM32F407, which uses 32-bit Cortex-M4 as the core and low-end high-speed ARM with floating-point arithmetic. It integrates a large number of resources for immediate use, such as Flexible and transparent interface (Flexible Stactie Memory Control, FSMC), camera interface (Camera Inter face), DMA controller, etc., convenient and practical.

1.2 Introduction to OV7670

OV7670 is OmniVision's CMOS VGA-based image sensor, which can control the output of full frame, sub-acquisition, and window capture through SCCB bus. Its VGA image can reach up to 30 fps. Its external important interfaces are: XCLK (clock input), HREF (output line sync signal), VSYNC (output field sync signal), PCLK (output pixel clock), RESET (reset input signal), PWDN, SIO_C (SCCB bus clock signal ), SIO_D (SCCB bus data signal), D0 to D7 (camera output data signal).

The OV7670 used in this system does not have a FIFO. The STM32F407 directly reads data through the SCCB bus and displays it on the LCD.

2 hardware and software implementation

2.1 hardware implementation

The hardware circuit of the system is simple to implement. The main peripheral connection between the microprocessor and the system is shown in Figure 1. It mainly relates to the connection between the STM32F407 and the TFT liquid crystal module and the connection with the OV7670 image sensor. The interface circuit is shown in Figure 2 and Figure 3.

Low-end video surveillance system based on STM32F407 and OV7670

When the STM32F407 is connected to the TFT liquid crystal module, the module only needs to be considered as an SRAM. The specific connection method is shown in Figure 2. The only thing to note is that the RS and CS terminals of the LCD module are connected to the FSMC controller of the STM32F407. In this system, the RS connection FSMC_A0 (PF0) and the CS connection FSMC_NE4 (PG12) are directly related to the relevant register address setting during software initialization. .

Low-end video surveillance system based on STM32F407 and OV7670

As shown in Figure 3, when the STM32F407 is connected to the OV7670, the XLCK PC9 of the OV7670 can select the MC01 or MC02 pin of the STM32F407, and the PCI SOIC and SOID PC2 pins can be connected to the I2C bus. Other I/Os can also be defined according to the software design. Pin (this system uses this scheme), the other ports of the OV7670 can be connected to the DCMI corresponding interface.

Low-end video surveillance system based on STM32F407 and OV7670

2.2 Software Implementation

The key points of the software design of this system are system clock configuration, TFT liquid crystal module initialization, OV7670 image sensor initialization, and SCCB bus timing simulation. The software program flow chart is shown in Figure 4.

Low-end video surveillance system based on STM32F407 and OV7670

The system clock configuration is done by the RCC_Config() function. The internal structure of the function is as follows:

Low-end video surveillance system based on STM32F407 and OV7670

The key point of the TFT liquid crystal module initialization is the configuration of the FSMC controller and the calculation of the register address. The FSMC of the STM32F407 uses the clock signal provided by the AHB3. Therefore, it is necessary to enable the clock signal of the AHB3 clock and other I/O ports multiplexed by the FSMC controller. The register address needs to be calculated according to the specific connection method of the RS and CS terminals of the LCD module and the FSMC interface. Because the external device address mapping of the FSMC controller of the STM32F4 series microprocessor starts from 0x60000000 to 0x9FFFFFFF, there are 4 BANKs, each BANK size is 256 MB, and each BANK is divided into 4 small blocks, each block size is 64 MB.

In the TFT liquid crystal initialization program, BANK1 is selected, and CS is connected to FSMC NE4 (PG12). Therefore, the register start address of the TFT liquid crystal module is 0x6C000000; RS is connected to FSMC_A0 (PF0), so the RAM of the TFT liquid crystal module is 0x6C000000+20×2. =0x6C000002. If BANK1 is selected in the TFT liquid crystal initialization program, and CS is connected to FSMC NE1 (PD7), the register start address of the TFT liquid crystal module is 0x60000000; RS is connected to FSMC A18 (PD13), and the RAM of the TFT liquid crystal module is 0x60000000+218×2. =0x60080000.

By analogy, the register start address and RAM address of the liquid crystal module can be calculated when other connection methods are calculated. code show as below:

#define LCD_RAM ​​*(vu16*)((u32)0x6c000002) //Define the RAM base address

#define LCD_REG *(vu16*)((u32)0x6c000000) //Define the REG base address

There are two key points for OV7670 image sensor initialization. The first is the configuration of the DCMI interface and DMA part of the microprocessor. These configurations are mainly reflected in the clock bus of the DCMI interface, DMA controller and other I/O ports used by the image sensor. The aspect is the second; the second is the OV7670's own register configuration. Due to space limitations, some important functions are listed and important notes are given for reference only.

Low-end video surveillance system based on STM32F407 and OV7670
Low-end video surveillance system based on STM32F407 and OV7670

The SCCB bus timing simulation can be programmed according to the timing defined in the SCCB standard. This part is well known and will not be described again.

Conclusion

Through the above program writing, software and hardware debugging, the final satisfactory results are obtained, as shown in Figure 5.

Low-end video surveillance system based on STM32F407 and OV7670

Although the video image display is a bit fuzzy, and the picture is slightly frustrated, it can be improved by software and hardware re-optimization, and also provides ideas for the application of STM32F407 and OV7670 in the video surveillance system.

  • STM32 microcontroller Chinese official website
  • STM32 microcontroller official development tools
  • STM32 microcontroller reference design

We cover many types of Connectors for industrial, electrical and automotive, such as IP68 and Waterproof Connectors, OBD diagnostic connectors, also the standard or custom-designed power connectors for MINI FIT, MICRO FIT,  MATE-N-LOCK.


We can support customers to copy some original componenst for local/equivalent connecotors by considering short L/T and competitive price.  Also it's workable to offer solutions for unique and customized connectors  by overmold tooling with low cost.

Connectors System

Connectors System,Board System Connector,Efi System Injector Connector,Efi System Car Connector

ETOP WIREHARNESS LIMITED , https://www.etopwireharness.com

Posted on