PDA

View Full Version : Problems with LCD display



fratello
- 25th April 2012, 18:21
I recently bought some LCD's ; all are made in PRC, and "full compatible with HD44780 standard".
I try to use with an "old" schematic (with an "old" display (model -PRC 1602 A) this schematic work without any problem !).
But ... with original code (with only this : "LCDOUT $FE, 1, $FE, $0C" line ), none of them is initialized correctly on first "start" !
I put one picture with ...stranges characters that appear on the display (to all of them !).
After modification of program, they go right ... in 7 cases of 10 (I mean when I power on the schematic ...).

DEFINE LCD_DREG PORTC ' LCD on port c
DEFINE LCD_DBIT 0 ' Data bits C0..C3
DEFINE LCD_RSREG PORTA ' RS on PORTA
DEFINE LCD_RSBIT 1 ' RS on A1
DEFINE LCD_EREG PORTA ' E on PORTA
DEFINE LCD_EBIT 2 ' E on A2
DEFINE LCD_BITS 4 ' LCD 4 bit mode
DEFINE LCD_LINES 2 ' 2 line LCD display
Define LCD_COMMANDUS 2000 ' Command Delay (uS)
Define LCD_DATAUS 50 ' Data Delay (uS)


LCDOUT $FE,1:PAUSE 3000:LCDOUT $FE,1 ' Initialize LCD WITH HUGE PAUSE !!!
Pause 3000 ' AND AGAIN ...
LcdOut $FE, $80," DUAL TERMOMETER "
LcdOut $FE, $C0," AND THERMOSTAT "
PAUSE 5000 ' AND AGAIN ...
LCDOUT $FE, 1, $FE, $0C ' Clear display, cursor off
Pause 1000
What can I do in this case ? Thanks in advance for any suggestion !

HenrikOlsson
- 25th April 2012, 18:59
Try increasing the LCD_COMMANDUS and LCD_DATAUS. Double or tripple them, if it OK then work your way down to the lowest values that works. Alternatively look in the datasheet for the specified delay needed.

fratello
- 25th April 2012, 19:11
I already try this, BEFORE increasing Pause ... I discovered the "scroll" code dont work fine too...I think these displays are "stinky" !

Sherbrook
- 26th April 2012, 21:01
I have had this problem with some cheap displays, they are slow to start up.
Try a pause before initializing

PAUSE 1000
LCDOUT $FE,1

Phil

Archangel
- 27th April 2012, 07:51
Hi Fratello,
I found it helps to add bypass capacitors on the power inputs of these too.

fratello
- 27th April 2012, 12:27
Thanks !
I found this great piece of code (Thanks to Mr.Darell !!!) ; ALL my LCD's work fine now !!!

GOSUB LCD_INIT ' Do manual LCD Initialization

;---- Manual LCD Initialization -------------------------------------
LCD_INIT:
@ MOVE?CT 0, LCD_RSREG,LCD_RSBIT ; Start with RS LOW
@ MOVE?CT 0, LCD_RSREG+80h,LCD_RSBIT ; RS is OUTPUT

@ MOVE?CT 0, LCD_EREG,LCD_EBIT ; Start with Enable LOW
@ MOVE?CT 0, LCD_EREG+80h,LCD_EBIT ; Enable is OUTPUT

@ MOVE?CT 0, LCD_DREG+80h,LCD_DBIT ; Data Bus is OUTPUT
@ MOVE?CT 0, LCD_DREG+80h,LCD_DBIT +1
@ MOVE?CT 0, LCD_DREG+80h,LCD_DBIT +2
@ MOVE?CT 0, LCD_DREG+80h,LCD_DBIT +3

PAUSE 1000
BUSdata = 3
GOSUB Send4Bit : pause 8 ; FunctionSet 4 times
GOSUB Send4Bit : pauseUS 200
GOSUB Send4Bit : pauseUS 200
GOSUB Send4Bit : pauseUS 200
BUSdata = 2 : GOSUB Send4Bit ; 4-bit mode

BUSdata = 2 : GOSUB Send4Bit ; 2-line, 5x7
BUSdata = 8 : GOSUB Send4Bit

BUSdata = 0 : GOSUB Send4Bit ; Display OFF
BUSdata = 8 : GOSUB Send4Bit

BUSdata = 0 : GOSUB Send4Bit ; Display Clear
BUSdata = 1 : GOSUB Send4Bit
PAUSE 3

BUSdata = 0 : GOSUB Send4Bit ; Entry Mode Set
BUSdata = 6 : GOSUB Send4Bit
PAUSE 3

BUSdata = 0 : GOSUB Send4Bit ; Display ON
BUSdata = $C : GOSUB Send4Bit

@ MOVE?CT 1, LCDINITFLAG ; Tell PBP LCD is already Initialized
return


Send4Bit:
@ MOVE?CT 1, LCD_EREG,LCD_EBIT ; Enable LCD
@ MOVE?BB LCD_DREG, _TempB ; Put Data on the Bus R-M-W
@ if LCD_DBIT == 0 ; Bus starts at 0
TEMPB = (TEMPB & $F0) | BUSdata
@ else ; Bus starts at 4
TEMPB = (TEMPB & $0F) | (BUSdata << 4)
@ endif
@ MOVE?BB _TempB, LCD_DREG

PAUSEUS 25 ; Keep enabled extra long
@ MOVE?CT 0, LCD_EREG,LCD_EBIT ; Disable LCD
Pauseus 50
return
;---------- END LCD_INIT --------------------------------------------

Darrel Taylor
- 27th April 2012, 19:44
That's awesome!

It didn't work for the guy I wrote it for 6 years ago.
I'm glad to see it fixed your problem!

Thanks fratello.

fratello
- 27th April 2012, 20:12
I THANK YOU ! Glad to be member of this forum, where I "met" so special people ... Best regards !