PDA

View Full Version : LCD Problem



Sabahan
- 20th June 2013, 17:48
This is my first post here

I am very new to microcontroller,I had bought the PBP3 with LAB-X1,I try to test the LCD program from melabs with 16f887(Comes with the bundle),I assume the program have no problem,so why the LCD screen on the first line all are solid block,and empty on the second line,what have I done wrong?it happen to the LAB-X1 LCD and a external LCD.


The Program
http://melabs.com/samples/PBP-mixed/lcd.htm

wdmagic
- 20th June 2013, 21:54
You might want to go ahead and add DEFINE's at the beggining of your program, and the first PAUSE 500, change to Pause 1000
Make sure the correct LCD pins are going to the correct PIC pins, some LCDs pinouts are different even if they have 14 or 16 pins.
What did you use to set your occilator value, if your not using a internal OSC you might need to DEFINE OSC. You will probobly want to use a TRIS command to define the I/O of your pins too, this causes alot of problems when left out.

What I find is that if the LCD is a 2 line display, and the top is full and bottom empty, the LCD is not initialized, on a 4 line its the top 2.
it will usually do this for about a second when first turned on then will clear and then show data when its working right.

Look in the manual and read up on DEFINE, LCDOUT you can also access a free ebook on GoogleBooks, search for "30 pic projects" on the google books site, its great for learning PBP.

Here is a program I wrote for 18F 40Pin devices and only using PORT D for "Display", You can also tie a LED (Long Leg) directly to PORTD Pin 6 and the Short Leg to GND the led will be very bright, you can add a resistor if you want.


DEFINE LCD_DREG PORTD ' LCD Data bits on PORTD
DEFINE LCD_DBIT 0 ' PORTD starting address
DEFINE LCD_RSREG PORTD ' LCD RS bit on PORTD
DEFINE LCD_RSBIT 5 ' LCD RS bit address
DEFINE LCD_EREG PORTD ' LCD E bit on PORTD
DEFINE LCD_EBIT 4 ' LCD E bit address
DEFINE LCD_BITS 4 ' LCD in 4-bit mode
DEFINE LCD_LINES 4 ' LCD has 4 rows

TRISD = 0 ' PORTD is output

PAUSE 1000 ' Wait 1 sec for LCD to initialize
LCDOUT $FE, 1 ' Clear LCD

AGAIN:
LCDOUT $FE, 2
LCDOUT $FE, $80
LCDOUT "I Am ---"
Pause 500
LCDOUT $FE, $80
LCDOUT "WORKING!"
PAUSE 500 ' Wait .5 seconds
TOGGLE PORTD.6 ' Blink LED to show Program Running
GOTO AGAIN ' Repeat
END

Charlie
- 21st June 2013, 08:41
Getting LCD displays going the first time can often be difficult. If you are using an example program and a development board where you don't need to set any jumpers, then the main code and board are likely O.K. The most likely issue is that you don't have the PIC clock configured properly. LCD displays are quite sensitive to timing. You should actually start off by trying to blink a single LED - in fact if your development board has several, you could try blinking LEDs on a whole port to make sure you don't accidentally choose a special function pin. In any case, blink to start and verify that the length of the blinks actually match the time you put in your code, which proves you have the clock set up right and that you've told PBP correctly what it's set to.

Sabahan
- 22nd June 2013, 00:44
I had tried the blinking led and the running led,it works fine,I have tried to see if there any signal being pass to the LCD on a oscilloscope ,seems that there are no signal being sent,the scope show a straight line,not a single pulse

Charlie
- 22nd June 2013, 00:55
Time to post your code then...

Darrel Taylor
- 22nd June 2013, 03:13
Since you are using a LAB-X1, it'll be best to start with the LAB-X1 samples.

For the LCD - http://melabs.com/samples/LABX1-16F887/lcdx.htm
More LAB-X1 samples for the 887 - http://melabs.com/samples/LABX1-16F887/index.htm

Sabahan
- 22nd June 2013, 15:03
Thank You for the reply and help,I am out station now for two weeks,will try it out when I am back hoe,thank you very much for thw assistance