Hello everyone, I made a counter with 3 sectional of the schematic in attachments.On schematic is another pic, and I use the 16f76, 4MHz oscilator.Display with common cathode.
In the Basic, I got the written code and tried to adjust it to end,but i do not now how and i ask for help!
The counter is conceived to work like this: When the timer turns on dislpleju keys (ones, tens, hundreds) to set the desired number (say 100). When you've set that,when the "start" button pressed -activates the relay (portc.4) and display shows three zeros and controler "waiting" impulses with pulse from portc.0.Each impulse from portc.0,display is shows as number.(frist is 001, the second impulse on the display-002...) and so on until impulses reach to set number (in this case 100). Then relay is off,and count is stop.
"Stop" button is used to stop program- in a any time.When" pause" is pressed, the counting impuse stops, the relay is turned off until the start button is pressed again, when the counting continues counting from '"place"(number) wher a "pause" is pressed,and relay is on again.
I got seting up number code, how to do a rest of code?
Ufffffffff complicated right? Driving me insane,please help...
p.s. Sorry on my bad english!
In the Basic, I got the written code and tried to adjust it to end,but i do not now how and i ask for help!
The counter is conceived to work like this: When the timer turns on dislpleju keys (ones, tens, hundreds) to set the desired number (say 100). When you've set that,when the "start" button pressed -activates the relay (portc.4) and display shows three zeros and controler "waiting" impulses with pulse from portc.0.Each impulse from portc.0,display is shows as number.(frist is 001, the second impulse on the display-002...) and so on until impulses reach to set number (in this case 100). Then relay is off,and count is stop.
"Stop" button is used to stop program- in a any time.When" pause" is pressed, the counting impuse stops, the relay is turned off until the start button is pressed again, when the counting continues counting from '"place"(number) wher a "pause" is pressed,and relay is on again.
I got seting up number code, how to do a rest of code?
Ufffffffff complicated right? Driving me insane,please help...
p.s. Sorry on my bad english!
Code:
Ones var byte
Tens var byte
Hundreds var byte
CntOnes var byte
CntTens var byte
CntHundreds var byte
NumToShow var byte
KeyOnesReleased var bit
KeyTensReleased var bit
KeyHundredsReleased var bit
KeyOnesPressed var bit
KeyTensPressed var bit
KeyHundredsPressed var bit
KeyOnes var porta.3
KeyTens var porta.4
KeyHundreds var porta.5
CatodeOnes var portc.5
CatodeTens var portc.6
CatodeHundreds var portc.7
DebCnt con 3
True con 1
False con 0
TRISA = 255 ' all input
TRISB = 0 ' all output
TRISC=%00000001
ADCON1 = 7 ' svi digital
clear
KeyOnesReleased = true
KeyTensReleased = true
KeyHundredsReleased = true
Main:
gosub Debounce
gosub decisions
NumToShow = Ones
gosub ShowNum
CatodeOnes= true
pause 5
CatodeOnes= false
NumToShow = Tens
gosub ShowNum
CatodeTens = true
pause 5
CatodeTens = false
NumToShow = Hundreds
gosub ShowNum
CatodeHundreds = true
pause 5
CatodeHundreds = false
goto main
Debounce:
if keyOnes = 0 then
cntOnes = cntOnes + 1
else
cntOnes = 0
KeyOnesPressed = false
endif
if cntOnes >= debcnt then
KeyOnesPressed = true
endif
if keyTens = 0 then
cntTens = cntTens + 1
else
cntTens = 0
KeyTensPressed = false
endif
if cntTens >= debcnt then
KeyTensPressed = true
endif
if keyHundreds = 0 then
cntHundreds = cntHundreds + 1
else
cntHundreds = 0
KeyHundredsPressed = false
endif
if cntHundreds >= debcnt then
KeyHundredsPressed = true
endif
return
Decisions:
OdlOnes:
if KeyOnesPressed = true then
if KeyOnesReleased = true then
KeyOnesReleased = false
Ones = Ones + 1
if Ones > 9 then Ones = 0
endif
else
KeyOnesReleased = true
endif
OdlTens:
if KeyTensPressed = true then
if KeyTensReleased = true then
KeyTensReleased = false
Tens = Tens + 1
if Tens > 9 then Tens = 0
endif
else
KeyTensReleased = true
endif
OdlHundreds:
if KeyHundredsPressed = true then
if KeyHundredsReleased = true then
KeyHundredsReleased = false
Hundreds = Hundreds + 1
if Hundreds > 9 then Hundreds = 0
endif
else
KeyHundredsReleased = true
endif
return
ShowNum:
LookUp NumToShow, [$3F,$06,$5B,$4F,$66,$6D,$7D,$07,$7F,$6F], PORTB
return