This tutorial assumes the reader:
(1) Has a basic knowledge of Visual C++
(2) Has some familiarity with GPS concepts
The rest of the tutorial is presented as follows:

com com2 9600 n 8 1 n saveconfig log com2 rtcaobs ontime 2 log com2 rtcaref ontime 10 log com2 rtcadata1 ontime 5 interfacemode com2 none rtca saveconfig fix position LAT LON ALT saveconfigLAT, LON, and ALT are the latitude, longitude, and altitude of the base station location, the more accurately determined these are the better the accuracy of the differential GPS system will be. Rover Station Config:
com com2 9600 n 8 1 n interfacemode com2 rtca none saveconfigNote you don't have to have a computer connected to the base station after configuring it. Now to see the current position of the rover, type into its prompt "log bestposa" and hit enter. The Lat/Long/Alt will be amoung the data.
int GPSport = 9;
unsigned char *GPSBuffer = new unsigned char[400];
int i;
// Time to run
int seconds = 250;
CSerial GPS_Serial;
if(GPS_Serial.Open( GPSport, 57600)){
int count = 0;
for(int j = 0; j < seconds; j++){
for(i=0; i < 400; i++){
GPSBuffer[i] = 0;
}
// Get GPS Data
static char command[14];
command[0] = '\r';
command[1] = 'L';
command[2] = 'O';
command[3] = 'G';
command[4] = ' ';
command[5] = 'B';
command[6] = 'E';
command[7] = 'S';
command[8] = 'T';
command[9] = 'P';
command[10] = 'O';
command[11] = 'S';
command[12] = 'A';
command[13] = '\r';
unsigned char lat_gps[15], long_gps[15];
int lat_size = 0;
int long_size = 0;
int data_waiting = 0;
GPS_Serial.SendData( command, 14 );
while(GPS_Serial.ReadDataWaiting() < 219);
data_waiting = GPS_Serial.ReadDataWaiting();
GPS_Serial.ReadData( GPSBuffer, data_waiting);
printf("Got GPS data...\n");
for(i=4; i < data_waiting; i++){
if( (GPSBuffer[i-4] == 'O') && (GPSBuffer[i-3] == 'A') && (GPSBuffer[i-2] == 'T') && (GPSBuffer[i-1] == ',') ){
printf("Single found\n");
int k = 0;
while(GPSBuffer[i+k] != ','){
lat_gps[k] = GPSBuffer[i+k];
k++;
}
lat_size = k;
i += k+1;
k = 0;
while(GPSBuffer[i+k] != ','){
long_gps[k] = GPSBuffer[i+k];
k++;
}
long_size = k;
}
}
// Begin Text File Output
FILE *textOutput = fopen("SICK_Data.csv", "a");
// Output GPS data
for(i=0; i < lat_size; i++){
fprintf(textOutput,"%c", lat_gps[i]);
}
fprintf(textOutput,",");
for(i=0; i < long_size; i++){
fprintf(textOutput,"%c", long_gps[i]);
}
fprintf(textOutput,"\n");
fclose(textOutput);
//End Text File Output
}
delete [] GPSBuffer;
return 1;
}else{
printf("Com port failed to open\n");
return 0;
}
Click here to email me.
Click here to return to my Tutorials page.