Use an 8-bit microcontroller to access the Internet through an ISP (Internet Service Provider) without the need for a PC or a high-end microcontroller. With the rapid development of embedded systems and the emergence of IA (information appliances), the application system is gradually replacing the traditional PC-centric applications, becoming the main force in the future development of the Internet; it will be widely used in smart home systems, Industrial intelligent slave system, LED network control display system, network security encryption system and other aspects.
The main technical difficulty in using the single-chip microcomputer to implement the embedded WebServer solution is how to use the limited resources of the single-chip microcomputer to process the information such as HTTP, SMTP, POP3, TCP, UDP, ICMP, IP and PPP, so that it can become available in the Internet. IP packets transmitted over and data that can be viewed on the built-in web page.
1 application plan 1.1 program introductionThe use of single-chip microcomputer to implement embedded WebServer can generally have the following three forms:
1MCU+ dedicated network chip, such as E1552, Webchip PS2000, etc. The main advantage of this solution is that the application system design engineer does not have to consider any network protocol at all, only the solution
Interpreting and executing the instructions and data transmitted by the network chip can be connected to the Internet.
2EMIT technology. EMIT uses a desktop computer or a high-performance embedded processor as the gateway, called emGateway, which supports the TCP/IP protocol and runs the HTTP service program to form a server that users can access remotely through a web browser. emGateway is connected to peripherals via a lightweight bus such as RS232, RS485, CAN, etc. Each peripheral application contains an independent communication task called emMicro that monitors the predefined variables in the embedded device and will The results are fed back into emGateway; emMicro can also interpret emGateway commands, modify variables in the device or perform some kind of control. The complex network protocol in this solution is implemented on the PC through emGateway. The application system MCU only processes the simple emNet protocol and performs Internet connection.
3MCU directly implements the form. To realize this form of Web Server, various types of MCUs can be used to implement network protocols, such as AT89C8252 and SX52BD100, and MCUs of different speeds can be selected as core chips according to specific requirements, but the basic hardware structure is roughly the same.
Obviously, in the above scheme, the hardware structure of "MCU direct implementation form" is the most compact, and it is the preferred solution. The following is discussed in detail.
1.2 hardware platformThe hardware platform of the WebServer directly implemented by the MCU is shown in Figure 1.
In Figure 1, the MCU uses the SX52BD100 to operate at the fastest speed. Under the 100 MHz crystal drive, the instruction execution speed can reach 100 MIPS; RABBIT2000 is the second, and the 51 series is the slowest. However, the hardware cost is just the opposite. Users can configure the MCU according to different requirements. The Ethernet control chip can be used by RealTek's RTL8019AS. The chip is a full-duplex Ethernet controller that can work in Ethernet II and IEEE802.3. 10Base5, 10Base2, 10BaseT, and compatible with NE2000. E2PROM is mainly used to store WEB pages, image files, PDF documents and other content, so there is no special requirement, and the user can freely choose, generally about 32 KB.
In this solution, the MCU is the core chip, through which the Ethernet control chip RTL8019AS is controlled, thereby completing the work of accessing the network; and the communication circuit type such as RS232, RS485, MODEM, etc. can be selected through programming. The biggest feature of this technical solution is that the application platform is designed with simple hardware, so that the cost of the original hardware cost can be used for relatively complex software development, and the I/O interface of the solution can be freely extended and dominated.
1.3 Workflow and software designThe workflow of the entire system is shown in Figure 2. After the data packet is transmitted to the RTL8019AS and the MCU through the RJ45 interface, the internal TCP/IP stack performs packet parsing and flow direction judgment, and then performs an unpacking or packing operation to continue the subsequent work. Obviously, the final processing results will be carried out through WebServer.
2 network protocol stack implementationGenerally, the so-called TCP/IP protocol is a four-layer protocol system, including a data link layer, a network layer (including an IP protocol), a transport layer (including a TCP protocol), and an application layer, each layer being responsible for different functions. Based on the TCP/IP protocol, you can implement a variety of functional applications, such as: HTTP (Hypertext Transfer Control Protocol), TELNET (Remote Login), FTP (File Transfer Protocol), SMTP (Simple Mail Transfer Protocol), SNMP (Simple Network Management Protocol) )Wait. This article focuses on HTTP, which is the main composition of WebServer at the application layer. Of course, users can also attach other protocol functions as needed.
P.lib main(){ sock_init();for(;;){ tcp_TIck(NULL);} } sock_init() and tcp_TIck() are the basic functions of the TCP/IP function library. The former is to initialize the TCP/IP protocol stack. The function causes the protocol stack to start processing the incoming datagram; the latter has two main purposes: 1 to support the latest information in the background processing; 2 to test the state of the TCP socket. It can be seen that with the TCP/IP protocol package provided by Dynamic C, users can easily establish TCP/IP communication. After the communication is established, subsequent further functional extensions can be performed on this basis, and protocol implementations such as HTTP and PPP are implemented. 2.2 HTTP Implementation The HTTP (Hypertext Transfer Protocol) server allows HTML (Hypertext Markup Language) pages, such as Web pages, and other files to be used by clients. In Dynamic C, HTTP is implemented by HTTP.LIB. The main body of the HTTP server implementation is as follows: #define TCPCONFIG 1 #memmap xmem #use "dcrtcp.lib" #use "http.lib" main(){ sock_init();http_init();tcp_reserveport(80);while(1 ) { http_handler();} } Users can add all other dynamic or static elements that make up the WebServer (whether or not they conform to the HTML standard) on this program framework according to their needs. Due to space limitations, specific examples are not listed.
summaryAfter establishing the corresponding hardware connection, different development tools and development languages ​​can be selected for the WebServer architecture according to different hardware characteristics.
We are dedicated charging solution Manufacturer since 2005.
Supply various Power Station including Portable Power Stations, Solar Power Generators, Smallest Generator etc.
Manufacturing high quality products for customers according to international standards, such as CE ROHS FCC REACH UL SGS BQB etc.
To constantly offer clients more innovative products and better services is our consistent pursuit.
portable power stations for camping, solar pow er stations, jackery portable power station
TOPNOTCH INTERNATIONAL GROUP LIMITED , https://www.itopnoobluetoothes.com