|
|
View previous topic :: View next topic |
Author |
Message |
drosah
Joined: 15 Jul 2012 Posts: 2
|
Problem LCD 16x2 + PIC 18F4550 |
Posted: Sun Jul 15, 2012 7:27 pm |
|
|
The PIC doesn't transfer data to LCD, only shows some squares at the second line of the LCD. But working perfectly at the simulation. If I change the potentiometer, the squares disappear, but still doesn't show words. I'm using PIC18F4550 and LCD flex drive with that configuration:
Code: |
#define LCD_DB4 PIN_D7
#define LCD_DB5 PIN_D6
#define LCD_DB6 PIN_D5
#define LCD_DB7 PIN_D4
#define LCD_E PIN_B2
#define LCD_RS PIN_B4
#define LCD_RW PIN_B3
// 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 |
My code:
Code: |
#include <18F4550.H>
#include <stdio.h>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#define LCD_POWER PIN_B6
#include "LCD16x2.c"
//============================
void main(){
output_high(LCD_POWER); // Turn on power to LCD
output_high(PIN_B7);
output_low(LCD_RW); // Set R/W pin on LCD to a low level
lcd_init(); // Initialize the LCD
lcd_gotoxy(1,0);
//lcd_putc("\fHello World\n");
lcd_putc("\fOla, mundo!");
while(1);
}
} |
The LCD datasheet:
http://www.sparkfun.com/datasheets/LCD/GDM1602K.pdf
Model: 1602GD1622Y (16x2 with backlight)
Simulation SS:
The levels on LCD input pins is the same at the simulation and the protoboard circuit. I've already tested it.
Sorry my bad english. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jul 15, 2012 8:21 pm |
|
|
The biggest problem is that your schematic shows LCD power and ground
are connected in reverse. If you did that on your hardware board,
then you have probably already destroyed your LCD.
Other problems:
Quote: | void main(){
output_high(LCD_POWER); // Turn on power to LCD
|
The line in bold above is for the PicDem2-Plus board (Rohs version).
You don't have any LCD power circuit on your schematic. Do you have
the PicDem2-Plus board ? I doubt it. If you don't have that board, get
rid of that line.
Your schematic doesn't show the crystal and capacitors that are
necessary for use with the XT oscillator fuse. Your schematic also
doesn't show the 10K resistor for MCLR. You need to add that resistor.
One side of the resistor should go to +5v and the other side should
connect to MCLR.
If you don't have the crystal, then change the oscillator fuse from XT to
INTRC_IO as shown below in bold. This fuse will tell the PIC to use its
internal oscillator:
Quote: |
#include <18F4550.h>
#fuses INTRC_IO, NOWDT, PUT, BROWNOUT, NOLVP
#use delay(clock=4M)
|
|
|
|
drosah
Joined: 15 Jul 2012 Posts: 2
|
|
Posted: Sun Jul 15, 2012 9:59 pm |
|
|
I'm using crystal with 2 33pf capacitor on the protoboard, and i connected the LCD correctly. I just put the 10k resistor in the MCLR pin. And the same thing.
The image of the circuit:
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jul 15, 2012 11:27 pm |
|
|
Your photos are not focused, very low resolution, and too dark.
They are not useful.
If your LCD was connected with power and ground reversed, and the
power was turned on for a small time, the LCD is probably destroyed.
It doesn't matter if you later changed the connections to be correct.
If you applied power with the connections reversed, the LCD is now bad. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19498
|
|
Posted: Mon Jul 16, 2012 4:38 am |
|
|
Step by step:
First, ignore the LCD. Prove your chip is actually running. Do a 'toggle LED' program, and verify the LED does toggle, and gives the right frequency. You already have a LED on B7. Use this.
Second, you don't show any processor decoupling. The PIC _requires_ a capacitor with a good HF response, right by it's legs.
Third try adding a delay before initialising the LCD. A _lot_ of these LCD clones take massively longer to wake up than the original Hitachi chips. Also they sometimes don't even start waking, till long after the PIC is already running.
Proteus, can be very 'misleading'. It'll run the chip with no oscillator, without complaining. It also doesn't care about decoupling, and doesn't physically show the power connections to the chip, which it makes 'behind the scenes', assuming you will know to connect these. Are you?.
Add the fuses:
NOPBADEN, NOXINST
Best Wishes |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Mon Jul 16, 2012 5:21 am |
|
|
Unfortunatley you've probably destroyed the LCD module.
GET RID OF Proteus !! As others have said, and I say all the time, Proteus is FULL of bugs,errors and faulty DRCs! It 'works' fine yet allows you to have serious fatal errors( revesed power leads !!)..
I have a 4550 with LCD using the flexdriver and it's 100% working,been that way for over a year, so I KNOW it works.Running at 48MHz on a white breadboard too !
Please follow the advise of previous posters,all have valid points. I allow a full second for the LCD to init.yes, overkill, maybe not required but I've never had any LCD not run right.Besides, that time allows me another gulp of coffee!
Please go back to basics.1- prove the PIC runs with the blinking LED program.2- get another LCD. 3-wireup and CONFIRM proper connections 4 then powerup your 'hello world' LCD program. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|