Once I changed to mode 8 instead of mode 4 for Serout, everything worked up to line 28 of the code below.
It worked briefly, but begins to lag. Almost instantly, I notice a considerable delay in the response time between a hex value in and the coresponding ASCII display. The delay gets longer after several seconds, then crashes all together. I tried adding a 3 second delay to the loop of this function to reduce the number of serial transmissions to the lcd, but it still doesn't work. The display is erratic. Sometimes when going from bit 16 high to bit 32 high, it will briefly display the sum of the two & after a few seconds delay, then the proper value of "32" is displayed. And the lower 4 bits don't work at all. The display always reads "none" if any of the lower 4 bits is high.
Do I need a debounce? Should I use a standard LCD instead of the Parallax serial LCD? Or am I likely to have the same problems with a 44780 controlled LCD also? Possibly I need to use interrupts instead of looping the same data over and over until there is a change in state?
Here's a simplified version of the code with just the LCD functions:
Code:
'program for integrated firing panel
'portA = hexadecimal rotary encoder input (value to be displayed as an ASCII on LCD)
'portB.1 = serial Tx
'initialize device
@ device pic16f747, INTRC_OSC_NOCLKOUT, MCLR_OFF
OSCCON = $60 '4mhz internal oscillator
'initialize variables
TxPin var PORTB.1 'alias pin B.1 to "TxPin"
'Initialize Display
Pause 1000 'pause 1 sec to let LCD initialize
serout TxPin,8, [22] 'turn display on, no cursor
serout TxPin,8, [17] 'turn backlight on
serout TxPin,8, ["Firing Panel v1"]
pause 5000
serout TxPin,8, [22] 'Clear LCD
serout TxPin,8, [128] 'move cursor to beginning of first line
serout TxPin,8, ["Panel Selected:"]
message:
serout TxPin,8, [199] 'cursor to line 1, position 8
IF PORTA = 0 then
serout TxPin,8, ["None"]
Else
serout TxPin,8, [#PORTA] 'display ASCII of portA on LCD
Endif
pause 3000
goto message 'loop LCD forever
End
Bookmarks