CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

GPS problems

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Aiden



Joined: 27 Jul 2010
Posts: 2
Location: Johannesburg South Africa

View user's profile Send private message

GPS problems
PostPosted: Wed Jul 28, 2010 8:44 am     Reply with quote

Hi guys I am new to all this and ppl say this is the best site to get help with CCS (I wonder why), but jokes aside, ppl say this forum is really great so here goes.

I need only One String From The GPS and I keep on getting only the $GPRMC string.

I've connected my GPS (LEA 5h to hyperterminal and she sends the string I need as well).

I get $GPRMC. I need $GPGGA, and send it over the RFL_COM stream.

First the user enters a ID := 12345 if that is correct then wait for the correct message from GPS_COM and send it via RFL_COM at 1200 baud

Heres the code pls help me.
Code:

#include <16F627.h>

#USE DELAY( CLOCK=4000000 ) /* Using a 4 Mhz clock */
#use rs232(baud=9600,parity=N,xmit=PIN_B0,rcv=PIN_B4,bits=8, invert, stop =1, Stream=GPS_COM)
#use rs232(baud=1200,parity=N,xmit=PIN_B2,rcv=PIN_B3,bits=8, invert, stop =1, Stream=RFL_COM)
#FUSES XT   

void main()
   {   
      char NEMA[83];
      char ID[6] = "12345";
      unsigned int i = 0;
/*      NEMA[0] = '$';
      NEMA[1] = 'G';
      NEMA[2] = 'P';
      NEMA[3] = 'G';
      NEMA[4] = 'G';
      NEMA[5] = 'A'; */ //The NEMA Test
      while(1)
      {
         if(KBHit(RFL_COM))
         {
            ID[i] = fgetc(RFL_COM);
            i++;
            if(i >= 4)
            {
               i = 0;
               if((ID[0] == '1') && (ID[1] == '2') && (ID[2] == '3') && (ID[3] == '4') && (ID[4] == '5'))
               {
                  if(KBHit(GPS_COM))
                     {
                        fgets(NEMA, GPS_COM);
                        
                        while((NEMA[0] != '$') &&   (NEMA[5] != 'A'))
                           {
                              fgets(NEMA, GPS_COM);
                           }
                        fputs(NEMA, RFL_COM);
                     }
               }
               else
               {
                  fputs("Wrong ID", RFL_COM);
               }   
            }
         }
      }
   }

_________________
Well music maths science pics electronics and well just everything good
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jul 28, 2010 12:50 pm     Reply with quote

Do you know for certain that your GPS transmits the GPGGA message ?
Have you tested it by connecting it to a PC, and looked at the messages
in a terminal window ?

Why are you using only software UARTs ? The 16F627 has a hardware
UART on pins B2 and B1 (Tx and Rx).
Aiden



Joined: 27 Jul 2010
Posts: 2
Location: Johannesburg South Africa

View user's profile Send private message

PostPosted: Thu Jul 29, 2010 2:31 am     Reply with quote

Quote:
I've connected my GPS (LEA 5h to hyperterminal and she sends the string I need as well).

Yes it sends 6 different strings and one is $GPGGA.

And for using 2 software uarts, I am using one of my old boards for another project, I'll build the new board and use the Hardware UART then....

With this version of the code I get $GPGGA and $GPRMC:
Code:

         fputs("GPS Processor Online \r", RFL_COM);
         
         
         while(i <=4)
         {
            tempc[i] = fgetc(RFL_COM);
               if(i == 4)
               {
                  break;
               }
               i = i + 1;
         }
         
         if((tempc[0] == '1') && (tempc[1] == '2') && (tempc[2] == '3') && (tempc[3] == '4') && (tempc[4] == '5'))
         {
            
            tempc[0] = "";
            tempc[1] = "";
            tempc[2] = "";
            tempc[3] = "";
            tempc[4] = "";
            tempc[5] = "";
            
            while(c[0] != '$')
               {
                  fgets(c, GPS_COM);
                  fgets(d, GPS_COM);                  
               }   
               
            //fputs(d, RFL_COM);
            //delay_ms(2);
            //fputs(c, RFL_COM);
            
            fputs(c, RFL_COM);
            fputs(d, RFL_COM);
            fputs("ITAG 4 Life: ID 12345", RFL_COM);
         }
         else
         {
            fputs("ID's Do Not Match", RFL_COM);
         }   
      }
   }

I don't know WHY???

p.s. the if test is for the ID the user inputs and
Code:

char c[83];
char d[80];
char tempc[6];
int  i;

sometimes if the pic starts up and you enter the id "12345" it just skips this section of code and goes back to the start of the while(1) loop but if you enter the ID incorrectly it says "ID's Do Not Match" ?????
Code:

               {
                  fgets(c, GPS_COM);
                  fgets(d, GPS_COM);                  
               }   
               
            //fputs(d, RFL_COM);
            //delay_ms(2);
            //fputs(c, RFL_COM);
            
            fputs(c, RFL_COM);
            fputs(d, RFL_COM);
            fputs("ITAG 4 Life: ID 12345", RFL_COM);
         }

Thanks for the reply.

aiden
_________________
Well music maths science pics electronics and well just everything good
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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