PDA

View Full Version : LCD wont work :(



EvilGhozt
- 18th August 2009, 17:08
I cant get my LCD (Sharp LM16A211 HD44780) working with PIC16F628 :/

The connections look like this:

PortA.0 > DB4
PortA.1 > DB5
PortA.2 > DB6
PortA.3 > DB7
PortA.4 > RS (with pull-up resistor)
PortB.3 > E
PortB.5 > LED (to check if the program is running)
Ground > R/W


I'm using the internal Osc (4MHz)

The code:

loop:
Pause 1000
High PORTB.5
Pause 1000
Low PORTB.5
LCDOut $FE,1
LCDOut $FE,$80,"Hello"
GoTo loop




The LCD isnt showing anything at all! Its just a empty screen. I have checked all the connections and they are OK.
If I put the RS wire to GND, I will get the first row on the screen showing ###### (Not the #-char itself, more like black squares).

Datasheets:
http://www.kjell.com/filarkiv/SUPPORTPDF/81-90/90/90574/90574.pdf
http://www.evilghozt.se/download/LM16A211.pdf


(Note: my english isnt that good :P )

Regards Micke

Fredrick
- 18th August 2009, 17:42
How are the pin 3 (Contrast adjustment) connected?

Have you tried to change the LCD defines?


‘ Set command delay time in us
DEFINE LCD_COMMANDUS 1500
‘ Set data delay time in us
DEFINE LCD_DATAUS 44

mackrackit
- 18th August 2009, 22:56
The 628A has comparators on portA. Not sure about the 628. If it does look at this.
http://www.picbasic.co.uk/forum/showthread.php?t=561

tiger_bel
- 19th August 2009, 02:01
hoi,

this works with 628 and Sharp LM16A211 at 4Mhz
2 rows of black squares if disp is not initialised ( at power up)
init the display first at startup

rgds
tb

pause 2000

DEFINE LCD_DREG PORTD 'dataport select'
DEFINE LCD_DBIT 0 'first databit
DEFINE LCD_RSREG PORTA 'lcd register port
DEFINE LCD_RSBIT 3 'register select bit'
DEFINE LCD_EREG PORTA 'enable poort'
DEFINE LCD_EBIT 1 'enable bit'
DEFINE LCD_BITS 4 'lcd bus size'
DEFINE LCD_LINES 2 'lcd lines'
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50 'data delay in µs'

'init display
LCDOUT $FE,1 ' clear LCD
pause 100 ' pauze 0,1s
LCDOUT $FE,2 ' cursor home
LCDOUT $FE,$0C ' cursor off
pause 1000 ' pauze 0,1s


' message

LCDOUT $FE, $80, " hello "
LCDOUT $FE, $C0, " ready "
pause 1000 ' pauze 0,1s

go on

EvilGhozt
- 27th August 2009, 23:06
hoi,

this works with 628 and Sharp LM16A211 at 4Mhz
2 rows of black squares if disp is not initialised ( at power up)
init the display first at startup

rgds
tb

pause 2000

DEFINE LCD_DREG PORTD 'dataport select'
DEFINE LCD_DBIT 0 'first databit
DEFINE LCD_RSREG PORTA 'lcd register port
DEFINE LCD_RSBIT 3 'register select bit'
DEFINE LCD_EREG PORTA 'enable poort'
DEFINE LCD_EBIT 1 'enable bit'
DEFINE LCD_BITS 4 'lcd bus size'
DEFINE LCD_LINES 2 'lcd lines'
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50 'data delay in µs'

'init display
LCDOUT $FE,1 ' clear LCD
pause 100 ' pauze 0,1s
LCDOUT $FE,2 ' cursor home
LCDOUT $FE,$0C ' cursor off
pause 1000 ' pauze 0,1s


' message

LCDOUT $FE, $80, " hello "
LCDOUT $FE, $C0, " ready "
pause 1000 ' pauze 0,1s

go on


I have try that code, and I cant get it work.
I have try to switch to a new LCD display, and still same problem.
Now i have try with PIC16F676, almost the same problem there, but this time the first row is showing black squares on initializing and then clear screen 1 sec later...

Here is the code for pic16f676:

@ device INTRC_OSC_NOCLKOUT
DEFINE LCD_DREG PORTC 'dataport select'
DEFINE LCD_DBIT 0 'first databit
DEFINE LCD_RSREG PORTC 'lcd register port
DEFINE LCD_RSBIT 4 'register select bit'
DEFINE LCD_EREG PORTC 'enable poort'
DEFINE LCD_EBIT 5 'enable bit'
DEFINE LCD_BITS 4 'lcd bus size'
DEFINE LCD_LINES 2 'lcd lines'
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50 'data delay in µs'

CMCON = 7
VRCON = 0

Pause 1000
'init display
LCDOut $FE,1 ' clear LCD
Pause 100 ' pauze 0,1s
flags = 0
LCDOut $FE,2 ' cursor home
LCDOut $FE,$0C ' cursor off
Pause 1000 ' pauze 0,1s


' message

LCDOut $FE, $80, " hello "
LCDOut $FE, $C0, " ready "
Pause 1000 ' pauze 0,1s


loopme:
Pause 1000
High PORTA.0
Pause 1000
Low PORTA.0
GoTo loopme

mackrackit
- 28th August 2009, 00:09
The 676 has ADC on port C. Might help to turn that off.
How do you have the LCD contrast pin connected?

tiger_bel
- 28th August 2009, 00:28
you are using 4bit datatransfer to display.
are the 4 bits connected to DB4 to DB7 on display side ???

rgds
tiger_bel

EvilGhozt
- 28th August 2009, 13:48
Wiring diagram:
http://www.evilghozt.se/download/lcd.jpg

This is how the LCD display looks like for about 1sek before the screen goes blank again..
http://www.evilghozt.se/download/DSC_0806.JPG

Thanks for all help so far :)

mackrackit
- 28th August 2009, 14:02
Normally the contrast likes things on the "-" side. If you have a pot wire it like the example in the PBP manual. If not just try it going to the zero rail (-).

And PORTC 0-3 needs to be digital.

ANSEL = %00000000
That should turn all ADC off.
I think...

EvilGhozt
- 28th August 2009, 14:35
Normally the contrast likes things on the "-" side. If you have a pot wire it like the example in the PBP manual. If not just try it going to the zero rail (-).

And PORTC 0-3 needs to be digital.

ANSEL = %00000000
That should turn all ADC off.
I think...

If I set Vo (contrast) to GND, I wont even get the black squares at start.

ANSEL = %00000000 <- I try that, no change.

If I use a voltmeter on PortC 0-3 all are logic low (0volt) idle. In start before the LCD initailized portC 0-3 are logic high (5volt), is that right?

aratti
- 28th August 2009, 18:07
Your diagram in post #8 has the contrast pot wrongly wired. Correct the wiring as per the attached snap. Then adjust the pot till you have clean characters on LCD.

Al.

EvilGhozt
- 28th August 2009, 18:35
Your diagram in post #8 has the contrast pot wrongly wired. Correct the wiring as per the attached snap. Then adjust the pot till you have clean characters on LCD.

Al.

im not using any pot at all. I have just put the Vo to +5volt with resistor between, if thats wrong I wouldnt seen those black squares, right?

mackrackit
- 28th August 2009, 19:20
Having the contrast wired wrong is the reason you see the black squares.

Having the contrast going to 5+ is wrong. Sometimes going to (-) will work but the best bet is to use a pot like the manual and Al said. Then it is adjustable.

EvilGhozt
- 28th August 2009, 19:25
I have just put a pot there, and now I either get black squares or nothing

Acetronics2
- 28th August 2009, 19:38
Hi,

For a quick contrast setting ... just use the forward voltage of a Si diode ( .5 to .6 v @ 1 mA ) to set Vo ... ( do not work with OLED displays !!! )

