Clocks
uses a ds1307 to keep acurate time updates every minute
and a ds18b20 to read temperature.(cause every1 seems to have em)
temp will be displayed every minute for 14 secs approx
at the half minute mark
and then update time from the ds1307
pm time will be displayed in 12hr format
push the button to program ds1307
push to select hours 1 to 24
ie if your want 10.
push to select 9.
push and hold to get 10. then will jump to minutes 00
push to select 29
push and hold on 30 will display last digit 0
when you release clock starts at 10.30
uses a ds1307 to keep acurate time updates every minute
and a ds18b20 to read temperature.(cause every1 seems to have em)
temp will be displayed every minute for 14 secs approx
at the half minute mark
and then update time from the ds1307
pm time will be displayed in 12hr format
push the button to program ds1307
push to select hours 1 to 24
ie if your want 10.
push to select 9.
push and hold to get 10. then will jump to minutes 00
push to select 29
push and hold on 30 will display last digit 0
when you release clock starts at 10.30
Code:
' -- -- -- -- -- -- -- --
' B0-A | | | | | | | |
' B1-B
' B2-C | | | | | | | |
' B3-D -- -- -- -- -- -- -- --
' B4-E | | | | | | | |
' B5-F
' B6-G | | | | | | | |
' B7-dp -- -- -- -- o -- -- -- --
'
'Display 1 2 3 4
'Common anode C.3 C.2 C.1 c.0
eeprom 0,(192,249,164,176,153,146,130,248,128,144,255) 'Display (0,1,2,3,4,5,6,7,8,9,blank)
let dirsb = %11111111
let dirsc = %00111111
main:
let b31= bcdtobin b31 'sec
let w3= bcdtobin b32 * 60 'min
let b33= bcdtobin b33 'hrs
if b33>12 then
let w4= b33 -12*3600+w3+b31 'pm
else
let w4= b33 *3600+w3+b31 'am
endif
SETTIMER T1S_8
let timer = w4 'up date time from ds1307 every minute
clock:
w1=Timer/3600 'time hours
w2=Timer//3600/60 'time minutes
b34=timer//3600//60 'time seconds
high c.0
b0=10 : if w1 < 10 then dig1 'Zero blanking
let b0 = w1 dig 1
Dig1: read b0,b11
if pinc.6 = 1 then hours 'program time
if b34=30 then temp 'display temp at 30 secs
let pinsb = b11 : low c.3 : pause 1 'Display1
let b0 = w1 dig 0
Dig2: read b0,b12 : let b12=b12-128 'with d.p
high c.3 : let pinsb = b12 : low c.2 : pause 1 'Display2
let b0 = w2 dig 1
Dig3: read b0,b13 : let b13=b13-0 '
high c.2 : let pinsb = b13 : low c.1 : pause 1 'Display3
let b0 = w2 dig 0
Dig4:read b0,b14 : let b14=b14-0 '
high c.1 : let pinsb = b14 : low c.0 : pause 1 'Display4
goto clock
Hours:w1=0
hrs:w20=0
Ho:
b0=10 : if w1 < 10 then dig11 'Zero blanking
let b0 = w1 dig 1
dig11: read b0,b11
high c.2 : let pinsb = b11 : low c.3 : pause 1 'Display1
high c.1 : high c.0
let b0 = w1 dig 0
read b0,b12 : let b12=b12-128 'with d.p
high c.3 : let pinsb = b12 : low c.2 : pause 1 'Display2
if pinc.6=0 then hrs 'reset ready for next count
let w20=w20+1
if w20 > 200 then Minutes 'hold to goto Minutes
if w20 > 1 then ho 'ignores button bounce
let w1=w1+1 'Add count by 1
if w1=25 then hours 'Reset after 24 reached
goto ho
Minutes:w2=65535 ' start at 0
mins:w21=0
Mi:
let b0 = w2 dig 1
read b0,b13
high c.0 : let pinsb = b13 : low c.1 : pause 1 'Display3
high c.3 : high c.2
let b0 = w2 dig 0
read b0,b14
high c.1 : let pinsb = b14 : low c.0 : pause 1 'Display4
if pinc.6=0 then mins 'reset ready for next count
let w21=w21+1
if w21 > 200 then prog 'hold to goto prog
if w21 > 1 then Mi 'ignores button bounce
let w2=w2+1 'Add count by 1
if w2=60 then minutes 'Reset after 59 reached
goto Mi
prog:
if pinc.6 = 1 then prog 'release to program
let b32= bintobcd w2
let b33= bintobcd w1
hi2csetup i2cmaster, %11010000, i2cslow_8, i2cbyte 'prog time ds1307
hi2cout 0, ($00, b32, b33, $03, $07, $05, $10, $10) '(seconds,mins,hour,day,date,month,year,control)
goto prog1
temp:
readtemp c.7,w1
let dirsb = %11111111 'read temp turns off b3 pin (restore pinsb)
for w14=1 to 1000 'display temp time about 14secs
let b0 = w1 dig 1
read b0,b11
let pinsb = b11 : low c.3 : pause 1 : high c.3 'Display1 temp
let b0 = w1 dig 0
read b0,b12
let pinsb = b12 : low c.2 : pause 1 : high c.2 'Display2 temp
let pinsb = 156 : low c.1 : pause 1 : high c.1 'Display3 o
let pinsb = 198 : low c.0 : pause 1 : high c.0 'Display4 C
next w14
prog1:
hi2csetup i2cmaster, %11010000, i2cslow_8, i2cbyte
hi2cin 0,(b31,b32,b33) 'read time ds1307
HI2cSetup OFF
let dirsb = %11111111 'hi2c leaves b5 b7 pins high (restore pinsb)
goto main
Attachments
-
188.8 KB Views: 483
Last edited: