Go Down

Topic: DS1307 and it's SMD counterpart's are driving me NUTS! (Read 1 time) previous topic - next topic

cjdelphi

Jan 17, 2013, 02:07 am Last Edit: Jan 17, 2013, 02:20 am by Coding Badly Reason: 1
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.

Coding Badly

#1
Jan 17, 2013, 02:13 am Last Edit: Jan 17, 2013, 02:21 am by Coding Badly Reason: 1

Nothing.  It's a serial EEPROM (not a processor).

Coding Badly


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

LarryD

From the last image it looks like the crystal is twisted!
The way you have it in your schematic isn't the same as how you have it wired up!

cjdelphi

#4
Jan 17, 2013, 02:34 am Last Edit: Jan 17, 2013, 02:36 am by cjdelphi Reason: 1
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?...




cjdelphi

Code: [Select]

/*
*
* 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.

LarryD

#6
Jan 17, 2013, 02:52 am Last Edit: Jan 17, 2013, 02:54 am by LarryD Reason: 1
FYI: PDF schematic
The way you have it in your schematic isn't the same as how you have it wired up!

Coding Badly


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

cjdelphi

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.

Go Up