Ultimate GPS shield: RTC use

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
michelv
 
Posts: 11
Joined: Thu Oct 17, 2013 5:13 am

Ultimate GPS shield: RTC use

Post by michelv »

Hey,

Is there any example code for use of the RTC? Currently I don't see a the time/date being shown after a fix is lost (using any example code for leo). Or am I missing something?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Ultimate GPS shield: RTC use

Post by adafruit_support_rick »

The shield does not have an RTC. The time-date information comes directly from the GPS module.
The information is contained in the RMC and GGA sentences, which continue to transmit from the module after the fix is lost, so you should be getting updates.

User avatar
michelv
 
Posts: 11
Joined: Thu Oct 17, 2013 5:13 am

Re: Ultimate GPS shield: RTC use

Post by michelv »

Hey,

ok, so what is then the function of the backup battery? What exactly is it back up for? The internal RTC as far as I understand, but why is that then giving empty dates after power cut?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Ultimate GPS shield: RTC use

Post by adafruit_support_rick »

It shouldn't give empty dates after a power loss if you have the backup battery installed. Maybe you have a dead battery? Or maybe you just have a poor connection. We recommend a small bump of solder on the contact pad under the battery.

I believe the RTC does time out after something like two weeks without a fix. Perhaps that's what you're seeing?

User avatar
michelv
 
Posts: 11
Joined: Thu Oct 17, 2013 5:13 am

Re: Ultimate GPS shield: RTC use

Post by michelv »

Hey,

I just checked after a night of non-power.
Result from "parsing", indoors, with battery in since a week and fix the day before for several hours:

Time: 7:6:3.328
Date: 0/0/200
Fix: 0 quality: 0
$PGTOP,11,2*6E
$GPGGA,070604.332,,,,,0,3,,,M,,M,,*4C
$GPRMC,070604.332,V,,,,,0.06,0.00,290814,,,N*4A
$PGTOP,11,2*6E
$GPGGA,070605.332,,,,,0,3,,,M,,M,,*4D
$GPRMC,070605.332,V,,,,,0.02,0.00,290814,,,N*4F

So time works (and is correct) but date is not.

As soon as I get a fix, the date is corrected correctly.

So the RTC is only there for time? That is actually what it says here:
https://learn.adafruit.com/adafruit-ult ... y-and-more
so I might be wishing for more than is there actually.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Ultimate GPS shield: RTC use

Post by adafruit_support_rick »

The RTC should maintain both time and date. What seems to be happening is that your RTC is resetting when you remove power, but that should not happen. Possibly you have a loose connection, or your battery is not making good contact. If you can, put a small blob of solder on the battery contact pad.

lucgallant
 
Posts: 39
Joined: Sat Mar 15, 2014 12:21 pm

Re: Ultimate GPS shield: RTC use

Post by lucgallant »

Instead of making a new thread, I thought I'd respond to this one.

I wanted to use the GPS RTC as well but couldn't figure a way to use the GPS chip RTC for both time and date. And also it didn't seem to do anything if I stopped reading sentences. I wouldn't mind spending the 18$ to get the Adafruit one but then I'd have to get it shipped all the way here to Canada... I'll probably end up buying it later when some bug in what I've programmed annoys me enough.

I've taken the Time library by Michael Margolis and modified it slightly, not that cleanly, but oh well - to sync to the PPS signal coming out of the GPS.

So I setup an input pin interrupt to the PPS line on the GPS, and made a new nowPPS() function in Time.cpp, and made it increase the system time based on the receipt of that pulse.

Here's my function. Note that you MUST disable the "sysTime++" line in now() otherwise you'll be doubly increasing time every second...

Code: Select all

time_t nowPPS(bool PPSTick){
  if(PPSTick){ 
    sysTime++;
#ifdef TIME_DRIFT_INFO
    sysUnsyncedTime++; // this can be compared to the synced time to measure long term drift     
#endif	
  }
  if(nextSyncTime <= sysTime){
	if(getTimePtr != 0){
	  //Serial.println("Next Sync Time: " + (String)nextSyncTime);
	  //Serial.println("System Time: " + (String)sysTime);
	  //Serial.println("Calling get time function.");
	  time_t t = getTimePtr();
      if( t != 0)
        setTime(t);
      else
        Status = (Status == timeNotSet) ?  timeNotSet : timeNeedsSync;        
    }
  }  
  return sysTime;
}
Anyway, by increasing the system time (it is the Linux time from Jan 1 1970) via the PPS pulses, my clock is now extremely accurate. I still sync every once in a while to the GPS time in case something's gone wonky, but it's been good so far. Thanks...

