PDA

View Full Version : What am I missing????



cphillips82
- 15th July 2008, 09:41
[code]
Define LCD_DREG PORTB
'Set starting data bit
Define LCD_DBIT 4 'rb4,rb5,rb6,rb7
'Set LCD RS Port
DEFINE LCD_RSREG portb
'Set LCD RS Bit
define LCD_RSBIT 3
'Set LCD Enable Port
Define LCD_EREG portb
'Set LCD Enable Bit
Define LCD_EBIT 2
'Set number of LCD Lines
Define LCD_LINES 2
'Set Command Delay time in uS
define LCD_COMMANUS 2000
'Set Data delay time in uS
define LCD_DATAUS 50



'
' Set Hardware Directions
' -----------------------
CMCON=%00000111 ' Disable Comparators
TRISA=%00000111 ' PORTA all set to Output
'

'
UP var PORTA.0 ' Press to Decrement Button
Enter var PORTA.1 ' Press to Set/memorise Button
Down var PORTA.2 ' Press to Increment Button
CounterC var Byte



LCDOut $FE,1 ' Clear LCD



CounterC=0 ' Set to Start of Setup (seven steps from 0 to 6)

SetupLoop:
LCDOut $FE,1,"Set "
pause 1000
'
If CounterC=0 then
LCDOut "Real Time"
endif
If CounterC=1 then
LCDOut "On Time"
endif
If CounterC=2 then
LCDOut "Off Time"
endif
If CounterC=3 then
LCDOut "Date"
endif
If CounterC=4 then
LCDOut "Day Temp"
endif
If CounterC=5 then
LCDOut "Night Temp"
endif
If CounterC=6 then
LCDOut "MODE"
endif

'

' --------------------
SetupDisplayLoop:

If Enter = 1 then
if CounterC=0 then Set_time

If counterC=1 Then Set_ontime

if counterC=2 Then Set_offtime

if counterC=3 Then Set_Date

if counterC=4 Then Set_dtemp

if counterC=5 Then Set_ntemp

if counterC=6 Then Set_Btemp

endif


counterC = counterC + 1
if counterC >= 7 then
counterC = 0
endif

goto setupLoop

Set_time:
Set_ontime:
Set_offtime:
Set_Date:
Set_dtemp:
Set_ntemp:
Set_Btemp:
End
[code/]
all I get is set on the screen at powerup then when i push up I get on of the options then thats it? thanks to anyone in advanced

cphillips82
- 15th July 2008, 09:47
Define LCD_DREG PORTB
'Set starting data bit
Define LCD_DBIT 4 'rb4,rb5,rb6,rb7
'Set LCD RS Port
DEFINE LCD_RSREG portb
'Set LCD RS Bit
define LCD_RSBIT 3
'Set LCD Enable Port
Define LCD_EREG portb
'Set LCD Enable Bit
Define LCD_EBIT 2
'Set number of LCD Lines
Define LCD_LINES 2
'Set Command Delay time in uS
define LCD_COMMANUS 2000
'Set Data delay time in uS
define LCD_DATAUS 50



'
' Set Hardware Directions
' -----------------------
CMCON=%00000111 ' Disable Comparators
TRISA=%00000111 ' PORTA all set to Output
'

'
UP var PORTA.0 ' Press to Decrement Button
Enter var PORTA.1 ' Press to Set/memorise Button
Down var PORTA.2 ' Press to Increment Button
CounterC var Byte



LCDOut $FE,1 ' Clear LCD



CounterC=0 ' Set to Start of Setup (seven steps from 0 to 6)

SetupLoop:
LCDOut $FE,1,"Set "
pause 1000
'
If CounterC=0 then
LCDOut "Real Time"
endif
If CounterC=1 then
LCDOut "On Time"
endif
If CounterC=2 then
LCDOut "Off Time"
endif
If CounterC=3 then
LCDOut "Date"
endif
If CounterC=4 then
LCDOut "Day Temp"
endif
If CounterC=5 then
LCDOut "Night Temp"
endif
If CounterC=6 then
LCDOut "MODE"
endif

'

' --------------------
SetupDisplayLoop:

If Enter = 1 then
if CounterC=0 then Set_time

If counterC=1 Then Set_ontime

if counterC=2 Then Set_offtime

if counterC=3 Then Set_Date

if counterC=4 Then Set_dtemp

if counterC=5 Then Set_ntemp

if counterC=6 Then Set_Btemp

endif

if enter = 1 then
counterC = counterC + 1
if counterC >= 7 then
counterC = 0
endif
endif

goto setupLoop

Set_time:
Set_ontime:
Set_offtime:
Set_Date:
Set_dtemp:
Set_ntemp:
Set_Btemp:
End

