2772 views|0 replies

1148

Posts

0

Resources
The OP
 

Implementation of GPS system supporting GPRS using IP2002 device [Copy link]

As GPS is increasingly used in social life, people are also studying it more deeply. As an important part of GPS, the remote transmission of GPS data is also changing with the development of communication technology, from the original cluster mode to the paging mode and then to the SMS mode, which all reflect people's pursuit of cost-effectiveness.

With the development of mobile GPRS services, the advantages of using GPRS for GPS data transmission are gradually emerging. Compared with traditional remote transmission methods (such as dialing by phone), GPRS data transmission has outstanding advantages. On the one hand, GPRS charges are relatively cheap and can adopt a variety of tariff plans. For users of large data volume services, monthly packages can be used, and for users of small data volume services, billing can be performed based on the amount of data communicated and the quality of service provided. On the other hand, in the GPRS network, users only need to establish a connection with the network once to maintain this connection for a long time, and only occupy the channel and be charged when transmitting data, and no channel is occupied during the maintenance period. No charge. In this way, data collection points do not need to frequently establish connections, nor do they have to pay for transmission gaps, and GPRS can better support frequent, small-volume burst data services. In addition, the GPRS network has a fast access speed and provides seamless connection with the existing data network. Since the GPRS network itself is a packet-based data network that supports TCP/IP, X.25 and other protocols, it can communicate directly with the packet data network (IP network or X.25 network) without going through the PSTN and other networks, and the access is fast, generally only a few seconds, which is significantly faster than circuit-based data services.

For high-level protocols, TCP/IP protocol is used, which makes network access more direct and convenient than previous wireless data networks (trunking, two-way paging, GSM short messages).

This paper introduces a GPS system that supports GPRS, and gives a detailed description of the hardware and software design involved. Through this model, the remote transmission of GPS positioning information data can be achieved relatively well.

System Model

Figure 1 is the system model of this solution. The positioning data collected from the GPS terminal is transparently transmitted to the remote GPS server through the GPRS network. The remote GPS server can obtain the positioning information by decoding the GPS data. The detailed process is as follows:

① First, the GPS terminal sends a GPRS login request including the APN number to log in to the GPRS network;

② The mobile SGSN finds the registered Radius server according to the APN in the login request and sends the user authentication information to the Radius server;

③The Radius authentication server confirms whether the request is from a legitimate user based on the authentication information passed. If it is a legitimate user, it will assign an IP address to it according to the configuration;

④The Radius server sends a confirmation message carrying the user address to the GGSN;

⑤After the GPS terminal obtains the IP address, it can establish a TCP connection with the GPS server according to the configuration (as a server or client);

⑥After the connection is established, the positioning information data collected by the GPS terminal will be transparently transmitted to the GPS server through the established TCP data connection; ⑦When the GPS server has control commands or other data to send downward, it can be transmitted to the GPS terminal through the TCP connection;

⑧GPS terminal can establish data connection with user management server as server or client according to configuration. User management server monitors, manages and remotely updates system kernel program of GPS terminal through this connection.

Design of GPS Terminal

◇Hardware DesignThe

hardware circuit block diagram of the GPS terminal is shown in Figure 2. The core of the GPS terminal is a network processor IP2022 chip responsible for TCP/IP data transmission. IP2022 is a high-performance network processor from UbiCom, with a processing capacity of 100 MIPS and is optimized specifically for network applications. Two full-duplex serializer/deserializer (Ser/Des) hardware units are integrated in the IP2022 chip, which can be directly connected to various commonly used interfaces. This function enables it to implement on-chip 10Base-T Ethernet, USB, and various other fast serial protocols. Because of the Ser/Des hardware unit, IP2022 is also easy to convert from one protocol to another, so it is more suitable for implementing GPS terminals.

The software modules of IP2022 include USB, UART, I2C, SPI and a complete TCP/IP stack, which can provide high-speed computing, flexible I/O control and efficient data processing functions while executing applications.

In this system, two Ser/Des hardware units of IP2022 and its TCP/IP protocol stack are mainly used. Two full-duplex Ser/Des hardware units are converted into two standard RS232 interfaces through the serial port conversion circuit (core is MAX232), which facilitates communication with GPS module and GPRS module.

