Shop OBEX P1 Docs P2 Docs Learn Events
Looking for some input about RTCs — Parallax Forums

Looking for some input about RTCs

KyeKye Posts: 2,200
edited 2009-01-16 11:52 in Propeller 1
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,

Comments

  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2009-01-12 22:03
    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 , Propeller Cookbook 1.4 & Software Index
    Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
    Got an SD card connected? - PropDOS
  • KyeKye Posts: 2,200
    edited 2009-01-12 22:06
    But its not I2C...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • shanghai_foolshanghai_fool Posts: 149
    edited 2009-01-12 22:53
    It certainly works on I2C for me, and works very well.
  • BradCBradC Posts: 2,601
    edited 2009-01-13 02:05
    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.
  • KyeKye Posts: 2,200
    edited 2009-01-13 04:01
    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 JakackiPeter Jakacki Posts: 10,193
    edited 2009-01-13 07:54
    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*
  • dMajodMajo Posts: 855
    edited 2009-01-13 09:53
    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

    [noparse][[/noparse]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_foolshanghai_fool Posts: 149
    edited 2009-01-13 10:34
    That looked so good I ordered 5. Mouser has 23 more shown in stock.

    Thanks

    Donald
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2009-01-13 12:57
    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*
  • KyeKye Posts: 2,200
    edited 2009-01-13 14:05
    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_foolshanghai_fool Posts: 149
    edited 2009-01-13 14:38
    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
  • dMajodMajo Posts: 855
    edited 2009-01-13 14:42
    Peter,
    you have forgot to add the cost of the eeprom that is no more needed

    shanghai_fool,
    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 MileskiAndrew E Mileski Posts: 77
    edited 2009-01-13 16:51
    Personally I prefer to use a binary counter RTC like the DS1672, 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[noparse][[/noparse]])
    {
            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[noparse][[/noparse]] = {
                    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[noparse][[/noparse]] = {
                    "Sunday",
                    "Monday",
                    "Tuesday",
                    "Wednesday",
                    "Thursday",
                    "Friday",
                    "Saturday"
            };
    
            char *month_str[noparse][[/noparse]] = {
                    "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[noparse][[/noparse] 1 ] = 29 * 24 * 60 * 60;
                            sec = (7 * 31 + 4 * 30 + 29) * 24 * 60 * 60;
                    } else {
                            days[noparse][[/noparse] 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[noparse][[/noparse]month]) {
                    month++;
                    date -= days[noparse][[/noparse]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[noparse][[/noparse]month]);
            printf("Day of Week = %s\n", dow_str[noparse][[/noparse]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 AllenTracy Allen Posts: 6,663
    edited 2009-01-13 17:02
    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 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
  • shanghai_foolshanghai_fool Posts: 149
    edited 2009-01-16 11:52
    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
Sign In or Register to comment.