sayzer
- 15th July 2008, 10:28
May be you forgot to include increment/decrement buttons into your code.

Example:


IF UP = 0 THEN
WHILE UP = 0 : WEND
IF CounterC < 6 THEN CounterC = CounterC + 1
ENDIF


IF DOWN = 0 THEN
WHILE DOWN = 0 : WEND
IF CounterC > 0 THEN CounterC = CounterC - 1
ENDIF



Currently, CounterC gets 0 at the beginning.
AND, since your code does not change its value, it takes you to SET_TIME subroutine when you press Enter button.

AND, since there is no GOTO in your subroutines, your program hits END and stops there.
So, add "GOTO SetupLoop" at the end of each subroutine.


----------------------

cphillips82
- 15th July 2008, 11:05
thanks for your suggestion sayzer, I see where I made a mistake in that code but there is still a problem which creates the same result. or am I missing something else.


UP var PORTA.0 ' Press to Decrement Button
Enter var PORTA.1 ' Press to Set/memorise Button
Down var PORTA.2 ' Press to Increment Button
CounterC var Byte



LCDOut $FE,1 ' Clear LCD



CounterC=0 ' Set to Start of Setup (seven steps from 0 to 6)

SetupLoop:
LCDOut $FE,1,"Set "
pause 1000
'
If CounterC=0 then
LCDOut "Real Time"
endif
If CounterC=1 then
LCDOut "On Time"
endif
If CounterC=2 then
LCDOut "Off Time"
endif
If CounterC=3 then
LCDOut "Date"
endif
If CounterC=4 then
LCDOut "Day Temp"
endif
If CounterC=5 then
LCDOut "Night Temp"
endif
If CounterC=6 then
LCDOut "MODE"
endif

'

' --------------------
SetupDisplayLoop:

If Enter = 1 then
if CounterC=0 then Set_time

If counterC=1 Then Set_ontime

if counterC=2 Then Set_offtime

if counterC=3 Then Set_Date

if counterC=4 Then Set_dtemp

if counterC=5 Then Set_ntemp

if counterC=6 Then Set_Btemp

endif

IF UP = 1 THEN
WHILE UP = 1 : WEND
IF CounterC < 6 THEN CounterC = CounterC + 1
ENDIF


IF DOWN = 1 THEN
WHILE DOWN = 1 : WEND
IF CounterC > 0 THEN CounterC = CounterC - 1
ENDIF

goto setupLoop

Set_time:
Set_ontime:
Set_offtime:
Set_Date:
Set_dtemp:
Set_ntemp:
Set_Btemp:
End

sayzer
- 15th July 2008, 11:19
What happens when the program jumps to "Set_time" subroutine?

There is no GOTO there. None of them has.

Thus, your program stops.

cphillips82
- 15th July 2008, 11:47
I'm really just wanting to make a kind of graphic interface so I can navigate. eg I want to be able to press up and down to show real time, on time, off time etc then click enter to goto the labels

Jerson
- 15th July 2008, 12:29
What happens when the program jumps to "Set_time" subroutine?

There is no GOTO there. None of them has.

Thus, your program stops.

As sayzer has posted, you need to have a goto setuploop just before your end statement. That's what you're missing :)

cphillips82
- 15th July 2008, 14:03
thanks for you suggestions but i don't think I was explaining myself properly, Anyway I nutted it out and got it working. cheers


SetupLoop:
LCDOut 254,1,"Set "

SetupDisplayLoop:
If CounterC=0 then
LCDOut 254,132,"Real Time "
endif
If CounterC=1 then
LCDOut 254,132,"On Time "
endif
If CounterC=2 then
LCDOut 254,132,"Off Time "
endif
If CounterC=3 then
LCDOut 254,132,"Date "
endif
If CounterC=4 then
LCDOut 254,132,"Day Temp "
endif
If CounterC=5 then
LCDOut 254,132,"Night Temp"
endif
If CounterC=6 then
LCDOut 254,132,"MODE "
endif

If Enter = 1 then
if CounterC=0 then Set_time

If counterC=1 Then Set_ontime

if counterC=2 Then Set_offtime

if counterC=3 Then Set_Date

if counterC=4 Then Set_dtemp

if counterC=5 Then Set_ntemp

if counterC=6 Then Set_Btemp

endif

IF UP = 1 THEN
pause 100
IF CounterC < 6 THEN CounterC = CounterC + 1
ENDIF


IF DOWN = 1 THEN
pause 100
IF CounterC > 0 THEN CounterC = CounterC - 1
ENDIF

goto setupdisplayLoop

Set_time:
Set_ontime:
Set_offtime:
Set_Date:
Set_dtemp:
Set_ntemp:
Set_Btemp:
End