RTC


37 posts   Page 1 of 2   1, 2
by Pieter-Jan » Mon Jan 02, 2012 7:58 pm
Hello,

I was wondering why there isn't a real time clock on the final design of the raspberry pi?It's a very cheap component and so useful! With a "relatively big" condensator and a blocking diode it would be possible to keep it alive for several days without the need of a battery!

Could anyone shed some light on this?

Thanks!
Posts: 5
Joined: Mon Jan 02, 2012 4:36 pm
by nelson » Mon Jan 02, 2012 8:21 pm
No rtc on the final board if internet connection is available the pi may (depending on the distro used) try to set the clock and will maintain the time correctly until it's turned off.
Posts: 38
Joined: Sat Dec 17, 2011 3:43 am
by Tomo2k » Mon Jan 02, 2012 8:21 pm
Probably because it would cost ~$3 in parts, plus the extra board space needed which adds more cost.

Maxim DS1338 is $1.12, plus crystal, coin cell holder and coin cell.

(A supercap is about $5 alone, and usually requires manual soldering)

The margin on this thing is extremely tight!

If you need a RTC, it's easy enough to fit one to the GPIO that takes a coin cell.

Single-IC solutions exist for both the I2C and SPI bus - eg the Maxim DS1338, which needs an external crystal, or DS3234 ($3.36) which has integrated crystal.

There are several threads about this already, eg this one.
Posts: 126
Joined: Mon Dec 19, 2011 10:00 pm
by Pieter-Jan » Mon Jan 02, 2012 8:25 pm
Aha sorry I did look for another thread but didn't find one.

Just wanted to add that I am definitely not talking about super caps or battery (coins) powered devices. Just a normal condensator with a simple i2c rtc would be more than good enough. But as you said ... I will waste some GPIO pins on this then...
Posts: 5
Joined: Mon Jan 02, 2012 4:36 pm
by Chromatix » Mon Jan 02, 2012 8:29 pm
If you put it on SPI, you can make it a pass-through board, ie. without wasting any pins.
The key to knowledge is not to rely on people to teach you it.
User avatar
Posts: 430
Joined: Mon Jan 02, 2012 7:00 pm
Location: Helsinki
by Wooloomooloo » Mon Jan 02, 2012 8:44 pm
Pieter-Jan said:

Just wanted to add that I am definitely not talking about super caps or battery (coins) powered devices. Just a normal condensator with a simple i2c rtc would be more than good enough.


Frankly, I haven't done the math on this, but the only place I've ever seen time maintained by regular caps was digital photo cameras and PDAs, and it only worked for mere minutes on both. You might get a better result with a dedicated RTC chip, but I'd still say that any sort of half-serious timekeeping that would actually require a RTC should be done with at least a coin cell - that should last more or less forever.
Posts: 92
Joined: Fri Nov 25, 2011 10:52 am
by arm2 » Mon Jan 02, 2012 8:50 pm

Pieter-Jan said:


Aha sorry I did look for another thread but didn't find one.

Just wanted to add that I am definitely not talking about super caps or battery (coins) powered devices. Just a normal condensator with a simple i2c rtc would be more than good enough. But as you said ... I will waste some GPIO pins on this then...


We (CJE/4D) have desiged an RTC module for the RaspberryPi! I've asked if one of the beta testers wants to test it, I am awaiting a reply. (They would need to do/have access to an I2C driver!

The forum search only works on words of four letters or more, hence so may VGA, RTC, PSU threads!
Posts: 240
Joined: Thu Dec 15, 2011 3:46 pm
by Burngate » Tue Jan 03, 2012 1:10 pm
arm2 said:



We (CJE/4D) have desiged an RTC module for the RaspberryPi! I've asked if one of the beta testers wants to test it, I am awaiting a reply. (They would need to do/have



I've just looked on cjemicros.co.uk , couldn't find it ? When will you be selling it?
Wyszkowski's Second Law: Anything can be made to work if you fiddle with it long enough.
Brain surgery is easier than psychoanalysis
User avatar
Posts: 2842
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK
by arm2 » Tue Jan 03, 2012 3:47 pm
We won't be selling them until we have been able to test them on a RaspberryPi! I think that is going to take some weeks :-( 6

I hope to list on the website soon some of the items that will be useful to RaspberryPi users.
Posts: 240
Joined: Thu Dec 15, 2011 3:46 pm
by Burngate » Tue Jan 03, 2012 3:58 pm
Ok - thanks - maybe I should exercise some patience? 8)
Wyszkowski's Second Law: Anything can be made to work if you fiddle with it long enough.
Brain surgery is easier than psychoanalysis
User avatar
Posts: 2842
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK
by graham_chow » Sat Jan 07, 2012 11:12 pm
Given the lack of a RTC, will the system prompt the user for the date/time or just start at 1970/1/1 00:00:00?
Posts: 3
Joined: Sat Jan 07, 2012 10:59 pm
by sylvan » Sat Jan 07, 2012 11:49 pm
graham_chow said:


Given the lack of a RTC, will the system prompt the user for the date/time or just start at 1970/1/1 00:00:00?



It's so easy to program it could go either way.  Or any of dozens of alternatives.

If network connected it could get the time via NTP.

It could write the time to disk (sdcard) or any other non-volatile memory available on shutdown (and/or periodically during operation) and read it from there the next boot.  While not correct, at least it would be (most always) increasing which keeps linux much happier.
Posts: 115
Joined: Sun Nov 27, 2011 8:39 pm
by hanysl » Mon Jan 09, 2012 10:50 pm
I thing DS1307 is good but it isn´t integrated crystal but it is cheap. Circuit is realy easy and small. It has I2C bus.
Posts: 4
Joined: Thu Sep 22, 2011 8:20 pm
by The Cageybee » Tue Jan 10, 2012 10:27 am
Might be able to help out here.