The system clock module provides the clock pulses required for the hardware system to work. This part is relatively simple, but there are two aspects that need to be paid attention to. The first is the choice of crystal oscillator. Although IP2022 also supports passive crystal oscillators, it is found in actual applications that active crystal oscillators are more compatible with IP2022, so it is better to choose active crystal oscillators when possible. The second is the choice of crystal oscillator frequency. Since the baud rate of serial communication is the frequency division of the crystal oscillator frequency, if the crystal oscillator frequency is not selected properly, garbled characters will appear during serial communication. After testing and calculation, the 4.9152MHz crystal oscillator can well support a variety of commonly used baud rates.

Program writing and debugging are achieved through the online programming interface. IP2022 supports online programming and debugging. This part mainly leads out the programming interface of IP2022, provides appropriate isolation protection, and connects to the parallel port of the debugging machine through the SPI and parallel port conversion circuit.

In this system, there are two internal voltages, one is 3 V required by the interface device, and the other is 2.5 V required by IP2022. These two voltages are converted by the power conversion module. Since the GPRS module has a large instantaneous current when sending data, the power conversion module also provides sufficient power and necessary protection.

The GPRS data module realizes the GPRS transmission function, which is equivalent to an ordinary modem. The more popular ones on the market include Motorola's G18.

When communicating with the GPRS data transmission module, the GPRS data transmission module interface is not directly manipulated, but connected through RS232, which greatly reduces the dependence on the GPRS data transmission module. Users can select the GPRS data module according to their needs.

The GPS receiver uses Motorola's M12, which is connected to the RS232 interface unit through a serial port.

◇Software design

In the GPS terminal software design, in order to facilitate future expansion, this design adopts a strict hierarchical structure, and its specific software structure is shown in Figure 3. The main functions of each part are as follows:


(1)Serial port driver module

When using the serial port driver module to complete the operation of the serial port, the serial port parameter configuration function should be provided to the upper layer, and the IndicateReceive and IndicateSend callback functions should be used to report to the upper layer when data is received or sent. The upper layer software can call Send and Receive to send and receive.

(2) Network driver module

The GPRS module in the hardware only provides a hardware channel, and the data connection with the server must be completed through software. During communication, the software first connects to the GPRS network through the GPRS module's unique commands (usually AT+CCMD), then establishes a data link through the PPP protocol, and finally communicates with the remote server through the TCP/IP protocol. This part and the network operation functions are implemented in the network driver module. Similar to the serial port driver module, the network driver module also provides some data transmission services. (3) Bridge module

Since the serial port is a slow connection, the communication between the host and the serial port is sometimes even a single-byte operation. If each such small communication is sent through a separate TCP packet (for example, one byte of data), this will generate some 41-byte packets, namely: 20 bytes of IP header, 20 bytes of TCP header and 1 byte of data. If it is on a high-speed network (such as a local area network), these small packets usually do not cause trouble, but if it is on a network such as GPRS (the average round-trip time is as high as hundreds of ms), it will increase the possibility of congestion and will make the network efficiency extremely low. In the usual TCP/IP implementation, the Nagle algorithm is generally used to solve this problem. However, there is no such function in the Ubicom protocol stack, so this algorithm must be completed by yourself. Considering the independence from the underlying hardware structure, it can be implemented in the bridge module instead of the network driver module during design. In the algorithm implementation, when serial port data arrives, for smaller packets, it is not sent out immediately, but waits for a period of time (about 200 s). If no small data arrives during this period, it is sent out, otherwise the data is accumulated and then sent out. Of course, some systems require immediate sending, so this function can also be canceled through configuration. After this implementation, the efficiency has been greatly improved. The specific effect can be referred to the experimental data below.

(4) Auxiliary modules

In the introduction of some modules above, we can see that some key data must support user configuration, such as serial port communication speed, stop bit, APN to which GPRS in the network driver module is connected, account, password, working mode (whether to run as a server or client), static IP or dynamic IP, etc. This part of data is stored in the external memory by the configuration module and loaded by the configuration module every time the system starts. The auxiliary module also includes an important submodule: the remote management module, which realizes the remote management of the GPS terminal, including remote tracking and remote update program. The operation status of the system is counted by the statistics module, and then can be reported through the remote management module.

(5) System monitoring module

