View Full Version : LCD defines?
RUBiksCUbe
- 13th July 2005, 23:01
Im using a PIC18F252 with a 16x2 LCD with a 44780 controller and I cant get LCDOut to work. I just get a row of black boxes on the second line of the LCD. Ive been using the basic MicroCode Studio example for an LCD display:
' LCD should be connected as follows:
' LCD PIC
' DB4 PortA.0
' DB5 PortA.1
' DB6 PortA.2
' DB7 PortA.3
' RS PortA.4 (add 4.7K pullup resistor to 5 volts)
' E PortB.3
' RW Ground
' Vdd 5 volts
' Vss Ground
' Vo 20K potentiometer (or ground)
' DB0-3 No connect
@ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H
@ __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
@ __CONFIG _CONFIG4L, _LVP_OFF_4L
Pause 500 ' Wait for LCD to startup
loop:
Lcdout $fe, 1 ' Clear LCD screen
Lcdout "Hello" ' Display Hello
Pause 500 ' Wait .5 second
Lcdout $fe, 1 ' Clear LCD screen
Lcdout "World"
Pause 500 ' Wait .5 second
Goto loop ' Do it forever
But it does not work. Do I need to define a bunch of "LCD_xxxx" things?
Bruce
- 13th July 2005, 23:25
Turn off A/D on portA.
ADCON1 = 7
RUBiksCUbe
- 14th July 2005, 00:57
I added ADCON1 = 7 right after I define OSC, but I still get the same results.
mister_e
- 14th July 2005, 01:12
you'll have to use those define to change PBP defaults.
@ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H
@ __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
@ __CONFIG _CONFIG4L, _LVP_OFF_4L
' LCD should be connected as follows:
' LCD PIC
' DB4 PortA.0
' DB5 PortA.1
' DB6 PortA.2
' DB7 PortA.3
' RS PortA.4 (add 4.7K pullup resistor to 5 volts)
' E PortB.3
' RW Ground
' Vdd 5 volts
' Vss Ground
' Vo 20K potentiometer (or ground)
' DB0-3 No connect
DEFINE LCD_DREG PORTA
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTA
DEFINE LCD_RSBIT 4
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 3
ADCON1=7
AND SINCE you use HS osc you'll have to add
Define OSC 20
or the right crystal speed at the top of your code under the fuse setting
RUBiksCUbe
- 14th July 2005, 01:23
Still not working. I have a 10 MHz resonator, so I added Define OSC 10 under the fuses. My code is now:
'@ INCLUDE "P18F252.INC" ; MPASM Header
@ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H
@ __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
@ __CONFIG _CONFIG4L, _LVP_OFF_4L
Define OSC 10
DEFINE LCD_DREG PORTA
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTA
DEFINE LCD_RSBIT 4
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 3
ADCON1=7
Pause 500 ' Wait for LCD to startup
loop:
Lcdout $fe, 1 ' Clear LCD screen
Lcdout "Hello" ' Display Hello
Pause 500 ' Wait .5 second
Lcdout $fe, 1 ' Clear LCD screen
Lcdout "World"
Pause 500 ' Wait .5 second
Goto loop ' Do it forever
Bruce
- 14th July 2005, 01:30
Try this;
@ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H
@ __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
@ __CONFIG _CONFIG4L, _LVP_OFF_4L
Define OSC 20 ' change to osc freq you use if different
Define LCD_BITS 4 ' 4-bit interface
Define LCD_LINES 2 ' 2 line LCD
' LCD should be connected as follows:
' LCD PIC
' DB4 PortA.0
' DB5 PortA.1
' DB6 PortA.2
' DB7 PortA.3
Define LCD_DREG PORTA
Define LCD_DBIT 0
' RS PortA.4 (add 4.7K pullup resistor to 5 volts)
Define LCD_RSREG PORTA
Define LCD_RSBIT 4
' E PortB.3
Define LCD_EREG PORTB
Define LCD_EBIT 3
' RW Ground
' Vdd 5 volts
' Vss Ground
' Vo 20K potentiometer (wire wiper to Vo, adjust for contrast)
' DB0-3 No connect
Define LCD_COMMANDUS 2000 ' Adjust for slower LCD modules
Define LCD_DATAUS 50
ADCON1 = 7 ' portA digital
Pause 500 ' Wait for LCD to startup
loop:
Lcdout $fe, 1 ' Clear LCD screen
Lcdout "Hello" ' Display Hello
Pause 500 ' Wait .5 second
Lcdout $fe, 1 ' Clear LCD screen
Lcdout "World"
Pause 500 ' Wait .5 second
Goto loop ' Do it forever
RUBiksCUbe
- 14th July 2005, 01:44
I tried that code and I still only see the black boxes on the second row. Im going to check all of the connections and try a potentiometor on Vo
Edit:
The connections are all good and my contrast is fine without a potentiometor. I think my LCD might be dead, but Im not sure because the backlight works and I can see the boxes it displays.
mister_e
- 14th July 2005, 04:19
out of curiosity...
what kind of programmer do you use?
Are you sure your programmer software program the fuses to the PIC?
And... of course, is a simple LED blink work on all the pin you use???
RUBiksCUbe
- 14th July 2005, 04:38
Im using a JDM programmer (the one called "Serial Port Programmer - Socketed" at http://www.sparkfun.com/shop/index.php?shop=1&cart=323317&cat=3&) and IC-Prog as my downloading program. I just tested the IO lines and they all work.
I have also tried the program on another PIC18F252 and I get the same results.
EDIT:
The LCDOut command is for 44780 controllers right??
Dave
- 14th July 2005, 12:00
RUBiksCUbe, If I may ask, What type of LCD display is it? Who makes it? Part number?
Dave Purola,
N8NTA
Dwayne
- 14th July 2005, 15:45
I Noticed that your comment was the black squares were on the second line... I also noticed the examples presented looked like they were all for the first line of your LCD.
1. Since you only have 1 line of squares on your LCD, then I would suspect your line 1 is bad... test another LCD.
2. If you want, try writing to your second line on your LCD...
I believe the command is a $C0?
Somthing like :
LCDOUT $FE,$C0,“Hello”
If this works on your second line... then you may have found your problem.
Dwayne
RUBiksCUbe
- 14th July 2005, 15:45
The LCD is a 16 character by 2 line display. Although it says "UNIQ/eVision" on the back, it has the part number GC-1602I1 Ver: C, which is a part number for Solomon Goldentek display company. They don't have the exact datasheet on their website, but the closest one they have is here: http://www.goldentek.com/english/pdf/Dongguan/GC1602B0/GC1602B0SBL1B%20.pdf
I was told when I bought it (on ebay) that the display driver is 44780 compatible.
RUBiksCUbe
- 14th July 2005, 15:55
I put the LCDOUT $FE,$C0,“Hello” into the program but it did not work either. This LCD must be busted.
mister_e
- 14th July 2005, 17:59
They use samsung controller KS0066 wich is really compatible with Hitachi, in fact i have some LCD here with the same controller and i used the same code... as is and it's work...mmm weird
Yuk, probably not really handy but, worth a try...
@ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H
@ __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
@ __CONFIG _CONFIG4L, _LVP_OFF_4L
Define OSC 10
TRISA=0
TRISB=0
Define LCD_BITS 4 ' 4-bit interface
Define LCD_LINES 2 ' 2 line LCD
' LCD should be connected as follows:
' LCD PIC
' DB4 PortA.0
' DB5 PortA.1
' DB6 PortA.2
' DB7 PortA.3
Define LCD_DREG PORTA
Define LCD_DBIT 0
' RS PortA.4 (add 4.7K pullup resistor to 5 volts)
Define LCD_RSREG PORTA
Define LCD_RSBIT 4
' E PortB.3
Define LCD_EREG PORTB
Define LCD_EBIT 3
' RW Ground
' Vdd 5 volts
' Vss Ground
' Vo 20K potentiometer (wire wiper to Vo, adjust for contrast)
' DB0-3 No connect
Define LCD_COMMANDUS 2000 ' Adjust for slower LCD modules
Define LCD_DATAUS 50
ADCON1 = 7 ' portA digital
Pause 1000
FLAGS=0
Pause 1000
loop:
Lcdout $fe, 1,"Hello"
Pause 500 ' Wait .5 second
Lcdout $fe, 1,"World"
Pause 500 ' Wait .5 second
Goto loop ' Do it forever
I heard few time, but never encouter the problem, that some LCDs are noise sensitive, what about if you add a 0.1uF and a 10uF(or higher) on the VDD line close to the LCD(as close as you can)???
Now if nothing works... it could be a blowed one... On EBay... not a surprise ;)
RUBiksCUbe
- 14th July 2005, 19:20
I tried capacitors with no success, so Im going to try to get another. Thanks for all the diagnostic help!
Daniel
- 26th July 2005, 18:37
Hello RUBiksCUbe,
I have just bought the same display as you and I was searching the net for datasheet and found this page.
I have not received this display and I hope I will get it working.
But it doesnt sound good to read your problem.
I hope to get it in a week or two, then I will test it and come back to you guys.
Good luck now...
Daniel
- 4th August 2005, 10:03
I have tested same display...
WORKING GREAT!
RUBiksCUbe
- 8th August 2005, 22:16
Yep. I got a replacement and it worked fine. I mustve had a defective one
G8RPI
- 9th August 2005, 15:23
Hi,
Most of the intellegent LCD displays are very sensitive to static.
They are the only components I've used were I've had failures directly attributable it ESD.
Robert G8RPI.
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.