PDA

View Full Version : Looking for some input about RTCs



Kye
01-13-2009, 05:55 AM
Hey guys.

I'm working on making a driver to allow the use of real time clocks on the I2C line the propeller uses to communicate with its eeprom and also to communicate with the eeprom. I also plan to make the driver somewhat expandable capable of running multiple I2C devices at the same time. As in the driver will handle all low level and high level commands.

I plan to make the driver run on a cog. That being said I want my I2C engine to handle as many things as possible.

So, for right now I need help choosing the right real time clock to add to the I2C bus. I'm not sure which one to use.

Some consideration are that I would like to have a RTC capable of using a backup battery and also capable of holding some values that will presit over power cycles. I don't really care if its nvram or sram.

I also need to protype with the chip. That said I would like to use one that has a DIP variant and SMD, QFN, ect. variants for production. I do however have a pretty nice facility to work on this project however, Carnegie Mellon's Robotics club has afew precision soldering irons I can use. If anyone can point me to a site details how to connect surface mount chips to something like the·propeller protoboard then I will be able to use any chip package variants, as long as·then can be modfied with a sodering iron.

Thanks for your help.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Oldbitcollector (Jeff)
01-13-2009, 06:03 AM
I'd seriously consider the DS1302, there nice support for it in the OBEX
and it's in common use thanks to the PPDB.

OBC

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?