For an unattended system placed in a remote location, the most important point is fault tolerance. It must be able to automatically recover to normal operation in the event of any error. This part is achieved through the system monitoring module. In GPS terminals, common exceptions include TCP connection interruption and network connection interruption. These two errors are different and the solutions are also different. TCP connection interruption means that the TCP connection enters an abnormal state and data cannot be sent and received on the connection. The reason for this error is that the GPRS network sometimes enters a pseudo-dead state, which results in the inability to send and receive data even though it is still on the network. This error can be discovered by setting a send and receive timeout timer on each connection. When there is data transmission, the counter is reset. If the counter times out, it indicates that the TCP connection is interrupted. At this time, different treatments should be taken according to the working mode. If it is working in client mode, it is necessary to connect to the server again. If it is working in server mode, it is only necessary to simply disconnect.

It is difficult to detect network disconnection, which is usually detected by monitoring the lack of data communication for a long time. If such an error occurs, the network connection needs to be reconnected.

Since software will inevitably have some undetected errors, when such errors occur, the hardware watchdog circuit will reset the system and remotely transmit the information that such errors have occurred to the server the next time the software is started.

Server software design

The GPS server program can establish a connection with a remote GPS terminal in two ways, one is TCP and the other is serial communication. When using serial communication, you need to compile a virtual serial port driver to simulate a TCP connection into a serial port, so that the server can operate the remote GPS terminal like operating M12.

The communication protocol between the GPS server and the remote GPS terminal uses the original M12 communication command. The core module performs transparent data forwarding between the GPS server and M12. M12 supports two communication data formats: one is the Motorola binary data instruction format. When using the Motorola binary format, the communication rate can be guaranteed to be 9600bps; the other is the NMEA-0183 format, whose communication rate is only 4800bps. At the same time, when initializing GPS, it is also necessary to add instructions converted from Motorola binary to NMEA-0183. Therefore, it is recommended to use the Motorola binary data format. The key links in this design are two aspects: one is the establishment of the connection, and the other is the initialization of M12. The positioning information data format returned by the GPS terminal is as follows:

@@Eamdyyhmsffffaaaaoooohhhhmmmmvvhhddtntimsdimsdimsdimsdimsd
imsdimsdimsdsC<CR><LF>.

Time information: m month, d day, yy year, h hour, m minute, s second. Location information: aaaa latitude, oooo longitude, hhhh
ellipsoid height.

The byte before the <CR><LF> that terminates all information is the checksum, which is the "XOR" of all information bytes.

After receiving the data, the positioning information and time can be obtained by decoding the data.

Server-side considerations

In GPRS networking, one concept that must be paid attention to is APN. When logging in to GPRS, different APNs are used, and the methods that can be used between the GPS terminal and the server will also be different.

If the public APN (cmnet) is used, the server only needs to have a fixed public IP. In this case, the Radius server is provided by the mobile company, and the IP of the GPS terminal after accessing the Internet is also randomly assigned by the Radius server of the mobile company. The GPS terminal and the server must go through NAT (Network Address Translation) before they can communicate, and the IP address of the GPS terminal seen from the data server is not its real address. Therefore, the connection between the GPS terminal and the data server can only be initiated by the GPS terminal. In other words, the GPS terminal can only work in the client state. Although it can save costs when using the public network, security issues need to be considered because it is directly connected to the Internet at this time, and clients cannot directly access each other.

A method corresponding to the public network APN is to use a private APN, that is, the user applies for an APN number from China Mobile. When this method is used, all users who log in to this APN can access each other through IP addresses. Therefore, when the amount of data is relatively small, even a user who also uses a GPRS terminal can be used as a server. The setting of the Radius server is relatively flexible. You can use the Radius server of a mobile company or build a set of Radius servers yourself. The biggest advantage of building a Radius server yourself is that GGSN will send verification information to the user so that a static IP address can be assigned to it based on the number or other information. Therefore, building a Radius server yourself is very suitable for GPS terminals to run as servers.

The Radius server can use some commercial servers, but from a practical point of view, writing a set of Radius servers by yourself may be more suitable for GPRS.

Conclusion

The system has been fully tested. In terms of transmission efficiency, the system performs very well. It only takes about 3 seconds to connect to the network. When using the Class 12 GPRS module, the transmission rate can reach 38kbps upload speed and 44kbps download speed. For general data acquisition equipment, it can ensure timely data transmission. When the GPRS network fails temporarily, it can be back online within 10 seconds after the network is restored, basically ensuring uninterrupted transmission, so it can meet the needs of GPS users.

Since the system is designed with strict functional module isolation, it can be expanded as a prototype system to support more GPS functions.

This post is from Automotive Electronics

Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list