PDA

View Full Version : 16f688 LCD what have I done wrong



spitfiredriver
- 7th August 2009, 19:03
Hello
I am new to using pic's, I have bought a Pickit 1 and have started with a 16f688. I can not get my display to show anything, can some one point out where I am going wrong. R/W is connected to ground.

TRISC.0 = 0 '(pin 10) Blue Lcd Data bit 4
TRISC.1 = 0 '(pin 9) White Lcd Data bit 5
TRISC.2 = 0 '(pin 8) Green Lcd Data bit 6
TRISC.3 = 0 '(pin 7) Orange Lcd Data bit 7
TRISC.4 = 0 '(pin 6) Orange/Black Lcd Register select
TRISC.5 = 0 '(pin 5) Blue/White Lcd Enable bit

' PIC Hardware Definitions (ie Pin-Out & Port Assignments)
ANSEL = 0 ' all pins are digital
CMCON0 = 7 ' turn off comparators
ADCON0 = 0
ADCON1 = 0

'pin name connection
'1 VDD 5V
'2 OSC1 Crystal
'3 OSC2 Crystal
'4 MCLR Pulled up
'5 RC5 E LCD
'6 RC4 RS LCD
'7 RC3 DB7
'8 RC2 DB6
'9 RC1 DB5
'10 RC0 DB4
'11 RA2 NC
'12 RA1 NC
'13 RA0 NC
'14 VSS Ov

'Define LCD registers and bits
DEFINE LCD_DREG PORTC 'Define PIC port used for LCD Data lines
DEFINE LCD_DBIT 0 'LCD Data Starting Bit = Bit 0 or 4
DEFINE LCD_EREG PORTC 'Define PIC port used for E line of LCD
DEFINE LCD_EBIT 5 'Define Port pin used for E connection
DEFINE LCD_RSREG PORTC 'Define PIC port used for RS line of LCD
DEFINE LCD_RSBIT 4 'Define Port pin used for RS connection
DEFINE LCD_BITS 4 'Define the 4 bit communication mode to LCD
DEFINE LCD_LINES 2 'Define using a 2 line LCD
DEFINE LCD_COMMANDUS 2000 'Define delay time between sending LCD commands
DEFINE LCD_DATAUS 50 'Define delay time between data sent.



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

falingtrea
- 7th August 2009, 19:32
Can you see anything on the LCD? Like a cursor? If not, check the data sheet for the LCD. Some LCDs need a negative voltage for contrast.

Archangel
- 7th August 2009, 19:42
Hello Spitfiredriver,
Welcome to the forum !
To start with, I know nothing about PICKit1, so bear with me. I looked into your code, and using a breadboard the code looks good . . .but you forgot to DEFINE OSC x where x is the frequency you chose probably 4 if you are using default config. You will find the Default config listed in the 16f88.inc file which is in the root directory of your PBP installation, I just checked mine and it defaults to INTOSC which does not agree with your use of a crystal, so either change it there, comment it out there, and put it in YOUR source code ( I always do it that way), or plan on using internal OSC.

spitfiredriver
- 7th August 2009, 20:22
I have removed the crystal but still get nothing on the display, I have not got a datasheet for the LCD just the pinout, hope to be sent the pdf tomorrow. As it has a HD44780 compatible controller and a standard pinout I hoped it would be a positive V0 for contrast but that might be the problem. The only markings on the display are the pinout and (ELECTROLITE QY-162A)

mackrackit
- 8th August 2009, 09:19
Like Tim asked, can you see anything on the display? You may want to look at the PBP manual to see how to use a pot with the contrast pin.

And I will ask. Can you make an LED blink at the correct rate? Maybe the PIC is not even running?

If the PIC is running at the correct speed and you can change the contrast it could be in the commandus or dataus settings.

Archangel
- 8th August 2009, 09:31
As it has a HD44780 compatible controller and a standard pinout I hoped it would be a positive V0 for contrast but that might be the problem. The only markings on the display are the pinout and (ELECTROLITE QY-162A)Most HD44780 LCD units, pin 3 contrast is at or very near ground, I usually just ground pins 1,3,5

spitfiredriver
- 8th August 2009, 19:54
Thanks for the help
I have solved it, I could not see anything on the display, I knew the program was running as I put an extra led that flashed on each loop.
My mistake was that the display pdf that I was working to, said to wire the back light on pins A and K with a 10 ohm resister. This was wrong, I needed to use pins 15 and 16, there are extra resistors in the circuit. The back light was just too bright. Works fine now.
once again thanks for the advice.