“This paper presents an implementation scheme of embedded wireless data transmission terminal based on single chip microcomputer and GPRS module. The small GPRS communication system centered on the single-chip microcomputer application system has low cost, short design cycle and good portability, and is especially suitable for remote control and data transmission.
GPRS (General Packet Radio Service) is a set of wireless transmission methods developed using the concept of packet switching. The GPRS network is based on the existing GSM (Global System for Mobile Communications) network. Some nodes need to be added to the existing GSM network, such as GGSN (GPRS Gateway Support Node) and SGSN (GPRS Service Support Node). The main function of the SGSN is to record the current location information of the mobile terminal, and to complete the transmission and reception of mobile packet data between the mobile terminal and the GGSN. GGSN mainly functions as a gateway and can be connected to a variety of different data networks, such as ISDN (Integrated Services Digital Network), PSPDN (Packet Switched Public Data Network) and LAN (Local Area Network). GGSN can carry out protocol conversion on GPRS packet data packets in the GSM network, thereby transmitting these packet data packets to the remote TCP/IP or X.25 network.
GPRS network not only has the advantages of wide coverage, fast data transmission speed, high communication quality, always online and billing according to traffic, but also is a packet data network in itself, supports TCP/IP protocol, and can directly communicate with the Internet. Therefore, CPRS has unparalleled cost-effective advantages in industries such as wireless Internet access, portable environment monitoring, traffic monitoring, and mobile office.
1 GPRS communication system hardware design
The system uses Sony Ericsson’s GPRS communication module GR47 and PIC18f6720 single-chip microcomputer with TCP/IP protocol stack embedded inside, and the serial ports of both support the RS-232 communication standard.
The core design lies in the connection between the microcontroller and GR47 and the writing of the software. The PIC18f6720 microcontroller has two USARTs (Universal Asynchronous Serial Interface), one of which is connected to the GR47 module to transmit data and AT commands; the other is connected to the serial port of the terminal chip to communicate with the terminal. An antenna needs to be installed outside the GR47 module. As shown in Figure 1.
The PIC18F6720 single-chip microcomputer controls the GR47 module to send and receive data, and the interrupt of the serial port is used in the software to send and receive data and forward data.
1.1 Introduction to PICl8F6720
1.2 Introduction to GR47
GR47 is a dual-band GSM900/GSM=1800 communication module produced by Sony Ericsson. On the basis of this module, GPRS data transmission can be carried out, with functions such as supporting short message service. It uses 3.6 V voltage power supply; it can provide a variety of external interfaces, such as antenna interface, analog audio interface, asynchronous serial interface, SIM card interface, etc., and also supports I2C communication; internal integration of TCP/IP protocol stack, so the use of this chip will Greatly reduce the difficulty of programming the microcontroller.
There are not many GR47 ports used in this solution. Several key connection points are explained as follows:
a) Serial port TD: Connect to RX2 of the microcontroller, and RD to TX2 of the microcontroller.
b) DSR pin: DataSetReady, indicating that the module is ready to receive data. This pin is connected to RB0 of the single-chip microcomputer through a triode switch circuit. When DSR is high, it means it is in data mode, and when it is low, it means it is in command mode.
c) DTR pin: Data Terminal Ready, indicating that the terminal device is ready to receive data, and the data state and command state of GR47 can be switched by controlling the high and low time of this pin level. This pin is connected to RF2 of the microcontroller through a triode switch circuit.
2 GPRS communication system software design
The system software is written in C language and compiled under the MPLAB environment. Since this system is a module of the remote management terminal, certain protocols must be observed in the programming of the program to ensure correct communication. The main body of the program is how to control GR47’s AT command to initialize GR47 and process information and data. The program as a whole can be divided into the following blocks: initial setting of CPRS connection, short message judgment processing, heartbeat processing when there is no data transmission, data judgment forwarding, etc. The main program is to organically combine these program blocks, control each other, and loop infinitely. 2.1 Connection establishment
The realization process of GPRS module connecting to Internet and GPRS network is as follows:
a) The single-chip microcomputer software controls the GR47 module to start up, and waits for the module to start normally.
b) Write the corresponding AT setting command to the GR47 module through the serial port connected with the single-chip microcomputer and the GR47 module to initialize the module to successfully adhere to the GPRS network, obtain the dynamic IP address assigned by the network operator, and establish a connection with the destination terminal .
2.2 Data processing
The transmission of data packets between the data center server and the GPRS server is based on IP data packets, but it is not advisable to transmit IP packets in plain text. Therefore, PPP (point-to-point protocol) is mostly used for transmission to realize the transparent transmission of data through the GPRS module and the Internet network. . GR47 integrates the TCP/IP protocol stack, so users do not need to write programs related to the IP protocol, and can directly transmit data through GR47.
a) Data transmission between the module and the PC on the Internet: The PC is required to have an IP address of the public network and an open port, as well as operating software to monitor the transmission of messages. In this way, when the module and Internet transmit data, the message will be displayed. After the module is successfully connected to the network, as long as the single-chip microcomputer sends the data to be sent to GR47 through the serial port, GR47 will forward the data to the PC with the corresponding IP address.
b) Processing of short message data: GR47 has the function of GSM, which can send and receive short messages with mobile phones. The short message adopts the PDU format. In the program, it is necessary to judge the arrival of the short message and read the content of the short message, and perform corresponding functions according to the content, and finally construct the result into a PDU format and return it to the corresponding sender.
c) GPRS communication heartbeat information: After the network connection is established, when there is no data communication within the set period, the GPRS module sends heartbeat information to the data service center, and the data service center responds with a response signal after receiving the heartbeat information.
d) Storage of important data: In the program, some important commonly used and variable data such as the IP address of the computer server, port number, terminal address, SIM card number, etc. are stored in the EEPROM of the single-chip microcomputer. When necessary, read from EEPROM or rewrite data to EEPROM for setting.
2.3 Main program flow
The main program is composed of module functions, and the module functions are composed of nested basic functions. The main program flow is roughly as follows: First, initialize the setting variables of the single-chip microcomputer, which are generally 0; initialize the corresponding configuration unit of the single-chip microcomputer, such as setting the port direction, setting interrupt priority, timer initialization, etc.; and then controlling the GR47 by the single-chip microcomputer Power supply to determine whether to power on; after the power on is successful, query whether the network registration is successful; after success, you can establish a connection between the module and the PC server, and perform data transmission and short message processing; send a certain format of heartbeat information as needed. See Figure 2.
3 concluding remarks
This paper presents an implementation scheme of embedded wireless data transmission terminal based on single chip microcomputer and GPRS module. The small GPRS communication system centered on the single-chip microcomputer application system has low cost, short design cycle and good portability, and is especially suitable for remote control and data transmission.