using DS1307


Results 1 to 17 of 17

Thread: using DS1307

Threaded View

  1. #1
    Join Date
    Oct 2009
    Posts
    583

    Default using DS1307

    Following on from my previous threads, the current code for my aquarium controller has been running without issue for the past three days, and has been keeping time very well considering it uses a timer overflow rather than a dedicated time chip like the DS1307 (which the previous version used and kept issuing 10:10:10:10 as the time etc). My new code uses a variable to store a value based on minutes since midnight, and then logic statements are used to determine the phase of the lights (ramp up, on ramp down). This works really well, but as the code is using the internal timers to overflow, the main program loop must be less than the overflow timing, otherwise the clock looses time.

    The alternative is to use a DS1307, and but still do the conversion into minutes since midnight as that has proven to be more reliable than doing direct comparison to matching time in Hrs and Min format. However I only really need the HH:MM segment of the time, and I know that the DS1307 has a long string of info stored that includes month, day, year etc. What would be the best way to write / read the DS1307 so that it only gives the hours and minutes and nothing else.

    This way if I add features which would otherwise delay the cycle and cause the clock to loose time, with the reading of the DS1307 the counter would still be correct.

    The idea is

    Code:
    Counter1 variable word
    
    Read DS1307 to get hours and minutes
    Counter1 = (Hours * 60) + minutes
    
    Do logic of if on time >= counter1 then do something etc
    Last edited by Scampy; - 28th November 2013 at 13:55.

Similar Threads

  1. ds1307
    By mel4853 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 8th January 2013, 09:46
  2. ds1307
    By jonas2 in forum Code Examples
    Replies: 0
    Last Post: - 2nd November 2009, 09:50
  3. DS1307 on fire
    By brid0030 in forum General
    Replies: 6
    Last Post: - 25th November 2006, 02:44
  4. DS1307 help
    By Orlando in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th March 2005, 15:17
  5. Ds1307
    By miniman in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 2nd February 2005, 08:29

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts