Shop OBEX P1 Docs P2 Docs Learn Events
DS1302 question — Parallax Forums

DS1302 question

Lee HarkerLee Harker Posts: 104
edited 2005-11-26 00:28 in BASIC Stamp
Hi Stampers,
I'm working on a project that I'm hoping someone could advise me.
I am reading 4 different times in order somewhat like a relay race. I'm using the DS1302 RTC and it's mostly working. I want to set it to 0 to measure each of my 4 times and then read out the minutes and seconds. For convenience I made a subroutine that would just reset all the registers to 0 and found that they only get reset to 0 the first time after power-up. Then I read a single line in the DS1302 app note that the "date" should only be set once per power-up.
I have found no mention of this in any other document including the Dallas data sheet.
If this is true, does that mean If I try to do it, the registers will just ignore the command?
Thanks.

Lee Harker

Comments

  • Lee HarkerLee Harker Posts: 104
    edited 2005-11-23 22:32
    Follow up question.
    It seems as though the DS1302 will not allow the time to be set again unless it has been read first. Can anyone confirm if this is true or am just not doing something else right. If this is the case, I can put in a dummy read in the cases that I want to set the time and it has not been read yet but there's no reason if it's not necessary

    Lee Harker
  • NewzedNewzed Posts: 2,503
    edited 2005-11-23 22:51
    I have several programs that use my DS1302 piggyback.· Each time the program cycles I have the option to set the clock or read it.· As far as I know, the 1302 can be reset over and over.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Do you have a Stamp Tester yet?
    http://hometown.aol.com/newzed/index.html

    ·
  • NewzedNewzed Posts: 2,503
    edited 2005-11-23 22:58
    I just went into the program that controls the DS1302 piggyback and an LED display.· I reset the time three times within a space of 5 minutes - no problems.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Do you have a Stamp Tester yet?
    http://hometown.aol.com/newzed/index.html

    ·
  • NewzedNewzed Posts: 2,503
    edited 2005-11-23 23:07
    You can actually set the 1302 program to reset the clock to specified parameters when a certain event happens, such as pressing a button or if mins = $30 or secs = $55 - any condition you want to set.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Do you have a Stamp Tester yet?
    http://hometown.aol.com/newzed/index.html

    ·
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-11-24 00:52
    Lee,

    ·· Just curious why you're trying to reset the date if you're using the time, and resetting it anway?· You could optionally have the DS1302 set to the "real" time then convert that "on the fly" to all seconds.· For each event you store the time (In seconds), and then you can compare after.· Don't know if this would work in your application or not.· Also in the Projects forum there are 2 or 3 projects using the DS1302.· Some of the code may be of interest to you.· And I don't recall any problems setting the date repeatedly.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • ShortShort Posts: 26
    edited 2005-11-24 20:23
    The only drawback on reseting minuites and seconds to zero is that when you keep the ds1302 for real time and date display is ,you have to store the time you clocked after reset and add it back to real time.

    Short
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-11-24 22:26
    If you use a variable called, RawTime, which represents the time in all seconds, then, up to a point you could use the code to compare the difference in seconds between two times without affecting the DS1302 time whatsoever.· I say to a point, because there are 86,400 seconds in a day.· Too much for a word variable, but if you were only using the values before 6:00P you values would always be correct.· Of course, there are little math tricks you can use to compensate for this, but I was trying to offer an easy solution.· =)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Lee HarkerLee Harker Posts: 104
    edited 2005-11-26 00:28
    Thanks guys,
    Chris, it's a good question why I'm reseting everything. The only answer is that's where I started and I hadn't optimized my software. I just told the stamp to reset the whole enchilada then I wouldn't have to do the math for midnight operation and so forth. I just thought it would be easier to take 4 seperate times and add them at the end than to go through all the math every read. I usually have pretty good control of the beast but this one had me stumped.

    Lee Harker
Sign In or Register to comment.