Hi, I have a simple design for a time logging application running on an 18x picaxe. I have some simple code that looks up the the time & date from a clock chip and outputs to values in one of two formats depending on the position of a switch connected to input0.
I am using a momentary switch to supply power the chip and start the programme, data logs fine when switch on input 0 is open (set 0) but the data for the date section is garbled if the switch is set to on (1). If I power the setup continuously, and use a separate switch to run modified code to get the time stamp all works OK. So I assume the problem lies when powering up with the switch on input 0 on. I have tried adding pauses at various location in the programme but have been unsuccessful. As i want to run this setup for long period I'd like to have the code run only when powered on, rather than having to supply power all of the time.
Any help much appreciated.
Code:-
high 0
i2cslave %11010000, i2cslow, i2cbyte ‘ set slave details
symbol secs = b0
symbol mins = b1
symbol hours = b2
symbol day = b4
symbol month = b5
symbol year = b6
date:
pause 5000
readi2c 0,(b0,b1,b2,b3,b4,b5,b6) 'read clock values
BCDTOASCII day,b7,b8 'convert b4 (day) to ascii output to b3+b4
BCDTOASCII month,b9,b10 'convert b5 (month) to ascii output to b5+b6
BCDTOASCII year,b11,b12 'convert b6 (year) to ascii output to b7+b8
SerTxD (b7,b8,"/",b9,b10,"/",b11,b12," ") 'output date dd:mm:yy__
time:
readi2c 0,(b0,b1,b2) 'read clock values
BCDTOASCII secs,b3,b4 'convert b0 (seconds) to ascii output to b3+b4
BCDTOASCII mins,b5,b6 'convert b1 (minutes) to ascii output to b5+b6
BCDTOASCII hours,b7,b8 'convert b2 (hours) to ascii output to b7+b8
if pin0= 0 then timew
if pin0= 1 then timeb
timew:
SerTxD (b7,b8,":",b5,b6,":",b3,b4," David") 'output time in order hh:mm:ss
SerTxD (13, 10) 'new line
pause 500 'pause 500ms while data is written
low 0 'LED off
end
timeb:
SerTxD (b7,b8,":",b5,b6,":",b3,b4," Sam") 'output time in order hh:mm:ss
SerTxD (13, 10) 'new line
pause 500 'pause 500ms while data is written
low 0 'LED off
end
I am using a momentary switch to supply power the chip and start the programme, data logs fine when switch on input 0 is open (set 0) but the data for the date section is garbled if the switch is set to on (1). If I power the setup continuously, and use a separate switch to run modified code to get the time stamp all works OK. So I assume the problem lies when powering up with the switch on input 0 on. I have tried adding pauses at various location in the programme but have been unsuccessful. As i want to run this setup for long period I'd like to have the code run only when powered on, rather than having to supply power all of the time.
Any help much appreciated.
Code:-
high 0
i2cslave %11010000, i2cslow, i2cbyte ‘ set slave details
symbol secs = b0
symbol mins = b1
symbol hours = b2
symbol day = b4
symbol month = b5
symbol year = b6
date:
pause 5000
readi2c 0,(b0,b1,b2,b3,b4,b5,b6) 'read clock values
BCDTOASCII day,b7,b8 'convert b4 (day) to ascii output to b3+b4
BCDTOASCII month,b9,b10 'convert b5 (month) to ascii output to b5+b6
BCDTOASCII year,b11,b12 'convert b6 (year) to ascii output to b7+b8
SerTxD (b7,b8,"/",b9,b10,"/",b11,b12," ") 'output date dd:mm:yy__
time:
readi2c 0,(b0,b1,b2) 'read clock values
BCDTOASCII secs,b3,b4 'convert b0 (seconds) to ascii output to b3+b4
BCDTOASCII mins,b5,b6 'convert b1 (minutes) to ascii output to b5+b6
BCDTOASCII hours,b7,b8 'convert b2 (hours) to ascii output to b7+b8
if pin0= 0 then timew
if pin0= 1 then timeb
timew:
SerTxD (b7,b8,":",b5,b6,":",b3,b4," David") 'output time in order hh:mm:ss
SerTxD (13, 10) 'new line
pause 500 'pause 500ms while data is written
low 0 'LED off
end
timeb:
SerTxD (b7,b8,":",b5,b6,":",b3,b4," Sam") 'output time in order hh:mm:ss
SerTxD (13, 10) 'new line
pause 500 'pause 500ms while data is written
low 0 'LED off
end
Last edited: