1 Introduction
The concept of intelligent residential area (or "smart community") was introduced into China in the 1990s. It is centered on home intelligence, including remote meter reading, home anti-theft alarm, medical assistance, home appliance control and other functions. It adopts system integration methods to establish a comprehensive information interaction system between residents in the community, between residents and the community comprehensive service center, and between residents and the outside society, so as to create a safe, comfortable, convenient and efficient living environment for residents. Most of the current smart community systems are networked with buses such as RS485, CAN bus, LONWORKS, etc., with complex wiring, many conflicts, unstable systems, and fire safety and cost considerations. Ethernet realizes networking, simple wiring, and is cheaper than CAN, LONWOKS, etc., and is more conducive to the compatibility and unification of community intelligent products. In today's situation where computer technology and information technology are constantly developing, as well as people's needs and changes in concepts for home life, the three networks of telephone, television and computer have a trend of integration. In the future, the development of smart communities will definitely be dominated by Ethernet. Therefore, in view of the current development situation and trends of the industry, the research on IP-based Ethernet home smart terminals conforms to the trend of the times and has certain practical significance.
2. Smart Community System Structure
The community intelligent system proposed in this paper consists of three main parts: community computer management system, network switching equipment, and home intelligent terminal (CDT). The network structure is shown in Figure 1:
Figure 1 System network structure diagram
Figure 2 User terminal structure diagram
The community management system refers to a computer system installed in the community management center to complete the data collection and processing of user data terminals in the entire community. For systems with a large number of users, a client/server (C/S) structure can be used. The community management system is divided into two parts: a monitoring microcomputer (Client) and a server (Server). The client is only used for data collection, and data processing is performed on the server. The functions of the community management system include: displaying the Internet status of user terminals, receiving and displaying household alarms, reading water, electricity and gas meter data and generating reports, alarm log processing, system management, etc. User data terminal: The user terminal is used to communicate with the management system, complete the collection of various metering signals and alarm signals, answer calls from the host, answer Internet status, and provide an operation panel to welcome user inquiries.
3. User terminal hardware structure and RTL8019 configuration
3.1 User terminal structure The hardware structure diagram is shown in Figure 2:
The system consists of two single-chip microcomputers, one is responsible for collecting the readings of five meters, remote control and security signals, and the other is responsible for driving RTL8019 communication, responding to the keyboard and driving the LCD display. The two MCUs communicate through the serial port.
3.2 Configuration of RTL8019
RTL8019 is a highly integrated Ethernet control chip, it has two operation modes: one is jumper mode, the other is jumperless mode, the latter also supports Plug and Play. The jumper mode option is generally used in the microcontroller. The base address of the I/O port is determined by the connection between the microcontroller and 8019, P2.6 = 8019CS, low level is valid, then IO_BASE_ADDRESS = 0xBF00. In addition, 8019 also has 8 IRQ interfaces, IRQ is not used in this system, and the query method is adopted.
The 8019 has a total of 32 input and output addresses, and the address offset is 00H--1FH (corresponding to BF00H--BF1FH).
There are 16 addresses from 00H to 0FH, which are register addresses. The registers are divided into 4 pages PAGE0--PAGE3. There are only 3 pages (Page0-Page2) of registers compatible with NE2000. In order to ensure that the driver is valid for all Ne2000 network cards, do not operate the registers on the fourth page.
There are 8 addresses from 10H to 17H, which are DMA addresses.
There are 8 addresses from 18H to 1FH, which are soft reset ports. The hardware reset of 8019 is very simple. You only need to output a high level to RSTDRV when powering on. The reset process of 8019 will perform some operations, such as reading 93c46 and initializing internal registers, which takes at least 2 milliseconds. It is recommended to wait for a longer time before operating the network card, such as 100 milliseconds before operating it, to ensure a complete reset.
When ICS16B=LOW, the 8-bit DMA operation mode is adopted. Only 18 of the above addresses are useful: 00H-0FH, a total of 16 register addresses. 10H DMA address (the 8 addresses from 10H to 17H are the same and can all be used as DMA ports. Just use one of them). 1FH reset address (the 8 addresses from 18H to 1FH are all reset addresses. The function of each address is the same. Just use one of them. But in fact, only the reset ports 18H, 1AH, 1CH, and 1EH are valid. Do not use the others. Some compatible cards do not support reset of odd addresses such as 19H, 1BH, and 1DH).
4. Simplification of network card driver and TCP/IP protocol stack
From the programmer's perspective, the operation of 8019 is relatively simple. The driver only needs to write the data to be sent into the chip in a certain format and start the sending command. 8019 will automatically convert the data packet into a physical frame format for transmission on the physical channel. Conversely, after receiving the physical signal, 8019 restores it to data and stores it in the chip RAM in a specified format for the host program to use. In short, 8019 completes the mutual conversion between data packets and electrical signals: data packets <===> electrical signals. The Ethernet protocol is automatically completed by the chip hardware and is transparent to the programmer. The driver has three functions: chip initialization, packet receiving, and packet sending.
4.1 Sending subroutine
bit Transmit(void)
{
CardCopyDown();
XBYTE[IO_BASE_ADDRESS + NIC _COMMAND] = CR_NO_ DMA |CR_STOP|CR_PAGE0; //Stop 8019
XBYTE[IO_BASE_ADDRESS + NIC_INTR_STATUS] = 0xFF; //Mask interrupt
XBYTE[IO_BASE_ADDRESS + NIC_XMIT_START] = XMIT_START; //Set the start address of sending
XBYTE[IO_BASE_ADDRESS + NIC_XMIT_CONFIG] = TCR_NO_LOOPBACK; //Set to general mode
XBYTE[IO_BASE_ADDRESS+NIC_DATA_CONFIG]= DCR_FIFO_8_BYTE|DCR_NORMAL|DCR_BYTE_WIDE; //Set 8-bit DMA mode
XBYTE[IO_BASE_ADDRESS + NIC_XMIT_COUNT_LSB] = 100; //Set the send word length
XBYTE[IO_BASE_ADDRESS + NIC_XMIT_COUNT_MSB] = 0;
XBYTE[IO_BASE_ADDRESS + NIC_COMMAND] = CR_START|CR_XMIT|CR_PAGE0; //Start 8019
return (TRUE);
}
4.2 Receive subroutine
void Receive(void)
{
XBYTE[IO_BASE_ADDRESS + NIC_COMMAND] = CR_NO_DMA|CR_STOP|CR_PAGE0; //Stop 8019
Wait_xus();
XBYTE[IO_BASE_ADDRESS + NIC_INTR_STATUS] = 0xFF; //Mask interrupt
XBYTE[IO_BASE_ADDRESS+NIC_DATA_CONFIG]= DCR_FIFO_8_BYTE|DCR_NORMAL|DCR_BYTE_WIDE; //Set 8-bit DMA mode
XBYTE[IO_BASE_ADDRESS + NIC_RMT_ADDR_LSB] = 0x00; //Set destination address and length
XBYTE[IO_BASE_ADDRESS + NIC_RMT_ADDR_MSB] = PAGE_START;
XBYTE [IO_BASE_ADDRESS + NIC_RMT_ADDR_MSB] = PAGE_START; + NIC_RMT_COUNT_LSB] = 56;
XBYTE[IO_BASE_ADDRESS + NIC_RMT_COUNT_MSB] = 0x00;
XBYTE[IO_BASE_ADDRESS + NIC_PAGE_START] = PAGE_START; //Set the receive start address
XBYTE[IO_BASE_ADDRESS + NIC_PAGE_STOP] = PAGE_STOP; //Set the receive buffer length
XBYTE[IO_BASE_ADDRESS + NIC_BOUNDARY] = BOUNDARY; //Set the receive boundary
Wait_xus();
XBYTE[IO_BASE_ADDRESS + NIC_RCV_CONFIG] = RCR_BROADCAST; //Set the receive configuration
}
4.3 Protocol Streamlining
The implementation of TCP/IP in a microcontroller is different from that in a PC. A relatively complete TCP/IP protocol can be supported in a PC, but this cannot be done in a microcontroller because the microcontroller does not have enough code space to support these protocols. Generally, the parts related to the needs are implemented in the microcontroller, and the unused protocols are not supported at all. For example, the file sharing SMB protocol is supported in UNIX and Windows , but it is not necessary on the microcontroller. Generally, only protocols such as ARP, IP, ICMP, and TCP/UDP can be implemented in the microcontroller, while higher-level protocols such as HTTP, SMTP, and FTP generally do not need to be supported. Although some microcontrollers, such as the AVR Internet access solution, have implemented these protocols, they are not very practical. Because the TCP/IP protocol used by the microcontroller is mostly for data collection and data transmission, rather than web browsing and file transfer. In addition, due to the limited resources of the microcontroller, it is also possible to simplify a certain protocol. The protocols implemented in this system are only ARP, IP, ICMP, and UDP.
a. ARP: The MCU only responds to the ARP request from the host, but does not actively send ARP requests.
b. ICMP: Only one type of ICMP message is implemented, namely the ICMP response message.
c. IP: The maximum size of an IP packet is 65k. The microcontroller cannot store such a large data packet, so it generally does not support segmentation. It avoids segmentation by sending small data.
5. Conclusion
Smart community is the advanced form and mainstream of well-off housing development in the 21st century. Its emergence is the product of the combination of real estate industry and computer, network, communication and control technologies. Ethernet technology based on TCP/IP is the key to promoting the standardization and digitization of smart communities. This paper takes the research of smart community home intelligent terminal system based on TCP/IP technology as an example, describes in detail the driving method of RTL8019 network card chip, and gives a simplified solution of TCP/IP protocol in single chip microcomputer. This system has been successfully used in many communities, and its feasibility, reliability and flexibility have been confirmed. In addition, the low cost and simple wiring of Ethernet-based smart community system make Ethernet technology based on TCP/IP an important means to replace traditional field bus technology.
References:
1. Yu Yongquan. Embedded systems, smart home appliances and home networks. Microcontrollers and embedded system applications, 2001 (1)
2. Lao Gu. Microcontrollers and TCP/IP networks. Lao Gu Forum, 2002
3. REAL TEK SEMI -CONDUCTOR CO., LTD. RTL8019 data sheet, 2000, 8
Previous article:The SPWM waveform generation principle and software design points of 80C196MC waveform generator
Next article:Design of portable on-site law enforcement recorder based on SPCA1527A
Recommended ReadingLatest update time:2024-11-16 01:48
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- TI Automotive Headlight LED Lighting System (Single Stage) Solution
- Application of INA series current detection devices in TWS battery box
- KL25 uses low power timer to wake up MCU with low power consumption
- [RVB2601 Creative Application Development] Unboxing
- Would you consider domestic DDR4 memory?
- Analysis of the advantages and disadvantages of UWB high-precision positioning technology
- GD32E231 DIY Contest (4) - How to get long and short keys?
- How to Choose the Correct Thermistor for Your Temperature Sensor
- How to read the timing diagram--Detailed explanation of nand flash read operation
- FPGA Experiment (VI) SignalTap II parameter setting and waveform generation