Pages: [1]   Go Down
Author Topic: DS1307 and it's SMD counterpart's are driving me NUTS!  (Read 1006 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Edison Member
*
Karma: 29
Posts: 2455
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

DS1307 and it's SMD counterpart's are driving me insane i kid you not.

I can not get them to work over i2c, infact the only time i can is when the breakout
board comes with an atmel... hold on looking now.....







Here's the problem, I wire it up, i supply 5v and the battery rail with 3.3v to cover the lithium battery incase
you do not have one, i connect the sda and scl lines up... it fails everytime, i use 5v resistor pull ups, i do
everything ...

BUT




These WORK perfectly, i've got 3 all working fine, what is that little atmel processor doing to make it work ?


Moderator edit: corrected part number.
« Last Edit: January 16, 2013, 08:20:50 pm by Coding Badly » Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 208
Posts: 12929
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Nothing.  It's a serial EEPROM (not a processor).
« Last Edit: January 16, 2013, 08:21:07 pm by Coding Badly » Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 208
Posts: 12929
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Have you tried external pull-up resistors on the I2C lines?
Logged

Offline Offline
Faraday Member
**
Karma: 67
Posts: 2698
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

From the last image it looks like the crystal is twisted!
Logged

The way you have it in your schematic isn't the same as how you have it wired up!

Offline Offline
Edison Member
*
Karma: 29
Posts: 2455
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

lol larry, i thought that too, and used a flat screwdriver just to prise it open a bit..

I see a diode, is that a zener? 5v too much? lower voltage is the only thing i've not tried, but take a look at the breakout board
which arrived today the one with the 5 pins, they have all the pull up resistors, and yet it fails.

voltage 1 pin shows 3v (battery)
voltage 2 pin, was 0, so I hooked up 5v to pwr2

surely not have to give the "pullup" resistors on this board "pullup" resistors!?

This board here.



Is the one i'm trying to get going.

I have no documentation on this breakout, so i figured IO had to be either SDA OR SCL likewise for Sclck? Serial Clock, rst pin, i did not use it? maybe I should be?...



« Last Edit: January 16, 2013, 08:36:31 pm by cjdelphi » Logged

Offline Offline
Edison Member
*
Karma: 29
Posts: 2455
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
/*
 *
 * Read and set through serial port demo sketch for DS1307 I2C rtc clock
 *
 * DS1307 library provided by mattt & D.Sjunnesson, corrected by bricofoy.
 * See DS1307.h for more details.
 *
 * This exemple code is under GNU GPL
 *
 * (c) bricofoy 2012
 *
 */



// This is for compatibility with both arduino 1.0 and previous versions
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

#include <Wire.h>
#include <DS1307.h>

void setup() {
  Serial.begin(9600);
  use();
  read_RTC();
}


// use explanation message
void use() {
  Serial.println("\nUSE      : u U r R h[00-23]m[00-59]s[00-59]j0[1-7]D[01-31]M[01-12]A[00-49]");
  Serial.println("\nEXEMPLE  : h09m35d03 set time to 09h35 and day of week 3 (thuesday).");
  Serial.println("\nCommands : h** : hour,  m** : minutes, s** : seconds, d0* : day of week");
  Serial.println("           M** : month,  Y** : year,   D** : day of month.");
  Serial.println("           r stops clock, R starts it. ");
  Serial.println("           u or U shows this message, all other caracter shows time.");
}

// DS1307 time read function
void read_RTC() {
  Serial.print("\nActual time : ");
  Serial.print(RTC.get(DS1307_HR,true)); //read the hour and also update all the values by pushing in true
  Serial.print(":");
  Serial.print(RTC.get(DS1307_MIN,false));//read minutes without update (false)
  Serial.print(":");
  Serial.print(RTC.get(DS1307_SEC,false));//read seconds
  Serial.print(" ");                 // some space for a more happy life
  Serial.print(RTC.get(DS1307_DOW,false));
  Serial.print(" ");
  Serial.print(RTC.get(DS1307_DATE,false));//read date
  Serial.print("/");
  Serial.print(RTC.get(DS1307_MTH,false));//read month
  Serial.print("/");
  Serial.println(RTC.get(DS1307_YR,false)); //read year
}

// set clock values
void write_RTC() {
      char value=0;
      char command=0;

      command = Serial.read();
      delay(50); //delay to allow good serial port reading
      value=byte((Serial.read()-48)*10); //-48 becaus ASCII value for 0 is 48, 1 is 49, etc and *10 because we read tens first
      delay(50);
      value+=byte((Serial.read()-48)); //and then we read units

      switch (command) {
case 'h' :
  RTC.set(DS1307_HR,value);
  Serial.print("hours set to ");
  Serial.println(value,DEC);
  break;
case 'm' :
  RTC.set(DS1307_MIN,value);
  Serial.print("minutes set to ");
  Serial.println(value,DEC);
  break;
case 's' :
  RTC.set(DS1307_SEC,value);
  Serial.print("seconds set to ");
  Serial.println(value,DEC);
  break;
case 'D' :
  RTC.set(DS1307_DATE,value);
  Serial.print("day of month set to ");
  Serial.println(value,DEC);
  break;
case 'd' :
  RTC.set(DS1307_DOW,value);
  Serial.print("day of week set to ");
  Serial.println(value,DEC);
  break;
case 'M' :
  RTC.set(DS1307_MTH,value);
  Serial.print("month set to ");
  Serial.println(value,DEC);
  break;
case 'Y' :
  RTC.set(DS1307_YR,value);
  Serial.print("year set to ");
  Serial.println(value,DEC);
  break;
case 'u' :
case 'U' :
  use();
  break;
case 'r' :
  RTC.stop();
  Serial.println("Clock stopped");
  break;
case 'R' :
  RTC.start();
  Serial.println("Clock running");
  break;
default :
  break;
      }
      read_RTC();
}

void loop() {
   if (Serial.available()) {
     write_RTC();
    }
}


as I say, this code works fine with the boards with the ram on, frustrating.
Logged

Offline Offline
Faraday Member
**
Karma: 67
Posts: 2698
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

FYI: PDF schematic


* RTC.jpg (74.63 KB, 554x475 - viewed 34 times.)
« Last Edit: January 16, 2013, 08:54:20 pm by LarryD » Logged

The way you have it in your schematic isn't the same as how you have it wired up!

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 208
Posts: 12929
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


DS1302 (two)?  DS1307 (seven)?  What is printed on the not-working chip?
Logged

Offline Offline
Edison Member
*
Karma: 29
Posts: 2455
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i'm going to forget it, and go back to the 5 IC's I originally used.


The DS1307 and I2C - I thought the smaller chip was the same it's entirely different so i'll stick to this and the breakoutboards, and rebuild it all.

Thanks for the help.
Logged

Pages: [1]   Go Up
Jump to: