PDA

View Full Version : PICBASIC PRO 16F84 with 16X02 LCD



Marin
- 5th August 2007, 22:49
Hello to all, first time to write here!!!


So I've got a bit of problem getting work mine LCD and uP.....

I've already have connected pins from PORTA.0 to PORTA.3 to pushbuttons with pull-up resistors, and PORTA.4 to transistor which drives relay on mine bord....so I've got whole PORTB emty..and there is where mine LCD is connected, and because of that I must tell pibasic different definition about connection of LCD.....so i did that and still I haven't anything on mine LCD.

This is how i connected PIC16F84 and LCD

PIC LCD

PORTB0 ---> Enable (PIN 6)
PORTB1 ---> RS (PIN 4)
PORTB4 ---> DB4 (PIN11)
PORTB5 ---> DB5 (PIN12)
PORTB6 ---> DB6 (PIN13)
PORTB7 ---> DB7 (PIN14)

PIN 1(GND) i PIN 5 (RW) are grounded (GND)
PIN2 is on +5V, PIN 3 is connected to +5V also via trimmer pot of 10K for contrast.

This is mine code:


DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 1
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 0
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50

LCDOUT $FE, 1, "HELLO"
LCDOUT $FE, $C0, "WORLD"



That's it...ann I still didn't getting any on LCD.....

LCD is PC1602 HD44780 compatibile.....

Any ideas??

Dave
- 5th August 2007, 23:09
Marin, Where is the other side of the pot connected to? It should be between + 5 and ground. Most LCD displays require anywhere between 0 volts and 1 volt for the contrast voltage.

Dave Purola,
N8NTA

Marin
- 5th August 2007, 23:21
Dave, thanks for replay!

I know for that contract....I didn't have pot so i put two 10K resistor in seria and getting contrast V from middle...something about 2,5V!

Is it this OK?

Archangel
- 6th August 2007, 04:44
Hi Marin,
Is there more to this code which is unseen?
You should make it a practice to set your config fuses in code
and set the TRIS Registers too, also define your OSC speed.
Are you using a crystal, or resonator or are you trying to use
the internal osc?



DEFINE OSC 4 ' for 4 mhz osc
TRISA = %00001111 ' the ones stand for inputs
TRISB = %00000000 ' the zeros stand for outputs

Study this thread:
http://www.picbasic.co.uk/forum/showthread.php?t=543&highlight=configuration+fuse

Add this just before your first LCDOUT statement to allow the LCD time to initialize:
Pause 500 ' or a thousand or sometimes a little more :)

HTH
JS

Marin
- 6th August 2007, 08:08
HI Joe! Thanks for replay.....but still I have dead LCD :-(

That I wrote is whole mine code....this is code now:

DEFINE OSC 4 ' for 4 mhz osc
TRISA = %00001111 ' the ones stand for inputs
TRISB = %00000000 ' the zeros stand for outputs


DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 1
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 0
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50


pause 2500


LCDOUT $FE, 1, "HELLO"

Dave
- 6th August 2007, 11:55
Marin, You should use a pot of about 5 or 10 k between +5 and ground as the 2 10k's you have will not get the desired results. When you have the pot installed place it at the 0 volt position and start ramping it up. You will see the background boxes (pixels) start to diminish. This is the optimum contrast level. Read the level with a voltmeter and you will see that it is between 0 and 1 volt.

Dave Purola,
N8NTA

Marin
- 6th August 2007, 12:42
OK, gonna find pot and put it now.....but I saw that nobody comments mine code....do you think is OK now?

Dave
- 7th August 2007, 00:15
Marin, How can you say that? I see about 2 or 3 comments about your program. Have you tryed any of the suggestions? What were the results? Try what I posted in my last reply and if you can get the display to show darkened block outlines of the character positions and rotating the pot to diminish them then, try your code. You have to get the hardware working before the code......

Dave Purola,
N8NTA

Archangel
- 7th August 2007, 04:02
Marin,
take pin 3 much closer to ground, right now Mine is tied to ground with a 100 ohm resistor and no connection to 5v+ .
Which assembler are you using, are you using MPASM or the default PM assembler?
If using PM then add to your code:


@ DEVICE XT_OSC ' sets programmer to external oscillator - low power, HS would be for faster xtals.
@ DEVICE pic16F84, PWRT_ON ' Power-On Timer
@ DEVICE pic16F628, MCLR_ON ' Master Clear Options (External)
@ DEVICE pic16F628, LVP_OFF ' Low-Voltage Programming
@ DEVICE pic16F628, BOD_OFF ' Brown-Out Detect


If you looked at the thread I included, then these should look familiar, this way you do not have to set them manually every time you program a chip. Be sure your microcode studio is set for the proper chip number, the setting is about an inch from the top and an inch from the left. When the programmer software starts make sure it also has the proper chip number selected.

Marin
- 7th August 2007, 08:05
Joe, Dave....thanks!!

Problem wasm't with code.....it was with dead contrast pot.....can't velive...I buy it new...

Now is working good!

So....I probably gonna put more questions here about some other things....hehe...also I buy 16F877 to het analog inputs ass well!

Marin

Archangel
- 8th August 2007, 02:13
Very happy you got it working. Welcome to the PIC University!