Welcome, Guest. Please Login.
Surveyor Corporation Surveyor SRV-1
Home Help Search Login

Surveyor Robotics Forum

Welcome to the user support forum for Surveyor SRV-1 robots, SRV-1 robot controllers and SVS stereo vision systems. To register for this forum, please send an email to support@surveyor.com which includes your desired forum user name, your registration email address, and a brief explanation of why you wish to join, and we will create a forum account for you.

Please note that there is a Search button in the forum toolbar for forum topics. Another effective search method for the entire surveyor.com site is to use Google, e.g. "xyz site://www.surveyor.com" where "xyz" is the search topic.



Pages: 1 2 
Send Topic Print
Adding GPS to SVS / SRV-1 (Read 11557 times)
admin
YaBB Administrator
*****




Posts: 3602
Adding GPS to SVS / SRV-1
01/28/09 at 11:01am
 
Last week, I added a Locosys LS20031 GPS -
    http://www.sparkfun.com/commerce/product_info.php?products_id=8975
to my SVS setup.  At the moment, I'm using UART1 at 57600 baud (standard configuration for the LS20031 from Sparkfun) on the left Blackfin, but plan to use GPIO pin 31 or 32 with a software-only UART when I have a chance to finish that code.  The latest firmware (srv-blackfin-012509) has a command "$g" to dump the data from the GPS to the console, but one line in main.c has to be uncommented in order for this to work -
       //init_uart1();  // use UART1 with GPS until GPIO soft-UART is ready
 
The setup is quite simple.  I soldered a 4-pin header to the LS20031 as shown here -
 

 
and then ran a lead from the left-most pin on the GPS to pin 1 (3.3V) on the 32-pin header,  
a lead from the right-most pin on the GPS to pin 2 (GND) on the 32-pin header, and a lead from the pin next to GND on the GPS to pin 6 (UART1 RX) on the 32-pin header.
 

 
Finally, I put a block of non-conducting foam under the GPS to isolate it from the SVS.
 

 
This same setup would work with the SRV-1.  Only work remaining is to parse the incoming NMEA strings and move the RX line from UART1 to a GPIO pin once the soft-uart code is ready.
 
As mentioned elsewhere, to make this easier, we will be adding a 4-pin header for the GPS and another header for a compass on the next version of the SRV-1 radio/motor board, so no wiring will be required.
Back to top
 
« Last Edit: 01/28/09 at 11:05am by admin »  

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
PhaseSpace
Junior Member
**




Posts: 60
Re: Adding GPS to SVS / SRV-1
Reply #1 - 03/04/09 at 3:51am
 
I added the GPS as described and placed in the same position as described here. It seems to funtion and I am getting the NEMA data stings coming in through the terminal.
 
The GPS does not seem to get a lock on its position. The red LED on the chip is supposed flash every second when that happens.  
 
Is anyone getting good position data out of the GPS  in this setup? Perhaps the GPS is too close to the matchbox antenna?
 
Back to top
 
 
  IP Logged
admin
YaBB Administrator
*****




Posts: 3602
Re: Adding GPS to SVS / SRV-1
Reply #2 - 03/04/09 at 6:27am
 
I was able to get good data with that setup, though I needed a clear shot at the sky.  You might try moving the module around in relation to the rest of the electronics  to see if it makes any difference.
Back to top
 
 

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
AndreiSk
Full Member
***




Posts: 166
Re: Adding GPS to SVS / SRV-1
Reply #3 - 03/10/09 at 7:07am
 
yes, I connected it too and found, GPS sends infinity amount of data to client.
I wrote small function inside firmware and it sends only one piece of data for each $g command
 
======== main.c change ================
case 'g':  
                                                                             // Andrei
                                                                             gps_send();
                         break;
======== end of main.c change ================
 
