Calculating Time for clock's preset


Closed Thread
Results 1 to 34 of 34

Hybrid View

  1. #1
    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 ?

  2. #2
    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...

  3. #3
    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

  4. #4
    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

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


    Did you find this post helpful? Yes | No

    Default

    All those little details help.

    Here's another possibility.
    Run it once per second. Probably a gosub from the clock's code.
    Code:
    ;--Start Time--
    Start_Hours   CON 13
    Start_Minutes CON 10
    Start_Seconds CON 2
    ;--Stop Time--
    Stop_Hours    CON 13
    Stop_Minutes  CON 10
    Stop_Seconds  CON 5
    
    ProgON        VAR BIT
    ProgON = 0
    
    ;--sub--
    IF Hours = Start_Hours THEN
        IF Minutes = Start_Minutes THEN
            IF Seconds = Start_Seconds THEN
                ProgON = 1
            ENDIF
        ENDIF
    ENDIF
    
    IF Hours = Stop_Hours THEN
        IF Minutes = Stop_Minutes THEN
            IF Seconds = Stop_Seconds THEN
                ProgON = 0
            ENDIF
        ENDIF
    ENDIF
    DT

  6. #6
    Join Date
    Jun 2008
    Posts
    84


    Did you find this post helpful? Yes | No

    Default

    Thanks,
    The main risk is if for some reason you loose a check, then you have missed the program start time

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by menta View Post
    Thanks,
    The main risk is if for some reason you loose a check, then you have missed the program start time
    That's why you use LONG variables, calculate out the # of seconds since midnight then do a comparison, i.e.
    If current_time_in_seconds > _on_time_in_seconds then
    do-whatever

    Or do it the hard way with WORDs and multiple IF/Then And/Or statements...

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, 02:55
  2. Measuring time
    By AugustoPedrone in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 30th July 2007, 23:46
  3. Serout2/serin2 Pbp Problem
    By SOMRU in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th December 2006, 19:55
  4. Calculating elapsed time, how?
    By Eng4444 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 1st June 2006, 09:00
  5. Timer in real time
    By martarse in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 29th July 2005, 14: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