I want to know how to shorten the t800 TO t400 code routine... and use the LOOK
Hi Every One
I have been working on this off and on for a few months asking few questions along the way
Now i know that i could do like the i did with· select case endselect up at the top of the routine and if i do it that way
i will have to have different looknum name but what know how to is to set this up to turn the relay·ON and OFF
This where i need some help
I want explain a couple of thing first what i have here work JUST the way i want it to work
The reason the routine is written the way it is because if i lose power to the Basic Stamp it Pick up where it left off
The DS1302 has a Ni cad for it back up battery i have charging routine working
I know i could have set this with·REAL·TIME·OF DAY·but i do not want have to reset the time Day Light Saving Time
'
[noparse][[/noparse] Program Code ]
Clock_Run:
·DO
· GOSUB Get_Time
· DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
SELECT secs
·CASE >$45······ 'Sort by minute value
· GOSUB three_quater
·CASE >$30
· GOSUB half
·CASE >$15······ 'Sort by minute value
· GOSUB quater
·CASE >$00
· GOSUB oclock
ENDSELECT································ 'Based on selcted subnumber run proper routine
ON subnumber GOSUB t800, t745, t730, t715, t700, t645, t630, t615, t600, t545, t530, t515, t500, t445, t430, t415, t400, Rest_Clock
LOOP
three_quater:
LOOKDOWN mins, [noparse][[/noparse]$00, $01, $02, $03], looknum 'minute value of 30 is known, compare hour # and
LOOKUP looknum, [noparse][[/noparse]3, 7, 11, 15, 17], subnumber···· 'assign value to looknum. ie: $11 = 1, or $13 = 3
RETURN····································· 'Based on looknum select subroutine # ie: 3 >> 7
··········································· 'or 1>>3
half:
LOOKDOWN mins, [noparse][[/noparse]$00, $01, $02, $03], looknum 'minute value of 30 is known, compare hour # and
LOOKUP looknum, [noparse][[/noparse]2, 6, 10, 14, 18], subnumber···· 'assign value to looknum. ie: $11 = 1, or $13 = 3
RETURN····································· 'Based on looknum select subroutine # ie: 3 >> 7
··········································· 'or 1>>3
quater:
LOOKDOWN mins, [noparse][[/noparse]$00, $01, $02, $03], looknum 'minute value of 30 is known, compare hour # and
LOOKUP looknum, [noparse][[/noparse]1, 5, 9, 13, 19], subnumber···· 'assign value to looknum. ie: $11 = 1, or $13 = 3
RETURN····································· 'Based on looknum select subroutine # ie: 3 >> 7
··········································· 'or 1>>3
oclock:
LOOKDOWN mins, [noparse][[/noparse]$00, $01, $02, $03, $04], looknum
LOOKUP looknum, [noparse]/noparse]0, 4, 8, 12, 16, 20[color=white]·[/color, subnumber
RETURN
t800:
HIGH relay
DEBUG "t800 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $13 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t745:
HIGH relay
DEBUG "t745 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $28 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t730:
HIGH relay
DEBUG "t730 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $43 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t715:
HIGH relay
DEBUG "t715 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $58 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t700:
HIGH relay
DEBUG "t700 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $13 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t645:
HIGH relay
DEBUG "t645 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $28 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t630:
HIGH relay
DEBUG "t630 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $43 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
PAUSE 500
RETURN
t615:
HIGH relay
DEBUG "t615 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $58 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
·return
t600:
HIGH relay
DEBUG "t600 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $13 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t545:
HIGH relay
DEBUG "t545 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $28 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t530:
HIGH relay
DEBUG "t530 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $43 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t515:
HIGH relay
DEBUG "t515 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $58 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t500:
HIGH relay
DEBUG "t500 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $13 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t445:
HIGH relay
DEBUG "t445 "
PAUSE 500
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $28 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t430:
HIGH relay
DEBUG "t430 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $43 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t415:
HIGH relay
DEBUG "t415 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $58 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t400:
HIGH relay
DEBUG "t400 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF mins > $04 AND secs > $13 THEN
·LOW relay
·PAUSE 3000
·ENDIF
GOTO Rest_Clock
LOOP
return
Rest_Clock:
mins = $00
secs = $00
GOSUB Set_Time
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $05 THEN
EXIT
ENDIF
LOOP
GOTO Clock_Run
'
[noparse][[/noparse] Subroutines ]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 12/23/2007 11:40:13 AM GMT
I have been working on this off and on for a few months asking few questions along the way
Now i know that i could do like the i did with· select case endselect up at the top of the routine and if i do it that way
i will have to have different looknum name but what know how to is to set this up to turn the relay·ON and OFF
This where i need some help
I want explain a couple of thing first what i have here work JUST the way i want it to work
The reason the routine is written the way it is because if i lose power to the Basic Stamp it Pick up where it left off
The DS1302 has a Ni cad for it back up battery i have charging routine working
I know i could have set this with·REAL·TIME·OF DAY·but i do not want have to reset the time Day Light Saving Time
'
[noparse][[/noparse] Program Code ]
Clock_Run:
·DO
· GOSUB Get_Time
· DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
SELECT secs
·CASE >$45······ 'Sort by minute value
· GOSUB three_quater
·CASE >$30
· GOSUB half
·CASE >$15······ 'Sort by minute value
· GOSUB quater
·CASE >$00
· GOSUB oclock
ENDSELECT································ 'Based on selcted subnumber run proper routine
ON subnumber GOSUB t800, t745, t730, t715, t700, t645, t630, t615, t600, t545, t530, t515, t500, t445, t430, t415, t400, Rest_Clock
LOOP
three_quater:
LOOKDOWN mins, [noparse][[/noparse]$00, $01, $02, $03], looknum 'minute value of 30 is known, compare hour # and
LOOKUP looknum, [noparse][[/noparse]3, 7, 11, 15, 17], subnumber···· 'assign value to looknum. ie: $11 = 1, or $13 = 3
RETURN····································· 'Based on looknum select subroutine # ie: 3 >> 7
··········································· 'or 1>>3
half:
LOOKDOWN mins, [noparse][[/noparse]$00, $01, $02, $03], looknum 'minute value of 30 is known, compare hour # and
LOOKUP looknum, [noparse][[/noparse]2, 6, 10, 14, 18], subnumber···· 'assign value to looknum. ie: $11 = 1, or $13 = 3
RETURN····································· 'Based on looknum select subroutine # ie: 3 >> 7
··········································· 'or 1>>3
quater:
LOOKDOWN mins, [noparse][[/noparse]$00, $01, $02, $03], looknum 'minute value of 30 is known, compare hour # and
LOOKUP looknum, [noparse][[/noparse]1, 5, 9, 13, 19], subnumber···· 'assign value to looknum. ie: $11 = 1, or $13 = 3
RETURN····································· 'Based on looknum select subroutine # ie: 3 >> 7
··········································· 'or 1>>3
oclock:
LOOKDOWN mins, [noparse][[/noparse]$00, $01, $02, $03, $04], looknum
LOOKUP looknum, [noparse]/noparse]0, 4, 8, 12, 16, 20[color=white]·[/color, subnumber
RETURN
t800:
HIGH relay
DEBUG "t800 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $13 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t745:
HIGH relay
DEBUG "t745 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $28 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t730:
HIGH relay
DEBUG "t730 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $43 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t715:
HIGH relay
DEBUG "t715 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $58 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t700:
HIGH relay
DEBUG "t700 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $13 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t645:
HIGH relay
DEBUG "t645 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $28 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t630:
HIGH relay
DEBUG "t630 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $43 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
PAUSE 500
RETURN
t615:
HIGH relay
DEBUG "t615 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $58 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
·return
t600:
HIGH relay
DEBUG "t600 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $13 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t545:
HIGH relay
DEBUG "t545 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $28 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t530:
HIGH relay
DEBUG "t530 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $43 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t515:
HIGH relay
DEBUG "t515 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $58 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t500:
HIGH relay
DEBUG "t500 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $13 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t445:
HIGH relay
DEBUG "t445 "
PAUSE 500
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $28 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t430:
HIGH relay
DEBUG "t430 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $43 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t415:
HIGH relay
DEBUG "t415 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $58 THEN
LOW relay
PAUSE 2000
ENDIF
·GOTO Clock_Run
LOOP
return
t400:
HIGH relay
DEBUG "t400 "
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF mins > $04 AND secs > $13 THEN
·LOW relay
·PAUSE 3000
·ENDIF
GOTO Rest_Clock
LOOP
return
Rest_Clock:
mins = $00
secs = $00
GOSUB Set_Time
DO
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs, CR, CR
IF secs = $05 THEN
EXIT
ENDIF
LOOP
GOTO Clock_Run
'
[noparse][[/noparse] Subroutines ]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
![idea.gif](http://forums.parallax.com/images/smilies/idea.gif)
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 12/23/2007 11:40:13 AM GMT
Comments
I used to work in the irrigation industry -- this is how sprinkler timers handle watering schedules.