User avatar
jboyton
 
Posts: 101
Joined: Tue Sep 16, 2014 2:52 pm

Re: Ultimate GPS shield: RTC use

Post by jboyton »

MichelV wrote:Time: 7:6:3.328
Date: 0/0/200
Fix: 0 quality: 0
$PGTOP,11,2*6E
$GPGGA,070604.332,,,,,0,3,,,M,,M,,*4C
$GPRMC,070604.332,V,,,,,0.06,0.00,290814,,,N*4A
$PGTOP,11,2*6E
$GPGGA,070605.332,,,,,0,3,,,M,,M,,*4D
$GPRMC,070605.332,V,,,,,0.02,0.00,290814,,,N*4F

So time works (and is correct) but date is not.

As soon as I get a fix, the date is corrected correctly.
The date is there in the NMEA string, "290814". Why isn't it showing up in the way it's reported?

A quick perusal of Adafruit_GPS.cpp (assuming that's what you're using) makes me think the parse function isn't doing it's thing properly. It seems to be incrementing the string pointer as if the latitude and longitude data were always there. I could be misreading it though. What do you think?

Here is an excerpt:

Code: Select all

    // parse out latitude
    p = strchr(p, ',')+1;
    strncpy(degreebuff, p, 2);
    p += 2;
    degreebuff[2] = '\0';
    int32_t degree = atol(degreebuff) * 10000000;
    strncpy(degreebuff, p, 2); // minutes
    p += 3; // skip decimal point
    strncpy(degreebuff + 2, p, 4);
    degreebuff[6] = '\0';
    long minutes = 50 * atol(degreebuff) / 3;
    latitude_fixed = degree + minutes;
    latitude = degree / 100000 + minutes * 0.000006F;

lucgallant
 
Posts: 39
Joined: Sat Mar 15, 2014 12:21 pm

Re: Ultimate GPS shield: RTC use

Post by lucgallant »

MichelV wrote:Hey,

Is there any example code for use of the RTC? Currently I don't see a the time/date being shown after a fix is lost (using any example code for leo). Or am I missing something?
I never had issues in particular with the date except for one unrelated to this discussion.

I agree the date is in the sentences as you say. Not sure why the parser didn't like it, you might be on to something about Lat and Long not being there.

I've just decided that instead of parsing all the sentences continuously I'm going to use the PPS functionality...

User avatar
michelv
 
Posts: 11
Joined: Thu Oct 17, 2013 5:13 am

Re: Ultimate GPS shield: RTC use

Post by michelv »

Hey,

Maybe we hit two issues here. First the parsing, sorry I missed that one, but you are very right: the date is already there, and not being parsed correctly. I think the AdaFruit crew should check the code a bit.
The second issue still remains: the battery back up function is not working. I am implementing the shield in a situation that we want to save battery, and simply remove power during night/non-use. Time is more important for us than exact location (and I expect the usual long waits there anyway). I haven't used tried the blob of solder yet, will do that once I get back to this issue.

Thanks for all the replies,
Michel

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Ultimate GPS shield: RTC use

Post by adafruit_support_rick »

I'm looking into the parser...

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Ultimate GPS shield: RTC use

Post by adafruit_support_rick »

Download the latest version of the Adafruit GPS library and see if your date problem is fixed.
https://github.com/adafruit/Adafruit-GPS-Library

User avatar
michelv
 
Posts: 11
Joined: Thu Oct 17, 2013 5:13 am

Re: Ultimate GPS shield: RTC use

Post by michelv »

Hey,

I tried today, after a night of disconnect and with the library of Sept 27th, and tried to catch the first data (unsuccessful). But one of the first I did get, before a full fix:

Time: 9:57:30.843
Date: 28/9/2014
Fix: 0 quality: 0
$PGTOP,11,2*6E
$GPGGA,095731.849,,,,,0,3,,,M,,M,,*47
$GPRMC,095731.849,V,,,,,0.11,0.00,280914,,,N*47
$PGTOP,11,2*6E
$GPGGA,095732.849,,,,,0,3,,,M,,M,,*44
$GPRMC,095732.849,V,,,,,0.08,0.00,280914,,,N*4C
$PGTOP,11,2*6E
$GPGGA,095733.849,,,,,0,3,,,M,,M,,*45
$GPRMC,095733.849,V,,,,,0.27,0.00,280914,,,N*40

So the date is there now, and correctly. So it seems to have fixed the parsing issue, and possibly the battery issue as well. Thanks!

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Ultimate GPS shield: RTC use

Post by adafruit_support_rick »

No problem. Thanks for pointing out the bug!

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”