Shop OBEX P1 Docs P2 Docs Learn Events
iButton RTC — Parallax Forums

iButton RTC

LoopyBytelooseLoopyByteloose Posts: 12,537
edited 2006-09-10 21:10 in General Discussion
I have recently renoticed the iButtons with one-wire interface and see that they have a Real Time Clock that is quite compact and only requires the one wire to interface with the BasicStamps or even the Propeller.

One the other hand, I begin to wonder if the software overhead of One-wire is much larger than using an I2C or SPI device.· Does anyone know for sure?

I am pretty sure it is more if you want to address many devices on one bus. But if I just use the RTC do I have to concern myself with the addressing and the Cyclic Redundancy Checking?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"If you want more fiber, eat the package.· Not enough?· Eat the manual."········
···················· Tropical regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan

Post Edited (Kramer) : 9/10/2006 9:11:35 PM GMT

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-09-09 15:51
    If there's only one device on the bus, you don't need the addressing and CRC. If you have a Stamp with the built-in 1-Wire commands, it would be very easy to use their RTC. If it's the one I'm thinking of, it's just a counter that increments once a second. You have to convert to hours/minutes/secs, etc. The overhead for 1-Wire devices is more than SPI and I2C and the bus is slower, but the built-in commands hide most of that.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-09-09 19:09
    Thanks Mike. My first impression some years ago was that the most of the iButtons were not what I needed and that ICs could do anything cheaper and better. [noparse][[/noparse]The security iButtons seem a bit absure for a BasicStamp].

    But a Real Time Clock that keeps time when the unit is powered down is a different kind of a problem. You have to add a crystal and a backup battery. The One-wire package has all that inside and a very simple footprint that will provide time for ten years.

    I still face the dilemma that I would like to use one with the Propeller, but it is a 3.3volt system. I may just buy one and use it on my Development Board as the socket is already there. Seems to be a trade off between how much programing space or how much construction one is will to provide.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "If you want more fiber, eat the package.· Not enough?· Eat the manual."········
    ···················· Tropical regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • Mike GreenMike Green Posts: 23,101
    edited 2006-09-09 21:14
    I looked at the datasheet for the DS1904 RTC and the 1-Wire spec says it can operate down to 2.2V for a high logic level so it should be just fine connected directly to the Propeller. You'll need a pullup to 3.3V and no protective series resistor. There's already an object in the object library for 1-Wire access so you're set.
  • TimCTimC Posts: 77
    edited 2006-09-10 04:43
    I have been playing around with the iButton RTC's for a few months.
    A while back I wrote something that will be overkill for what you might want but should give you a feeling of what to do.

    - My feeling is when feeding all the devices with 5V you can use parasite power (2 wires).
    - The Propeller and others that use 3.3V go with 3 wire interface: Power, Data, Ground,
    - Don't bother with CRC on a basic stamp. If you are seeing errors then change your wires.
    - iButton's are VERY powerful once you understand them.
    - Compared to the I2C types: DS1307,PCF8583, The SPI type DS1302, The 1-Wire DS1921 seems to be doing very well with just a few lines of code.
    - iButton's are slow, the DS1904 can only work at 16.3Kbits. The DS1921 is faster with Hype drive at 125kbits/sec.

    The attached code is for the DS1921 which has a Clock and a whole lot more but I am afraid the DS1904 will be harder because it does not define Months Days Years, hours and so on. What you need to see is only about 5 lines of this attachment :


      DEBUG CR,"Current Date/Time: "
      OWOUT OW, OwFeRst, [noparse][[/noparse]SkipRom, RdMem, $00, $02] ' SkipROM means this works when only 1 device is on the buss
      FOR idx = 0 TO 6
        OWIN OW, 0, [noparse][[/noparse]transfer(idx)]
        'DEBUG HEX2 transfer(idx), " "
      NEXT
      temp = transfer(5) & $1F      ' Bitwise AND out the CENT data
      DEBUG HEX2 temp,"/", HEX2 transfer(4),"/", HEX2 transfer(6)," "
      temp = transfer(2) & $3F      ' Bitwise AND out the 12/24 data
      DEBUG HEX2 temp,":", HEX2 transfer(1),":", HEX2 transfer(0),CR
      'DEBUG "Day of week: ", HEX2 transfer(3)," 1=Sun.. 6=Sat",CR
    
    



    I have since written a version that uses slots but stamps and slots make for read only code. The Propeller looks like a good fit for one wire esp. since the demo board has so few spare I/O ports.

    Regards
    Tim

    Post Edited (TimC) : 9/10/2006 2:02:14 PM GMT
  • GadgetmanGadgetman Posts: 2,436
    edited 2006-09-10 19:48
    There's a very good reason to use a DS1921 'ThermoChron' iButton, and that is that it has an easily readable calendar.
    (BCD coded)

    Just remember to stop the oscilator when you don't need it, so that the Lithium cell lasts longer...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't visit my new website...
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-09-10 21:10
    Thanks to all,
    I just got the ThermoChron in the mail and downloaded a day's worth of data -- quite useful and nice [noparse][[/noparse]sees to be about 5 times as expensive too].
    It has temperature and clock alarms too.

    I used the Java Interface, but the above code will allow me to move data directly to an LCD or eliminate Java as a PC download requirement.

    Well, that settles it! I have to order some more of these ASAP.
    I have been looking at chips and clock crytals and BU batteries all year, but didn't like the complexity of the hardware.
    Seemed a bit too many pieces to play with and get right.

    It is nice to know I can have both a 3.3volt SX and a 3.3V Propeller use these.
    I need to print out the 44 page document

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "If you want more fiber, eat the package.· Not enough?· Eat the manual."········
    ···················· Tropical regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
Sign In or Register to comment.