View previous topic :: View next topic |
Author |
Message |
senur
Joined: 11 Dec 2013 Posts: 13
|
Interfacing LCD 2X16 JHD162A with PIC18F46K22 |
Posted: Sun Dec 29, 2013 1:31 am |
|
|
I'm really new to these stuff PIC and LCD. I'm trying to print "Hello" on the LCD but it doesn't work. I've been trying all day yesterday but still won't show the output nor the back-light. What I get in the LCD is full squares about 9 of them.
Here's my code:
Code: | #include <18F46K22.h>
#device adc = 8
#FUSES NOWDT //No Watch Dog Timer
#FUSES HSH // High Speed oscillator
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOLVP //Low Voltage Programming on B5 (PIC18)
#FUSES NOWRT //Program memory not write protected
#byte PORTA = 5
#byte PORTB = 6
#byte PORTC = 7
#byte PORTD = 8
#byte PORTE = 9
////I think my problem is the connection pins here. /////////
#define LCD_ENABLE_PIN PIN_B5
#define LCD_RS_PIN PIN_B4
#define LCD_RW_PIN PIN_E0
#define LCD_DATA4 PIN_D0
#define LCD_DATA5 PIN_D1
#define LCD_DATA6 PIN_D3
#define LCD_DATA7 PIN_D4
#use delay (clock = 20M )
//#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7,bits=8, stream = COM_B) //baud=9600
#include <lcd.c>
void main()
{
delay_ms(100);
lcd_init();
delay_ms(100);
printf(lcd_putc, "\f Hello");
while(true);
}
|
Please help me with this problem. I've checked the soldering already it's fine and I've changed the LCD I bought two of them. Thank you |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Dec 29, 2013 2:02 am |
|
|
That board has the lcd's R/W pin connected to ground. The CCS lcd.c
driver (which you are using) doesn't support that method of using the lcd.
You can use the Flex lcd driver with that board. It has support for that mode:
http://www.ccsinfo.com/forum/viewtopic.php?t=24661
In the flex lcd driver, setup the #define statements as shown below.
Also, make sure you comment out the two lines shown in bold below:
Quote: |
#define LCD_DB4 PIN_D4
#define LCD_DB5 PIN_D5
#define LCD_DB6 PIN_D6
#define LCD_DB7 PIN_D7
#define LCD_E PIN_B5
#define LCD_RS PIN_B4
// #define LCD_RW
// If you only want a 6-pin interface to your LCD, then
// connect the R/W pin on the LCD to ground, and comment
// out the following line.
// #define USE_LCD_RW 1
|
To make the lcd backlight work, you need to add a jumper on JP8 on
your board.
Also this stuff is completely wrong for the 18F46K22. You're using
register addresses for a 16F PIC:
Quote: | #byte PORTA = 5
#byte PORTB = 6
#byte PORTC = 7
#byte PORTD = 8
#byte PORTE = 9 |
If you need direct register access, use the getenv() function to get the
correct register addresses for those registers. |
|
|
senur
Joined: 11 Dec 2013 Posts: 13
|
Thank you now the backlight is working |
Posted: Sun Dec 29, 2013 8:27 am |
|
|
Thank you, the back-light is working now. But I still can't get the output on the LCD. Here's my code, am I missing something? I already #define the connection in flex_lcd.c
Code: | #include <18F46K22.h>
#device adc = 8
#FUSES NOWDT //No Watch Dog Timer
#FUSES HSH // High Speed oscillator
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOLVP //Low Voltage Programming on B5 (PIC18)
#FUSES NOWRT //Program memory not write protected
#FUSES XT, BROWNOUT, PUT
#use delay (clock = 4000000)
#include <flex_lcd.c>
void main()
{
lcd_init();
lcd_putc("\fHello World\n");
lcd_putc("Line Number 2");
while(1);
} |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19559
|
|
Posted: Sun Dec 29, 2013 8:36 am |
|
|
1) What have you got feeding Vee on the LCD?.
This depends on the LCD. Some types will accept 0v, but some high contrast, and older displays require a -ve voltage here. Data sheet for LCD.
2) Add a short delay (250mSec) before calling LCD_init.
Many LCD's don't start to wake, till quite a few moments after the PIC wakes up. Some also require more delay than the standard Hitachi controller after this point.
3) You have both 'XT', and 'HSH' oscillators selected. Should be only one.... |
|
|
senur
Joined: 11 Dec 2013 Posts: 13
|
|
Posted: Sun Dec 29, 2013 8:49 am |
|
|
Quote: | 1) What have you got feeding Vee on the LCD?. |
It's just connected to the board as in the picture. Sorry but I'm really new to these stuff.
Quote: | 2) Add a short delay (250mSec) before calling LCD_init.
3) You have both 'XT', and 'HSH' oscillators selected. Should be only one.... |
I've tested XT and HSH individually just now but still I'm not getting the output. And also I've added delay. |
|
|
gpsmikey
Joined: 16 Nov 2010 Posts: 588 Location: Kirkland, WA
|
|
Posted: Sun Dec 29, 2013 10:11 am |
|
|
The solder connections I see in the image are suspicious - the solder should flow on the connection when you solder it (like you put a drop of paint on the connection). Those connections *may* be ok, but if they were on a board I was working with, I would re-solder them.
mikey _________________ mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Dec 29, 2013 2:57 pm |
|
|
Quote: |
1) What have you got feeding Vee on the LCD?.
It's just connected to the board as in the picture. Sorry but I'm really new to these stuff. |
There is an LCD contrast trimpot on the right side of the board.
You can see it in your photo. It's called R7. Put a voltmeter or an
oscilloscope on the Vee pin of the LCD and adjust R7 so that you
have 0.4 volt on the Vee pin. If your LCD and program are working,
you should probably be able to see text on your LCD with that Vee voltage.
gpsmikey wrote: | The solder connections I see in the image are
suspicious - the solder should flow on the connection when you solder it
(like you put a drop of paint on the connection). Those connections
*may* be ok, but if they were on a board I was working with, I would re-
solder them.
|
You're right. He needs to re-do all the joints on the LCD with a hot
soldering iron (750 to 800 degrees F) and use solder with a flux core.
This photo on the Cytron website shows mostly better solder joints on the LCD:
http://tutorial.cytron.com.my/2011/01/05/new-starter-kit/
This solder is the flux core type:
http://cytron.com.my/viewProduct.php?pcode=SS-F12X-10H&name=Finex%20Solder%20Lead
Note: The cytron.com.my site is often down, or very slow to load. |
|
|
senur
Joined: 11 Dec 2013 Posts: 13
|
|
Posted: Mon Dec 30, 2013 6:53 am |
|
|
I tried to check if there's a 0.4 volt on the VEE. So I placed the red wire of the voltmeter on the VEE pin and the black wire on the R7 itself. I didn't get any reading. Am I doing right or my way is wrong? |
|
|
stinky
Joined: 05 Mar 2012 Posts: 99 Location: Central Illinois
|
|
Posted: Mon Dec 30, 2013 7:01 am |
|
|
Probably wrong.
Positive/Red lead from the meter to vee.
Negative/Black lead to ground. |
|
|
senur
Joined: 11 Dec 2013 Posts: 13
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9250 Location: Greensville,Ontario
|
|
Posted: Mon Dec 30, 2013 8:48 am |
|
|
comment: I still don't like the pin soldering.
I suggest you totally remove all connections to the LCD module, clean up with solderwick and install new 'posts'. You need a very fine tipped iron and good eye-hand corodination. I put the posts into the breadboard, position the LCD module ontop of the posts, then solder every other pin, then the ones in between. You need solid support before you solder.Use books, erasers, whatever to make the LCD module firm to the pins BEFORE you solder.You can spend 15 minutes 'setting it up' and 15 seconds to solder.
I've got a few LCD modules that are 10 years old, been in and out of countless breadboards, and still work today.
The picture shows you probably have a few bad connections but the module is 'alive'!
hth
jay |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Mon Dec 30, 2013 9:08 am |
|
|
Hi,
Do you know for sure that your PIC is actually running, and at the proper speed?? Every single PIC project I undertake includes a PWR LED
driven off an I/O pin of the PIC. I flash this LED at power-up to let me know that my PIC has actually started up, and is running! This technique has
saved me much aggravation in the past!!
I would connect an LED to an unused I/O pin on your PIC. Connect the anode (+) terminal of the LED directly to the PIC I/O pin. Connect the
cathode (-) terminal of the LED to GND through a series connected current limiting resistor of about 500 ohms value.
In your code, add the following:
Code: |
#define PWR_LED Pin_XX <--- change to match your hardware
|
Then add the following at the top of your Main():
Code: |
int8 iIndex = 0;
// Here we blip the Power LED at power-up to show that the hardware is working
for ( iIndex = 0 ; iIndex < 3 ; iIndex++ )
{
output_high(PWR_LED);
delay_ms(250);
output_low(PWR_LED);
delay_ms(250);
}
// Here we leave the Power LED ON
output_high(PWR_LED);
|
When you apply power to your board, the PWR LED should blink four times, and then stay on. Also, note the 'rate' of the flashing. The entire
sequence should take about 1 second. Adjust the delay times as needed if you aren't sure of the correct timing!!! You should do this in every
one of your PIC projects!!
Good Luck and Happy New Year!!
John |
|
|
senur
Joined: 11 Dec 2013 Posts: 13
|
|
Posted: Mon Dec 30, 2013 9:47 am |
|
|
temtronic wrote: | comment: I still don't like the pin soldering.
hth
jay |
I went to the store today to buy the flux core but they were out. So, I'll check other stores tomorrow. and I'll redo all of them. thank you
Quote: | You should do this in every
one of your PIC projects!!
Good Luck and Happy New Year!!
John |
Actually, I did that at the very beginning to check everything. And I just did it again to double check. It is working fine. My problem is with the LCD.
This is my second LCD I damaged the first one and I think I damaged this too
Thank you and Happy New Year!!! |
|
|
gpsmikey
Joined: 16 Nov 2010 Posts: 588 Location: Kirkland, WA
|
|
Posted: Mon Dec 30, 2013 10:11 am |
|
|
senur wrote: |
I went to the store today to buy the flux core but they were out. So, I'll check other stores tomorrow. and I'll redo all of them. thank you
This is my second LCD I damaged the first one and I think I damaged this too
Thank you and Happy New Year!!! |
You don't say just what store you went to - any decent electronics store should have Rosin core solder.
Your "home improvement" stores typically will not have rosin core solder, but will have either solid core or acid core - never
use either of those with electronics projects - acid core will eat the wiring in a while and solid solder will not "flow"
unless you use a liquid flux (you can get rosin flux in a small bottle with a brush, but that is not the easiest).
Use rosin core solder and a small tipped iron. If you are not sure about soldering, look on Youtube - there are some
good demos there. Good solder joints look good - bad solder joints will drive you nuts trying to find why something
works sometimes and not others (or not at all and you just "know" it is connected).
mikey _________________ mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
Last edited by gpsmikey on Mon Dec 30, 2013 10:12 am; edited 1 time in total |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9250 Location: Greensville,Ontario
|
|
Posted: Mon Dec 30, 2013 10:11 am |
|
|
hint: Before you damage another LCD module ,get some 'dead' PCBs( maybe old computers) or a copper clad perfboard with a zillion pads on it. Practice soldering by adding just enough solder to a pad to make a nice 'bump'.Repeat, do it again, another one, another one...do the entire board if necessary to better your skill at soldering.It is something you have to learn by doing a 'zillion' times. It takes time to figure out how much time to hold the tip to the PCB, how much solder, how long to hold,etc. Also get thin solder, a bit bigger than a wire wrap pin,smaller than a test lead probe.I've got 50+ years of doing it but can NOT do SMT work. Silly things are way too small for my bad eyes to see, let alone solder! DIPS are getting hard to do now too...sigh...getting old sucks !
Also be sure to have a damp real sponge to clean the tip every few solderings! A clean tip will make the job a LOT easier!!
hth
jay |
|
|
|