View previous topic :: View next topic |
Author |
Message |
sonicdeejay
Joined: 20 Dec 2005 Posts: 112
|
LCD Query |
Posted: Fri Feb 03, 2006 4:53 am |
|
|
Currently I am trying to display some character using my PIC18F... I will be displaying just 3 charcters.. (example character = "98%")
and also planning to use LCD420.C or LCD.C examples....
May I know the model(serial) of LCD panel that you guys recommend me to use....
thx
sonic |
|
|
sonicdeejay
Joined: 20 Dec 2005 Posts: 112
|
|
Posted: Fri Feb 03, 2006 8:16 am |
|
|
I think I can use HD44780 based LCD....
Quote: | http://www.electronic-engineering.ch/microchip/datasheets/lcd/the_lcd_data_sheet.pdf | |
|
|
sonicdeejay
Joined: 20 Dec 2005 Posts: 112
|
|
Posted: Mon Feb 06, 2006 12:57 pm |
|
|
But i bought use S6A0069 as controller....
so can I use LCD.c as the driver????
or where can I get t driver to use in my PIC18F2525??
thx
sonic |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
sonicdeejay
Joined: 20 Dec 2005 Posts: 112
|
|
Posted: Mon Feb 06, 2006 1:38 pm |
|
|
ok..thx for the support...I will test it out as soon as I get school in few hours time...
By the way, I am using PIC18F2525 with a 2x16 matric LCD based on S6A0069...I use PIC19F2525 PORT B instead of PORT D...
so my changes are...Please read the changes and comment pls...
Code: |
struct lcd_pin_map { // This structure is overlayed
BOOLEAN enable; // on to an I/O port to gain
BOOLEAN rs; // access to the LCD pins.
BOOLEAN rw; // The bits are allocated from
BOOLEAN unused; // low order up. ENABLE will
int data : 4; // be pin B0.
} lcd;
#if defined(__PCH__)
#if defined use_portb_lcd
#byte lcd = 0xF81 // This puts the entire structure
#else
#byte lcd = 0xF83 // This puts the entire structure
#endif
#else
//I comment out as below as I am using PORT B...
//#if defined use_portb_lcd
#byte lcd = 6 // on to port B (at address 6)
//#else
//#byte lcd = 8 // on to port D (at address 8)
//#endif
#endif
//I comment out as below as I am using PORT B...
//#if defined use_portb_lcd
#define set_tris_lcd(x) set_tris_b(x)
//#else
//#define set_tris_lcd(x) set_tris_d(x)
//#endif
#define lcd_type 2 // 0=5x7, 1=5x10, 2=2 lines
#define lcd_line_two 0x40 // LCD RAM address for the second line
|
Hopefully, I will get it done successfully and will post the driver in code lib forum for other brothers to use...
thx
sonic |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Feb 06, 2006 1:47 pm |
|
|
You're doing it completely wrong. Don't make any of the changes
that you have made.
All you have to do is add one #define statement before the
#include statement for the lcd driver. Example:
Quote: |
#define use_portb_lcd TRUE // This line tells the driver to use Port B.
#include <lcd.c>
void main()
{
lcd_init();
// etc.
while(1);
} |
|
|
|
sonicdeejay
Joined: 20 Dec 2005 Posts: 112
|
|
Posted: Mon Feb 06, 2006 2:01 pm |
|
|
PCM programmer wrote: | You're doing it completely wrong. Don't make any of the changes
that you have made.
All you have to do is add one #define statement before the
#include statement for the lcd driver. Example:
Quote: |
#define use_portb_lcd TRUE // This line tells the driver to use Port B.
#include <lcd.c>
void main()
{
lcd_init();
// etc.
while(1);
} |
|
thx for your in-time correction....
If not...I will be in deep sh*t,,,,when I at skool...
I also made a mod as i am using S6A0069 chip based LCD
correct me if I do it wrongly again,,,
Code: |
//Modified code to fit S6A0069 chip based LCD
void lcd_init() {
set_tris_lcd(LCD_WRITE);
lcd.rs = 0;
lcd.rw = 0;
lcd.enable = 0;
delay_ms(30);
lcd_send_nibble(0x02);
delay_us(1);
lcd_send_nibble(0x02);
delay_us(1);
lcd_send_nibble(0x0C);
delay_us(45);
lcd_send_nibble(0x00);
delay_us(1);
lcd_send_nibble(0x0F);
delay_us(45);
lcd_send_nibble(0x00);
delay_us(1);
lcd_send_nibble(0x01);
delay_ms(2);
lcd_send_nibble(0x00);
delay_us(1);
lcd_send_nibble(0x06);
delay_ms(2);
}
//Orignal LCD format
/*
void lcd_init() {
BYTE i;
set_tris_lcd(LCD_WRITE);
lcd.rs = 0;
lcd.rw = 0;
lcd.enable = 0;
delay_ms(15);
for(i=1;i<=3;++i) {
lcd_send_nibble(3);
delay_ms(5);
}
lcd_send_nibble(2);
for(i=0;i<=3;++i)
lcd_send_byte(0,LCD_INIT_STRING[i]);
}
*/
|
|
|
|
sonicdeejay
Joined: 20 Dec 2005 Posts: 112
|
|
Posted: Wed Feb 08, 2006 10:26 pm |
|
|
jus 1 more query,,,,
as I am using PORT B0-7 for LCD....
at the same time I'm using PORTB 6-7 as PGD and PGC for my ICD programming...
can I tied them together???
|
|
|
sonicdeejay
Joined: 20 Dec 2005 Posts: 112
|
|
Posted: Thu Feb 09, 2006 6:44 am |
|
|
Quote: |
at the same time I'm using PORTB 6-7 as PGD and PGC for my ICD programming...
can I tied them together???
|
after testing out...
i can't tied them together...
so I connect to PGD/PGC when in programming mode to Port B 6 and 7
and connect in PIN 13 and 14 of the LCD when in running mode... |
|
|
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Thu Feb 09, 2006 8:26 am |
|
|
sonicdeejay wrote: | jus 1 more query,,,,
as I am using PORT B0-7 for LCD....
at the same time I'm using PORTB 6-7 as PGD and PGC for my ICD programming...
can I tied them together???
|
Why whould you want to tie PGD and PGC together? Parsing your "sentance" (and I use that word very loosely here) results in asking to tie PGD and PGC together.
But I think what you are asking is:
Can I use PORTB6 and PORTB7 as both ICSP programming pins and data pins for my LCD?
The answer to that question is yes. Use a series resistor from the PIC to your LCD pins. Start with 4.7kOhm. Then when you connect your programming header, connect it on the PIC side of the resistor. You may need to adjust the resistor value upward.
I have not done this with a LVP system but I have done this with PIC16Fs several times. _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
|
sonicdeejay
Joined: 20 Dec 2005 Posts: 112
|
|
Posted: Fri Feb 10, 2006 8:52 pm |
|
|
I have connected according to the picture below...
To program the chip ..i have to disconnect PIN 14 and 13 of LCD, only then I can program the chip. I have tried 4.7K~6K..no use...
|
|
|
sonicdeejay
Joined: 20 Dec 2005 Posts: 112
|
|
Posted: Sun Feb 12, 2006 4:46 am |
|
|
PCM and gurus...
help...
sonic |
|
|
gs
Joined: 22 Aug 2005 Posts: 30 Location: Ioannina - Greece
|
|
Posted: Sun Feb 12, 2006 5:16 pm |
|
|
I have tried it this way (with the resistors) but it worked only for some LCD modules. Since then I connect my lcd to PortC _________________ www.hlektronika.gr |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Feb 12, 2006 6:19 pm |
|
|
The problem is that the circuit is not as simple as your drawing shows.
The LCD controller chip has pull-ups on the data lines.
Download the HD44780 data sheet here:
http://www.melabs.com/downloads/hd44780u.pdf
Look on page 51 near the bottom, at the section on "Pull-up MOS current".
The current can be from 50 to 250 ua. With a 5v Vdd, this translates
to a pull-up resistance from 20K to 100K ohms.
A schematic drawing of these pull-ups is shown on page 54 of the
data sheet. They are drawn as a FET, not as a resistor symbol.
Then download the Microchip ICD2 poster:
http://ww1.microchip.com/downloads/en/devicedoc/51265e.pdf
Then zoom in on the middle right side. Notice that the ICD2 has
got 4.7K pull-down resistors on the PGC and PGD pins.
So in fact, the circuit is a voltage divider with 3 resistors in it.
If you can't program the PIC, then it's very likely because the
proper voltage levels are not being maintained, due to the presence
of the voltage divider. |
|
|
|