RTC


37 posts   Page 2 of 2   1, 2
by XAPBob » Wed Feb 01, 2012 3:58 pm
There is also the old Rugby time signal (now broadcast from Cumbria I believe).

[PDF Details: http://www.npl.co.uk/science-+.....-date-code ]

I have a couple of receivers for those (IIRC I was going to hang them off a serial port) – one for the UK version, one for the German equivalent.
Posts: 85
Joined: Tue Jan 03, 2012 2:40 pm
by error404 » Wed Feb 01, 2012 6:27 pm
Crundy said:


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?


There is a driver in tree for DS1307 family (including DS1338). To use it will you probably have to modify the board config file for the Raspberry Pi and recompile your kernel. However, since the addresses of these devices can't change it's probably safe to put it in the default config file and build as a module, but that's something the foundation would have to do in their kernel tree, and may not want to.

Once the chip's internal NVRAM is set to make it act as an RTC (which you could do one time with the Linux i2c utilities before loading the module), it should work with the standard Linux hardware clock interface, and if your init scripts read/write the time using hwclock (and the module is loaded first / compiled in), they should pull the correct time from the module.

If you don't want to fiddle in the kernel it shouldn't be too hard to write a C program to interface manually via the i2c library to the chip instead.

XAPBob said:


I have a couple of receivers for those (IIRC I was going to hang them off a serial port) – one for the UK version, one for the German equivalent.


Along with other similar signals like DCF77, CHU and WWV. Many of these actually have soundcard-based decoders in the NTP sources, so all you need is a cheap USB soundcard and a shortwave radio to get within a few ms. Of course this is a lot more cumbersome than just attaching an RTC module.
Posts: 351
Joined: Wed Dec 21, 2011 11:49 pm
by karol » Sat Feb 18, 2012 2:09 am
Would not powering down help?

I'm thinking mainly about Model A: no built-in Internet connectivity but draws so little power I can simply keep it turned on (and just turn off the monitor for the night).

Would this setup be still susceptible to time drift? Would it be a substantial amount (say, 10 minutes or more) a week?
Posts: 3
Joined: Sat Feb 18, 2012 2:00 am
by drgeoff » Sat Feb 18, 2012 12:58 pm
sylvan said:



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


The wiki says not.
Posts: 2922
Joined: Wed Jan 25, 2012 6:39 pm
by Chromatix » Sat Feb 18, 2012 6:39 pm
karol said:


Would this setup be still susceptible to time drift? Would it be a substantial amount (say, 10 minutes or more) a week?


Typical quartz crystal oscillators, no matter the frequency, are pretty accurate.  A cheap watch or a clock built into an oven, microwave or VCR - none of which have special concern taken for accuracy - usually keeps time to within a few minutes per year - that's about 10^-7 accuracy.

The timer circuits on the R-Pi, which are driven from the main system clock, shouldn't be significantly worse than that.

Of course if you then discipline the clock using NTP (easy on a Model B) or a GPS receiver, the accuracy will be as near to absolutely correct as makes no odds.
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 naicheben » Thu Apr 12, 2012 2:57 pm
drgeoff said:


sylvan said:



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


The wiki says not.



But as far as I understand the datasheet the DS1307 only pulls the pins down to GND. Wouldn't that mean it is irrelevant if the resistors are tight to 5V or 3,3V?


Datasheet said:

SCL (Serial Clock Input) – SCL is used to synchronize data movement on the serial interface.
SDA (Serial Data Input/Output) – SDA is the input/output pin for the 2-wire serial interface. The SDA
pin is open drain which requires an external pullup resistor.



VIH (Voltage in High) Min: 2.2V

Posts: 344
Joined: Sat Jan 28, 2012 12:28 pm
by mahjongg » Fri Apr 13, 2012 12:04 am

drgeoff said:

But as far as I understand the datasheet the DS1307 only pulls the pins down to GND. Wouldn't that mean it is irrelevant if the resistors are tight to 5V or 3,3V? VIH (Voltage in High) Min: 2.2V


Yes, using pullups to 3,3V is standard practice if one of the devices on the I2C bus uses 3V3 levels. It should work fine.
User avatar
Forum Moderator
Forum Moderator
Posts: 5690
Joined: Sun Mar 11, 2012 12:19 am
by disneysw » Mon May 14, 2012 10:11 am
A couple of comments,

Having a RTC is not a big deal if the system has an Internet connection as the time can easily be established from a NTP server. Once set the OS can maintain reasonable accurate time. The real benefit and one not discussed is allowing for the RTC to wake-on-alarm. Even that is not such a big deal on the raspberrypi since it draws minimal power so it could just remain on all the time.

If you really want to add an RTC checkout http://www.coolcomponents.co.uk/catalog ... p-904.html
Posts: 14
Joined: Tue May 08, 2012 10:49 am
by Max » Mon May 14, 2012 12:16 pm
error404 wrote:Along with other similar signals like DCF77, CHU and WWV. Many of these actually have soundcard-based decoders in the NTP sources, so all you need is a cheap USB soundcard and a shortwave radio to get within a few ms. Of course this is a lot more cumbersome than just attaching an RTC module.


Looks like there are also ready-made DCF modules: http://www.conrad.nl/ce/nl/product/6411 ... rintplaat/
by psergiu » Mon May 14, 2012 11:03 pm
As soon as we have working I2C or SPI drivers for the RPi, all that remains is connecting a 3.3V RTC board to the GPIO pins and loading a kernel module - as most (if not all) of the common RTC chips already have kernel drivers.
User avatar
Posts: 212
Joined: Mon Nov 07, 2011 8:36 am
Location: Bucharest, Romania
by AndrewS » Sun May 20, 2012 4:40 pm
disneysw wrote:The real benefit and one not discussed is allowing for the RTC to wake-on-alarm. Even that is not such a big deal on the raspberrypi since it draws minimal power so it could just remain on all the time.

AFAIK there's no 'sleep mode' available on the Raspberry Pi? Hence no wake-on-alarm functionality either.
User avatar
Posts: 3626
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
by Embedded » Thu Jun 28, 2012 9:56 am
There are lot's of SPI based RTC modules you can buy off the shelf.

I did a bit of searching and this one has everything you need SPI bus, RTC and a battery holder: http://www.sparkfun.com/products/10160
Posts: 5
Joined: Thu Jun 14, 2012 3:09 am