PDA

View Full Version : Parallax GPS time problem



bob12345
02-14-2010, 06:27 PM
Hi,

I'm having an issue with requesting the time, more specifically just the hour from a Parallax GPS module (the one with the board attached to the GPS receiver) to a BS2PX24. Its setup to smart mode so I request specific NMEA data as and when I need it using serin/out commands.
I've set up the program into multiple·slots and in Slot 0 (start of the program), I run this subroutine to·acquire the hour when the device is powered on:

get_power_on_time:
· SEROUT gps_sio, gps_baud, ["!GPS", GetHour]
· SERIN gps_sio, gps_baud, 3000, no_gps_response, [power_on_time_hour]
· RETURN

Using debug/lcd output·I can display the·hour variable (above)·no issue and store it in the variable "power_on_time_hour". However the problem then occurs when·I call a similar subroutine below, now·on the second page of the program located in Slot 1, which is part of a loop:

current_time:
· SEROUT gps_sio, gps_baud, ["!GPS", GetHour]
· SERIN gps_sio, gps_baud, 3000, no_gps_response, [current_time]
· RETURN

The debugger/LCD output reports that the "no_gps_response" has been called, ie its timed out and somehow failed to acquire the time (hour) for the second time.
The idea of the above is that "current_time" variable is checked for changes relative to "power_on_time_hour".

I have no idea why it keeps timing out each time I try to receive the time on the second occasion. I've noticed the following patterns, it works if I only call the GetHour Serout/Serin in command once in the program in any slots, the second time will ruin it. Same occurs if I have the output variables the same, ie both outputting to "power_on_time_hour" or "current_time". If I change the first or second occurance to say GetLatitude it gets the latitude fine, despite there also being other latitude calls elsewhere in the program - basically it seems to be a problem with this specific command to GetHour. All variables are defined on each page of every slot and i've can confirm that each slot is setup correctly as other parts work fine.

Has anyone seen this before/know how to solve it?

Many thanks as i've spent many hours banging my head against the wall trying to work out why its broken...

Mike Green
02-15-2010, 07:57 AM
When you send a "!GPS",GetHour the response is 3 bytes. You only read one byte. If there's enough time between the two calls, the GPS module will send the 2nd and 3rd bytes and your Stamp will ignore them. If you try to send another command too quickly, the GPS module will still be sending data bytes and will miss the new command and eventually time out. I suggest you use a dummy (temporary) variable to hold the received additional bytes. That way the GPS module will be ready for a new command when you expect it to be ready.

Declare a variable "Dummy VAR Byte" and do "SERIN gps_sio, gps_baud, 3000, no_gps_response,[power_on_time_hour, Dummy, Dummy]"