PDA

View Full Version : Lcdout multiple variables issue



MarkEngineer
- 20th February 2015, 19:33
Having a problem with the LCDOUT Command on a PIC18F46K22 at 16MHz with a Vishay 4x20 LCD Display.

If I use LCDOUT this way:


LINE1 = $80
LCDOUT $FE, LINE1, "01234567890123456789"


It will work every time flawlessly.

But if I use:


LINE1 = $80
X1 = 10
X2 = 11
X3 = 12
X4 = 13
X5 = 14
LCDOUT $FE, LINE1, #X1, " ", #X2, " ", #X3, " ", #X4, " ", #X5

The display will show
10 11 12 garbage.....


If I do this:


LINE1 = $80
X1 = 10
X2 = 11
X3 = 12
X4 = 13
X5 = 14
LCDOUT $FE, LINE1, #X1, " ", #X2, " ", #X3, " "
LINE1 = LINE1 + 9
GOSUB DELAY30 '30 msec delay
LCDOUT $FE, LINE1, #X4, " ", #X5

then everything is correct
10 12 13 14 15

I tried changing these parameters to no avail
DEFINE LCD_COMMANDUS 1500 ; Set command delay time in us
DEFINE LCD_DATAUS 44 ; Set data delay time in us

Any suggestions?

Tabsoft
- 20th February 2015, 21:12
If you are trying to display the variable value as decimal, then try using this.

[CODE]
LINE1 = $80
X1 = 10
X2 = 11
X3 = 12
X4 = 13
X5 = 14
LCDOUT $FE, LINE1, Dec X1, " ", Dec X2, " ", Dec X3, " ", Dec X4, " ", Dec X5

Amoque
- 20th February 2015, 22:41
This, from the manual: "If a pound sign (#) precedes an Item, the ASCII representation for each digit is sent to the LCD. LCDOUT (on all devices except 12-bit core)"

Tabsoft
- 21st February 2015, 00:11
I use PBP v3 and the DEC output modifier with no issues.

MarkEngineer
- 23rd February 2015, 14:09
Thank you all for the replies but
LCDOUT $FE, LINE1, Dec X1, " ", Dec X2, " ", Dec X3, " ", Dec X4, " ", Dec X5
also works exactly the same.

The display will show 10 11 12 garbage.....
I need to have a slight delay.

Whether I use #X1 or DEC X1 the output is the same.

I think I'll try creating a 20 byte array then output the array and see what happens

MarkEngineer
- 23rd February 2015, 14:51
OK here is what I did to solve my issue....

LCDARRAY VAR BYTE[20]
LCD VAR BYTE
LCDHI VAR BYTE
LCDLO VAR BYTE



GOSUB CLEARLCDARRAY

LCD = X1 : GOSUB VALUE2STRING
LCDARRAY(0) = LCDHI : LCDARRAY(1) = LCDLO

LCD = X2 : GOSUB VALUE2STRING
LCDARRAY(3) = LCDHI : LCDARRAY(4) = LCDLO

LCD = X3 : GOSUB VALUE2STRING
LCDARRAY(6) = LCDHI : LCDARRAY(7) = LCDLO

LCD = X4 : GOSUB VALUE2STRING
LCDARRAY(9) = LCDHI : LCDARRAY(10) = LCDLO

LCD = X5 : GOSUB VALUE2STRING
LCDARRAY(12) = LCDHI : LCDARRAY(13) = LCDLO

LCDOUT $FE, LINE4, STR LCDARRAY{\20}


'take the value in LCD and convert it to a 2-character string in LCDHI and LCDLO (ONLY FOR 0 - 99)
VALUE2STRING:
LCDHI = 0

WHILE LCD >= 10
LCDHI = LCDHI + 1
LCD = LCD - 10
WEND

LCDHI = LCDHI + $30
LCDLO = LCD + $30
RETURN


CLEARLCDARRAY:
FOR LCDCTR = 0 TO 19
LCDARRAY(LCDCTR) = " "
NEXT LCDCTR
RETURN