Shop OBEX P1 Docs P2 Docs Learn Events
DS1302 Losing Time — Parallax Forums

DS1302 Losing Time

ZeusZeus Posts: 79
edited 2011-09-01 09:44 in BASIC Stamp
Hello All,

I have a DS1302 that I am using in a clock project and I have a chronic problem with it losing time. I know that there were/are issues with time loss while on battery backup however this is not my problem as I have not gotten to backing up the chip yet.

I have been running the clock for three days now and for the first few days it was spot on. No it seems to be losing 5 minutes a day.

I have mounted the crystal as close as possible on my breadboard.

Thanks in advance

Zeus

Comments

  • ZootZoot Posts: 2,227
    edited 2011-08-27 19:42
    It's never be spot on over months, but 5 minutes a day sounds like way too much drift.

    Double check that you have the absolutely correct crystal (for speed and capacitance).

    If the crystal is good, it's probably the breadboard introducing too much capicitance and noise into the crystal leads and throwing the time off. I would solder the crystal right to the pins of the DS1302 and try it that way (or sometimes you can force the leads in with the pins into a socket, but that's a one way trip and will probably trash the socket and very occasionally the crystal).

    Good grounding is important and no noise around the chip (route your power and signal wires elsewhere on the breadboard). A decoupling cap (.1uf or so) on the Vcc and Vss of the chip is good too, if you don't have one already.
  • CalMarinerCalMariner Posts: 64
    edited 2011-08-27 23:35
    Can you upload a picture of your project, specifically your breadboard area?
  • piguy101piguy101 Posts: 248
    edited 2011-08-29 13:14
    Here's a question: Is it ok to intentionally use a wrong crystal on the DS1302? Would it hurt the chip?
  • ZootZoot Posts: 2,227
    edited 2011-08-29 13:51
    Probably not, but it wouldn't keep time correctly.
  • ZeusZeus Posts: 79
    edited 2011-08-29 19:12
    Sorry for the delayed reply, modem died.

    Zoot,

    I will try the capacitor and let you know how it goes.

    CalMariner,

    I will see if I can post a picture tomorrow. It is nothing pretty but I made sure to mount the crystal as close as possible to the DS1302, if that is what you were wondering.

    Zeus
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2011-08-30 08:52
    Zeus,

    The DS1302 requires a crystal with a load capacitance of 6pF. Any more/less and the clock runs slower/faster and affects accuracy. Using a breadboard automatically adds capacitance to the circuits resulting in losing time. Once your circuit is moved to a PCB you can prevent interference of the crystal by following the guidelines in the following AppNote, which discusses this very issue.

    http://www.maxim-ic.com/app-notes/index.mvp/id/58
  • davejamesdavejames Posts: 4,047
    edited 2011-08-30 09:27
    The DS1302 requires a crystal with a load capacitance of 6pF.

    I was surprised to see that myself.

    @Zeus - one thing you could do prior to making a PCB with all the appnote related techniques would be to lift the X1 and X2 pins of the DS1302 and carefully solder the crystal to them. That would result in the least parasitic capacitance possible.
  • piguy101piguy101 Posts: 248
    edited 2011-08-30 14:06
    Is there a way to do it without soldering?
  • ZootZoot Posts: 2,227
    edited 2011-08-30 14:35
    sometimes you can force the leads in with the pins into a socket, but that's a one way trip and will probably trash the socket and very occasionally the crystal

    Then you could put the socket into the breadboard. If you used an 8-DIP IC socket, the idea is to insert the crystal leads into the socket at the same time as the chip pins. To be honest, at that point it might be better to go to Radio Shack or the like and get a $10 soldering iron and just solder the crystal to the chip. Then the chip could be put into a socket, or a breadboard, etc. and not suffer from capacitance on the crystal introduced by the circuit construction itself.
  • CalMarinerCalMariner Posts: 64
    edited 2011-08-30 19:07
    Yes, that was pretty much it. I noticed on my circuit that the timing could be affected by other components in close proximity.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2011-08-31 07:57
    I used to advise against soldering the crystal to the IC, however if you're proficient at soldering and can do it without over heating the crystal then it may be a better long-term solution for working with the DS1302 on a breadboard. That said, the crystal will still be affected by the capacitance of the breadboard the moment the leads are inserted, so I recommend that if you're going to go through the trouble of soldering the crystal to the leads, then you should also cut off the leads that go into the breadboard. This will remove the capacitive load from the crystal and solve connection issues at the same time. You'll still want to avoid running any signal wires across the crystal, which could still affect the timing.
  • ZeusZeus Posts: 79
    edited 2011-08-31 15:51
    Thanks to everyone for the input. I will live with the lag during development but will most likely solder directly to the I.C. for the long term solution. Does anyone see a problem with cooling/freezing the crystal with component cooler while soldering the leads?

    Once I get it soldered I most likely will pot it to the I.C. with epoxy.

    Thanks... Zeus
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2011-09-01 09:44
    Just apply the tip to the DS1302 legs and tack the solder on quickly and you should be good. If it takes more than 1 second to do each lead you're probably overheating it.
Sign In or Register to comment.