The main difference between these two chips is the ability of DS1337 to handle (set, trigger) an alarm. Otherwise, both have similar pin configurations, both "talk" I2C, and both use a 3V coin battery (DS1307 only as backup, DS1337 as the only power source).
The cuts are shown with yellow lines, the wires are light blue. The rightmost cut is on the back of the board.
Updated Apr 17/2010
After I started the actual work, I realized that, since DS1337 is powered by the 3V coin battery, voltage level adapters (on SCL and SDA lines) need to be used between the clock and a 5V-powered Wiseduino. So I decided to power Wiseduino with 3V as well (2xAA batteries). This means the frequency cannot be 16MHz (according to ATmega168/328 datasheet); so I installed an 8MHz resonator instead. So far so good. I am able to upload the DS1337 sketch and read back the time. Current consumption is a under 5mA.
Here are a few other things I did to make this work:
- on Wiseduino, I am using an ATmega168 with the bootloader, instead of the 328;
- I changed boards.txt to accommodate the 8MHz working frequency:
diecimila.upload.speed=9600
#diecimila.upload.speed=19200
...
diecimila.build.f_cpu=8000000L
#diecimila.build.f_cpu=16000000L
- tried unsuccessfully JLuciani's DS1337 library; it seems to require/use a different set of "wire" files than those coming with Arduino IDE 18; confusion ensues; files and functions need to be renamed etc etc; I just gave up;
- tried, with limited success, xSmurf's DS1337 library; there seem to be multiple versions of the DS1337 class (and header), no sample sketch that uses the class; I had to eliminate some alarm-related stuff, define some macros etc. In the end, I have a simplified version working;
- to upload the sketch to the board, I used the 3V3 version of the FTDI breakout from sparkfun (the 5V has the signal voltages too high).
Next steps:
- put the microcontroller to sleep when time is not read (this will reduce the consumption to micro amps, hopefully);
- implement the alarm functionality, with interrupts.
Conclusion DS1307 vs DS1337:
- DS1337 should be used in a 3V3 environment; it is not meant to be mixed with 5V signals;
- DS1337 libraries I looked at so far are pretty finicky compared to DS1307 libraries;
- an equivalent of (that is, as easy to use as) DS1307 for 3V3 is DS1340 (used by JeeLabs in their JeeNode boards).
Great stuff, thanks for the work.
ReplyDeleteI am hoping to attach the DS1337 alarm function to one of the arduino's interrupts, but couldn't seem to find a pre-built DS1337 library. I am not quite competent to write my own...
Any luck getting the alarm function to work?
Not yet, but I am working on it. I actually need that functionality for my next analog watch.
ReplyDeleteI am working on an application using the DS1337, and I have a question about your conclusion comparing the two chips. Why do you say the 1337 is a 3.3v device and not to be mixed with 5v signals? The datasheet clearly states the IC can operate normally from 1.8v to 5.5v. Am I missing something?
ReplyDeleteKevin,
ReplyDeleteIt's been a while since I wrote this.
You are right, DS1337 can be powered by 5V. But, unlike DS1307, it does not have provisions for a battery backup. If you power the chip from the main source as your Arduino, once the power goes down, your setting (time etc) are lost.
This is the main and only reason for my first conclusion enumerated above: just power the DS1337 from an independent, small (because the current taken is uA) source. Of course this source could be another 5V battery, but that may not be as practical as a small 3V coin battery.
You would need to use an logic level adapter between the 3V RTC chip and a 5V Arduino. Therefore, I concluded that a more practical solution would be to power the DS1337 with 3V, the Arduino with 3V3 and connect them directly.
Does this makes sense to you?