I've got a BifferBoard which I use as a NAS along with loads of other stuff running on it which, like the Rpi, has no RTC.

The way around it is to setup the NTP daemon to grab the time on boot then setup a cron job to update the time every 24h.

Looking at my NAS its uptime is 131 days (just over) and the time is bang on.

Obviously won't work with the non networked Rpi.

For those, I guess the easiest clock source would be the DS1307 as it's available in a DIP package. However, it requires an external crystal and isn't temperature compensated which, from experience, leads to serious drift in the time, so bad it makes it almost useless.

So it would be better to use the DS3234 which, as pointed out above, has an integrated crystal but, more importantly, is also temperature compensated so keeps time much better. However, it's only available in an SMD package.
Posts: 17
Joined: Fri Sep 16, 2011 11:28 pm
by hanysl » Tue Jan 10, 2012 10:49 am
I have DS1307 conected to arduino and DS has DIP8 package
Posts: 4
Joined: Thu Sep 22, 2011 8:20 pm
by grumpyoldgit » Tue Jan 10, 2012 10:50 am
I may be missing something but Ubuntu uses NTP to synchronise with international time servers. I assume other flavours of Linux and other OSs do the same.
User avatar
Posts: 1454
Joined: Thu Jan 05, 2012 12:20 pm
by Chromatix » Tue Jan 10, 2012 7:03 pm
There are two problems:

1) Until NTP gets to do it's thing, the date/time known by the system will be wrong - very wrong.  (At the moment, 42 years and a few days wrong.)

2) The Model A doesn't have an Ethernet port.  Hence, no NTP.  Even a Model B might not be plugged into a network every time it powers up.

The official solution seems to be to set the date/time manually on every boot.  To avoid this hassle, some people are thinking about adding hardware to keep the time automatically - an RTC.
The key to knowledge is not to rely on people to teach you it.
User avatar
Posts: 430
Joined: Mon Jan 02, 2012 7:00 pm
Location: Helsinki
by error404 » Tue Jan 10, 2012 7:09 pm
The Cageybee said:

The way around it is to setup the NTP daemon to grab the time on boot then setup a cron job to update the time every 24h.

Why don't you just run ntpd and let it compensate for your system's software clock drift? You will get saner clock behaviour (slewing, rather than stepping, guarantees that time always moves forward, which can be important) and more accurate time.
Posts: 351
Joined: Wed Dec 21, 2011 11:49 pm
by dreamgear » Wed Jan 11, 2012 5:28 am
Might be nice to stash the current time somewhere every so often and then retrieve at it boot so it doesn't end up 40 years behind on every boot.  Then NTP could fix things assuming there's net.

For disconnected operation looks like the RTC is going to be a must.
Posts: 1
Joined: Wed Jan 11, 2012 5:23 am
by m0thm » Sat Jan 14, 2012 6:57 pm
One other option ... and one i will be looking at for a project i have in mind would be to get the time from a serial port linked GPS. I understand GPS can also be used to generate very stable oscillators due to the high precision time keeping required to make the whole GPS system work!  Surely a small bit of code to poll a GPS and grab the time shouldn't be too hard to drop in on boot.
Posts: 6
Joined: Thu Jan 12, 2012 4:54 pm
by error404 » Sun Jan 15, 2012 12:49 am
This would be trivial, the software exists already and NTP with a GPS over serial will get you down in the 50-100ms time sync range. If we have enough information to accurately timestamp an interrupt in-kernel, it would also be possible to develop a PPS driver that could probably get you into the low us.

However, obviously it requires a sky view, though some recent GPS chips are sensitive enough to pick up a signal through a floor or two of wood construction.
Posts: 351
Joined: Wed Dec 21, 2011 11:49 pm
by paulie » Sun Jan 22, 2012 9:14 pm
" I understand GPS can also be used to generate very stable oscillators due to the high precision time keeping required to make the whole GPS system work!  "

You mean like this?
http://www.jrmiller.demon.co.u.....frqstd.htm
Posts: 181
Joined: Thu Jan 19, 2012 6:51 pm
by crundy » Mon Jan 23, 2012 1:48 pm
I bought one of these a while back which I'm going to solder to the GPIO:

http://www.ebay.co.uk/itm/2707.....1439.l2649
User avatar
Posts: 310
Joined: Fri Aug 12, 2011 7:47 am
by sylvan » Mon Jan 23, 2012 5:20 pm
Crundy said:


I bought one of these a while back which I'm going to solder to the GPIO:

http://www.ebay.co.uk/itm/2707.....1439.l2649


Looks like a good choice, especially with the 3.3v support.

I already have a DS1307 that I'm going to rig up...  It needs 5volt, but it looks like with a 5v Vcc it is happy using 3.3v pullups on the SCL and SDA.

(I wish I knew if the gpio on the broadcom was 5v tolerant!!!!!)

For those in the U.S. I prefer to patronize Adafruit.com or SparkFun.com but  as far as I know they only have the 5v parts, e.g.:

http://www.adafruit.com/products/264  (DS1307)

http://www.adafruit.com/products/255  (DS3231 -- temperature compensated for high accuracy)
Posts: 115
Joined: Sun Nov 27, 2011 8:39 pm
by crundy » Wed Feb 01, 2012 11:57 am
Speaking of which, does anyone know the BestTM way to update the system clock using a DS1338 module? I did find a C script a while back that did it using the DS1307 specification (which the DS1338 is apparently compatiable with) but I can't find it now. I was wondering if Linux's rtc command could do it or if there's a daemon I could run on startup out of the box?
User avatar
Posts: 310
Joined: Fri Aug 12, 2011 7:47 am