Source: http://blog.csdn.net/sdudubing/article/details/7682467
Working principle and main features of GPRS:
Introduction: In recent years, the rapid development of communication and network technologies, especially the development of wireless communication technology, further improves the automation of power systems. After the emergence of the GSM network, technicians quickly embed the GSM module into various instruments, such as multi-function Electric Energy Meter, fault recorder, meter reading system, and electricity load monitoring, therefore, these instruments can communicate remotely.
GPRS is a new data bearer service developed in the existing GSM system. It supports the TCP/IP protocol and can communicate directly with the grouped data network (Internet, etc. The GPRS wireless transmission system has a wide range of applications, covering almost all low-and mid-business and low-speed data transmission, especially suitable for sudden small-traffic data transmission services.
The GPRS wireless communication module designed in this paper is embedded with the TCP/IP protocol and uses the industrial-grade GPRS module. It is applicable to the single-chip microcomputer data collection and transmission system without the TCP/IP protocol stack, however, serial communication is used.
1. GPRS communication principle and application characteristics
1.1 Introduction to GPRS
GPRS is the abbreviation of general packet radio system. It is a technology between the second generation and the third generation, usually called 2.5G. GPRS adopts the same frequency band, frequency band width, burst structure, wireless modulation standard, frequency hopping rules, and the same TDMA frame structure as GSM. Therefore, when a GPRS system is built on the basis of the GSM system, most components of the GSM system do not need to be changed in hardware, but only need to be upgraded in software. With GPRS, the user's call establishment time is greatly shortened, and almost always online is possible ". In addition, GPRS charges fees based on the amount of data transmitted by the carrier rather than the connection time, thus reducing the service cost for each user.
1.2 basic working principle
GPRS introduces two new network nodes on the original GSM network based on Circuit Switching (CSD): the GPRS Service Support Node (sgsn) and the Gateway Support Node (ggsn ). Sgsn and MSC are at the same level, and the storage unit of a single MS is tracked to implement security functions and access control, and connected to the base station system through frame relay. Ggsn supports intercommunication with the external group exchange network, and is connected to sgsn through the IP-based GPRS backbone network. Figure 1 shows the schematic diagram of the connection between GPRS and Internet.
The GPRS terminal obtains data from the customer system through interfaces and sends the processed GPRS grouped data to the GSM base station. After the group data is encapsulated by the sgsn, The sgsn can communicate with the gateway through the GPRS backbone network. Ggsn processes the grouped data and sends the data to the destination network, such as the Internet or X.25 network.
If the grouped data is sent to another GPRS terminal, the data is sent to sgsn by the GPRS backbone network, and then sent to the GPRS terminal by the BSS.
2 Embedded GPRS Communication System implementation
2.1 Hardware Design of GPRS module
The Embedded GPRS wireless communication module consists of a single-chip microcomputer (msc1210y5) embedded with TCP/IP, a GPRS module, a SIM card holder, an external interface, and extended data storage. Figure 2 shows the hardware diagram of the system.
The MSC1210 control the information received and sent by the GPRS module, and communicate with the external controller (such as the Data Collection end) through the standard RS232 serial port. Use software to implement interruptions and forward data.
2.1.1 Single Chip Microcomputer Module
Single-Chip Microcomputer uses the 8051 kernel-based msc1210y5 recently launched by Texas Instrument. The chip has a strong data processing capability with a clock frequency of 33 MHz. The command running speed is actually equivalent to the standard 8051 kernel running at a 99 MHz clock frequency. 32 KB Flash program memory, 256 B internal RAM and 1024 B on-chip SRAM, 2 kb boot Rom, support for serial and parallel system programming. The Dual Data pointers dptr0 and dptr1 can accelerate the movement of data blocks.
The main implementation process is as follows:
① Use the AT command to initialize the GPRS wireless module so that it is attached to the gpsr network, obtain the IP address of the GPRS terminal dynamically allocated by the network operator, and establish a connection with the target terminal.
② Expand the connection between maxcompute standard serial port and external controller (such as data collection end) through serial port 0, and connect the external controller end to standard serial port, according to the agreed protocol, the Controller of this design can be easily used for communication.
③ Reuse p1.2 and p1.3, that is, connection between Serial Port 1 and txd0 and rxd0 of the GPRS module, and connect the other six ports of P1 to the remaining RS232 communication ports corresponding to the GPRS module, respectively, the mc35 is initialized and the data sent and received by the GPRS module is controlled through the software slot.
2.1.2 Extended Data Storage
The flash memory of MSC1210 can be used as both Flash program memory and data Flash program. Because it takes some space to embed the real-time operating system and network protocol, it is used as the program memory, and 74hc573 is used as the address lock, and 6264 is extended as the external data storage, the 8 KB data storage space is sufficient for the program to run normally.
Figure 3 shows the hardware connection between MSC1210 and data storage.
2.1.3 GPRS wireless data transmission module
As the wireless transceiver module of the terminal, the GPRS wireless module processes the IP packets sent from the microcontroller or the grouped data sent from the base station before forwarding.
The GPRS module uses the mc35 module produced by Simens. The mc35 module consists of a RF antenna, an internal flash, SRAM, a GSM baseband processor, a matching power supply, and a 40-foot zif socket. The GSM baseband processor is a core component and serves as a protocol processor to process at commands sent by external systems through serial ports. The RF antenna implements signal modulation and decoding, as well as signal conversion between the external RF signal and the internal baseband processor. The matching power supply is required for the processor-based RF part. The mc35 peripheral circuit 4 is shown.
As2815 converts an external voltage to a 3.3 V operating voltage.
The startup circuit consists of a transistor and a power-on reset circuit. After the module is powered on, a low-level signal of at least 100 MS must be added at 15 feet for normal operation. After startup, the 15-pin signal should be kept high.
The number of pins reserved by mc35 for the SIM card interface on the zif connector is 6. Note that the CCIN pin is used to check whether the SIM card holder has a SIM card. When the SIM card is inserted and the pin is set to high power, the system can enter normal operation.
The sync pin works in two modes: one is to indicate the power increase in the launch State, and the other is to indicate the group state of mc35. The latter mode is used in this design. When the LED is extinguished, it indicates that the mc35 is closed or sleep; when the LED is 600 Ms bright/600 Ms extinguished, it indicates that the SIM card is not inserted or mc35 is logging on to the network. When the LED is 75 Ms bright/3 s off, it indicates that mc35 has logged on to the network and is in the standby status.
2.2 MCU Communication Program Design
All the code in the software is written in C and compiled in the Keil environment. Keil is a specialized development tool provided by Keil software for 8051 and its compatible products. It supports system debugging. In Keil, the C51 compiler is well integrated with the RTX real-time multi-task operating system. When writing a program, you must add "# incluede rtx51.h" to the source code header ". After all the code passes debugging, It is downloaded to the memory through Ti Downloader.
Currently, most GPRS modules based on GPRS network application systems do not support TCP/IP. That is to say, to work on the same network layer, the data transmitted inside the network must adopt the same protocol. Therefore, apart from using the functions of the GPRS module, you must embed a program based on TCP/IP and PPP protocol standards in the single-chip microcomputer system so that the designed terminal devices can conveniently apply the GPRS data grouping service.
2.2.1 TCP/IP protocol embedding
There are many ways to complete protocol conversion. This design uses the part of the IP and PPP protocols that shift value in the embedded real-time operating system rtx51 to enhance the scalability of the system and the continuity of product development.
TCP/IP is a standard protocol suite that can be described using a layered model. During data packaging and processing, each layer adds its own information to a data header, which is encapsulated into the data body by the Protocol in the next layer. When the data unpacking handler receives the GPRS data, it splits the corresponding data header and treats the rest of the data packet as the data body.
Considering the characteristics of the embedded system, this design uses IP + UDP protocol with low system overhead to implement GPRS communication. The UDP data packets sent by the host are transmitted to the GPRS communication module through the GPRS Channel. the GPRS communication module is responsible for parsing the data packets. The parsed data is transmitted to the user terminal at a certain baud rate.
2.2.2 Data Processing
Data packets are transmitted in the host and GPRS server group using IP-based groups, that is, all datagram files must be based on IP packets. However, the IP packet for plaintext transmission is not available, so the PPP protocol is generally used for transmission. The module sends PPP packets to the gateway to the corresponding address in the Internet, and the response frames sent from the Internet are also transmitted to the gpsr module according to the IP address, in this way, the collected data and the Internet network are transparently transmitted through the GPRS module.
Note that the GSM network does not have a static IP address, so other communication devices cannot send a connection request to it. The monitoring center must have a fixed IP address, so that the monitoring terminal can find the monitoring center through the IP address after logging on to the GSM network. It is easy to solve this problem. You only need to apply for the corresponding service in China Telecom.
After logging on to the GSM network, the GPRS module automatically connects to the data center, reports its IP address to the data center, and maintains the connection of the data link. GPRS monitors the connection of the link. In the event of an exception, the GPRS module automatically reestablishes the link, and the data center and the GPRS module can communicate two-way through the IP address through UDP/IP protocol, transparent and reliable data transmission.
3 design of Host Computer Monitoring Center
The function of the monitoring center is to receive and save GPRS information. The design language uses Microsoft's Visual C ++ programming language. The C ++ language has flexible application and powerful functions, and provides powerful support for network programming and databases.
The central monitoring module can directly access the Internet through GPRS, so the monitoring module does not need to be set up. The center only needs to use the center software frame listening network to receive the UDP Protocol IP packet sent from the GPRS wireless module and send the control information of the upper computer to implement IP protocol communication with the GPRS terminal. The received information should be saved to the central database for future reference. The database uses SQL Server, and the interface window compiled by VC accesses data in SQL Server through ADO. It should be noted that I receive network terminal information through socket.
A socket interface is a TCP/IP network API. A socket interface defines many functions and routines. programmers can use it to develop TCP/IP network applications. The MFC class in VC provides a socket class such as casyncsocket, which is very convenient to implement socket programming. This design uses a data PACKET socket, which is a connectionless socket and corresponds to a connectionless UDP Service Application.
The casyncsocket class uses the docallback function to process the MFC message. When a network event occurs, the docallback function follows the network event type: fd_rea D, fd_write, fd_accept, and fd_connect call the onreceive, onsend, onaccept, and onconnect functions respectively to drive corresponding events and complete network data communication.
4 Conclusion
This paper uses the embedded TCP/IP protocol and high-speed 8-Bit Single-Chip Microcomputer to realize the data transmission function of GPRS services. It has the advantages of few peripheral circuits, simple circuits, and low system costs. Through Standard RS232 serial port and external controller connection, only according to the pre-defined protocol can communicate with each other, more universal. System software is written in C language, and can be implemented on various controllers with slight changes, with high portability.
The GPRS-based system also has some disadvantages. For example, the current GPRS network is not stable enough and packet loss occurs. The use of the master controller to implement the IP protocol is complicated; the privacy of the Internet-based PC solution is poor. The above problems can be avoided and solved after careful design, so the GPRS-based design still has unparalleled advantages.
Working principle and main features of GPRS
Working principle and main features of GPRS