simple and efficient ...

Alain

taitny
- 29th August 2009, 02:44
I recently got my PIC-MT-USB up and running, with help from this forum. I got the switches to work and the lights to blink. The LCD was the next headache. I was hoping that your thread may give me some ideas. But I managed to get it to work with the help from an article: http://www.epemag.wimborne.co.uk/lcd1.pdf
I am an old TTL guy, so the wiring diagram made lots of sense to me, and finally got it working. My code is attached with comments. It may offer some ideas. Hope it helps.
Comments about my code are welcome from the community. I am a nophyte.

'************************************************* ***************
'* Name : OILMEX TEST *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2009 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 8/24/2009 *
'* Version : 1.0 *
'* Notes : FOR THIS TO WORK ON THE OLMEX BOARD *
'* : the INC file had to be changed to *
'* : change the config to HS from XT *
'* : *
'************************************************* ***************
'************************************************* **************
'* This block of code sets up switches to drive LEDs

LED1 VAR PORTB.2
LED2 VAR PORTB.1
SWITCH1 VAR PORTB.4
SWITCH2 VAR PORTB.5

TRISB = %11111001 'sets bit 1, 2 to output. all else to input

LOW LED1 'inatilized leds
LOW LED2 'LED initalizain probabbly not needed

'********** END PUSH BUTTON / LED CODE*********************

'************* LCD DRIVER TEST CODE **********************
'****** PINS BASED ON SCHEMATIC ***************************
'* LCD Connections
'* _RS PORTD0 -DATA when LOW, Commands when HIGH
'* .R/W PORTD1 - LOW to WRITE Date, HIGH to READ data from LCD
'* E PORTD2 - Data transferred on Transition High to Low
'* Light PORTD3
'* DB4 PORTD4
'* DB5 PORTD5
'* DB6 PORTD6
'* DB7 PORTD7

'**************


define LCD_DREG PORTD 'Display connected to PORTD
DEFINE LCD_DBIT 4 'Data Starting Bit (0, or 4)
'When set to 0, Backlight Display Blinks, no Data
DEFINE LCD_RSREG PORTD 'Reset register is on PortD
DEFINE LCD_RSBIT 0 'Reset Bit is D0
Define LCD_EREG PORTD 'Enable on PORTD
DEFINE LCD_EBIT 2 'enable bit D2
'*********** These LCD DEFINES not needed (presumably) *******
'DEFINE RW_REG PORTD
'DEFINE LCD_RWBIT 1
'DEFINE LCD_BITS 4
DEFINE OSC 20 'The display was jumpp, This took care of it
'DEFINE LCD_COMMANDUS 2000
'DEFINE LCD_DATAUS 50 'data delay in µs'
'Define LOIADER_USED 1
'define NO_CLRWDT 1
'*************** End of UNUSED LCD DEFINES ******************
TRISD = %00001111 'Set D4-8 as output. D0-4 as Input

low PORTD.1 'Set NOT R/W to LOW (Write Data TO LCD)
High PORTD.3 'Turn on Back LIght (Tested - Works)



Pause 500 ' Wait for LCD to startup


mainloop:
Lcdout $fe, 1 ' Clear LCD screen
PAUSE 500
Lcdout "Hello" ' Display Hello
Pause 500 ' Wait .5 second

Lcdout $fe, 1 ' Clear LCD screen
Lcdout "World"
Pause 500 ' Wait .5 second

'************* PUSHBUTTON / LET TEST RUTINE *************
IF SWITCH1 = 0 Then 'NOTE Button Goes to 0 When pressed
HIGH LED1
else
low LED1

ENDif

IF SWITCH2 = 0 then
HIGH LED2
else
low LED2
endif
'***************** End Of Pushbutton Routine **********

Goto mainloop ' Do it forever

EvilGhozt
- 29th August 2009, 11:06
YES! Its alive! :D

It was a really simple problem, the R/W wire was not 100% connected LOL :D hehe, I feel quite silly :P