Global Positioning System Modules This section shows how to connect a GPS module to the CSM-12C32 module and provide several C functions for capturing the latitude, longitude, and UTC time information. There is other information such as the number of satellites that can be captured in the same way but is not covered in this section. An easy-to-use GPS module is Vincotech 340-V23993- EVA1080A51GPS module, which consists of one GPS module and one GPS antenna on a coaxial cable. The on-board firmware supports bi-directional serial interface by using a full duplex UART (Universal Asynchronous Receiver Transmitter) interface of the GPS processor. The default configuration of this serial port is: 4800 baud, 8 data bits, no parity, 1 stop bit, no flow control. A level shifter is needed for passing the data to a PC through a serial COM port. Pictures, ordering information and web link for the module are shown below. Vendor Part Number Weblink for the part Description Unit Price Mouser Electronic s 340- V23993- EVA1080- A EVA1080-A Evaluation kit for Vincotech A1080-A GPS module $130.00 Hardware interfacing to the Freescale 9S12C32 MCU on board the CSM-12C32 module If the CSM-12C32 module is powered at 5 V, the wiring diagram is shown below. If the CSM- 12C32 module is powered at 3.3 V, the voltage divider can be removed and the TXD of the microcontroller goes straight to the RX0 of the GPS module terminal block.
Software development The GPS module supports the NMEA inter-face. The description of the outputs coming from this interface and a summary of the commands that can be issued to this interface are discussed below. This will allow a programmer to fully control of the module. The outputs coming from the interface are in the form of NMEA sentences, which are in the NMEA 0183 Standard. These sentences were developed by the National Marine Electronics Association for digital data exchange among marine electronic products back in the early nineteen-eighties. Each sentence transmitted by a marine electronic product is in the form of $<vendor><message><parameters>*<checksum><cr><lf> The maximum length of a sentence is 80 characters. The combination of <vendor><message> is called address field. The vendor code for the Global Positioning System is GP. The Vincotech s GPS firmware for the GPS module supports six NMEA sentences. Each sentence can be individually turned off or on. $GPGGA (default: ON) $GPVTG (default: OFF) $GPRMC (default: ON) $GPGSA (default: ON) $GPGSV (default: ON, 0.2Hz) $GPGLL (default: OFF)
Commands can be sent to the GPS module to turn an NMEA sentence on or off. The two tables below contain the inputs. For example, to disable the GGA message, the command is $PSRF103,00,00,00,01*21 To enable the GGA message for a 1 Hz constant output with checksum enabled, the command is $PSRF103,00,00,01,01*20 A C function for initializing the SCI of the 9S12C32 for communicating with the GPS module is shown below. void init_sci(void){ SCIBDH=0x00; // BR = Bus Clock/(16 * Baud Rate) SCIBDL=104; // Baud Rate set to 4800 SCICR1=0x04; //normal 8 bit mode, no parity SCICR2=0x0C; //enable tx and rx, disable interrupts To capture the latitude, longitude and UTC time from the GPS module, can use the GPGGA sentence and the format of which is shown in the next table.
GPGGA - Global Positioning System Fix Data Sentence Format: e.g. $GPGGA,152145.000,4805.8193,N,01132.2317,E,1,04,2.5,607.5,M,47.6,M,,*67 (1) $GPGGA Vendor and message identifier (2) 152145.000 Universal time coordinated (15h 21m 45.000s) (3) 4805.8193 Latitude (48deg 05.8193min) (4) N N North S South (5) 01132.2317 Longitude (011deg 32.2317min) (6) E E East W West (7) 1 Fix quality: 0 fix not valid or invalid, 1 GPS SPS mode, fix valid, 2 Differential GPS, SPS mode, fix valid (8) 04 Four satellites in use (min 00, max 12) (9) 2.5 Horizontal dilution of precision (10) 607.5 MSL altitude (11) M Unit of antenna altitude: meters (12) 47.6 Geoidal separation (13) M Unit of geoidal separation: meters (14) <empty> Age of differential GPS data, null field when DGPS is not used (15) <empty> Differential reference station ID, null field when DGPS is not used (16) *67 Checksum A C function for capturing the latitude, longitude and UTC time from the GPS module is shown below. Every time this function is called, it will start the measurement and capture the information in global strings. The UTC time is stored in the global string UTC. The latitude is stored in the global string Latitude. The latitude direction (N or S) is stored in the global character Lat_direction. The longitude is stored in the global string Longitude. The longtitude direction (E or W) is stored in the global character Long_direction. void GPS_data(void){ int i; char GPGGA[80] = {0; char GPGGA_Off[25] = {"$PSRF103,00,00,00,01*24"; /*turn off GGA sentence*/ char GPRMC_Off[25] = {"$PSRF103,04,00,00,01*20"; /*turn off RMC */ char GPGSA_Off[25] = {"$PSRF103,02,00,00,01*26"; /*turn off GSA */ char GPSV_Off[25] = {"$PSRF103,03,00,00,01*27"; /*turn off GSV */ char GPGGA_On[25] = {"$PSRF103,00,00,01,01*25"; /*turn on GGA */ char end_sentence[3] = {0x0D,0x0A, 0x00; /*end of sentence <CR> <LF><NULL>*/ putstring(gpgga_off); // turn off GGA sentence putstring(gprmc_off); //turn off RMC sentence
putstring(gpgsa_off); //turn off GSA sentence putstring(gpgsv_off); //turn off GSV sentence putstring(gpgga_on); // turn on GGA sentence getstring(gpgga,80); /*saves GPGGA statement*/ for (i=7; i<=16; i++) UTC[i-7]=GPGGA[i]; for (i=18; i<=26; i++) Latitude[i-18]=GPGGA[i]; Lat_direction=GPGGA[28]; for (i=30; i<=39; i++) Longitude[i-30]=GPGGA[i]; Long_direction=GPGGA[41]; char getchar(void) { while (!(SCISR1 & 0x20)); return SCIDRL; void getstring(char *stringptr, int string_length){ int i=0; stringptr[0]=getchar(); while((stringptr[i]!= 0x0D) && (i < string_length)){ i++; stringptr[i]=getchar(); void putchar(char a){ while(!(scisr1 & 0x80)); SCIDRL = a; void putstring(char *stringptr){ while((*stringptr!= 0x00)) putchar(*stringptr++);