Design and Implementation of an Embedded Network Camera Based on AT91RM9200: 14:32:54
Source: Micro-Computer Information Author: Zhao yinwei Xie Shengli
1. Introduction
With
With the rapid development of communication and network technologies, network-based remote real-time monitoring of important places has attracted the attention of people. In this context, network cameras have become the focus of attention. The Network Camera must be of high definition
Degrees of real-time video information is transmitted to the monitoring terminal over the Internet, because of its huge amount of information, it must be compressed. It is usually realized by combining DSP and MPEG-4 algorithm.
Large, and the cost of the product is high. This paper introduces the Network Camera Using dedicated MPEG-4 compression chip, embedded Linux as the operating system, not only convenient development, low cost, but also real-time
Good, wide application scope.
2. Overall System Design
The overall system design includes two parts: hardware design and software design. The hardware design module mainly includes the microcontroller module, compression coding module, and network
Interface Module and camera control module. The microcontroller module consists of the master chip, DataFlash, and SDRAM (1. The main control chip is the core of the entire control system.
System scheduling. The embedded Linux kernel, its file system, application software, and system configuration files are solidified in DataFlash. SDRAM (1) serves as the memory for system operation.
The compression coding module consists of video data acquisition chip, MPEG-4 Compression Coding Chip, SDRAM (2), responsible for converting video stream into MPEG-4 code stream. The network interface module is mainly used with the master core
The bitrate of the chip transfer MPEG-4. The camera control module is mainly composed of a serial chip, which provides the function of forwarding control camera commands. When the system is started, the microcontroller passes through the SPI (Serial
Peripheral
Interface (serial peripheral Interface) transfers the Linux kernel to SDRAM (1), and the system starts from SDRAM (1. After the system is started, the microcontroller uses HPI (Host
Peripherial interface, host interface) controls the MPEG-4 encoding module. System Structure 1.
Figure 1 System Structure Diagram
Soft
Part of the design mainly includes embedded Linux transplantation, MPEG-4 compression coding module, CGI control program and MPEG-4 decoding program four parts. Embedded Linux System
In dataflash controlled by at91rm9200, it is responsible for scheduling the entire system software. MPEG-4 compression coding module is mainly responsible for analog video stream acquisition, and the digital video stream pressure
Shrink to MPEG-4 data flow. The CGI control program is mainly responsible for controlling the camera and setting the video stream of the MPEG-4. The MPEG-4 decoding program is mainly responsible for
Decoding of MPEG-4 data streams.
3. Hardware Design
3.1 microcontroller Module
The microcontroller is the core component of the system.
At91rm9200. It is a 32-bit microcontroller based on ARM920T core. The clock speed is 180 MHz, which features high processing speed, high functionality, high cost performance, and can meet the requirements of embedded systems.
Linux system requirements. It is mainly used in the system to configure the function registers of other chips when the system is powered on. It schedules and controls the entire system under normal working conditions, and controls the system through the on-Chip Ethernet controller.
The Physical Layer Chip sends the code stream.
At91rm9200 controls the peripheral dataflash and SDRAM through the on-chip SPI bus and the SDRAM controller, and controls the serial chip using the usart In the on-chip, the On-Chip Ethernet controller is used to control the on-chip network chip. Its control schematic 2 is shown in.
Figure 2 control schematic
3.2 compression and encoding Module
Pressure
The compression module includes analog video acquisition module and MPEG-4 compression module. The Video Acquisition chip uses TI's tvp5150 and the data compression chip uses yingjia's mpg440.
Two types of mixed Video signals at the TVP5150 input end are also Video signals at the S-Video terminal. Three formats are supported, including NTSC, PAL, and SECAM. The output data color format can be
8-bit digital signal or 8-bit synchronous ITU-R
BT.656 digital signal. The MPG440 chip has two-way host interfaces that comply with industrial standards for 16b/32b, which are used to communicate with the video capture chip and microcontroller chip respectively. At the same time, with mobile detection
Provides five resolution modes: D1, VGA, CIF, QVGA, and QCI. The microcontroller is implemented through the host interface
MPG440 initial configuration, also receives the MPEG-4 code stream. The hardware design principle of the compression encoding module is shown in 3.
Figure 3 compression and Encoding Circuit
TVP5150
The AI analog input port is connected to the output end of the analog camera to transmit analog video signals to the video processing chip. After the analog signal is sampled and processed, it passes the YOUT0 ~ Send the YOUT7 pin to MPG440,
The sample data is valid on the rising edge of PCLK. The VIDEO_CLK of MPG440 obtains the YOUT signal when receiving the rising edge of PCLK. TVP5150 field-based synchronous pulse and row-based synchronous pulse
And corresponding to VSYNC and HSYNC at the output end. MPG440 implements the field synchronization and row synchronization of the Image Based on the connected VSYNC and HSYNC signal lines.
MPG440 video input data line DATA_TV0 ~ DATA_TV7 and TVP5150 YOUT0 ~ Connect to YOUT7. While receiving data, MPG440 obtains
To the data spread to the MPEG-4 compression encoding unit, the MPEG-4 data stream after encoding is saved to the SDRAM (2. MPG440-bit PDMA Controller Based on configuration register settings
Accurately initiate access to SDRAM (2) and send the obtained data streams to HPI (Host bus interface, Host Peripherial
To wait for the AT91RM9200 to send data to the network through the DMA channel.
Mpg440 communicates with at91rm9200 through HPI. at91rm9200 uses resources such as the register and storage space of mpg440 as its memory addressing access. Mpg440
The at91rm9200 tunnel ncs4 is used for intercommunication. The address segments in the at91rm9200 addressing space are 0x50000000 to 0x5fffffff. Through
Mpg440 registers to access the storage space of the mpg440 system. Mpg440 interrupt signal rsc_int0 from the pb29 input of the general I/O pin, when the buffer is filled
When full, the rsc_int0 pin is low, prompting at91rm9200 to extract MPEG-4 data streams through DMA channels. After encoding, the video data reading process and mpg440 communicate with the host
At91rm9200 read signal CFRD and write signal cfwe control.
3.3 Network Module
The hardware design principle of the network module is shown in Figure 4.
Figure 4 network module Circuit
At91rm9200
Chip Ethernet Card port and network Physical Layer Chip dm9161e MII interface communication. When sending data, set the sending enable signal to etxen. Etx0 ~ Etx1 and
Etxo ~ of dm9161 ~ The etx1 pin is connected accordingly and serves as a data transmission channel. Data is sent using the dm9161e clock signal ref_clk. Data receiver erx
0 ~ Rxdo ~ of erx1 and dm9161e ~ The rxd1 pin is connected as a data receiving channel. Managing clock signals emdc and managing data input and output signals emdio for Chip Control
Write and read parameters. The mdintr end of dm9161e is used to generate an interrupt signal.
The On-Chip Ethernet Card transmits data through the DMA channel, without affecting the at91rm9200
Normal operation. First, set parameters such as the number of bytes transferred by the transfer control register and transfer address register, and the first address of the data block storage, and then read B data from the specified data storage address in sequence,
The data is sent to the internal sending buffer. The Mac encapsulates and sends the data, and records the number of transmitted bytes until the data block is sent. When a group of data is sent, a DMA interrupt request is sent from
At91rm9200. The entire network subsystem circuit is controlled and scheduled by at91rm9200.
4. Software Design
The embedded Linux system is mainly composed of four
Components: Boot Loader, kernel, ramdisk, and user space
(User ). They are placed in four partition modules in dataflash. Different file systems are used according to the specific functions of different modules: bootloader, kernel,
Ramdisk, which does not need to be dynamically changed after transplantation, uses a space-saving romfs read-only file system, and places some configuration files that can be dynamically updated in the user module, which requires a lot
Read/write operations, so use the jffs2 file system that supports dynamic write operation [1].
Linux porting technology is mature and will not be elaborated in detail in this article. The following describes the program design of MPEG-4 compression coding module and CGI Module.
4.1 MPEG-4 compression coding module Program Design
This module mainly completes the mpg440 and ti5150 related registers configuration, and ensures the normal output of the MPEG-4 code stream. When inserting
After the Linux system is started, configure the relevant registers of mpg440. After initialization, initialize the tvp5150 through the I2C bus [2]. When the system starts to compress the Encoding
The MPEG-4 code stream receiving storage program is controlled by the data stream buffer sign signal of the MPEG-440. When the 1024b buffer is full, risc_int0 is placed at a low level.
The DMA channel sends the code stream from the HPI port of mpg440 to the PC end. The MPEG-4 compression encoding module procedure flow 4 is shown.
Figure 5 program flowchart of MPEG-4 compression coding module
4.2 CGI program module design
CGI (Common
Gateway
Interface) is a standard Interface for external extended applications to interact with WWW servers. The CGI process of the system: Enter the IP address of the Network Camera in the IE browser on the PC end,
The embedded network server sends the corresponding control page to IE browser based on the request. The user fills in the form and submits it. The CGI program extracts the form information and processes the corresponding events based on the different information,
Such as adjusting MPEG-4 properties, camera related operations. CGI Control Principle 5 is shown.
Figure 6 CGI control schematic
The CGI module consists of three parts: Embedded web Server Configuration, html page writing, and CGI program design.
The embedded web server uses Apache. Its configuration is provided in the form of a configuration file and stored in the/etc/httpd/conf/directory of Ramdisk. The configuration mainly involves the following three aspects:
○ 1 configure the path of the root file: "DocumentRoot/home/httpd/html". The html page must be placed in this directory.
○ 2 configure the path of the CGI external program: "ScriptAlias/cgi-bin/home/httpd/cgi-bin /".
○ 3 configure the environment variable "SetEenv D_LIBRARY_PATH =/lib:/usr/local/lib:/usr/lib". The variable will be sent to the CGI script and SSI page, to ensure that the CGI program can correctly find the dependent database.
Webpage compilation uses the combination of html and shtml. The html parsing speed is fast. shtml can embed an external CGI program in a common webpage. In this way, the default configuration of the system is fed back to the client.
CGI programs use a combination of C and shell scripts. The specific compilation process is the same as programming in Linux. I will not repeat it for further details.
4.3 MPEG-4 decoding program
Yingjia technology has provided the OCX MPEG-4 decoding plug-in for secondary development. After OCX is registered on PC, OCX function can be conveniently called by web pages, so as to view Real-Time Images on PC.
5. Summary
This article introduces an Embedded Network Camera designed with chips such as AT91RM9200, TVP5150, MPG440, and DM9161E. Tested, the system is stable, reliable, real-time, and has excellent image quality. This product can be widely used in traffic monitoring, industrial monitoring, Home monitoring, video conferencing, and many other fields.