Tutorials to .com

Tutorials to .com » Mechine » Mcu » Real-time kernel μC / OS-II under the Network Monitoring System

Real-time kernel μC / OS-II under the Network Monitoring System

Print View , by: iSee ,Total views: 12 ,Word Count: 2659 ,Date: Mon, 24 Aug 2009 Time: 10:01 PM

With the advent of the information age, in particular, the rapid popularization of the Internet, more and more people began to come into contact with a new concept - embedded products. Embedded systems with access to Internet, not only realized the remote control of equipment, maintenance and upgrades, but also sharing of resources. Through the network to the device monitoring, an external interface is essential to use Web browser allows users to achieve through the network to the remote systems management and updates, greatly simplifies the man-machine interface design. If in the system, embedded real-time operating system, will enable the system has strong portability, In addition, adding and cutting hardware also has great flexibility. Using dynamic DHCP protocol to obtain IP information, so that TCP / IP software is no longer stored in the chip relies on a fixed IP address, which will facilitate the installation of large-scale system conditions.

This design, the key is how the memory resources are limited, SCM system, the use of real-time kernel μC / OS-II can turn information into the Internet, IP data packets transmitted to monitor through the IE browser, the status of remote device .

A Network Monitoring System Overview

This design uses a remote Internet monitoring equipment, the entire system is equivalent to a web server. The client to the server via IE browser to visit, real-time access to device status information in order to control equipment and maintenance. This requires WWW server provides services, that achieve the HTTP protocol. It should be all browsers support in order to ensure that any user can place orders through the browser. On the network interface, the system of their choice to run the Ethernet network environment. Figure 1 shows the design model of HTTP. First of all, the client browser and Web server, use one or more TCP connections through port 80 to communicate with the browser through the HTTP protocol here in the pre-stored in the EEROM control of web pages to pass through the page control commands to the network server, and then server command parsing, call the appropriate function to control the external I / O devices.

Real-time kernel μC / OS-II under the Network Monitoring System

The entire network monitoring system including hardware and software in two parts. In the hardware part of the embedded TCP / IP protocol stack. Because system resources are limited, in the layered architecture of the agreement remain under the premise of the agreement should be as concise as possible. According to the principle of network monitoring system, the system implements the following protocols: DHCP, HTTP, TCP, IP, ICMP, ARP.

2 Hardware Platform Design

This design uses Ethernet as the network operating environment, the need for hardware, network control chips. There are many current Ethernet control chip, but the majority of the high power consumption, functional complex, not suitable for low-cost embedded systems. Here use RTL8019AS [1], its advantage is NE2000 compatible, software portability is good, simple interface, without conversion chip, such as PCI-ISA bridges. Select the mcu 89C55, which has 20K of ROM, the internal structure is simple, as long as the code will be ported to it, we can more easily migrate to other architecture CPU, such as ARM and so on. Figure 2 shows the hardware block diagram. 24C64 and equipment used to store the physical address of the relevant information, etc.; external RAM for data processing to provide caching. System provides a RS232 interface used for testing, provides a RJ45 interface to connect to the Ethernet.

Real-time kernel μC / OS-II under the Network Monitoring System

3 operating system of choice

According to the characteristics of monitoring system, the system must meet the real-time and concurrency requirements in order to better support the TCP / IP run-time scheduling, so applications should be based on embedded real-time operating system. Suitable for on-chip real-time operating systems are more, but the code is open and suitable for transplant in the 51 series MCU rarely, mainly μC / OS-II, RTX51, Small RTOS51 so. Real-time kernel μC / OS-II is specifically designed for the MCU embedded applications, and Figure 3 for embedded real-time operating system, the internal structure diagram. It is mainly a standard written in ANSI c language, and hardware-related parts of the use of assembly language, so that the operating system can be easily ported to other processors. Can be seen that the use of an embedded operating system, application software only with the upper code related and has nothing to do with the processor, making the software transplantation only with low-level hardware-related function changes, so that the application software has a good portable and reliability. In μC / OS-II prepared with TCP / IP protocol, than the traditional system to be convenient for a lot of front and back; use it to allocate memory buffer prior to use for the use of post-release, which can effectively utilize system resources. In the program design will be TCP / IP protocol stack made of the task, while the user program running in another task. In this way, microcontroller can be completing the original control system functions under the premise of achieving network traffic. From the code length of the point of view, to achieve the basic functions of the TCP / IP protocol stack than the advantages of Linux and other operating systems more.

Real-time kernel μC / OS-II under the Network Monitoring System

4 Software Design

Network monitoring software design is an important part of system design, primarily to complete RTL8019AS drive, μC / OS-II on the application system management and TCP / IP protocol stack implementation.

4.1 μC / OS-II operating system, applications

μC / OS-II can be cut according to the need for appropriate post-transplantation [2] to 51 on the microcontroller. To use it to manage the system, making programs easy to read, and easy to transplant. μC / OS-II is mainly responsible for the management card to initialize, create system resources, create tasks, and so the work of three parts. The creation of resources in the system, use TxSem, RxSem semaphores [3] and TxQFIFO queue [3]. When you need to send or receive data, triggered RTL8019AS interrupt, CPU will interrupt vector into the interrupt service routine, for event handling. Interrupt service routine according to RTL8019AS internal interrupt status register to determine the value of IMR system in which the state, through the two semaphores TxSemPost and RxSemPost task switching system, so that the signal to wait for the corresponding amount of a task into the ready state. Send data frame by checking the signal process is carried out by a corresponding amount of TxSemPost handled properly in order to ensure that the data reaches the client, where a number of delivery mechanism used. When the semaphore RxSemPost arrives to begin receiving data. If the data frame is correct, the packet size under the appropriate memory space for storing the data, and then receives the correct frame of the destination address to decide whether or not the frame presented to the upper application. If correct then parse the data header and make the appropriate treatment.

