Hi,
I'm 90% complete on this countdown timer (Code and Schematic attached).
All that's left for me to do is figure out how 11 switches (possibly 13) can work properly as inputs into PortA (7 pins as A.4 is out only). If you look at Main: you'll see I'm working on 2 port pins being used for each input. This is simply because any less will cause unreliable and confusing operation.
I have purposefully left off the +ve, earth, control signal and switch connections to make the schematic less busy looking.
Comments on a postcard to the usual address - bear in mind this is my first PICaxe project (after the obligatory flashing LED lol)
Code can countdown from 99:59:59 or any manually set value (only hrs and mins can be set). Once I have completed the switchgear assy the code and cct will be modified to also be a laptimer in format mm:ss:tenths (each lap can be driven in under a minute).
I'll also probably wire up PinA.4 to flashing LEDs that sit between each pair of displays.
Once I've got all of that done the final step will be to make it HUGE! This will more than likely be as a strip of LEDs to create 12" high numbers. PICaxe chips obviously can't sink that much current, so a Darlington pair 7 channel chip will be used per display digit.
CCT Description:
40x2 as the brains, each port displays on 2 x 7 segment displays via a BCD to 7 segment decoder chip.
PortB for seconds, PortC for minutes, PortD for hours.
Low nibble of each port for secs/mins/hours units. High nibble for secs/mins/hrs tens.
i.e. 21hrs:45mins:30secs:
Secs low nibble would be 0, high nibble 3.
Mins low nibble would be 5, high nibble 4.
Hrs low nibble would be 1, high nibble 2.
I'm 90% complete on this countdown timer (Code and Schematic attached).
All that's left for me to do is figure out how 11 switches (possibly 13) can work properly as inputs into PortA (7 pins as A.4 is out only). If you look at Main: you'll see I'm working on 2 port pins being used for each input. This is simply because any less will cause unreliable and confusing operation.
I have purposefully left off the +ve, earth, control signal and switch connections to make the schematic less busy looking.
Comments on a postcard to the usual address - bear in mind this is my first PICaxe project (after the obligatory flashing LED lol)
Code can countdown from 99:59:59 or any manually set value (only hrs and mins can be set). Once I have completed the switchgear assy the code and cct will be modified to also be a laptimer in format mm:ss:tenths (each lap can be driven in under a minute).
I'll also probably wire up PinA.4 to flashing LEDs that sit between each pair of displays.
Once I've got all of that done the final step will be to make it HUGE! This will more than likely be as a strip of LEDs to create 12" high numbers. PICaxe chips obviously can't sink that much current, so a Darlington pair 7 channel chip will be used per display digit.
CCT Description:
40x2 as the brains, each port displays on 2 x 7 segment displays via a BCD to 7 segment decoder chip.
PortB for seconds, PortC for minutes, PortD for hours.
Low nibble of each port for secs/mins/hours units. High nibble for secs/mins/hrs tens.
i.e. 21hrs:45mins:30secs:
Secs low nibble would be 0, high nibble 3.
Mins low nibble would be 5, high nibble 4.
Hrs low nibble would be 1, high nibble 2.
Code:
'************************************************************************
'** 6 digit countdown timer using picaxe 40X2 output ports B, C & D **
'** to drive binary to BCD chips that then drive 7 segment displays. **
'** **
'** Kev Coe 16th March 2011. for RAF leeming Kart Club **
'************************************************************************
#no_data
#no_table
#picaxe40x2
let b0=0 'pinsB initialise to 0-----seconds variable
let b1=0 'pinsC initialise to 0-----minutes variable
let b2=0 'pinsD initialise to 0-----hours variable
let dirsA=%00010000 'all in except A.4 out
let dirsB=%11111111 'set all portB out
let dirsC=%11111111 'all all PortC out
let dirsD=%11111111 'all all POrtD out
let outpinsD=bintobcd b2
let outpinsC=bintobcd b1
let outpinsB=bintobcd b0
setint %10000000,%10000000, A
Main:
'Minutes increment
if pinsA=%00000011 and b1<=59 then
do
b1=b1+1
let outpinsC=bintobcd b1
pause 250
loop while b1=>0 and b1<=59 and pinsA=%00000001
endif
'Minutes decrement
if pinsA=%00000101 and b1>0 and b1<=60 then
do
b1 = b1-1
let outpinsC=bintobcd b1
pause 250
loop while b1>0 and b1<=59 and pinsA=%00000010
endif
'Hours increment
if pinsA=%00000110 and b2=>0 and b2<=98 then
do
b2=b2+1
let outpinsD=bintobcd b2
pause 250
loop while b2=>0 and b2<=98 and pinsA=%00000101
endif
'Hours decrement
if pinsA=%00001010 and b2>0 and b2<=99 then
do
b2=b2-1
let outpinsD=bintobcd b2
pause 250
loop while b2>0 and b2<=99 and pinsA=%00000110
endif
'Presets for 30m, 1hr, 1h30m, 2hrs
if pinsA=%00100001 then
b0=0
b1=30
b2=0
endif
if pinsA=%00100010 then
b0=0
b1=0
b2=1
endif
if pinsA=%00100100 then
b0=0
b1=30
b2=1
endif
if pinsA=%00101000 then
b0=0
b1=0
b2=2
endif
if pinsA=%01000001 then
b0=0
b1=0
b2=0
endif
if pinsA=%01000010 then 'Condition to start Countdown timer (CountSeconds).
if b2=0 then
if b1=0 then
pause 1000
goto CountSeconds
endif
if b1>0 then
dec b1
b0=59
pause 1000
goto CountSeconds
endif
endif
if b2>0 then
if b1=0 then
dec b2
b1=59
b0=59
pause 1000
goto CountSeconds
endif
if b1>0 then
dec b1
b0=59
pause 1000
goto CountSeconds
endif
endif
endif
let outpinsB=bintobcd b0
let outpinsC=bintobcd b1
let outpinsD=bintobcd b2
goto main 'Loops until START button is pressed.
CountSeconds:
if b0=0 and b1=>0 and b2=>0 then
b0=59
endif
for b10 = 0 to 59 step 1
let outpinsB=bintobcd b0
let outpinsC=bintobcd b1
let outpinsD=bintobcd b2
if b0=0 and b1>0 then
if b1 = 0 then
b1=59
b0=59
if b2=0 then
goto CountSeconds:
endif
if b1>0 then
dec b1
endif
goto CountSeconds:
endif
if b2>0 then
dec b2
endif
goto CountSeconds:
endif
pause 1000
dec b0
if b0=0 and b1=0 and b2=0 then
goto EndGame
endif
next b10
EndGame: 'Indication when timer has reached zero.
do
if pinsA=%01000001 then
let b0=0
let b1=0
let b2=0
let outpinsD=bintobcd b2
let outpinsC=bintobcd b1
let outpinsB=bintobcd b0
goto main
endif
let outpinsB=bintobcd 56
let outpinsC=bintobcd 34
let outpinsD=bintobcd 12
pause 500
let outpinsB=bintobcd 0
let outpinsC=bintobcd 0
let outpinsD=bintobcd 0
pause 500
loop while b0=0 and b1=0 and b2=0
Interrupt: 'Interrupt to pause timer
if pinsA=%10000000 then
goto interrupt
endif
setint %10000000,%10000000, A
return
Attachments
-
81.2 KB Views: 285