PDA

View Full Version : LCDOUT and the second line...



Chadhammer
- 17th February 2005, 20:53
My books haven't arrived yet so I'm trudging on "Learn by example" style, so nudges will suffice.

What I'm thinking: I'd like my circuit to LCDOUT on line 1 (message on steady) and maybe have the 2nd line flash the "CHECK AUTO MODE" indicating a problem with "Auto" mode. Is there a way to clear the second line of the display only so I can pause/clear/resend to flash the message to the second line until the program jumps out of the current condition?


Mess2: LCDOUT $fe, 1, "AUTO MODE" : RETURN 'Auto mode ok

Mess3: LCDOUT $fe, 1, "MANUAL MODE" 'Atuo mode messed up
LCDOUT $c0 , "CHECK AUTO MODE" 'Flash this part of the message
Gosub Beep1 : RETURN


Even a step further and have it beep 3 times. Will the REPEAT command serve me here?


Beep1: Sound PORTC.2 [100,30] 'beep 3 times and quit and maybe wait 10 minutes and beep 3 times, etc...
S = 0
Repeat Beep1 = 0
S = S + 1
Until S > 4 : RETURN


I am looking at the output of Optos to let me know what's available

Used to write Basic when a kid, not sure what I can get away with in PicBasic pro, e.g. Nested loops and what not. Need my books....




Pic16F870 pinout
_._
RB7 - MPB (Sw1) Menu?
RB6 - SPDT (Sw2)
RB5 - LCD En
RB4 - LCD Rs
RB3 - LCD DB7
RB2 - LCD DB6
RB1 - LCD DB5
RB0 - LCD DB4
Vdd
Vss
RC7 -
RC6 - Piezo Spkr
RC5 - 1/4 Opto in
RC4 - 1/4 Opto in
RC3 - 1/4 Opto in

mister_e
- 18th February 2005, 00:25
there's probably 2 304 681 673 264 954 different way to do the same thing

WHILE/WEND


' Let's flash error message 3 times method 1
' ------------------------------------------
'
loop = 2
While Loop
lcdout $fe,$c0,"Error !"
pause 500
LCDOUT $fe,$c0," "
pause 500
loop = loop - 1
wend


FOR TO NEXT


' Let's flash error message 3 times method 2
' ------------------------------------------
'
for Loop=1 to 3
lcdout $fe,$c0,"Error !"
pause 500
LCDOUT $fe,$c0," "
pause 500
next

REPEAT/UNTIL


' Let's flash error message 3 times method 3
' ------------------------------------------
'
LOOP=0
REPEAT
lcdout $fe,$c0,"Error !"
pause 500
LCDOUT $fe,$c0," "
pause 500
LOOP=LOOP+1
UNTIL LOOP=3

IF THEN ELSE


' Let's flash error message 3 times method 4
' ------------------------------------------
'
LOOP=0
RedoLoop:
lcdout $fe,$c0,"Error !"
pause 500
LCDOUT $fe,$c0," "
pause 500
LOOP=LOOP+1
if loop !=3 then redoloop



Something to work with.. didn't test it.. should work


' I/O definition
' --------------
'
TRISB = %11000000
TRISC = %10111111
OPTION_REG.7 = 0 'enable pull-up resistor on PORTB

'Alias to I/O definition
'-----------------------
'
SW1 VAR PORTB.7
SW2 var PORTB.6
PiezoSPK var PORTC.6
Opto1 var PORTC.5
Opto2 var PORTC.4
Opto3 var PORTC.3

' LCD define
' ----------
'
define LCD_DREG PORTB ' Set data pin of LCD to
define LCD_DBIT 0 ' PORTB.0-PORTB.3

define LCD_RSREG PORTB ' Set RS bit of LCD to
define LCD_RSBIT 4 ' PORTB.4

define LCD_EREG PORTB ' Set E bit of LCD to
define LCD_EBIT 5 ' PORTB.5

' Variable definition
' -------------------
'
ActiveSwitch var byte
DelayVar var WORD

' Main Program
' ============
'
Start:
lcdout $fe,1, "Line1"
DELAYVAR=0
ReadSomething:
activeswitch=(PORTB & %11000000) | (PORTC & %00111000)
Select case activeswitch
case %01111000
Goto SW1Sub
case %10111000
GOto SW2Sub
case %11011000
goto Opto1Sub
case %11101000
goto Opto2Sub
case %11110000
goto Opto3Sub
end select
IF DELAYVAR<500 THEN
LCDOUT $FE,$C0,"Waiting !"
PAUSE 1
DELAYVAR=DELAYVAR + 1
ELSE
LCDOUT $FE,$C0," "
pause 1
delayvar=delayvar + 1
if delayvar = 1000 then delayvar = 0
endif
goto readsomething

SW1Sub:
lcdout $fe,1,"sw1"
pause 1000
goto start

SW2Sub:
lcdout $fe,1,"sw2"
pause 1000
goto start

Opto1Sub:
lcdout $fe,1,"Opto1"
pause 1000
goto start

Opto2Sub:
lcdout $fe,1,"Opto2"
pause 1000
goto start

Opto3Sub:
lcdout $fe,1,"Opto3"
pause 1000
goto start