View previous topic :: View next topic |
Author |
Message |
benni
Joined: 28 Jun 2012 Posts: 28
|
General LCD question |
Posted: Tue Dec 18, 2012 11:12 am |
|
|
Hello Guys,
I've just got a simple question:
Would this code work if i connect everything right?:
main.c
Code: | #include <main.h>
#define LCD_ENABLE_PIN PIN_B3
#define LCD_RS_PIN PIN_B2
#define LCD_RW_PIN PIN_B1
#define LCD_DATA4 PIN_B4
#define LCD_DATA5 PIN_B5
#define LCD_DATA6 PIN_B6
#define LCD_DATA7 PIN_B7
#include <lcd.c>
void main()
{
lcd_init();
delay_ms(1000);
lcd_putc("\fReady...\n");
delay_ms(1000);
delay_ms(1000);
lcd_putc("Hello Benni");
} |
main.h
Code: |
//#include <18F4550.h>
#include <16F887.h>
#device adc=16
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOIESO //Internal External Switch Over mode disabled
#FUSES NOFCMEN //Fail-safe clock monitor disabled
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOPUT
#FUSES NOCPD //No EE protection
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT //Program memory not write protected
#FUSES NOIESO //Internal External Switch Over mode disabled
#FUSES NOFCMEN //Fail-safe clock monitor disabled
#FUSES NOMCLR //Master Clear pin enabled
#use delay(clock=20000000)
|
AND:
Why they are Resistors at RB7 and RB6 in this schematic:
http://www.best-microcontroller-projects.com/support-files/serial-lcd.pdf
Here is a other schematic without Resistors:
Thanks for help!
Regards Benni.[/code]
Last edited by benni on Tue Dec 18, 2012 11:41 am; edited 1 time in total |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Tue Dec 18, 2012 11:36 am |
|
|
quickly...
1) no.......
The program is not complete.
You need a processor type as well as 'fuses'.
You must have the LCD pin defines before loading the LCD driver,otherwise the default values(within the driver) will be used.
2) the resistors are used to 'isolate' the ICSP pins RB7,RB6. |
|
|
benni
Joined: 28 Jun 2012 Posts: 28
|
|
Posted: Tue Dec 18, 2012 11:41 am |
|
|
Hey,
I've updated the first post, I found another schematic and updated the code.
Is it right now?
Thanks
Regards Benni |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Tue Dec 18, 2012 1:47 pm |
|
|
no...
1) schematic shows 4 MHz xtal..code say 20MHz.
2) schematic shows 16F877..code says 16F887.
3) some fuses are wrong, ie: nomclr yet comment says enabled
4) LCD lower nibble pins grounded ? May or may not work,depends on LCD module.
bottom line...
wire up the board, compile the code, burn the PIC, see what happens..
hth
jay |
|
|
benni
Joined: 28 Jun 2012 Posts: 28
|
|
Posted: Tue Dec 18, 2012 2:08 pm |
|
|
Hello,
I am using a 20 MHz crystal, the schematic is just from the internet. I just want to know how to connect it right.
The PIC is also a 16f887 and not a 16F877.
So it should work. We will see it. When I'm done I will post something here.
Thanks.
Regards Benni |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Tue Dec 18, 2012 4:06 pm |
|
|
Other comment, put the first delay _before_ lcd_init.
Some LCD's do not start to wake up till the supply gets to nearly 5v. The PIC starts to wake much earlier. Most LCD's require quite a long delay before the initialisation, and some of the clones require more than 'standard'. Add the wake-up sequencing, and a good long delay before trying to send anything often helps....
Also, grounding the lower nibble, will just waste power. If you check the data sheet for most LCD's, these lines are _pulled up_ in the LCD, so they can be left disconnected.
Best Wishes |
|
|
benni
Joined: 28 Jun 2012 Posts: 28
|
|
Posted: Sat Dec 22, 2012 10:58 am |
|
|
Hello
I am not getting it to work, the background of the LCD is working but it doesn't shows the Text.
Here is the code:
Code: | #include <main.h>
#define LCD_TYPE 2
#define LCD_RS_PIN PIN_B7
#define LCD_RW_PIN PIN_B6
#define LCD_ENABLE_PIN PIN_B5
#define LCD_DATA4 PIN_B4
#define LCD_DATA5 PIN_B3
#define LCD_DATA6 PIN_B2
#define LCD_DATA7 PIN_B1
#include <lcd.c>
void main()
{
delay_ms(5000);
lcd_init();
delay_ms(3000);
printf(LCD_PUTC, "\fHello Benni");
} |
Does someone knows an idea why its not working?
Regards Benni |
|
|
benni
Joined: 28 Jun 2012 Posts: 28
|
|
Posted: Sat Dec 22, 2012 12:23 pm |
|
|
Thanks for Help.
It's now working i thought RB0 was RB7 and so on, i just wired it wrong.
Here are pictures:
Regards Benni |
|
|
|