clock/timer calculations


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2007
    Posts
    3

    Red face clock/timer calculations

    Hi to all,

    I am a novice in programming but I wish to design a 24-hour Clock/Timer that it could switch a relay alternatively on and off during two to four programmable periods, for instance:

    1.- 06:00 to 10:00 on
    2.- 10:00 to 14:30 off
    3.- 14:30 to 22:00 on
    4.- 22:00 to 06:30 off

    Obviously, the fourth period is between two different days. I thought it was very easy with a 16F628A, a DS1307 and PICbasic but I have stopped in the PICbasic's subroutine to control when the clock is in the fourth period.

    Please, any suggestion?

    Happy New Year

    Virolay

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by virolay View Post
    Hi to all,
    I am a novice in programming but I wish to design a 24-hour Clock/Timer that it could switch a relay alternatively on and off during two to four programmable periods, for instance:
    1.- 06:00 to 10:00 on
    2.- 10:00 to 14:30 off
    3.- 14:30 to 22:00 on
    4.- 22:00 to 06:30 off
    Obviously, the fourth period is between two different days. I thought it was very easy with a 16F628A, a DS1307 and PICbasic but I have stopped in the PICbasic's subroutine to control when the clock is in the fourth period.
    I've got one of these.
    It's called a TX-9000a. Check the first link on a Google search...

    http://www.google.com/search?hl=en&q=tx-9000a

    Got it at Menards for $30.

  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 virolay View Post
    Obviously, the fourth period is between two different days.
    Just use OR instead of AND.

    For simplicity, IF you were only using the Hours.
    Code:
    IF (RTChour >= 6)  AND (RTChour < 10) then INperiod_1
    IF (RTChour >= 10) AND (RTChour < 14) then INperiod_2
    IF (RTChour >= 14) AND (RTChour < 22) then INperiod_3
    IF (RTChour >= 22) OR  (RTChour < 6)  then INperiod_4
    HTH,
    DT

Similar Threads

  1. CRC Calculations
    By timmers in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 16th June 2009, 17:10
  2. Incorrect calculations... please help.
    By bearpawz in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 29th January 2007, 22:03
  3. Floating Point calculations in PBP
    By uuq1 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 20th June 2005, 15:08
  4. Calculations for using faster Clocks.
    By Tissy in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th April 2005, 14:24
  5. timing calculations
    By scorpion in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 28th November 2004, 22:58

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