Abstract: In the WiTadowsCE embedded system, the serial port is used to implement GPS and PDA communication.
First, introduce the data format of the GPS signal, and describe the system's hardware and software environment and serial communication. Finally, the GPS signal processing module is designed to describe in detail how to use the embedded programming language to develop a serial communication program, and provide specific steps and part of the implementation code.
Key words: GPSPDA serial port communication Windows CE
Introduction
The Global Positioning System (GPS) consists of three major components: Space constellation, ground monitoring, and user equipment. Among them (GPS Space constellation and ground monitoring are all controlled by the United States; (GPS user devices are mainly composed of receiver hardware and processing software. The user receives GPS satellite signals through the User device, and obtains the user's location, speed, and other information through signal processing, so as to use GPS for navigation and positioning. At present, many GPS manufacturers follow the NMEAO183 Protocol to develop many navigation GPS for PDA handheld computers.
GPS implements data communication with PDA through the serial port, and uses (3 Ps data) to obtain real-time object location, speed, and other parameters on PDA. By integrating with the GIS system, you can implement digital navigation on the PDA to intuitively understand the location and other information on the map. The following describes how to implement serial communication between GPS and PDA.
Serial Communication
Each PocketPC has a serial port to facilitate communication between the PocketPC and external serial devices. The essential function of a serial port is to act as an encoding converter between a chip and a serial device. When data is sent from the chip through a serial port, the byte data is converted to a serial bit. When receiving data, the serial bit is converted to byte data. WindowsCE uses the communication driver Comm. drv to send and receive data using standard WindowsAPI functions. Drivers are usually provided by serial device manufacturers to connect hardware to Windows CE. In programming, a COM6 serial port is simulated. First, use Comm6.PoxtOpen to open the serial port and set the properties of the Comm control. Timer triggers the OnComm event to receive the GPS signal, so as to receive the GPS signal in real time. GPS provides a serial communication interface. The serial communication parameter is: baud rate = 57 600 bps, data bit = 8 bits, start bit = 1 bits, stop bit = 1 bits, no parity.
GPS Data Format
The NMEA0183 protocol is a GPS interface protocol standard developed by the National Oceanic Electronics Association (NationaIMarineElectronlcsAssociation. NMEA0183 defines several statements that represent different meanings. Each statement is actually an ASCII code string. This code is intuitive and easy to recognize and apply. In the test, you do not need to know all the information about the NMEA0183 communication protocol. You only need to select the desired part of the positioning data, and the remaining information is ignored.
When GPS communicates with the handheld computer, 10 pieces of data are sent per second through the serial port. When the actual navigation application reads the GPS Spatial positioning data, it can update the latitude and longitude and time data every several seconds as needed, without frequently updating the data. Otherwise, it will waste the limited power of the handheld device. If the communication with the satellite is normal, the following data formats can be received: $ GPGGA, <2 >,< 3 >,< 4 >,< 5 >,< 6>, <7>, <8>, <9>, <10>, <12> * hh. The specific information is listed in Table l.
A complete NEMA0183 statement is a string from the start Letter "$ GPGGA" to the Terminator. The required information is the longitude and latitude, latitude and longitude directions, GPS Positioning status, and receiving time. Therefore, when such a complete NEMA0183 statement is received, the method for extracting useful information is: first determine the position of the Start operator $ GPGGA and read the human data from the start operator, find the character "," in the statement after the exception or verification, and then extract the character (string) between the two "," to obtain the data of interest, take the carriage return as the terminator of a CPS statement to obtain a complete GPS signal. In the extracted GPS statement, find the comma location of the latitude and longitude, read the latitude and longitude coordinates, and then convert the latitude and longitude coordinates. Because the coordinates of a map are measured in degrees.
GPS signal processing
Based on the principle of serial communication and the format of GPS data, a GPS signal processing module can be designed to extract information related to (3 Ps location. Generally, the user coordinate system is a drawing coordinate system. Therefore, the coordinates extracted from the GPS signal must be transformed from the WGS84 coordinates to the 54, 80, or local coordinates.
Design of GPS signal processing module
The design scheme l of the GPS data processing module is shown in. The GPS receiver transmits the positioning data (NMEA0183Ver2. O) to PocketPC through serial port 6 and locates the GPS data on an electronic map. In EVB, the Comm control reads the positioning data, classifies the positioning data, extracts the required information, and transmits the useful information to the main application. The main application then organizes the control information of the GPS receiver into the NEMA0183 VER2.O statement, transmits the control information through the Comm control and sends it to the GPS receiver. In this case, P0cket. The serial communication between the PC and the GPS receiver and the GPS positioning data processing function are encapsulated by the ActiveX Server outside the process, and the real-time performance of the system is achieved through the Process Manager of the operating system. this bypasses the deficiency of a single EVB thread.
GPS signal Receiving and Processing Process
After GPS receives the location signal, the system will decompose the GPS positioning information and extract useful data. GPS signal receiving and processing process: the GPS output data is transmitted to the PDA through serial port 6. the PDA main program obtains the current location of the target (longitude and latitude coordinates, altitude ), the GPS data obtained by the receiver is decomposed to obtain the current position of the target and the Greenwich Mean Time (8 hours after this time is the standard in China, then, the current location is displayed on the electronic map. GPS signal Receiving and Processing 2 is shown.
Implementation of GPS signal receiving program
The system uses the Comm communication control and Timer in EmbeddedVisualBasic. The timer is set to update the longitude and latitude and time data once every 2 seconds. Each Comm control provides a communication port for data transmission.
Start receiving in real time.
PrlvateSubmnustart ()
Timerl. lrlteIval = 2000
Timerl. Enabled = True
Comml. comatrix = 6
Comml. Settings = "57600, N, 8.1 ″
Comml. PortOpen = True
Strsmsdata = Comml. Input 'removes the temporary storage information in the serial Buffer.
Timerl_timer
Endsub
Privatesubtimerltimer ()
Dimingnextvbcrlfaslong 'records the next carriage return line break location
Dimingfirstgpggaaslong
Dimmessageasstring
Dimsdateasstring
Dimcn
Strsmsdata = comml. Input
Ingfirstgpgga = instr (1, strsmsclata, "$ gpgga ″)
Iflngfirstgpggathen
Ingnextvbcrlf = lnstr (ingfirstgpgga + 1,
Strsmsdata, vbcrlf)
Message = mid (strsmsdata, ingfirstgpgga, lngnextvb
CRLF-ingfirstgpgga)
Parsenmeamessagemessage, dblxcoord, dblycoord, sdate
Processinputdblxcoord, dblycoord
Endtf
GPS coordinate transformation
The GPS Positioning Result belongs to the WGS84 coordinate, while most of the practical engineering aspects are the national coordinate system or the Independent coordinate system. The independent coordinate system is generally formed on the basis of the national coordinate system. Therefore, the use of GPS positioning results involves the coordinate conversion problem with the national coordinate system. Generally, two-step conversion is required: first, the coordinate (L, B) of WGS84 is converted to the Gaussian plane coordinate (x84, y84) corresponding to the WGS84 elliptical, and then the plane coordinate transformation is performed, the Gaussian plane coordinates (x84 and y84) are forcibly attached to the Local Gaussian plane coordinate system.
Gaussian Conversion
Convert the geocoordinate (L, B) obtained by GPS positioning to the Gaussian plane coordinate (X84, Y84 ). The derivation process is complex. This article only provides the results:
Formula, separator = (L-L .) /P, ι o is the projection with the central meridian longitude, p = 206265 s/rad; the curvature radius of the inner ring
Elliptical first eccentric heart rate e = 2 α-α 2; auxiliary variable t = tgB; auxiliary variable ETA = e 'cosB; elliptical second eccentric Heart Rate
The calculation formula is as follows:
Plane Coordinate Transformation
The purpose of plane coordinate transformation is to convert the Gaussian plane coordinates (X84 and Y84) to the Gaussian plane coordinates in the local national or independent coordinate systems. In this paper, an average shaft similarity conversion method is designed. The implementation process of this method is described in the example of converting to the coordinate system (X54 and Y54) in beijing 54.
First, based on the Gaussian plane coordinates of the common points in the WGS84 coordinate system and the Beijing 54 coordinate system, the difference △a between the common points and the length proportional coefficient k between the two coordinate systems are obtained. Then, the coordinates of any point in the Beijing 54 coordinate system are calculated as follows.
Formula: xo and yo are the center of gravity coordinates of common points in Beijing 54, and X' and y' o are the center of gravity coordinates of common points in WGS84, respectively; k is the ratio of the edge length of the same edge in beijing 54 to WGS84. When there are more than two public edges, calculate them separately and take the average value; △aa is the difference between the azimuth angle of the same side in beijing 54 and WGS84, △a = a54 a a84. When there are more than two public points, calculate them and take the average value.
Generate space exchange format Vector Data
The geometric data and attribute data of the survey object are collected by GPS-PDA in the field. This data is a custom format. After processing, the positioning data and attribute data are combined to generate a Standard Interchange Format for Space Vector Data that meets the requirements. This standard format vector data file consists of six parts: File Header, element type parameters, attribute data structure, geometric data annotation and attribute data.
Application Instance
A self-developed data acquisition system is used to record GPS positioning information and attribute data from the GPS receiving devices of Lenovo Tianji XP 208 PDA and navmangps1010 cf.
Start the main program and enter the main interface. After the code and parameter settings are complete, enter the measurement interface. First, select the measurement mode. For irregular objects, the "continuous measurement" mode is generally used, and the rule object adopts the "intermittent measurement" mode. Then, click the measurement key to start the measurement and record the data. The default observation time is 10 s. When the system calls a bell, press the hour key to end the observation data record. At this time, the measured 1st points are displayed on the PDA screen. At the same time, during the station migration process, the GPS receiver continues to keep the tracking satellite. At the next point to be tested, press the measurement key to continue recording and press the measures key to end the observation data record. The remaining points are measured and displayed in sequence. If you enter a property, click the property key and click "pen" to point any point in the image. A dialog box is displayed. After you select a feature, the attribute entry page of the image is displayed. Field Measurement Result 3 is shown.
Conclusion
By using this design method, GPS positioning and navigation information can be completely received from the GPS receiver and stored as space vector Interchange Formats after coordinate transformation. The processed space data can be used by other application systems, such as GIS, RS, and its (intelligenttransportatl011system), which can be used in vehicle navigation, intelligent transportation, field exploration, tourism, and other aspects. The example described in this article is implemented on the wired serial port. In practical application, other interfaces can be used to interconnect GPS with PDA, such as infrared interfaces and Bluetooth technology. You can easily apply the modification to it.