Calculating Time for clock's preset


Closed Thread
Results 1 to 34 of 34

Hybrid View

  1. #1
    Join Date
    Jun 2008
    Posts
    84

    Default Calculating Time for clock's preset

    What is the best way to verify that Current Time of a clock is within the program(preset) Start-End time? e.g if a program should be ON from 13:00:00 and off at 14:00:00
    I thought about calculating time in seconds from midnight, but represanting 24 Hours in seconds require more than 16Bit.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by menta View Post
    I thought about calculating time in seconds from midnight, but represanting 24 Hours in seconds require more than 16Bit.
    Then don't use every second...use every 2 seconds. 60*60*24=86,400 / 2 = 43,200.
    Or you could use every 1.5 seconds, 60*60*24=86,400 / 1.5 = 57.600.

    Or use 'binary time'...if there is such a thing...
    Instead of dividing a day into 86,400 chunks, it's broken up into 65,536 chunks, each chunk being 1.318359375 seconds long.

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by menta View Post
    What is the best way to verify that Current Time of a clock is within the program(preset) Start-End time? e.g if a program should be ON from 13:00:00 and off at 14:00:00
    At first glance I'd say ...
    Code:
    IF Hours = 13 THEN
        ProgON = 1
    ELSE
        ProgON = 0
    ENDIF
    But I'm guessing you want more than the example showed.
    <br>
    DT

  4. #4
    Join Date
    Jun 2008
    Posts
    84


    Did you find this post helpful? Yes | No

    Default

    Taylor, Do you mean calculate time from Mid or Noon ?

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by menta View Post
    Taylor, Do you mean calculate time from Mid or Noon ?
    Well, if 13 is 13 hours, and you want to check from 13:00 to 14:00, then I suppose it's from midnight...

  6. #6
    Join Date
    Jun 2008
    Posts
    84


    Did you find this post helpful? Yes | No

    Default

    I think that calculating time from midnigh or noon will be a problem if end time of a program is after 00:00, e.g Start time - 13:00 , End time - 1:00

  7. #7
    Join Date
    Jun 2008
    Posts
    84


    Did you find this post helpful? Yes | No

    Default

    If I didn't make it clear, a program can be:
    Start 13:10:02
    End 13:10:05
    HH:MM:SS

Similar Threads

  1. I don't understand this code!
    By Russ Kincaid in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 13th February 2008, 03:55
  2. Measuring time
    By AugustoPedrone in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 31st July 2007, 00:46
  3. Serout2/serin2 Pbp Problem
    By SOMRU in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th December 2006, 20:55
  4. Calculating elapsed time, how?
    By Eng4444 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 1st June 2006, 10:00
  5. Timer in real time
    By martarse in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 29th July 2005, 15:24

Members who have read this thread : 0

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