======== myfunc.c change ================
void gps_send() {
     unsigned char gpsRecordCounter, ch;
     char *buffer;
     unsigned int lastBufferIdx, i;
 
     // Buffer for gps response
     buffer = (char*) malloc((unsigned int) 10000);
     lastBufferIdx = -1;
     // GPS record counter, in total 6 records from LOCOSYS,
     gpsRecordCounter = 0;
     /* Sample:
     $GPGGA,000141.027,8960.0000,N,00000.0000,E,0,0,,137.0,M,13.0,M,,*42  
     $GPGLL,8960.0000,N,00000.0000,E,000141.027,V,N*47  
     $GPGSA,A,1,,,,,,,,,,,,,,,*1E  
     $GPGSV,1,1,00*79  
     $GPRMC,000141.027,V,8960.0000,N,00000.0000,E,0.00,0.00,060180,,,N*7F  
     $GPVTG,0.00,T,,M,0.00,N,0.00,K,N*32  
     */
           
     printf("##gps\r\n");
     while(1 == 1) {
           if (!uart1GetChar(&ch)) continue;
 
           // New record?
           if (ch == '$') {
                 // Increase record counter
                 gpsRecordCounter++;
                 // Set last buffer index for first record to -1 (clean up buffer counter)
                 if (gpsRecordCounter == 1) lastBufferIdx = -1;
           }
           // Save char to buffer
           lastBufferIdx++; buffer[lastBufferIdx] = ch;
           
           // Have data to check?
           if (gpsRecordCounter == 1 && lastBufferIdx == 5) {
                 // Check first record for $GPGGA
                 if (buffer[0] == '$' && buffer[1] == 'G' && buffer[2] == 'P' &&
                             buffer[3] == 'G' && buffer[4] == 'G' && buffer[5] == 'A') {
                       // It is correct first record, nothing to do.
                 }
                 else {
                       // Wrong first record, reset record counter
                       gpsRecordCounter = 0; lastBufferIdx = -1;
                 }
                 continue;
           }
 
           // Is it last record (\r\n=CRLF=0D0A)?
           if (ch == 0x0A && gpsRecordCounter == 6) {
                 // Write response to client
                 for(i = 0; i <= lastBufferIdx; i++) putchar(buffer[i]);
                 // Release used memory and exit
                 free(buffer);
                 return;
           }
     }
}
======== end of myfunc.c change ================
Back to top
 
 
  IP Logged
admin
YaBB Administrator
*****




Posts: 3602
Re: Adding GPS to SVS / SRV-1
Reply #4 - 03/10/09 at 7:34am
 
One of the tasks at the top of my "TODO" list is to add a parser for NMEA strings - I need to add this function to the new C interpreter.
 
Here is a NMEA parser written by Jordi Munoz for the www.diydrones.com Ardupilot open source project.  GGA and RMC are the only strings he parses.  This is probably a good starting point.
 
Code:
/*By Jordi Munoz*/
/*NMEA parser, ArduPilot*/

#include <string.h>


#include "WProgram.h"
void setup();
void loop();
char buffer[90];
char head_rmc[]="GPRMC";
char head_gga[]="GPGGA";
byte unlock=0;
byte checksum=0;
byte checksum_received=0;
byte counter=0;

/*Pointers*/
char *token;
char *search = ",";
char *brkb, *pEnd;

unsigned int temp=0;
unsigned int temp2=0;
unsigned long temp3=0;

byte fix_position=0;
float lat=0;
float lon=0;
byte ground_speed=0;
int  course=0;
int alt=0;

void setup()
{
  Serial.begin(38400); 
  Serial.println("GPSSSSS!!!"); 
}

