Calculating Time for clock's preset


Closed Thread
Results 1 to 34 of 34

Hybrid View

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

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

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

  4. #4


    Did you find this post helpful? Yes | No

    Default

    how about using 2 loops depending on operating output,

    if progon=1 then do turnoff checking ' "otherwise"
    do turn on checking
    '''
    '''
    '''
    turnoff checking stuff
    ''''
    turnon checking stuff

    don

  5. #5
    Join Date
    Jun 2008
    Posts
    84


    Did you find this post helpful? Yes | No

    Default

    Calculating time from Midnight is not possible since it more than 16Bit.
    Moreover, If start time is 13:00:00 and end time is 01:00:00 will be also a problem.

  6. #6
    Join Date
    Jun 2008
    Posts
    84


    Did you find this post helpful? Yes | No

    Default

    Maybe, checking the Seconds can be with > instead of =, since there is no chance that it will miss for more than few seconds.
    Next time if the Program is already On the check will be passed.

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by menta View Post
    Calculating time from Midnight is not possible since it more than 16Bit.
    Moreover, If start time is 13:00:00 and end time is 01:00:00 will be also a problem.
    Which is why I suggested only counting every other second above....
    Or like DT said, you have another bit that'll signify AM or PM...
    Code:
    time_of_day var bit
    am con 0
    pm con 1
    if time_of_day = 0 ' then it must be between 0000 and 1159
    if time_of_day = 1 ' then it must be between 1200 and 2359...

    Or again, you can use a LONG variable type and use a 32 bit (ok, 31 plug a sign) variable type.

  8. #8
    Join Date
    Jun 2008
    Posts
    84


    Did you find this post helpful? Yes | No

    Default

    How do I define LONG variable?
    What do I do with a situation where start is 10:00 and end is 09:00?
    If using AM/PM sign, what do I do if start is at AM and stop is PM ?

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