Boston, MA
Offline
Edison Member
Karma: 0
Posts: 1024
wiblocks
|
 |
« Reply #90 on: October 16, 2009, 10:04:32 am » |
What uC are you using?
I've run that code on the 168,328 and 644 (with the Sanguino).
Try putting some Serial.print statements before each instruction in the loop to see if you can isolate the specific instruction that is causing a problem.
In my main program I have a couple of other include statements. I am assuming that if these were required your program wouldn't compile.
(* jcl *)
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 0
Posts: 115
Arduino rocks
|
 |
« Reply #91 on: November 02, 2009, 10:32:15 pm » |
Aha! A moment to get back to this.
I am using a 168.
The code gets through the setup, enters the loop, and gets as far as: rtc.read_regs(); It never returns from that call.
It could be something simple, what pins should I be using? Is it analog pins 4 and 5?
|
|
|
|
|
Logged
|
|
|
|
|
Boston, MA
Offline
Edison Member
Karma: 0
Posts: 1024
wiblocks
|
 |
« Reply #92 on: November 03, 2009, 06:37:49 am » |
Yes it is analog pins 4 and 5. Do you have pull-ups on those lines? There is a schematic in the NB1A datasheet at http://www.wiblocks.com(* jcl *)
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 14
Arduino rocks
|
 |
« Reply #93 on: November 27, 2009, 05:05:58 am » |
Hello, I just started with this library, it seems to work but every time I close the serial port and open it agian the time resets (I have a 3V battery connected) This is the sketch I use: #include <Wprogram.h> #include <Wire.h> #include <DS1307.h>
int rtc[7];
void setup() { Serial.begin(9600); RTC.stop(); RTC.set(DS1307_SEC,1); RTC.set(DS1307_MIN,23); RTC.set(DS1307_HR,12); RTC.set(DS1307_DOW,1); RTC.set(DS1307_DATE,1); RTC.set(DS1307_MTH,10); RTC.set(DS1307_YR,7); RTC.start(); }
void loop() { RTC.get(rtc,true); for(int i=0; i<7; i++) { if (rtc[0] < 10 && i==0){ Serial.print("0");} Serial.print(rtc[i]); Serial.print(" "); } Serial.println(); delay(1000);
}
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
The Netherlands
Offline
Sr. Member
Karma: 1
Posts: 287
don't panic...
|
 |
« Reply #94 on: November 27, 2009, 05:11:09 am » |
Hi Wouterk,
Isn't that what you do in the setup() of the sketch? Setting the time to 12:23:01.
Jeroen
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 14
Arduino rocks
|
 |
« Reply #95 on: November 27, 2009, 05:20:46 am » |
So every time a serial connection is established the Setup() routine is called?
That should indeed explain the kind of behaviour that i'm experiencing...hmm
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 14
Arduino rocks
|
 |
« Reply #96 on: November 27, 2009, 05:52:50 am » |
Okay so I removed the RTC.set statements from the Setup routine. And set it once to the right time and date. After 4 minutes the RTC is already more than 2 minutes behind I'm using an 32,768 Mhz crystal, here's a picture of my setup: 
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15316
Measurement changes behavior
|
 |
« Reply #97 on: November 27, 2009, 08:45:29 am » |
Your picture is very fuzzy so I can't say for sure but it seems like the wiring my not be correct. The crystal should wire to pins 1 & 2, batt + to pin 3 and batt- to pin 4 and common ground.
Lefty
|
|
|
|
|
Logged
|
|
|
|
|
London
Offline
Sr. Member
Karma: 0
Posts: 330
Arduino rocks
|
 |
« Reply #98 on: November 27, 2009, 12:11:23 pm » |
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 0
Posts: 115
Arduino rocks
|
 |
« Reply #99 on: November 28, 2009, 08:48:00 pm » |
Yes it is analog pins 4 and 5. Do you have pull-ups on those lines? There is a schematic in the NB1A datasheet at http://www.wiblocks.com(* jcl *) Me again, had another few minutes to poke at this. No pull up resistors on the data lines. I think the wiring is correct however, because the sketch with no library worked great. I tried the original DS1307 library next, it works great! Yea! I set the correct time and modified my alarm clock prototype to use the DS1337 breakout board using the DS1307 library. The only extra feature of the DS1337 that I care about really is the added precision, so I think this will work ok for now.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 14
Arduino rocks
|
 |
« Reply #100 on: November 30, 2009, 05:07:12 am » |
Excuse me for the fuzzy picture. I verified the wiring with gordon's picture and it's exactly the same. I think the arduino uses internal pull ups, because I can read the I²C data just fine. The only problem is that the time just isn't "ticking" at the right speed. The clock ran (still is running) after the weekends, and the date is correct, the time is off by approx 2,5 hours (in 3 days) so it has to be a crystal issue in my opinion.. I'll have another go with a new 32,768 kHz crystal today 
|
|
|
|
« Last Edit: November 30, 2009, 05:13:09 am by Wouterk »
|
Logged
|
|
|
|
|
SF Bay Area
Online
Edison Member
Karma: 6
Posts: 1215
Arduino Ninja
|
 |
« Reply #101 on: December 04, 2009, 05:25:30 pm » |
These kinds of problems are why the DS3231 is so good. Even if you get the DS1307 crystal calibrated just right, when the room temperature changes by 10 degrees you'll be right back where you started. The DS3231 has a built in crystal and compensates for temperature changes.
I don't have any more ChronoDots for sale, but EMSL has them now.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Faraday Member
Karma: 6
Posts: 2504
|
 |
« Reply #102 on: December 04, 2009, 11:23:38 pm » |
Temperature doesn't have that much effect. I flew a random 32.768kHz crystal and a commercial (0C-70C) temperature rated DS1307 on a high altitude balloon, with only the self-heating from the 7805 regulator to keep the tiny package warm. The DS1307 stopped reporting time via I2C when the temperature reached 0C, but the clock actually kept ticking and the system returned to normal behavior as it warmed back up, with no appreciable loss of time accuracy.
-j
|
|
|
|
|
Logged
|
|
|
|
|
SF Bay Area
Online
Edison Member
Karma: 6
Posts: 1215
Arduino Ninja
|
 |
« Reply #103 on: December 05, 2009, 04:28:38 am » |
Yes, I'm pretty sure that the effect wouldn't be very noticeable over the course of an hour or two.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 15
Arduino rocks
|
 |
« Reply #104 on: February 19, 2010, 05:59:23 pm » |
Hi, I run into strange problem with DS1307 as mentioned by many others. My setup uses SD-shield, DS18B20 sensors, LCD from Nokia3310, DS1307. All blocks worked fine separately and might going very badly in combinations. Then I foung that http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1222946089 thread, where it was suggested possible out of memory error. Then very helpful article http://itp.nyu.edu/~gpv206/2008/04/making_the_most_of_arduino_mem.html. Suggestions from this article helped me to get all modules to work together.. except DS1307  It was last in the chain though.. Then I found function FreeRam() from fat16lib which I use for SD operations and started to play with it. Some results are that: - bare sketch (it just outputs FreeRam value in setup and loop) gives 836 bytes of free RAM (with ATmega168); - + #include <Wire.h> leaves 814 bytes; - + #include <DS1307.h> leaves 622 bytes. So if with my current sketch which shows 170 bytes of free RAM I add include for DS1307.h it dies for sure. Is not it too high price for one i2c device to take 200 bytes of RAM? Especially in situation where I just want to get timestamp from it and store it on SD with other datas..
|
|
|
|
« Last Edit: February 19, 2010, 06:18:04 pm by dimas »
|
Logged
|
|
|
|
|
|