void loop()
{
  
  while(Serial.available() > 0)
  {
    if(unlock==0)
    {
	buffer[0]=Serial.read();//puts a byte in the buffer

	if(buffer[0]=='$')//Verify if is the preamble $
	{
	  unlock=1; 
	  //Serial.println("Fase 1");
	}
    }
    /*************************************************/
    else
    {
	buffer[counter]=Serial.read();


	if(buffer[counter]==0x0A)//Looks for \F
	{
	  unlock=0;


	  if (strncmp (buffer,head_rmc,5) == 0)//looking for rmc head....
	  {

	    /*Generating and parsing received checksum, */
	    for(int x=0; x<100; x++)
	    {
		if(buffer[x]=='*')
		{ 
		  checksum_received=strtol(&buffer[x+1],NULL,16);//Parsing received checksum...
		  break; 
		}
		else
		{
		  checksum^=buffer[x]; //XOR the received data... 
		}
	    }

	    if(checksum_received==checksum)//Checking checksum
	    {
		/* Token will point to the data between comma "'", returns the data in the order received */
		/*THE GPRMC order is: UTC, UTC status ,Lat, N/S indicator, LON, Lon, E/W indicator, speed, course, date, mode, checksum*/
		token = strtok_r(buffer, search, &brkb); //Contains the header GPRMC, not used

		token = strtok_r(NULL, search, &brkb); //UTC Time, not used
		//time=  atol (token);
		token = strtok_r(NULL, search, &brkb); //Valid UTC data? maybe not used... 


		//Longitude in degrees, decimal minutes. (ej. 4750.1234 degrees decimal minutes = 47.835390 decimal degrees)
		//Where 47 are degrees and 50 the minutes and .1234 the decimals of the minutes.
		//To convert to decimal degrees, devide the minutes by 60 (including decimals), 
		//Example: "50.1234/60=.835390", then add the degrees, ex: "47+.835390=47.835390" decimal degrees
		token = strtok_r(NULL, search, &brkb); //Contains Latitude in degrees decimal minutes... 

		//taking only degrees, and minutes without decimals, 
		//strtol stop parsing till reach the decimal point "."  result example 4750, eliminates .1234
		temp=strtol (token,&pEnd,10);

		//takes only the decimals of the minutes
		//result example 1234. 
		temp2=strtol (pEnd+1,NULL,10);

		//joining degrees, minutes, and the decimals of minute, now without the point...
		//Before was 4750.1234, now the result example is 47501234...
		temp3=(temp*10000)+(temp2);

		//modulo to leave only the decimal minutes, eliminating only the degrees.. 
		//Before was 47501234, the result example is 501234.
		temp3=temp3%1000000;

		//Dividing to obtain only the de degrees, before was 4750 
		//The result example is 47 (4750/100=47)
		temp/=100;

		//Joing everything and converting to float variable... 
		//First i convert the decimal minutes to degrees decimals stored in "temp3", example: 501234/600000= .835390
		//Then i add the degrees stored in "temp" and add the result from the first step, example 47+.835390=47.835390 
		//The result is stored in "lat" variable... 
		lat=temp+((float)temp3/600000);


		token = strtok_r(NULL, search, &brkb); //lat, north or south?
		//If the char is euqal to S (south), multiply the result by -1.. 
		if(*token=='S'){
		  lat=lat*-1;
		}

		//This the same procedure use in lat, but now for Lon....
		token = strtok_r(NULL, search, &brkb);
		temp=strtol (token,&pEnd,10); 
		temp2=strtol (pEnd+1,NULL,10); 
		temp3=(temp*10000)+(temp2);
		temp3=temp3%1000000; 
		temp/=100;
		lon=temp+((float)temp3/600000);

		token = strtok_r(NULL, search, &brkb); //lon, east or west?
		if(*token=='W'){
		  lon=lon*-1;
		}

		token = strtok_r(NULL, search, &brkb); //Speed overground?
		ground_speed= atoi(token);

		token = strtok_r(NULL, search, &brkb); //Course?
		course= atoi(token);

		/*Print values*/
		Serial.print((long)((float)lat*1000000)); 
		Serial.print(" ");
		Serial.print((long)((float)lon*1000000)); 
		Serial.print(" ");	   
		Serial.print(course);
		Serial.print(" ");
		Serial.print((int)ground_speed);
	    }
	    checksum=0;
	  }//End of the GPRMC parsing

	  if (strncmp (buffer,head_gga,5) == 0)//now looking for GPGGA head....
	  {
	    /*Generating and parsing received checksum, */
	    for(int x=0; x<100; x++)
	    {
		if(buffer[x]=='*')
		{ 
		  checksum_received=strtol(&buffer[x+1],NULL,16);//Parsing received checksum...
		  break; 
		}
		else
		{
		  checksum^=buffer[x]; //XOR the received data... 
		}
	    }

	    if(checksum_received==checksum)//Checking checksum
	    {

		token = strtok_r(buffer, search, &brkb);//GPGGA header, not used anymore
		token = strtok_r(NULL, search, &brkb);//UTC, no usado!!
		token = strtok_r(NULL, search, &brkb);//lat, no usato!!
		token = strtok_r(NULL, search, &brkb);//north/south, noup
		token = strtok_r(NULL, search, &brkb);//lon, no use!!
		token = strtok_r(NULL, search, &brkb);//wets/east, noup
		token = strtok_r(NULL, search, &brkb);//Position fix, used!!
		fix_position =atoi(token); 
		token = strtok_r(NULL, search, &brkb); //sats in use!! Nein...
		token = strtok_r(NULL, search, &brkb);//HDOP, nein gebraucht
		token = strtok_r(NULL, search, &brkb);//ALTITUDE, is the only meaning of this string.. in meters of course. 
		alt=atoi(token);


		/*Print values*/
		Serial.print(" ");
		Serial.print(alt);
		Serial.print(" ");
		Serial.println((int)fix_position);

	    }
	    checksum=0;
	  }

	  for(int a=0; a<=counter; a++)//restarting the buffer
	  {
	    buffer[a]=0;
	  } 
	  counter=0;
	}
	else
	{
	  counter++;
	}
    }
  }


}

