|
|
View previous topic :: View next topic |
Author |
Message |
uni_student
Joined: 01 Aug 2007 Posts: 38 Location: AUckland, NEW ZEALAND
|
GPS and 2 baud rates |
Posted: Tue May 04, 2010 3:45 am |
|
|
Hi, im trying out a new gps module which is using 4800 baud. Problem im having is reading time info from the RMC message and displaying onto LCD with the following format "HH:MM:SS". Old Gps module ran on 9600 baud and worked perfectly with my code. New gps module only displays seconds and "IZ" for hours and "CH" for minutes. I only seem to be reading seconds properly. So in format it looks like this "IZ:CH:32" example
Using PIC18F452, LCD using LCD117 phanderson.com kit
Code: | #use rs232(baud=9600, xmit=PIN_A5, rcv=PIN_A4, parity=N, bits=8, stream=LCD, ERRORS)
#use rs232(baud=4800, xmit=PIN_C6, rcv=PIN_C7, parity=N, bits=8, stream=GPS, ERRORS)
//code in a function
r=message (messge, 1);
if(r==TRUE){
i=0;
while(TRUE){
z=fgetc(GPS);
if(z==',')
break;
temp[i]=z;
i++;
}
if(x==1){
fprintf(LCD, "?x06");
fprintf(LCD, "%c%c:%c%c:%c%c\r", temp[0], temp[1], temp[2], temp[3], temp[4], temp[5]);
}
//
int message (char *mess, int x){
int j;
j=0;
while(TRUE){
z=fgetc(GPS);
if(z=='$')
break;
}
z=fgetc(GPS);
if(z==mess[0])
z=fgetc(GPS);
if(z==mess[1])
z=fgetc(GPS);
if(z==mess[2]){
z=fgetc(GPS);
if(z==mess[3])
z=fgetc(GPS);
if(z==mess[4])
while(j<x){
z=fgetc(GPS);
if(z==',')
j++;
}
return TRUE;
} else{
return FALSE;
}
} |
Any help appreciated |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Tue May 04, 2010 4:08 am |
|
|
Seriously, I'd be looking at what the data format is from the GPS. Classic thing, would be something like the new unit, and the old using different lengths for the numbers. NMEA, allows you to send a time, with or without leading zeros for example, which is why you really need to search for the commas.
Best Wishes |
|
|
uni_student
Joined: 01 Aug 2007 Posts: 38 Location: AUckland, NEW ZEALAND
|
|
Posted: Tue May 04, 2010 3:55 pm |
|
|
Thanx for reply.
I've had both modules on the hyperterminal and messages, commas, etc are the same. Forgot to mention the LCD is running at 9600 baud, so I am switching between 9600 and 4800 all the time...has that got any implications on anything???
Cheers |
|
|
Douglas Kennedy
Joined: 07 Sep 2003 Posts: 755 Location: Florida
|
|
Posted: Wed May 05, 2010 2:14 am |
|
|
A gps squawks sentences at a rate the GPS determines. Probably you were lucky with the earlier GPS in that your code actually worked. An interrupt driven circular buffer is the only reliable way to interface with a GPS and for that matter most RS232 input. Without the interrupt approach is not that it doesn't work sometimes the issue is it only works sometimes. |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Sun May 09, 2010 4:05 pm |
|
|
Douglas Kennedy wrote: | A gps squawks sentences at a rate the GPS determines. Probably you were lucky with the earlier GPS in that your code actually worked. An interrupt driven circular buffer is the only reliable way to interface with a GPS and for that matter most RS232 input. Without the interrupt approach is not that it doesn't work sometimes the issue is it only works sometimes. |
I agree.
I've written routines for both the Garmin GPS16 and the DeLorme GPS2058 module (both have configurable data rates and message outputs with different config methods) both using a common IRQ driven receive buffer.... although I didn't do circular. I did a per/sentence flag and go --- just in case which ended up working out fine.
It really makes dealing with GPS's easier.
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|