Using GPS module to update an RTC module every once in a while
MarcusG
Posts: 6
I've found that sparkfun's RTC modules drift a bit too much, it looses over an hour a week. So my plan is to have a gps module that is woken up once a day or something and set the RTC off of it. I happened to have a EB85a around so I'm using that. Using Perry's GPS_IO_mini.spin I am able to read the NMEA output and print it to an LCD just fine. The problem is that I need to be able to pull the hours, minutes and seconds out on their own so I can set the RTC module's time with them. I can't figure out what the actual format of "GPGGAa[noparse][[/noparse]0]" is or how to parse out the three character groups I need (first and second, third and fourth, fifth and sixth). I know it's not a string because printing "strsize (variable that is set to GPGGAa[noparse][[/noparse]0])" to the LCD puts random ASCII to the screen instead of a valid number; a blank square followed by a lowercase "h" then a "(".
Any help would be greatly appreciated.
Thanks much,
-Marcus
Any help would be greatly appreciated.
Thanks much,
-Marcus
Comments
Perry
You may also want to check out this post from earlier this week (or last):
http://forums.parallax.com/showthread.php?p=715452
I've never worked with an LCD before so I may be way off on this, but it sounds like you are printing ASCII values to the screen rather than numbers. If the LCD object you're using requires a conversion from ascii to number before printing to the display that may also be causing your problem.
p
I mis-read your post. It sounds like you are successfully writing to the LCD but are unable to get usable values for your RTC. That does sound like a int vs string problem. The RTC wants numbers. I think all this is covered in the post above.
Best of luck.
Post Edited (pgbpsu) : 3/21/2008 1:59:17 AM GMT
Here ar some of the date and time changes I made to Perry's object. Sorry, I have not updated the documentation comments yet, or generalized the time zone calculations. It requires the "Calendar.spin" object.
.
[noparse][[/noparse]code]
pub timehh | hh
hh := to_hex(byte[noparse]/noparse]GP_GGA_a[noparse][[/noparse] 0[noparse][[/noparse] 0 ]) *10 'uses existing hex lookup as a decimal lookup
hh += to_hex(byte[noparse]/noparse]GP_GGA_a[noparse][[/noparse] 0[noparse][[/noparse] 1 ])
return hh
pub timemm | mm
mm := to_hex(byte[noparse]/noparse]GP_GGA_a[noparse][[/noparse] 0[noparse][[/noparse] 2 ]) *10 'uses existing hex lookup as a decimal lookup
mm += to_hex(byte[noparse]/noparse]GP_GGA_a[noparse][[/noparse] 0[noparse][[/noparse] 3 ])
return mm
pub timess | ss
ss := to_hex(byte[noparse]/noparse]GP_GGA_a[noparse][[/noparse] 0[noparse][[/noparse] 4 ]) *10 'uses existing hex lookup as a decimal lookup
ss += to_hex(byte[noparse]/noparse]GP_GGA_a[noparse][[/noparse] 0[noparse][[/noparse] 5 ])
return ss
pub localtime(dateStr,timeStr) | hh,mm,ss, month,day,yyyy
hh := timehh
mm := timemm
ss := timess
month := dateMonth
day := dateDay
yyyy := dateYear
Cal.ConvertUTCtoLocaltime( -6, yyyy, month, day, hh, mm, ss, true, dateStr, timeStr)
pub timeHHMMSS
'' UTC time of fix HHMMSS
return GP_GGA_a[noparse][[/noparse] 0 ]
pub dateDay | dd
dd := to_hex(byte[noparse]/noparse]GP_RMC_a[noparse][[/noparse] 8[noparse][[/noparse] 0 ]) *10 'uses existing hex lookup as a decimal lookup
dd += to_hex(byte[noparse]/noparse]GP_RMC_a[noparse][[/noparse] 8[noparse][[/noparse] 1 ])
return dd
pub dateMonth | mm
mm := to_hex(byte[noparse]/noparse]GP_RMC_a[noparse][[/noparse] 8[noparse][[/noparse] 2 ]) *10 'uses existing hex lookup as a decimal lookup
mm += to_hex(byte[noparse]/noparse]GP_RMC_a[noparse][[/noparse] 8[noparse][[/noparse] 3 ])
return mm
pub dateYear | yy
yy := to_hex(byte[noparse]/noparse]GP_RMC_a[noparse][[/noparse] 8[noparse][[/noparse] 4 ]) *10 'uses existing hex lookup as a decimal lookup
yy += to_hex(byte[noparse]/noparse]GP_RMC_a[noparse][[/noparse] 8[noparse][[/noparse] 5 ])
return yy + 2000
pub dateDDMMYY
'' DDMMYY
return GP_RMC_a[noparse][[/noparse] 8 ]
/code]
Post Edited (Chuck Rice) : 3/21/2008 8:46:01 AM GMT
I've been reusing this AtoI PUB for converting ASCII string value to a number. the author was MK Borri (another great source forGPS code) Sorry if that’s not the correct attribution!
where the conversion occurs:
pptr is the string address of the GPS data
C = is the number to characters to convert.
Sure, I call the routine a bunch of times, but its still simple!
Let us know if this works for you.
Paul
Post Edited (Paul H) : 3/22/2008 3:09:50 AM GMT
Thanks again