PDA

View Full Version : clock/timer calculations



virolay
- 4th January 2008, 19:54
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

skimask
- 4th January 2008, 19:59
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.

Darrel Taylor
- 4th January 2008, 20:20
Obviously, the fourth period is between two different days.
Just use OR instead of AND.

For simplicity, IF you were only using the Hours.

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,