int main(void)
{
	init();

	setup();
	
	for (;;)
		loop();
	  
	return 0;
}
 


Back to top
 
 

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
AndreiSk
Full Member
***




Posts: 166
Re: Adding GPS to SVS / SRV-1
Reply #5 - 03/10/09 at 1:46pm
 
Yes, I looked at it, nothing complex there.
My output looks as following now (I skipped several fields).
Do not worry about 'Satellites Used: 0', my workplace located inside big tower at first floor near corner Smiley
===============
##gps
$GPGGA,010504.027,8960.0000,N,00000.0000,E,0,0,,137.0,M,13.0,M,,*46
$GPGLL,8960.0000,N,00000.0000,E,010504.027,V,N*43
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,1,1,00*79
$GPRMC,010504.027,V,8960.0000,N,00000.0000,E,0.00,0.00,060180,,,N*7B
$GPVTG,0.00,T,,M,0.00,N,0.00,K,N*32
Latitude: 8960.0000 N
Longitude: 00000.0000 E
Position Fix: 0
Satellites Used: 0
Altitude: 137.0 M
Header: GPRMC
UTC Time: 010504.027
Status: V
Latitude: 8960.0000 N
Longitude: 00000.0000 E
Speed over ground: 0.00
Course over ground: 0.00
Date: 060180
Mode: N
===============
I will check it again when I will place SVS to box
Back to top
 
 
  IP Logged
admin
YaBB Administrator
*****




Posts: 3602
Re: Adding GPS to SVS / SRV-1
Reply #6 - 03/10/09 at 1:53pm
 
When you are ready to post your code, I'll add it to the main SRV-1 firmware.
Back to top
 
 

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
AndreiSk
Full Member
***




Posts: 166
Re: Adding GPS to SVS / SRV-1
Reply #7 - 03/10/09 at 2:11pm
 
You can download it from here.  
http://81.17.152.8/download/test/gps_pack.zip
 
For admin: I added several functions to string.h/string.c
Start point is "gps_send();" inside myfunc.c
 
Let me know if it works for you.
Back to top
 
 
  IP Logged
admin
YaBB Administrator
*****




Posts: 3602
Re: Adding GPS to SVS / SRV-1
Reply #8 - 03/10/09 at 5:23pm
 
I merged your string functions into string.h and created a new gps.c and gps.h.  At the moment, I'm calling them from main() with '$g'.  Next step is to create a gps() call for the new C interpreter.  I'll post code in a day or so, as a few other tasks need to be wrapped up ...
 
$g
##gps
$GPGGA,002239.525,3514.5954,N,12037.1995,W,0,0,,180.8,M,-30.8,M,,*73
$GPGLL,3514.5954,N,12037.1995,W,002239.525,V,N*56
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,1,1,00*79
$GPRMC,002239.525,V,3514.5954,N,12037.1995,W,0.00,0.00,110309,,,N*6B
$GPVTG,0.00,T,,M,0.00,N,0.00,K,N*32
Latitude: 3514.5954 N
Longitude: 12037.1995 W
Position Fix: 0
Satellites Used: 0
Altitude: 180.8 M
Status: V
Latitude: 3514.5954 N
Longitude: 12037.1995 W
Speed over ground: 0.00
Course over ground: 0.00
Mode: N
Back to top
 
« Last Edit: 03/10/09 at 5:23pm by admin »  

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
AndreiSk
Full Member
***




Posts: 166
Re: Adding GPS to SVS / SRV-1
Reply #9 - 03/10/09 at 6:31pm
 
strange, you have no satellites used too Sad
Back to top
 
 
  IP Logged
admin
YaBB Administrator
*****




Posts: 3602
Re: Adding GPS to SVS / SRV-1
Reply #10 - 03/10/09 at 6:42pm
 
I know - I have to take the robot outside to receive GPS signals.
Back to top
 
 

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
mshapiro
Full Member
***




Posts: 143
Re: Adding GPS to SVS / SRV-1
Reply #11 - 03/10/09 at 7:11pm
 
If you are not connecting to any satellites, how are you getting any Lat/Long information?  You need at least 4 satellites to triangulate in 3-dimensional space.  I noticed that the data for AndreiSk places him on the Prime Meridian, just shy of the North Pole.  The Admin's data, however, seems to be reasonable for California.
Back to top
 
 
  IP Logged
admin
YaBB Administrator
*****




Posts: 3602
Re: Adding GPS to SVS / SRV-1
Reply #12 - 03/10/09 at 7:52pm
 
The LOCOSYS gps is just dumping its last fix.  Presumably, the algorithm uses last known position as an estimate to get a quick fix once satellites are available.
Back to top
 
 

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
admin
YaBB Administrator
*****




Posts: 3602
Re: Adding GPS to SVS / SRV-1
Reply #13 - 03/15/09 at 10:33am
 
Okay - I have real data now, and I'm getting some parsing errors when I don't have a good fix, though with a fix the GGA message seems to be parsing correctly.
 
Incomplete fix:
Quote:
$g
##gps
$GPGGA,172727.430,3514.5954,N,12037.1995,W,0,0,,180.8,M,-30.8,M,,*7A
$GPGLL,3514.5954,N,12037.1995,W,172727.430,V,N*5F
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,2,1,05,26,,,22,29,,,19,15,,,25,24,,,29*76
$GPGSV,2,2,05,18,,,24*73
$GPRMC,172727.430,V,3514.5954,N,12037.1995,W,0.00,0.00,150309,,,N*66
UTC Time: 172727.430
Latitude: 3514.5954 N
Longitude: 12037.1995 W
Position Fix: 0
Satellites Used: 0
Altitude: 180.8 M
Status: 2
Latitude: 05 18
Longitude:    
Speed over ground: 24*73
N
Course over ground: (null)
Mode: (null)

 
Here's with a good fix.  It's not showing the RMC message:
Quote:
$g
##gps
$GPGGA,173415.400,3514.5974,N,12037.2028,W,1,8,1.18,84.6,M,-30.8,M,,*50
$GPGLL,3514.5974,N,12037.2028,W,173415.400,A,A*49
$GPGSA,A,3,29,22,15,24,18,26,16,21,,,,,1.49,1.18,0.91*0E
$GPGSV,4,1,13,21,65,344,21,18,63,230,23,29,55,140,28,51,46,157,28*79
$GPGSV,4,2,13,24,43,064,29,15,37,079,21,26,33,072,25,22,29,228,16*7A
$GPGSV,4,3,13,16,28,290,21,06,14,315,,30,04,184,,10,04,046,*70
UTC Time: 173415.400
Latitude: 3514.5974 N
Longitude: 12037.2028 W
Position Fix: 1
Satellites Used: 8
Altitude: 84.6 M

 
Back to top
 
