Shop OBEX P1 Docs P2 Docs Learn Events
DS1302 demo display is 00:00 00/00/00 — Parallax Forums

DS1302 demo display is 00:00 00/00/00

skywaterblueskywaterblue Posts: 3
edited 2011-12-07 09:01 in BASIC Stamp
A continual problem! I read through previous forums and they suggested it was a problem with the crystal getting heated during sauter - my professor and I agreed that was the most likely cause and I ordered a new pair. No such luck. After a thorough debugging, we can't figure out what's wrong with the DS1302 chip because with new chip and crystal and we're still getting the 00:00 00/00/00 error in the debug window. We've double and triple checked the ports.

This chip is going to a neon animation box - I am planning on making a menorah that lights up on the appropriate days by itself. What do you think I should do next? Order another crystal? (Are they often bad?) Is there an easier chip I can use with the basic stamp to keep track of time?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-11-17 12:20
    What board are you using with the DS1302? Did you follow the manufacturer's (Maxim/Dallas) recommendations for connecting the crystal to the DS1302. Most of the real time clock chips are very very sensitive to exactly how you've connected the crystal to the chip. Often people solder the crystal directly to the pins involved. A breadboard won't work. It's always best to use someone else's design that works. Here's one from SparkFun that has a built-in crystal and a socket for a backup battery. Here's another with a DS1307 that uses I2C rather than SPI for interfacing. It works better with a BS2p / BS2pe / BS2px. Otherwise you have to use I2C subroutines in your code. One of the Nuts and Volts Columns shows how to do this. The only breakout board for the DS1302 I've seen is from Dontronics in Australia. They're having a closeout on it. Check their website.

    Make sure your code initializes the Clock Halt bit to zero (see the datasheet for details). If the DS1302 powers up with with this bit set to one, the clock won't run.
  • skywaterblueskywaterblue Posts: 3
    edited 2011-11-17 13:35
    This is a basic stamp 2.5. I had done the soldiering directly to the pins on the first go-round and it had the same error - which I had attributed to getting the crystal can too hot in the process. I will include a picture of the box - not sure I can be too helpful about the other components in the neon animation set-up. The professor built these with us in class from a kit that he had assembled, and we didn't get specs or a guide to assembly or anything. (I am assuming, because this is a kit that he created himself, that I would have to hunt down spec kits for everything by myself.)

    IMG_0890.JPG


    I'm assuming that for my project purposes (lighting 'candles' at the pre-determined shabbat times) there's no real reason to choose a DS1302 over the DS1307? And both of these work with BS and not just Arduino? (Switching is not an option for this class and I have zero experience with Ardunio with three weeks until final crit.) I did not know there were pre-assembled kits and I think I would have saved a lot of time and effort had I just bought one. As you can see, I've made about three different mistakes here. Heh.
    960 x 720 - 345K
    720 x 960 - 339K
  • Mike GreenMike Green Posts: 23,101
    edited 2011-11-17 15:33
    You have the DIP packaged DS1302. It's possible that the board you're using is part of the problem, but I'm not sure. Typically, you carefully bend the two crystal pins on the DS1302 so they jut out to the side while the other pins are meant to go into the socket, then you wrap the leads from the crystal around the pins and carefully and quickly solder the leads to the pins. You shouldn't need much solder since both the DS1302 pins and the wires from the crystal are already tinned and the crystal's leads are fairly tightly wrapped around the pins. Practice with some scrap wire.

    How do you have the DS1302 connected to your stamp? Can you attach a schematic? Can you attach a copy of the program you're using to test it?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2011-11-17 17:07
    If I may add, the ceramic capacitor you can see in the background looks like it is shorted. It could be just the way the photo came out, but it does look twisted up some.
  • hover1hover1 Posts: 1,929
    edited 2011-11-17 17:21
    If I may add, the ceramic capacitor you can see in the background looks like it is shorted. It could be just the way the photo came out, but it does look twisted up some.

    Good eye Chris!
  • skywaterblueskywaterblue Posts: 3
    edited 2011-11-18 16:39
    I'll try and answer the questions to the best of my ability. As you may have gathered, I am a student and not entirely super capable at circuit building though I did pass my earlier class (electronics 101) where I built the BoeBot. (It helps if you know this is a fine arts program and NOT MIT or anything. As if you couldn't tell.)

    1. The ceramic capacitor is fine because we tested all the components for burnt out things yesterday.

    2. The circuit I am using for the ds1302 is the basic one included in the ds1302 pdf file. It's possible there's something wrong with the way it is connected to the BasicStamp but I am not able to provide a circuit diagram for the neon animation kit since I was never give one.

    3. The program I was using with the ds1302 was the demo program that can be found on this forum, since I just wanted to make sure the chip worked and could display an accurate time in the debug window. It does not.

    Anyway. I may give it one last attempt, but my professor has pretty much give up on this since the neon animation box wasn't designed with too much interface in mind. Given the amount of time I have left this semester, classmates and I were discussing the possibility of writing a program that would have to be turned on during sundown of the first night of Haunkkah, left running and then the next light would go on after a Pause or Count duration of 24 hours. I think that's theoretically possible, although it doesn't have the conceptual thrill of programming it to go on at the right date every year for a hundred years.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-11-18 17:24
    It's really hard to advise you with the limited information available. I've seen DS1302 circuits that worked, even with wires as long as the ones shown in your photo. On the other hand, we know that the DS1302 and other real-time clocks are really sensitive to capacitance and other aspects of long wire connections and that the crystal connection is the most sensitive.

    If you can indeed reduce your project description so that a 24 hour (roughly) period is mostly what you have to keep track of, you could do that without the DS1302. The Stamp's PAUSE statement is pretty accurate, certainly over a few days. You could use a PAUSE 60000 as a one minute timer and keep track of the number of minutes that pass by. Once a minute, you can increment a variable from 0, check it against 60 and, if equal to 60, set it back to zero, then increment another variable from 1 and check it against 25. If equal to 25, you'd set it back to 1 and increment a day counter. Then you'd go back to the PAUSE again.

    You'd have a time in days, hours, and minutes and could use that to turn the candle lights on and off. You'd start the program at midnight on the day of the first night. You could set a sundown and sunrise time for each day in a table or assume that it's not changed enough over the course of 8 days to bother ... whatever.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2011-11-22 10:36
    Are you sure the display isn't reading 00:00 00/00/00? The reason I ask is that if the crystal wasn't working I believe you should be seeing 00:80 00/00/00 instead (not the seconds). With all zeros that would indicate that the DS1302 either isn't working at all of there is a code error. The 80 in the seconds is caused by the clock halt bit not being cleared and can happen when the crystal isn't working.
  • JLockeJLocke Posts: 354
    edited 2011-12-07 03:26
    I see I'm a little late to this party, but have a (possibly stupid) question. Did you set the time on the clock chip? I ask, as I had a circuit I had breadboarded which contained a DS1307. I had the back-up battery wired up to it on the breadboard and had set the time on the chip using a demo routine (I was using a Propeller chip). When I move everything onto a pcb I designed, everything worked except the clock. I tried replacing the crystal, but that didn't work. I finally moved the clock circuit back to a breadboard (I had the chip in a socket) and everything worked great. Move it back to the pcb, and the clock didn't run. I had put off adding the ability to set the time from within my circuit, but once I had the button and supporting programming working I was able to set the time on the clock and it ran like a champ. Guess I was expecting it to power up with some random date/time and start running from there. The chip lost the time when it was moved to the breadboard onto the pcb and had never been initialized again. I felt pretty stupid, but relieved that it was working!
  • Beau SchwabeBeau Schwabe Posts: 6,560
    edited 2011-12-07 09:01
    Datasheet reference ... http://datasheets.maxim-ic.com/en/ds/DS1307.pdf ... page #8

    "Bit 7 of Register 0 is the clock halt (CH) bit. When this bit is set to 1, the oscillator is disabled. When cleared to 0, the oscillator is enabled. On first
    application of power to the device the time and date registers are typically reset to 01/01/00 01 00:00:00 (MM/DD/YY DOW HH:MM:SS). The CH bit in the seconds register will be set to a 1.
    The clock can be halted whenever the timekeeping functions are not required, which minimizes current (IBATDR)."
Sign In or Register to comment.