PDA

View Full Version : coundown problem on LCD



SuB-ZeRo
- 6th June 2005, 15:08
Hi everybody.
i again have problem with pic :(
i am trying to countdown the hours minutes and seconds
like 01:19:49 and lcd will show the countdown
if i press button1 i want to add 30 minute
i start like this
second VAR BYTE [59] 'I WANT TO LIMIT THE TIME
minute VAR BYTE[59]
hour VAR BYTE[59]
second=0 'start with 0
minute=0 'start with 0
hour=0 'start with 0
button porta.4 ,0,0,0,b1,1,plus_the_count
simlpy my codes re like these but the compiler allways give error
(unable to fit second)
after then i try it basicly
'''''''''''''''''''''''''''''''''''''''''''''''''r eal codes for 16F628'''''''''''''''''''''''''''''''''''''''''''' '
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 3
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50
saniye var byte[59]
dakika var byte[59]
saat var byte[59]
saniye=0
dakika=0
saat=0
loop:
saniye = saniye -1
if dakika =00 then saat= saat-1
LCDOut $FE,1 'ekranı temizle
lcdout "KALAN SURE"
LCDOut $Fe,$C0
LCDOUT #saat,":",#dakika,":",#saniye
pause 1000
goto loop
end
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''end'''''''' ''''''''''''''''''''''''''''''''''''
and still have problem "unable to fit variable saniye"
how can i limit the numbers when reverse counting?

Dave
- 6th June 2005, 15:48
SuB-ZeRo, You are using almost all of the available ram with the 3 arrays you are trying to declare. The processor you are using only has 192 bytes available and you are declaring 180 of them. Why?

Dave Purola,
N8NTA

Dave
- 6th June 2005, 16:08
SuB-ZeRo,
I beleive you want to do something like this:
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 3
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50
saniye var byte
dakika var byte
saat var byte
saniye=59
dakika=59
saat=59
loop:
LCDOut $FE,1 'ekranı temizle
lcdout "KALAN SURE"
LCDOut $Fe,$C0
LCDOUT #saat,":",#dakika,":",#saniye
saniye = saniye - 1
if saniye > 59 then
saniye = 59
dakika = dakika - 1
if dakika > 59 then
dakika = 59
saat = saat - 1
if saat > 59 then
saat = 59
endif
endif
endif
pause 1000
goto loop
end

DynamoBen
- 6th June 2005, 16:09
Are you sure you are using the following line correctly?

second VAR BYTE [59] 'I WANT TO LIMIT THE TIME

This doesn't limit the byte to 59 it creates an array of 59 bytes. It sounds like you want 1 byte that doesn't go any higher than 59. I would do the following within a loop:

IF UP=0 Then ' Button Up command
While UP=0:Wend
second = v+1
IF second > 59 Then second = 1
LCDOut $FE,1
EndIF

SuB-ZeRo
- 6th June 2005, 19:05
i thing every body understand me wrong coz i want to set i timer that start with 00:00:00 and if i push the button that connected to the RA4 it will plus the reverse timer 30 minute 00:00:00 will become 00:30:00 after than countdown beguns 00:29:59 .......00:28:59...... till 00:00:00 but when the countdown starts or continues if i push the button again for example when the time 00:25:19 it will plus 30 minute again and the time will become 00:55:19 every push will plus 30 minute 01:25:19 ... 01:55:19 and goes.My problem is when i try to start the time from 00:00:00 on the LCD i see 0:0:0 if i push the button it becomes 0:30:0 after than it goes 0:29:1=>0:29:0=>0:28:1=>0:28:0 i really cant find the problem :(

DynamoBen
- 6th June 2005, 19:20
try:
LCDOUT DEC2 saat,":",DEC2 dakika,":",DEC2 saniye

DEC2 will always print two digits to your display.

SuB-ZeRo
- 7th June 2005, 00:51
ok i resolve the problem the real problem is putting the codes to the right place i am getting to learn programming in pic basic :)