« Last Edit: 03/15/09 at 10:34am by admin »  

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
admin
YaBB Administrator
*****




Posts: 3602
Re: Adding GPS to SVS / SRV-1
Reply #14 - 03/15/09 at 1:29pm
 
I just rewrote the gps function to parse only GGA, which saves lat, lon, alt, utc time, fix quality and # of satellites to a global data structure, therefore making the data available for calculations.  Here is the result -  
Quote:
$g
##gps
$GPGGA,202140.600,3514.5970,N,12037.1915,W,1,6,1.66,122.8,M,-30.8,M,,*66
lat deg: 35
lat min: 145970
lon deg: 120
lon min: 371915
gps alt: 122
gps fix: 1
gps sat: 6
gps utc: 202140

 
The code could be significantly simplified with functions to find commas and convert the strings to int, but this seems to be solid.  It will be posted with a firmware update later today, but here it is ...
 
gps.h:
Code:
void gps_show();
int gps_parse();

typedef struct gps_data {
    int latdeg;
    int latmin;
    int londeg;
    int lonmin;
    int alt;
    int fix;
    int sat;
    int utc;
} gps_data;

extern struct gps_data gps_gga; 


 
gps.c:
Code:
#include "gps.h"
#include "print.h"
#include "malloc.h"
#include "string.h"
#include "srv.h"
#include "uart.h"

/* typedef struct gps_data {
    int latdeg;
    int latmin;
    int londeg;
    int lonmin;
    int alt;
    int fix;
    int sat;
    int utc;
}; 

$GPGGA,173415.400,3514.5974,N,12037.2028,W,1,8,1.18,84.6,M,-30.8,M,,*50
$GPGAA,hhmmss.sss,ddmm.mmmm,n,dddmm.mmmm,e,q,ss,y.y,a.a,z,g.g,z,t.t,iii*CC
    where:
        GPGAA        : GPS fixed data identifier
        hhmmss.ss    : Coordinated Universal Time (UTC), also known as GMT
        ddmm.mmmm,n  : Latitude in degrees, minutes and cardinal sign
        dddmm.mmmm,e : Longitude in degrees, minutes and cardinal sign
        q            : Quality of fix.  1 = there is a fix
        ss           : Number of satellites used
        y.y          : Horizontal precision
        a.a,M        : GPS antenna altitude in meters
        g.g,M        : geoidal separation in meters
        t.t          : age of the differential correction data
        iiii         : Differential station's ID
        *CC          : Checksum 
*/

extern unsigned int uart1_flag;
struct gps_data gps_gga;

void gps_show() {
    printf("##gps\r\n");
    if (!gps_parse())
        printf("no response from gps\n\r");
    printf("lat deg: %d\n\r", gps_gga.latdeg);
    printf("lat min: %d\n\r", gps_gga.latmin);
    printf("lon deg: %d\n\r", gps_gga.londeg);
    printf("lon min: %d\n\r", gps_gga.lonmin);
    printf("gps alt: %d\n\r", gps_gga.alt);
    printf("gps fix: %d\n\r", gps_gga.fix);
    printf("gps sat: %d\n\r", gps_gga.sat);
    printf("gps utc: %d\n\r", gps_gga.utc);
}

