Ultimate GPS / MTK3339 RTC Question

Breakout boards, sensors, Drawdio, Game of Life, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Ultimate GPS / MTK3339 RTC Question

Postby Stephanie » Sat Apr 28, 2012 2:58 pm

I've been reading the data sheet and command manual for the MTK3339 GPS device, but haven't been able to find a definite answer to what I'm looking for.

I am building a wearable device and would like to incorporate a clock into it. I will have the MTK3339 unit for positional information, and I know I can grab the UTC time/date from that, but there are going to be situations where the GPS won't be able to maintain a lock on the sattelites. Plus, for power savings, I was thinking of shutting down the GPS at times using the built-in backup mode.

For all I've read about the MTK3339 having a built-in RTC, what I can't figure out is if it is possible to access this RTC externally, in order to get the time from the GPS even if it has no satellites?

If I can't rely on the GPS for the time without satellites in view, one alternative is to add a Chronodot to my project. However, if I can omit that it'll cut down the parts count and save me some space in the final build.

I suppose I could also utilize a soft-RTC in the microcontroller (it's Arduino compatible) and update the soft-RTC from the GPS when the GPS has a lock?

Thanks!
User avatar
Stephanie
 
Posts: 286
Joined: Sat Dec 11, 2010 12:17 am
Location: Canada

Re: Ultimate GPS / MTK3339 RTC Question

Postby adafruit » Sun Apr 29, 2012 11:38 pm

install the battery and coin cell
the GPS will spit out time data even when there is no lock, try it and you'll see how it works
User avatar
adafruit
 
Posts: 10485
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: Ultimate GPS / MTK3339 RTC Question

Postby Stephanie » Mon Apr 30, 2012 6:32 am

Super, thank you!

It's still in the mail but I'll test it as soon as it arrives.
User avatar
Stephanie
 
Posts: 286
Joined: Sat Dec 11, 2010 12:17 am
Location: Canada

Re: Ultimate GPS / MTK3339 RTC Question

Postby djszk » Sun Jul 22, 2012 8:10 pm

I'm thinking of using the MTK3339 in my device as a substitute for a Chronodot 99% of the time and as a tool to dump the coordinates once per power-on (after a fix is gained) the remaining 1% of the time. Is the standby battery draw from the coin cell higher than what the Chronodot does when the unit is powered down? Again, I would use this mostly as a RTC and leave the GPS on only until a fix can send a full set of coordinates; I would then disable the GPS until the device is reset.

Thanks!
djszk
 
Posts: 22
Joined: Mon May 14, 2012 2:43 pm

Re: Ultimate GPS / MTK3339 RTC Question

Postby Stephanie » Sun Jul 22, 2012 9:49 pm

The gps does not output any data while it is off (or on backup battery power). Its RTC is only useful for the gps internally. You only get time data from it if it is fully on and sending NMEA sentences.

So for the MTK3339 thats 20mA if it has a fix, or 25mA if it is trying to acquire a fix.

What I ended up doing is implementing a software RTC and then powering up the gps now and then to sync the time. It keeps time accurately enough for me that way.
User avatar
Stephanie
 
Posts: 286
Joined: Sat Dec 11, 2010 12:17 am
Location: Canada

Re: Ultimate GPS / MTK3339 RTC Question

Postby djszk » Mon Jul 23, 2012 3:23 pm

That actually makes sense for my application, and in fact I also query the RTC only once per session to start a software RTC. Do you have any idea how long the coin cell lasts in standby? I really am concerned only if it's doing anything more than keeping an RTC running (e.g. occasionally querying satellites, etc). It's going to be difficult in my device to replace a coin cell more than once every few years...
djszk
 
Posts: 22
Joined: Mon May 14, 2012 2:43 pm

Re: Ultimate GPS / MTK3339 RTC Question

Postby Stephanie » Mon Jul 23, 2012 3:55 pm

I don't know how long the coin cell would last. IIRC the gps module draws 7uA in backup mode, but you should double-check the datasheet to be sure. If that's accurate then a 200mAh coin cell (eg 2032) ought to be good for a couple years.

Edited to add: One peculiarity I discovered was that when you wake the GPS up from sleep, the first NMEA sentence(s) it transmits has the timestamp from when it was put to sleep. After that, the NMEA data gets updated to the current time. So using it to syncronize a software RTC, you have to discard the initial data or the clock is wrong.

My workaround was to not update my software RTC until the GPS has a positional fix.
User avatar
Stephanie
 
Posts: 286
Joined: Sat Dec 11, 2010 12:17 am
Location: Canada

Re: Ultimate GPS / MTK3339 RTC Question

Postby djszk » Mon Jul 23, 2012 4:14 pm

Thanks so much for this very useful information!
djszk
 
Posts: 22
Joined: Mon May 14, 2012 2:43 pm

Re: Ultimate GPS / MTK3339 RTC Question

Postby wbp » Wed Sep 26, 2012 2:19 pm

install the battery and coin cell
the GPS will spit out time data even when there is no lock, try it and you'll see how it works


Can you please tell us how it "spits out" the time data? Which sentence is sent? It would be helpful if this feature were better documented. There doesn't seem to be anything in the doc except how to install the battery.

Thanks,
William
User avatar
wbp
 
Posts: 149
Joined: Mon Mar 07, 2011 12:18 pm

Re: Ultimate GPS / MTK3339 RTC Question

Postby billn » Wed Sep 26, 2012 3:37 pm

Can you please tell us how it "spits out" the time data? Which sentence is sent? It would be helpful if this feature were better documented. There doesn't seem to be anything in the doc except how to install the battery.


Have you looked at the online tutorial for this product at http://learn.adafruit.com/adafruit-ultimate-gps/overview
In the Downloads & Resources section you can get the full data sheet on the GPS that includes all of the details for the NMEA strings that come out of it, what inputs it takes, speeds, ...

In addition the library code for this device will extract the time information from both the GGA and RMC strings.
About the only things the library does not decode is Magnetic Variation, but the code is structured well enough it
would be easy to add.

I bought one of these a few weeks ago and found everything I needed from the tutorial and its links.
billn
 
Posts: 9
Joined: Sat Aug 18, 2012 10:25 am

Re: Ultimate GPS / MTK3339 RTC Question

Postby wbp » Thu Sep 27, 2012 1:28 pm

Yes, I looked at the tutorial. There is nothing there about what it "spits out" the time data when there is no GPS signal. There is nothing there at all about what having the battery installed actually does, just info on how to install it. Thus my question.

For example, does it continue to output the RMC NMEA string with an "A" for "Active" even though there is no GPS signal? That would seem unlikely.

My testing so far shows that what the battery does is cause the GPS module to remember the configuration settings, such as the update rate and what strings to output, so you only have to set these once. Remove power AND the battery and it goes back to defaults.

I would guess that with the battery installed, but no GPS signal, the RMC string would have a "V" for status, but the time would still be correct because of the internal RTC. I can find NOTHING in the documentation that confirms this. Thus my question.

William
User avatar
wbp
 
Posts: 149
Joined: Mon Mar 07, 2011 12:18 pm

Re: Ultimate GPS / MTK3339 RTC Question

Postby wbp » Thu Sep 27, 2012 2:02 pm

I did some more testing with the GPS in a Faraday cage and the battery installed. Removed all external power for several minutes and then connected it back up.

Aside: This thing is sensitive! I thought I had a complete shield but there was a tiny leak around where the USB cable entered the cage, and it managed to find enough GPS signal to get an intermittent fix!

If there is no GPS signal, with the battery installed, it does output an RMC sentence with the correct time. I have no information on how accurate the RTC is under this condition but it's probably good enough for normal timekeeping until GPS signal is re-acquired.

Without the battery installed, on startup the RMC sentence has a time value of roughly 23:58:xx or 23:59:xx.

There does not appear to be a way to determine if the RTC has valid time or not - perhaps there are commands for this?

William
User avatar
wbp
 
Posts: 149
Joined: Mon Mar 07, 2011 12:18 pm

Re: Ultimate GPS / MTK3339 RTC Question

Postby Stephanie » Thu Sep 27, 2012 7:47 pm

wbp wrote:There does not appear to be a way to determine if the RTC has valid time or not - perhaps there are commands for this?


I don't know of any NMEA command or query to ask the GPS if its RTC is correct. The GPS (Ultimate, PA6C) seems to start off at 00:00:00, 01/01/80 when it is turned on, and counts time from that moment. As soon as it gets a time signal from a satellite it updates its RTC. This can happen without a fix.

In my application, I test the time & date together. I'm using the Arduino Time library (software RTC) and theoretically in my application the GPS's RTC should only be completely wrong on initial startup before it has locked onto a sattelite's time signal. Subsequently, when the GPS has been woken from sleep the first sentence seems to be wrong, so I don't allow it to update the software RTC in the Arduino until the GPS has a recent 3d fix.

So the first thing I test is the year the GPS is returning - if it is less than 2011 or more than 2079 then the time is discarded. (I went with 2079 because sometimes it reports 1980 that somehow gets read into the time library as 2080.)

The second thing I test is if the last known fix is more than 2 seconds old, and we have had a fix in the past, then I discard the data. (If we have never had a fix but the year is > 2011 and < 2079 then I accept it as 'good enough' just to get data on the clock ASAP.)

If it passes those two tests then I am confident that the time & date from the GPS is good, and use it to update the software RTC in the Arduino. Here's the function I use, built to work with the time library:
Code: Select all
time_t gpsTimeSync() {
  if((gps.fix_age() > 2000) && (timeStatus() != timeNotSet)) return 0;          // gps data probably stale & clock was set so skip sync
  tmElements_t tm;
  int year;
  gps.crack_datetime(&year, &tm.Month, &tm.Day, &tm.Hour, &tm.Minute, &tm.Second, NULL, NULL);
  tm.Year = year - 1970;
  if((year > 2011) && (year < 2079)) {                                          // gps data probably good
    time_t time = makeTime(tm);
    time += (timeZone * SECS_PER_HOUR);
    return time;
  }
  return 0;                                                                     // no valid time to set
}


Cheers!

p.s. I'm using the TinyGPS library for parsing the NMEA data, that's where the gps.nnnnn functions come from.
User avatar
Stephanie
 
Posts: 286
Joined: Sat Dec 11, 2010 12:17 am
Location: Canada

Re: Ultimate GPS / MTK3339 RTC Question

Postby wbp » Thu Sep 27, 2012 10:10 pm

Thanks, Stephanie, that's very helpful. I was just thinking about checking the date, that's a great idea.

I am not using Arduino libraries for this project, I'm parsing the data myself. This is for a couple of clocks (including IceTube).

Thanks!
William
User avatar
wbp
 
Posts: 149
Joined: Mon Mar 07, 2011 12:18 pm


Return to Other Adafruit products

Who is online

Users browsing this forum: No registered users and 4 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [100]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[108]
 
Wireless[14]
Cables[60]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[69]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]