Shop OBEX P1 Docs P2 Docs Learn Events
Parallax GPS Module - reading bytes problem? — Parallax Forums

Parallax GPS Module - reading bytes problem?

FrankdjFrankdj Posts: 1
edited 2008-05-12 17:23 in General Discussion
Hi guys... first of all I would like to mention that I am using a PIC 18f4550 microcontroller, and I am programming in C with the C18 compiler. I allready tried to find a solution in many different ways, but since my GPS module is from Parallax I hope to find some users who have experience in how this things works.

The Problem:
I'm having problems reading my Parallax GPS module.·I am using the Smart Mode, which sort of works right. What happens is that I now open a USART connection and send a command byte .. after that I open a new connection to receive the 5 corresponding bytes·with data I requested. This all works fine, since I analyzed the bytes with an ossiloscope and received the exact coordinates of my house (which means it works). However when I write a receive loop for my PIC18f4550 microcontroller, I can't get the data right. The first byte I received has the same data from my ossiloscope analysis, but bytes 2 to 5 are different from what I analyzed on the scope.

This has probably something to do with reading multiple bytes out of the USART buffer. Can somebody help me with this?
·
The Documents:
- Parallax GPS Datasheet (http://www.parallax.com/Portals/0/Downloads/docs/prod/acc/GPSManualV1.1.pdf)
- PIC18F4550 Datasheet (http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1335&dDocName=en010300)
- C18 Libraries (page 70 for USART)·(http://kevin.org/frc/C18_libraries.pdf)

The Code:

RECEIVE PROCEDURE

OpenUSART (USART_TX_INT_OFF &    
            USART_RX_INT_OFF &
            USART_ASYNCH_MODE &
            USART_EIGHT_BIT &
            USART_CONT_RX &
   USART_BRGH_LOW, 160 );  //(Baudrate is good )
 
while(DataRdyUSART());    // If data is not ready, turn LED on
{PORTD = 0b00010001;}  

while(!DataRdyUSART());    //Wait fot data is ready
{lat0 = ReadUSART();    //Read data byte 1

lat1 = ReadUSART();     //Read data byte 2

lat2 = ReadUSART();     //Read data byte 3

lat3 = ReadUSART();     //Read data byte 4

lat4 = ReadUSART();     //Read data byte 5
}

process_GPS();      //Do something with the data

CloseUSART();      //Close connection

 
 
 
----------------------------------------------------------------------------------------------------------------
and I also tried the following method:
----------------------------------------------------------------------------------------------------------------



RECEIVE PROCEDURE

OpenUSART (USART_TX_INT_OFF &     //Open USART 
            USART_RX_INT_OFF &
            USART_ASYNCH_MODE &
            USART_EIGHT_BIT &
            USART_CONT_RX &
   USART_BRGH_LOW, 160 );  //(Baudrate is good )
 
while(DataRdyUSART());    // If data is not ready, turn LED on
{PORTD = 0b00010001;}  

while(!DataRdyUSART());    //Wait fot data is ready
{lat0 = ReadUSART(); }   //Read data byte 1

while(!DataRdyUSART());    //Wait fot data is ready
{lat1 = ReadUSART();}     //Read data byte 2

while(!DataRdyUSART());    //Wait fot data is ready
{lat2 = ReadUSART();}     //Read data byte 3

while(!DataRdyUSART());    //Wait fot data is ready
{lat3 = ReadUSART();}     //Read data byte 4

while(!DataRdyUSART());    //Wait fot data is ready
{lat4 = ReadUSART();}     //Read data byte 5


process_GPS();      //Do something with the data

CloseUSART();      //Close connection

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-05-12 14:31
    Probably can't help you, sorry. The Parallax GPS module, as you've noticed, sends pretty standard asynchronous serial data.
    Whatever problem you're having has to do with the PIC processor or the I/O libraries or how you've used them and you're not likely to find the expertise or experience here to help you with that. The only place to post questions like this is the Sandbox Forum which is set aside for questions outside the normal range or anything else that doesn't fit the subject matter of the other forums. I suggest you ask in Microchip's support forums.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-05-12 16:04
    Attached you will find my class for the javelin. It is much like C,
    so you should be able to understand it.
    It appears your code is lacking the "!GPS" preamble bytes that must
    be present for every command.
    You can open the file with any text editor.

    regards peter
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-05-12 17:23
    This thread is being moved from the Stamps In Class Forum to the Sandbox Forum.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.