int gps_parse() {
    unsigned char buf[100];
    unsigned char ch;
    unsigned int t0, sum, pow10;
    int i1, i2, ilast, ix;
    
    if (!uart1_flag) {
        init_uart1();
        uart1_flag = 1;
    }
    t0 = readRTC();  // set up for 1-second timeout
    
    while (1) {
        if ((readRTC() - t0) > 1000)  // check for timeout
            return 0;
        if (!uart1GetChar(&ch)) 
            continue;
        if (ch != '$')   // look for "$GPGGA," header
            continue;
        for (i1=0; i1<6; i1++)     
            buf[i1] = uart1GetCh();
        if ((buf[2] != 'G') || (buf[3] != 'G') || (buf[4] != 'A'))
            continue;
        for (i1=0; i1<100; i1++) {
            buf[i1] = uart1GetCh();  // read 100 chars into data buffer
            if (buf[i1] == '\r') {
                buf[i1] = 0;
                ilast = i1;
                break;
            }
        }
        printf("$GPGGA,%s\n\r", buf);

        // i1 = start of search, i2 = end of search (comma), ilast = end of buffer

        // parse utc
        i1 = 0;
        sum = 0;
        pow10 = 1;
        for (ix=0; ix<ilast; ix++) {
            if (buf[ix] == ',') {
                i2 = ix;
                break;
            }
        }
        for (ix=(i2-1); ix>=i1; ix--) {
            if (buf[ix] == '.')
                continue;
            sum += pow10 * (buf[ix] & 0x0F);
            pow10 *= 10;
        }
        gps_gga.utc = sum / 1000;
        
        // parse lat
        i1 = i2+1;
        sum = 0;
        pow10 = 1;
        for (ix=i1; ix<ilast; ix++) {
            if (buf[ix] == ',') {
                i2 = ix;
                break;
            }
        }
        for (ix=(i2-1); ix>=i1; ix--) {
            if (buf[ix] == '.')
                continue;
            sum += pow10 * (buf[ix] & 0x0F);
            pow10 *= 10;
        }
        gps_gga.latdeg = sum / 1000000;
        gps_gga.latmin = sum - (gps_gga.latdeg * 1000000);
        
        // skip N/S field
        i1 = i2+1;
        for (ix=i1; ix<ilast; ix++) {
            if (buf[ix] == ',') {
                i2 = ix;
                break;
            }
        }

        // parse lon
        i1 = i2+1;
        sum = 0;
        pow10 = 1;
        for (ix=i1; ix<ilast; ix++) {
            if (buf[ix] == ',') {
                i2 = ix;
                break;
            }
        }
        for (ix=(i2-1); ix>=i1; ix--) {
            if (buf[ix] == '.')
                continue;
            sum += pow10 * (buf[ix] & 0x0F);
            pow10 *= 10;
        }
        gps_gga.londeg = sum / 1000000;
        gps_gga.lonmin = sum - (gps_gga.londeg * 1000000);
        
        // skip E/W field
        i1 = i2+1;
        for (ix=i1; ix<ilast; ix++) {
            if (buf[ix] == ',') {
                i2 = ix;
                break;
            }
        }

        // parse fix
        i1 = i2+1;
        sum = 0;
        pow10 = 1;
        for (ix=i1; ix<ilast; ix++) {
            if (buf[ix] == ',') {
                i2 = ix;
                break;
            }
        }
        gps_gga.fix = buf[i2-1] & 0x0F;
        
        // parse satellites
        i1 = i2+1;
        sum = 0;
        pow10 = 1;
        for (ix=i1; ix<ilast; ix++) {
            if (buf[ix] == ',') {
                i2 = ix;
                break;
            }
        }
        for (ix=(i2-1); ix>=i1; ix--) {
            sum += pow10 * (buf[ix] & 0x0F);
            pow10 *= 10;
        }
        gps_gga.sat = sum;
        
        // skip horz-precision field
        i1 = i2+1;
        for (ix=i1; ix<ilast; ix++) {
            if (buf[ix] == ',') {
                i2 = ix;
                break;
            }
        }

        // parse alt
        i1 = i2+1;
        sum = 0;
        pow10 = 1;
        for (ix=i1; ix<ilast; ix++) {
            if (buf[ix] == ',') {
                i2 = ix;
                break;
            }
        }
        for (ix=(i2-1); ix>=i1; ix--) {
            if (buf[ix] == '.')
                continue;
            sum += pow10 * (buf[ix] & 0x0F);
            pow10 *= 10;
        }
        gps_gga.alt = sum / 10;
        
        return 1;
    }
}
 


 
By the way, I think there may be an issue with the proximity of the gps to the Wifi antenna or Blackfins.  It seems to work a lot better if I move it at least 3" away from the other electronics.
Back to top
 
« Last Edit: 03/15/09 at 1:34pm by admin »  

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
Pages: 1 2 
Send Topic Print