Check out: Protoboard Introduction (http://jeffledger.googlepages.com/Protoboard_Introduction.pdf) , Propeller Cookbook 1.4 (http://ucontroller.com/Propeller%20Protoboard%20Designs%20for%20the%20Beg inner.pdf) & Software Index (http://forums.parallax.com/showthread.php?p=770318)
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us (http://propeller.warrantyvoid.us)
Got an SD card connected? - PropDOS (http://www.orrtech.net/propdos/)

Kye
01-13-2009, 06:06 AM
But its not I2C...

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

shanghai_fool
01-13-2009, 06:53 AM
It certainly works on I2C for me, and works very well.

BradC
01-13-2009, 10:05 AM
DS1307 is what you are looking for, the DS1302 is SPI. I have it here strapped in parallel to the eeprom on my proto board. The chip needs 5v though.
I'm using Mike Greens simple I2C driver and it's a doddle to talk to.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cardinal Fang! Fetch the comfy chair.

Kye
01-13-2009, 12:01 PM
Mmm, I was really wondering if there are many more option thans those. I was looking at the newer models with extremely accurate clocks and piles of nvram or sram. Is DS the only company that makes them?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Peter Jakacki
01-13-2009, 03:54 PM
I have used a few different types and I do favor the I2C interfaces. The biggest problem I find is that some of these RTC chips cost just as much as a micro and availability is another problem. The DS1302 is SPI but I usually just connect up CLK and DAT to the SCL and SDA of the I2C bus and run the chip select to a spare I/O. This chip is probably one of the most common and readily available at a good price.

Chips with RAM don't really interest me for a couple of reasons at least:
1) They consume more power
2) They are much more expensive

I prefer to power the chips with a 0.1F supercap such as the EDLSD104H5R5C etc as they do not require any holders or maintenance. Any application that is off power for more than a week can just as easily have it's clock parameters updated anyway. The DS1302 does a neat job of charging the cap as well.

*Peter*

dMajo
01-13-2009, 05:53 PM
Kye,

consider ramtron FM31L278 (http://www.ramtron.com/products/integrated/processor-companion-product.aspx?id=29) solution: it will replace the standard eeprom with unlimited write capability, add a RTC, Counters, Serial ID ...
... and of course it is battery backed

[Post Edit]
It is double I2C one address for the 256K fram and other for peripherals.

Post Edited (dMajo) : 1/13/2009 9:59:08 AM GMT

shanghai_fool
01-13-2009, 06:34 PM
That looked so good I ordered 5. Mouser has 23 more shown in stock.

Thanks

Donald

Peter Jakacki
01-13-2009, 08:57 PM
The price for a Propeller chip one-off is $12.99 from Mouser. The price for the FM31L27 RTC for one-off from Mouser is $8.32 which is 64% of the price of a Propeller. Well it does have sub-microamp current consumption, it is I2C up to 1MHz, and it has 32KB of FRAM along with a lockable serial number etc. Nice chip, hefty price, whereas the DS1302 is around $2.50 one-off. But it's worthwhile considering the FM31L27 for certain jobs anyway.

*Peter*

Kye
01-13-2009, 10:05 PM
Mmm, well thats a really sweet chip honestly. However, I'm still in the protyping phase. I really want to use better chips for the final design phase but I do not have the ability to build anything using non dip chips. I'm using the propeller protoboard for prototyping. Annyone else have any ideas on chips I could buy to work with? Or ways to get surface mount chips onto the protoboard?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

shanghai_fool
01-13-2009, 10:38 PM
Nyameke,
I thought the same until I tried. You can work with SMD but it takes more patience and a good magnifing glass. For prototyping, I usually look for an adapter. Usually, its a small PC board with the SMD layout to a dip type. They have them in normal sizes. I have just glued SMD chips onto perfboard and very carefully soldered small wire to the pins. I have some old 28 gauge wire wrapping wire left from my younger days. Try to stay away from the 0.5mm stuff though. Thats really hard. Keep the braid wick handy.

Peter,
Since it also has additional memory, it will be accomplishing multiple tasks with a single chip. The cost is reasonable for proto work anyway. The shipping to Shanghai is a bear though.

I've had a 10+ year old lithium coin battery on my DS1307 for a few months now and its still keeping time. I hope the FM31 is as frugal.

Donald

dMajo
01-13-2009, 10:42 PM
Peter,
you have forgot to add the cost of the eeprom that is no more needed

shanghai_fool (http://forums.parallax.com/member.php?u=54678),
I think that should be better since the battery on DSxxx keeps alive also the ram locations where the time is stored while on FM the locations are fram and the battery is used just to count the time


Post Edited (dMajo) : 1/13/2009 2:50:43 PM GMT

Andrew E Mileski
01-14-2009, 12:51 AM
Personally I prefer to use a binary counter RTC like the DS1672 (http://datasheets.maxim-ic.com/en/ds/DS1672.pdf), which is available as an 8-pin DIP.

- Most calendar RTC parts can handle leap years, but they can't handle leap seconds, and few handle daylight savings time automatically.
- it is easier to compute elapsed time.
- Don't have to worry about time zone, except on output for display.

Computing the date from a 32 bit count isn't that hard. Here it is in C (sorry, I don't think in SPIN):




#include <stdio.h>

/*
* Convert seconds from Unix epoch (Jan 1, 1970, 00:00:00)
*/
int main(int argc, char *argv[])
{
unsigned long date;

unsigned int year = 1970;
unsigned int month = 0;
unsigned int day = 0;
unsigned int dow = 4;
unsigned int hour = 0;
unsigned int min = 0;
unsigned int sec = 0;

/*
* Thirty days has September, April, June, and November.
* All the rest have Thirty-one, except February coming once in four,
* It then has one day more.
*/
unsigned int days[] = {
31 * 24 * 60 * 60, /* January */
28 * 24 * 60 * 60, /* February */
31 * 24 * 60 * 60, /* March */
30 * 24 * 60 * 60, /* April */
31 * 24 * 60 * 60, /* May */
30 * 24 * 60 * 60, /* June */
31 * 24 * 60 * 60, /* July */
31 * 24 * 60 * 60, /* August */
30 * 24 * 60 * 60, /* September */
31 * 24 * 60 * 60, /* October */
30 * 24 * 60 * 60, /* November */
31 * 24 * 60 * 60 /* December */
};

char *dow_str[] = {
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
};

char *month_str[] = {
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
};

if (argc != 2)
return 1;

date = strtoul(argv, NULL, 0);

/* Day of Week */
day = date / (24 * 60 * 60);
dow = (day + dow) % 7;

/* Scale date by years */
for (;;) {
if (year % 400 == 0 || (year % 4 == 0 && year % 100)) {
days[ 1 ] = 29 * 24 * 60 * 60;
sec = (7 * 31 + 4 * 30 + 29) * 24 * 60 * 60;
} else {
days[ 1 ] = 28 * 24 * 60 * 60;
sec = (7 * 31 + 4 * 30 + 28) * 24 * 60 * 60;
}

if (date < sec)
break;

year += 1;
date -= sec;
}


/* Scale date by months */
while (date >= days[month]) {
month++;
date -= days[month];
}
month++;

/* Scale date by days */
day = date / (24 * 60 * 60);
date = date % (24 * 60 * 60);
day++;

/* Scale date by hours */
hour = date / (60 * 60);
date = date % (60 * 60);

/* Scale date by minutes */
min = date / 60;
date = date % 60;

sec = date;

printf("year = %d\n", year);
printf("month = %d\n", month_str[month]);
printf("Day of Week = %s\n", dow_str[dow]);
printf("day = %d\n", day);
printf("hour = %d\n", hour);
printf("minute = %d\n", min);
printf("second = %d\n", sec);

return 0;
}


Post Edited (Andrew E Mileski) : 1/13/2009 8:55:09 PM GMT

Tracy Allen
01-14-2009, 01:02 AM
The DS1338 is the 3.3 volt version of the DS1307. It is only available in surface mount, although the SO-8 package is not too difficult.

Intersil (http://www.intersil.com/timing/) has an extensive line of I2C RTCs, some with advanced features and up to 512 bytes of SRAM.

For my own purposes, I consider the NV memory essential. I also like to have versatility in the timing/alarm output. Accuracy is determined primarily by the 32kHz crystal. A few RTCs have temperature sensing and compensation circuitry that allows at least a first order correction of the parabolic error curve of the typical watch crystal, and some at a premium $$ even have a built in crystal that is better matched to the oscillator.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)

shanghai_fool
01-16-2009, 07:52 PM
I received the FM31L278-G today and breadboarded it. Unfortunately, it uses the same addresses as the built-in eeprom and the DS1307. I will have to pull-up A0 address line. It does answer to the defaults in I2Cdemo.spin but the clock registers are not the same. I'll have to write a driver for it. It is basically the same as DS1307 except you have to set/reset a bit to update time registers and the seconds register starts at 02H. Should be done tomorrow. I like it. 256k FRAM. Thats 8K longs. And, no write waits.

Donald