4.2 RTL8019 driver

RTL8019AS complete data packages and convert between electrical signals. Drivers include chip initialization, close bag, bidding three parts. The physical channel transceiver operating using Ethernet protocol 802.3 format [4]. The system works by sending and receiving data packets first microcontroller to send data packets to be deposited in RTL8019 chip RAM, the first address given to send the buffer and packet length (write TPSR, TBCR0, 1), start to send a command (CR = 0x3E), the sending function can be realized RTL8019. RTL8019 Ethernet protocol will automatically send the results to complete write status register. RTL8019 chip to form a circular receive buffer FIFO queue, PSTART, PSTOP two registers limits the cycle start and end of the queue page, CURR as the write pointer, controlled by the chip, BNRY to read out the pointer, by the host program control. According to CURR == BNRY +1? Can determine whether the receipt of new data packets, the new received packet stored in the address that led to CURR site of RAM. When CURR == BNRY, the chip stops receiving packets.

4.3 The network protocol stack implementation

Based on TCP / IP protocol can achieve a variety of functions, this article focuses on HTTP protocol [5], that is, Web server, the main component in the application layer protocol. As the TCP / IP protocol stack itself is a kind of layer structure, so the design of the protocol stack modular thinking, layer by layer to achieve, and then through the layers of interface function calls to achieve a complete protocol stack. To achieve TCP / IP protocol stack as shown in Figure 4 the general flow.

Real-time kernel μC / OS-II under the Network Monitoring System

To the embedded system as a terminal and use TCP / IP to connect, you must set the IP address, gateway and subnet mask and other information. To enhance the flexibility of the system requires an automatic configuration capability, that is, the system automatically from a central server to obtain IP addresses and other information. The standard way to achieve this functionality is through Dynamic Host Configuration Protocol (DHCP) [5]. DHCP is based on the UDP layer on top of the application, using ports 68 and 67 in the form of radio communication, its work includes exploration, given the request to confirm such an operation.

Select HTTP protocol defines a request - response mechanism for access to Web server files. When a user visits a Web page Web server, an HTTP request would be in the form of multi-line strings sent from the browser to the Web server, the first line specifies a method of GET, followed by a string of parameters. The server to the client's response packet must contain HTTP headers, if the request was successful, but also the document itself, this information is sent along the TCP connection until the transfer is complete disconnect. With minimal packet header contains information on the success or failure of the state and transmission of the document content type (text, HTML, GIF graphics, etc.). All connection-related information such as IP addresses, client port number, serial number, response number and the TCP have been placed in a state of such structures, each element of structure can be seen as a connection status. Server process closes the connection, said the end of this response. Web information is stored in HTML text format EEROM in, Web server, create a local variable to match the special characters in the document, this information along the TCP connection through the HTTP protocol sent to the browser, the server in response encountered in the appropriate characters in the document, replace a variable value, dynamic web pages.

In order to pass between the server and the client HTTP request and response messages, and the need for a reliable communication channel, which provided by the transmission control protocol TCP. TCP provides a connection-oriented reliable stream of data services, its main task is to create a process to process communication. Data transmission is divided into three stages: establish a connection, transmit data, disconnect, relatively complex to achieve them. Since the embedded system is a server-side, always on the client's connection request for response, and never take the initiative to initiate a connection request, so just ensure that the embedded system can properly respond to the TCP packet, under the premise of the TCP protocol can be greatly simplified. Embedded systems are always responding to customer connections, always passively open connections, so you simply for the establishment of the connection process for embedded systems LISTEN, SYN_RCVD two states can be. Although the state transition diagram than the standard missing CLOSED, SYN_SENT state, but LISTEN, SYN_RCVD enough to describe the state of the system to establish a connection. When the system is spreading the last packet, set FIN, called for an end the current connection. Connect to switch off and simultaneous closure of two kinds of situations are possible, so only need to provide the system to switch off and simultaneous closure of the state can be involved.

In order to be passed between the host TCP segment, the need to achieve IP. IP protocol to achieve more complex, but from the Web server to achieve the requirements of this particular proceeding, the main design ideas need to grasp the following two points: first, the docking of the IP datagram received for processing, submit it to the upper-layer protocols; second, responsible for TCP packets, ICMP packets encapsulated binding to the data link layer. In practice, this is the most basic functions of IP protocol, but also the necessary Web server in the network layer functionality. ICMP protocol is responsible for passing error messages and other information that should be noted, Ping use ICMP echo protocol function realization host / server whether there is response test. Ping mainly by the implementation of ping requests, ping response and echo operates three functions to complete.

As a result of Ethernet access mode, so the system must achieve the IEEE802.3 standards, primarily by RTL8019AS completed. In order to guarantee system in Ethernet communications, but also need to implement ARP protocol. ARP is the nature of the agreement to complete the network address to physical address mapping, thus ensuring the correct transmission network. The whole ARP process ARP requests from, ARP reply, ARP deals with three function implementation, ARP handler set up ARP cache table.

This article describes the embedded network monitoring system uses IE browser as a client interface, support for RS232 and Ethernet connectivity, Ethernet access through the Internet, so as to realize from the Internet, monitoring of embedded devices. In practice, if the I / O port connected to the other hardware devices, only the processing function of the variable changes accordingly, you can achieve the remote monitoring and control. Embedded within the system μC / OS-II operating system, the use of flexible and can be programmed to increase the functionality required. Using DHCP to obtain dynamic IP addresses and other information to enhance system flexibility. The program achieved a network monitoring system with low cost, visualization, and platform-independent characteristics, can be widely used in industrial control field, has a high practical value.


Micro Controller Unit Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.