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

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

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

  3. #3


    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

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

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

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

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

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Cool

    Quote Originally Posted by menta View Post
    How do I define LONG variable?
    It's in your PBP manual...just like you define any other 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 ?
    Time to start thinking a bit...
    If it starts at AM, then the flag would equal AM AND the time would match.
    If it starts at PM, then the flag would equal PM AND the time would match.
    Doesn't matter if it starts or stops, it's all in how you set up your If/Then statement to match what YOU want to do.

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