knobby67
Posts: 40
Joined: Fri Mar 09, 2012 9:18 am

Re: Attaching a RTC

Thu Mar 29, 2012 7:53 am

Hi all,

Does anyone know if attaching a RTC to either of the GPIO peripheral busses will auto detect from the Linux build?  If so what RTC have people find work.  Or will drivers need to be written for a RTC?

Thanks

PS sorry if this has been asked, I'm having real problems finding answers from the search box, seems to just bring up random questions.

User avatar
nick.mccloud
Posts: 804
Joined: Sat Feb 04, 2012 4:18 pm

Re: Attaching a RTC

Thu Mar 29, 2012 8:05 am

Nothing will be auto-detected on GPIO without a driver and as this would be a unique arrangement you'd need to write a driver that checked for and accessed the RTC on GPIO or get someone to do it for you.

User avatar
SN
Posts: 1014
Joined: Mon Feb 13, 2012 8:06 pm
Location: Romiley, UK
Contact: Website

Re: Attaching a RTC

Thu Mar 29, 2012 8:08 am

is there not a super simple solution where an rtc device is just read at init time - I assume you can get these things as USB connected devices - may be have a cron job that checks every minute or so and adjusts raspi time accordingly
Steve N – binatone mk4->intellivision->zx81->spectrum->cbm64->cpc6128->520stfm->pc->raspi ?

naicheben
Posts: 344
Joined: Sat Jan 28, 2012 12:28 pm
Contact: Website

Re: Attaching a RTC

Thu Mar 29, 2012 8:32 am

Maybe with I2C:

http://www.ladyada.net/learn/b.....07rtc.html

Perhaps you will have to enable hwclock in the Kernel (make menuconfig ....) and rebuild your own Kernel.

When the first boards arrive at home it will probably not take much time until we finally know how to attache RTC.

bbramble
Posts: 60
Joined: Wed Jan 04, 2012 4:10 pm

Re: Attaching a RTC

Thu Mar 29, 2012 8:36 am

SN said:


is there not a super simple solution where an rtc device is just read at init time - I assume you can get these things as USB connected devices - may be have a cron job that checks every minute or so and adjusts raspi time accordingly



The simplest solution is to use either the on-board ethernet or a usb wifi adapter and get the time from an NTP server. Of course, this does not help if you are planning on running the board disconnected.

Chris.Rowland
Posts: 239
Joined: Thu Jan 12, 2012 5:45 pm

Re: Attaching a RTC

Thu Mar 29, 2012 9:03 am

The hardware for a RTC would be connected to the I2C bus.  From what I've seen in previous posts here the RTC module can use the 3V3 I2C bus even though it's a 5V device.

A general purpose interface library to use the I2C bus is so useful that it will be out very rapidly - if it's not already there.

It needs a program to read the time from the RTC and set the system clock. I imagine this could be run by the startup script if it fails to get the time from an external NTP server.

A program that sets the time in the RTC would also be needed.

None of these things seem inherently difficult, for example existing code that can do this on a Arduino would probably need only a small amount of tweaking - mostly to handle the different I2C interface library.

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Attaching a RTC

Thu Mar 29, 2012 9:20 am

I've just checked the data-sheets of two RTC chips. They will both run on 3.3V and RS sell them both for just over £1. Only minimal extra components are required and they could be powered from the GPIO connector.

User avatar
SN
Posts: 1014
Joined: Mon Feb 13, 2012 8:06 pm
Location: Romiley, UK
Contact: Website

Re: Attaching a RTC

Thu Mar 29, 2012 9:51 am

bbramble said:


SN said:


is there not a super simple solution where an rtc device is just read at init time - I assume you can get these things as USB connected devices - may be have a cron job that checks every minute or so and adjusts raspi time accordingly


The simplest solution is to use either the on-board ethernet or a usb wifi adapter and get the time from an NTP server. Of course, this does not help if you are planning on running the board disconnected.


My question was ONLY for non-interneted connected raspi's
Steve N – binatone mk4->intellivision->zx81->spectrum->cbm64->cpc6128->520stfm->pc->raspi ?

Chris.Rowland
Posts: 239
Joined: Thu Jan 12, 2012 5:45 pm

Re: Attaching a RTC

Thu Mar 29, 2012 11:08 am

rurwin said:


I've just checked the data-sheets of two RTC chips. They will both run on 3.3V and RS sell them both for just over £1. Only minimal extra components are required and they could be powered from the GPIO connector.



That would be the PCF8563 I suppose. It looks just the thing. Just a crystal, two capacitors, two resistors, two diodes and a 3V battery to make it work. Pricing seems to be all over the place, I've found it from £0.61 to £2.85 (That was eBay).

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Attaching a RTC

Thu Mar 29, 2012 11:22 am

The other one was the ISL1208, which just requires a crystal, a diode, a resistor and a battery. It costs marginally more - £1.38 as against £1.05 (RS prices).

User avatar
fodi
Posts: 112
Joined: Wed Mar 14, 2012 9:03 pm
Location: Hungary

Re: Attaching a RTC

Thu Mar 29, 2012 5:49 pm

is it possible to write a script that saves the system time into a file when the board is shutting down, then uses this as new time when turned on again?

and when booted up it might look for network time server, if connected to the internet

that way it wouldn't always boot up as 1-1-1970 00:00

and then we might include it somehow in the boot and shutdown sequence

User avatar
nick.mccloud
Posts: 804
Joined: Sat Feb 04, 2012 4:18 pm

Re: Attaching a RTC

Thu Mar 29, 2012 6:41 pm

fodi said:


is it possible to write a script that saves the system time into a file when the board is shutting down, then uses this as new time when turned on again?


There are such scripts lurking about this forum:

http://www.raspberrypi.org/for.....pi/page-15

User avatar
fodi
Posts: 112
Joined: Wed Mar 14, 2012 9:03 pm
Location: Hungary

Re: Attaching a RTC

Thu Mar 29, 2012 7:13 pm

nmcc said:





There are such scripts lurking about this forum:

http://www.raspberrypi.org/for.....pi/page-15


thanks, i'm glad it is worked on

User avatar
Gert van Loo
Posts: 2487
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Attaching a RTC

Thu Mar 29, 2012 7:28 pm

Storing and reading the time has been done in the latest Debian release.

Some  (Dom & I) complained that after a re-boot "make" complains about 'time in the future'. I gotr used to start with a touch * after re-booting.

(Yes, I was too lazy to put in a date & time)

error404
Posts: 351
Joined: Wed Dec 21, 2011 11:49 pm

Re: Attaching a RTC

Thu Mar 29, 2012 9:24 pm

The Linux kernel does contain drivers for many I2C RTC devices. If you instantiate it properly in the kernel you shouldn't really have to write any code at all, just a custom kernel build. See: http://lxr.linux.no/#linux+v3......rivers/rtc

Nice thing about PCF8563 for this is that it's available in DIP in addition to being cheap and supported by Linux. If you're okay with SMD options and you're doing this dead-bug I'd probably just pay the extra buck or two for an integrated XTAL and get the DS1337C.

knobby67
Posts: 40
Joined: Fri Mar 09, 2012 9:18 am

Re: Attaching a RTC

Thu Mar 29, 2012 9:54 pm

Storing and reading the time has been done in the latest Debian release.

Some  (Dom & I) complained that after a re-boot "make" complains about "time in the future". I gotr used to start with a touch * after re-booting.

(Yes, I was too lazy to put in a date & time)

May iask is there a reason why you dont cross compile?

Return to “General discussion”