Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] SIM908 GPS: how to extract the Longitude,Latitude

Status
Not open for further replies.
Does your GPS send line break character at the end of each data transmission? If you GPS data frequency is 1 Hz that is emits data every 1 sec?

How do you get data with different formats everytime?


mikroC PRO AVR Code.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
unsigned char gpsData[85], myData[18], processNMEA = 0;
unsigned int k = 0;
 
void extractData(){
 
     unsigned int i = 0, j = 0, gotData = 0;
 
     if(gpsData[1] == '0'){
     
          j = 0;
          
          do{
              while(gpsData[i] != ',')i++;
              ++i;
              ++gotData;
              j = 0;
 
              while(gpsData[i] != ','){
                    myData[j] = gpsData[i];
                    ++i;
                    ++j;
              }
 
              myData[j] = '\0';
              UART1_Write_Text(myData);
              UART1_Write(13);
              UART1_Write(10);
 
          }while(gotData < 8);
     }
}
 
void main() {
 
     DDRD = 0xFE;
     PORTD = 0x00;
     
     UART1_Init(57600);
     Delay_ms(2000);
 
 
     
     UART1_Write_Text("Paste some GPS data to Virtual Terminal\r\n\r\n");
     
     while(1){
 
              UART1_Read_Text(gpsData, "st", 85);
              k = strlen(gpsData);
              gpsData[k] = ',';
              k = 0;
              extractData();
 
     }
}




99749d1386858859-gpsdata1.png
 

Attachments

  • gpsData1.png
    gpsData1.png
    60.2 KB · Views: 162
  • nmea.rar
    1.1 KB · Views: 94
Last edited:

Here is a version which use ISR. It has 2 methods, one using ISR and one using library.
 

Attachments

  • ATMEGA32 GPS NMEA Extract.rar
    134.6 KB · Views: 117

Not in your code it's some fault in my code as i have separated it with new line so some errors came,anyways thanks Jayanth

- - - Updated - - -

Code:
7739.1581837
3
1258.0692791
5
811.9531868
1
20131213072750.1302
1
77
1
101

0.0000000
0
0.0000000
0

- - - Updated - - -

This '3' , '5' are coming which is not supposed to be
 

Ya Finally fixed it done but I think the code once running it's in the ISR only not coming out of this

as
at the end

the message "ends***********" should also get to be printed
but it's not like that

Code:
[CODE]
////////////////////////////////////////ISR////////
unsigned char index;
volatile unsigned char inData[80]= "";
///////////////////////////////////////////
ISR(USART1_RX_vect)
{
	inData[index] = UDR1;
	if(inData[0] == '0')
	index++;
}
/////////////////
/*Extract Data function*/
void extract_data()
{
	unsigned char mydata[18] = "";
	unsigned int  i=0,j=0 , gotdata = 0;
	_delay_ms(100);
	if(inData[0] == '0'){
		i=j=0;
		do
		{
			while(inData[i] != ',')i++;
			++i;
			++gotdata;
			j=0;
			
		while(inData[i] != ',')
		{
		mydata[j] = inData[i]; ++i ; ++j;
		}
		mydata[j] = '\0';
		_delay_ms(100);
sendstring_softuart(mydata);
_delay_ms(5);
sendstring_softuart("\r\n");

		
	} while (gotdata < 8);
	
	
}
///////////while(1) loop/////////////////////////
	while(1)
	{
		
		
		_delay_ms(3000);
		sendstring_softuart("start\r\n");
				_delay_ms(2000);
		sendstring_uart("AT+CGPSINF=0\r");  //AT Command to get GPS
		_delay_ms(500);

extract_data();  //To get and print gps data
	_delay_ms(15000);
	sendstring_softuart("end*********************END\r\n");
	
}
[/CODE]
and the output
Code:
start
7739.139568
1258.082222
851.041199
20131213104502.827
11
12
0.000000
0.000000
start
7739.146266
1258.068929
829.928833
20131213104540.650
8
12
0.000000
0.000000
start
7739.145327
1258.070563
831.828552
20131213104618.408
8
12
0.000000
0.000000

Is that in ISR onnly ??
 

Ok , exactly it's correct but what about printing the last line "end*********" i mean why its not printed on the Serial Port ?
 

hello
I have extracted Latitude, Longitude, Time and Speed from the response of AT+CGPSINF=32.But i have a question.
Can anybody say to me What the unit of speed is? Is Speed over Ground in knots or not?
I multiplied it at 1.85 to convert it to km/h But The speed is not correct.
The response in AT command mode with AT+CGPSINF=32 is: 32,170139.000,A,3546.343899,N,5121.076898,E,26.32,256.26,170114,,E,A
and the speed is 26*1.85=48 (km/h).
But the string in GPS/TXD is: $GPRMC,170138.000,A,3546.347408,N,05121.093972,E,51.020,,170114
and the real speed is 51*1.85=94 (km/h).
Why these speeds are different?
Please help me.
Thanks in advance
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top