View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Jan 22, 2011 1:27 pm |
|
|
You don't need to add delays to the Flex driver. You're running at 20 MHz.
It's fully tested and known to work at 20 MHz or even faster.
Here is your problem:
You are using the R/W line. You have it connected to the PIC.
It's not connected to Ground. You are using it.
Quote: |
LCD
PIN 1 --> Ground
PIN 2 --> +5V
PIN 3 --> POT 20K
PIN 4 - RS --> RD1
PIN 5 - R/W --> RD2
PIN 6 - E --> RD0
PIN 7 --> GND
PIN 8 --> GND
PIN 9 --> GND
PIN 10 --> GND
PIN 11 --> RD4
PIN 12 --> RD5
PIN 13 --> RD6
PIN 14 --> RD7
PIN 15 --> +5V
PIN 16 --> GND |
But here, in the code below, you have commented out the statement to
use the R/W line. That's the problem ! You need to un-comment it.
Quote: |
// flex_lcd.c
// These pins are for the Microchip PicDem2-Plus board,
// which is what I used to test the driver. Change these
// pins to fit your own board.
#define LCD_DB4 PIN_D4
#define LCD_DB5 PIN_D5
#define LCD_DB6 PIN_D6
#define LCD_DB7 PIN_D7
#define LCD_E PIN_D0
#define LCD_RS PIN_D1
#define LCD_RW PIN_D2
// 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
|
Remove the comments, so the line looks like this:
Code: | #define USE_LCD_RW 1
|
Also, you ignored my post on setting the correct Vo voltage for the LCD
contrast. You need to fix that, too.
I think you have another problem. You don't appear to have a series
resistor in your backlight LED connections to the LCD. Read this
thread, which explains how to calculate the size of the series resistor:
http://www.ccsinfo.com/forum/viewtopic.php?t=37646&start=10
And even one more thing: You have the unused pins on the LCD (which
are DB0 to DB3) connected to ground. You don't really need to do that.
The LCD has internal pull-ups on the data pins, so if you leave them
floating they will be pulled up to +5v. |
|
|
champ720
Joined: 22 Dec 2010 Posts: 12
|
|
Posted: Sun Jan 23, 2011 1:02 am |
|
|
Thank you PCM,
I adjust Vo to 0.5V and leave DB0-DB3 floating but they aren't pulled up to +5v. Their voltage are about 0.25V
I notice that there are two resistors on LCD module connecting from Anode. I'm not sure that it must add any series resistor. However I'm asking maufacturer this problem and waiting for their reply.
Moreover, I'm not sure what LED parameter value is. I guess this is below
Code: |
Total LEDs LED voltage LED current Total Voltage
1 4.2 15 mA 5
|
PCM, could you read LCD datasheet below. Maybe, you help me about LED parameter value and LED series resistor.
(I can't enter LED series resistor calculation page http://www.bowdenshobbycircuits.info/led.htm)
This is LCD datasheet :
http://www.mediafire.com/?io9zpabz4itz6ao
and
http://www.mediafire.com/?0z5xlt61mo0u8rf |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jan 23, 2011 10:02 pm |
|
|
Quote: | I'm testing my LCD 16x2 (ABC016002A07-GHY)
|
This is a direct link to the data sheet:
http://www.es.co.th/Schemetic/PDF/ABC016002A07-GHY.PDF
On page 10, it gives the Backlight specifications.
To fill in the form on the LED resistor calculator website, use these values:
Number of LEDs: 1
LED voltage: 4.2
LED current: 110
Total Voltage: 5
Most of those numbers come directly from page 10 of the LCD data sheet.
Given those values, the form suggests a 7.5 ohm resistor. However, to
be safe, maybe it's better to begin with a 15 or 22 ohm resistor. |
|
|
champ720
Joined: 22 Dec 2010 Posts: 12
|
|
Posted: Tue Jan 25, 2011 12:50 am |
|
|
Hello, PCM
I connect series LED resistor 15 ohm, 0.5W and do anything you suggest but it doesn't work. what is next your idea ?
Thank you very much. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jan 25, 2011 4:20 pm |
|
|
That circuit only affects the backlight. You don't need the backlight
to be working. The LCD will run without it.
Did you do you all the things I listed in my post below?
http://www.ccsinfo.com/forum/viewtopic.php?t=44512&start=13
You don't need to worry about the backlight. Just do all the things
I listed in the post. Get the LCD working first.
If the LCD doesn't work, then maybe you destroyed it accidentally by
reversing the +5v and Ground connections. |
|
|
champ720
Joined: 22 Dec 2010 Posts: 12
|
|
Posted: Wed Jan 26, 2011 11:25 pm |
|
|
PCM programmer wrote: | That circuit only affects the backlight. You don't need the backlight
to be working. The LCD will run without it.
Did you do you all the things I listed in my post below?
http://www.ccsinfo.com/forum/viewtopic.php?t=44512&start=13
You don't need to worry about the backlight. Just do all the things
I listed in the post. Get the LCD working first.
If the LCD doesn't work, then maybe you destroyed it accidentally by
reversing the +5v and Ground connections. |
Thank you PCM,
LCD works now. I think my problem is power supply and ground is not good. When I connect PIC with GPS module, LCD works fine but GPS doesn't work.
If I use circular buffer without interrupt, it works unsmoothly. Also, I add interrupt service code (EX_SISR.c in PCWHD compiler), but nothing received through RS232. How can I solved this interrupt code problem?
This code without Interrupt
Code: | //---------------Without Interrupt--------------------//
#include <16F877A.h> // Standard Header file for the PIC16F877A
#include <stdlib.h>
#include <math.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP // Configuration word
#use delay(clock=20000000) // oscillator
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // Standard output
#include "flex_lcd.c"
#define BUFFER_SIZE 70
int gps_data[BUFFER_SIZE]={};
int i = 0;
void main(void)
{
lcd_init();
lcd_putc("\f"); //Clear display
lcd_gotoxy(1,1);
lcd_putc("GPS Test");
while(TRUE)
{
gps_data[i]=getch();
putc(gps_data[i]);
i++;
if (i>BUFFER_SIZE-1)
{
i=0;
}
}
}
|
This code with Interrupt
Code: | #include <16F877A.h> // Standard Header file for the PIC16F877A
#include <stdlib.h>
#include <math.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP // Configuration word
#use delay(clock=20000000) // oscillator
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // Standard output
#include "flex_lcd.c"
#define BUFFER_SIZE 70
BYTE buffer[BUFFER_SIZE];
BYTE next_in = 0;
BYTE next_out = 0;
#INT_RDA
void gps_isr()
{
int t;
buffer[next_in] = getc();
t = next_in;
next_in = (next_in+1)%BUFFER_SIZE;
if(next_in == next_out)
{
next_in = t; //Buffer full
}
}
#define bkbhit (next_in!=next_out)
BYTE bgetc()
{
BYTE c;
while(!bkbhit) ;
c=buffer[next_out];
next_out=(next_out+1)%BUFFER_SIZE;
return(c);
}
void main(void)
{
lcd_init();
lcd_putc("\f"); //Clear display
lcd_gotoxy(1,1);
lcd_putc("GPS Test");
delay_ms(200);
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
do
{
delay_ms(500);
while(bkbhit)
putc(bgetc());
} while (TRUE);
}
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jan 26, 2011 11:44 pm |
|
|
Quote: | do
{
delay_ms(500);
while(bkbhit)
putc(bgetc());
} while (TRUE);
|
Delete the two lines in bold. |
|
|
champ720
Joined: 22 Dec 2010 Posts: 12
|
|
Posted: Wed Jan 26, 2011 11:55 pm |
|
|
PCM programmer wrote: | Quote: | do
{
delay_ms(500);
while(bkbhit)
putc(bgetc());
} while (TRUE);
|
Delete the two lines in bold. |
I delete these two lines, but it doesn't work. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jan 27, 2011 1:51 pm |
|
|
I don't understand your program.
Here, you use the LCD to display output:
Quote: | void main(void)
{
lcd_init();
lcd_putc("\f"); //Clear display
lcd_gotoxy(1,1);
lcd_putc("GPS Test");
|
But then down here, you get characters from the GPS on the serial port.
But then you just transmit them back on the serial port, using putc().
What's the purpose of that ? Where is the transmit line of the PIC's
serial port going ? To the GPS ? Or to the PC ?
Quote: |
do
{
delay_ms(500);
while(bkbhit)
putc(bgetc());
} while (TRUE);
} |
Are you using a split rs232 cable, and receiving characters from the GPS
and sending them to the PC ?
Do you really want to send GPS data to the LCD, instead, and you just
made a mistake by using putc(bgetc()) above ?
Is this a Proteus program or is this real hardware ? |
|
|
champ720
Joined: 22 Dec 2010 Posts: 12
|
|
Posted: Thu Jan 27, 2011 6:14 pm |
|
|
Hello PCM,
I'm doing GPS data logger which display lat/long at LCD and connected laptop's usb cable for navigation. I add LCD for displaying lat/long when GPS isn't connected to laptop.
Now, I'm testing first step, receiving GPS data (by interrupt service) and display on hyper terminal. If it works, I will program code to display lat/long on LCD later. I test all on proto board.
Moreover, I attach my circuit for considering it.
Thank you,
Uploaded with ImageShack.us |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Fri Jan 28, 2011 8:58 am |
|
|
Hi,
What GPS module are you using. Post a link to the datasheet!
Your use of 500 ohm "pull-ups" on the Tx and Rx lines of the PIC is "interesting"...... My guess is that the Schmitt Trigger input on the Rx input is not compatible with your GPS receiver output. You'll probably need a proper level shifter.
John |
|
|
andrewg
Joined: 17 Aug 2005 Posts: 316 Location: Perth, Western Australia
|
|
Posted: Fri Jan 28, 2011 10:51 pm |
|
|
I hope they aren't 33pF I'm seeing either side of the 7805! I'd expect something more like 33uF, but at least 10uF is what I'd have, maybe up to 200uF (no real upper limit) on the "out" side. _________________ Andrew |
|
|
|