CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Flexible LCD Driver with Powertip PC2004-A 20x4 LCD

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
adamp524



Joined: 06 May 2010
Posts: 22

View user's profile Send private message

Flexible LCD Driver with Powertip PC2004-A 20x4 LCD
PostPosted: Mon May 10, 2010 7:15 am     Reply with quote

Hi,

I'm having trouble getting anything to display on my Powertip PC2004-A 20x4 LCD. I'm using a PIC18F4580.

Currently I have 4 data pins DB4:DB7 and the three control pins wired up to port B on the PIC.

I'm using the 20x4 flexible LCD driver posted here:http://www.ccsinfo.com/forum/viewtopic.php?t=28268

Now, I'm not sure if this is a problem or not but I've noticed that when the LCD is powered up with no data going to it, there are no blank squares appearing on the screen. I've read in other forum posts that you should get something on the screen even when you have no data to it. Is what I'm seeing normal for this make of LCD?

The main issue with the LCD is that when I run the testcode given on the flexible LCD driver page, nothing appears on the screen. After maybe around 2 mins of the program running, sometimes there will be rows of random characters displayed on the 1st and 3rd line of the screen which randomly change, so there is some sort of communication going on between the PIC and LCD.

Anyone have any ideas what could be going wrong?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon May 10, 2010 10:48 am     Reply with quote

Read this thread. It discusses problems with making the Powertip 20x4
lcd work with the Flex driver:
http://www.ccsinfo.com/forum/viewtopic.php?t=31167

If that doesn't help, post the following:

1. Your compiler version.

2. A list of all connections between the PIC and the LCD.

2a. Also post the #define statements that define the PIC pins used by
the flex driver.

3. Describe the external contrast control circuit that you have
connected to the LCD.

4. The Vdd voltage used to run the PIC and the LCD.

5. Post a small test program that #includes the flex driver.
This should just be a small "Hello World" program. Don't post the large
test program shown in the Flex driver post.

Make sure the test program will compile with no errors before you post it.
adamp524



Joined: 06 May 2010
Posts: 22

View user's profile Send private message

PostPosted: Tue May 11, 2010 5:13 am     Reply with quote

Have tried everything suggested in the flexdriver post you suggested - nothing appears on the LCD.

The compiler version I'm using is: Version 4.033

Connections between PIC and LCD:
Code:
#define LCD_RS    PIN_B1
#define LCD_RW    PIN_B2
#define LCD_E     PIN_B0
#define LCD_DB4   PIN_B4
#define LCD_DB5   PIN_B5
#define LCD_DB6   PIN_B6
#define LCD_DB7   PIN_B7

┌───────────┐
|  P    RB0┼──── E
|  I    RB1┼──── RS
|  C    RB2┼──── RW
|  1    RB4┼──── D4
|  8    RB5┼──── D5
|       RB6┼──── D6
|       RB7┼──── D7
|          |
└───────────┘
D0 to D3 on the LCD left floating

my main.h file:
Code:
#FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT
#FUSES NOPROTECT                //Code not protected from reading
#FUSES BROWNOUT                 //Reset when brownout detected
#FUSES BORV21                   //Brownout reset at 2.1V
#FUSES MCLR                     //Master Clear pin enabled
#FUSES NOPBADEN                 //PORTB pins are configured as digital I/O on RESET
#use delay(clock=8000000)
#use rs232(baud=9600, UART1, bits=8, stop=1)

my main.c file:
Note: all printf statements go to UART1
Code:
#include "main.h"
#include "lcd_driver.c"

void main()
{
   printf("\r\nProgram start:\r\n");
   delay_ms(100);
   lcd_init();
   delay_ms(500);
   while(TRUE)
   {
      delay_ms(1000);
      printf("Before output to LCD\n\r");
      lcd_putc('c');
      printf("After output to LCD\n\r");
   }
}


When I run this program, the output that appears on the serial port is:
Code:
Program start:

Then in a continuous loop:
Code:
Before output to LCD
After output to LCD
Before output to LCD
After output to LCD


I have tried using a 5K pot connected to Vdd, Vo (Contrast Adj) and Vss) as well as connecting Vo straight to Vss.
I've found that when the LCD displays its random characters, the display is most clear when Vo is pulled to 0V - so that's what it's set to at the minute.

As for voltage levels, I'm using the Microchip PICDEM 2 Plus development board which supplies the pic and LCD with a Vdd of 5V
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue May 11, 2010 11:32 am     Reply with quote

PicDem2-Plus has tons of things on PortB. Try this:

1. Remove jumper J6, which connects the LEDs to Pins B0-B3.

2. Pins B6 and B7 are used by the ICD. This will interfere with the
LCD if the ICD is plugged in. To fix this, program the PIC with the
"Programmer" menu in MPLAB, so it will be a stand-alone program.
Then remove the ICD connector from the board, and press the reset
button.

3. Check your connections one more time, and make sure you don't
have any crossed wires.

Also, I tested compiler vs. 4.033 with an 18F4580 and the 16x2 lcd on my
PicDem2-Plus board, and it worked. So vs. 4.033 should work OK with
the 20x4 flex driver. The built-in LCD on the board doesn't use PortB.

Here is the test program:
Code:

#include <18F4580.h>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000) 
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#include "flex_lcd.c"

//===========================
void main()
{

lcd_init();

lcd_putc("Hello there");

while(1);
}
adamp524



Joined: 06 May 2010
Posts: 22

View user's profile Send private message

PostPosted: Wed May 12, 2010 2:31 am     Reply with quote

I've removed jumper J6 from the start - still no change.
Quote:
2. Pins B6 and B7 are used by the ICD. This will interfere with the
LCD if the ICD is plugged in. To fix this, program the PIC with the
"Programmer" menu in MPLAB, so it will be a stand-alone program.
Then remove the ICD connector from the board, and press the reset
button.

I've actually been doing that already, using PCW to create a hex file and program that onto the PIC manually.

Checked the connections one more time, they seem to be right.

I've connected up another 16wire 20x4 LCD with (what i'm assuming is) a different controller. This LCD looks a little more promising. I can send a string to it and after a bit of a delay, some of the characters I've sent display on the LCD (along with some extra ones). - sounds like a timing issue to me!

Any ideas?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 12, 2010 11:16 am     Reply with quote

It's possible that your LCD doesn't support the Busy bit correctly.
You could try configuring the Flex driver so it doesn't use the R/W pin.
There are instructions on how to do this in the Flex driver post.

Note that you must either:

Connect the R/W pin on the LCD to Ground (disconnect it from the PIC
before you do that).
or
You must set the R/W pin to a constant low-level with a line of code.
Do this at the start of main().

Also, it's possible that the delays in the driver may need to be increased
for your LCD. For example, if the driver has "delay_cycles()", then
change it to "delay_us()" instead. The initial power-up delay may
also need to be increased. This is the delay_ms() line in the lcd_init()
function. Change it to delay_ms(50) or more. The driver should work
for 99% of all people as it is, but it's possible in a few cases that longer
delays are necessary.
adamp524



Joined: 06 May 2010
Posts: 22

View user's profile Send private message

PostPosted: Fri May 14, 2010 2:52 am     Reply with quote

Hi, I seem to have got the driver to work at last!

It looks like my problem was that the programming pins were shared with the LCD's DB4-DB7 pins and when I programmed the PIC, the LCD controller got corrupted and would not recover until the LCD and PIC were reset!

Thanks for all your help.
adamp524



Joined: 06 May 2010
Posts: 22

View user's profile Send private message

Update!
PostPosted: Fri Jun 04, 2010 7:23 am     Reply with quote

Update: I've bought a new Powertip PC2004 A LCD to compare with the original one I had, but I cant get it to work either. I bought it just as a precautionary measure on the chance that the original LCD was broken.

I am fairly sure that this LCD does indeed work with your driver as post #6 by Neckruin on this thread http://www.ccsinfo.com/forum/viewtopic.php?t=28268 states that he got it working.

Would you have any other ideas on what could be wrong?

Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jun 04, 2010 10:03 am     Reply with quote

Which version of the PicDem2-Plus board do you have ?

Does it look like this one ?
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en010072
That's the original version.

Or does it look like this one ?
http://www.microchipdirect.com/ProductSearch.aspx?Keywords=DM163022
That's the new "Rohs" version. It looks different in the prototype
area. Notice the two silver "bars" in that area of the photograph.


Also, have you tried the CCS 4x20 lcd driver ? It uses PortB and it lists
the connections at the top of the file. Here's the file location:
Quote:
c:\program files\picc\drivers\lcd420.c
adamp524



Joined: 06 May 2010
Posts: 22

View user's profile Send private message

PostPosted: Mon Jun 07, 2010 2:28 am     Reply with quote

Hi PCM programmer, thanks for getting back to me quickly.

I have the original PicDem2-Plus board.

I've tried both LCDs (the one I could get working with the flex driver and the new Powertip PC2004). I cant get either of them working with the CCS 4x20 driver.

One odd thing I have noticed with the Powertip PC2004 display and the CCS 4x20 driver: If the power supply GND is removed but the contrast pin is still connected to GND (to give highest contrast), black '-' characters sometimes appear on lines 1 and 3 of the display, these slowly fade out after approx 2 seconds.
If using the CCS 4x20 driver and you initialise the display as soon as you disconenct GND and the black characters appear, the characters promptly disappear again. - This looks as if the LCD initialisation has completed but it is not possible to write any characters to it afterwards.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jun 07, 2010 11:03 am     Reply with quote

You're using PortB. I still think this is a large part of the problem.

1. Remove Jumper J6. This will remove the LEDs from PortB.

2. After you program the PIC, unplug the ICD programmer from
the PicDem2-Plus board. After doing that, if necessary, press the
reset button on the board. It's essential to unplug the ICD after
programming, when you're using pins B6 and B7 for the LCD.

3. Make sure you program the PIC with your IDE in "Programmer" mode.
Don't program the PIC in "Debug" mode.
adamp524



Joined: 06 May 2010
Posts: 22

View user's profile Send private message

PostPosted: Mon Jun 07, 2010 11:22 am     Reply with quote

Hi

I've already removed jumper J6 connected to the LEDs.

I'm not actually using an ICD programmer, I'm programming straight through ICSP port with a meLabs EPIC programmer http://store.melabs.com/prod/epic/EPICA.html, but I have tried programming, disconnecting the ICSP port and pressing the reset button on the development kit - no change to the LCD, it still stays blank

What confuses me is that this setup works with the unbranded LCD I have (mentioned in my post on Wed 12th May) but does not work when I directly replace it with the Powertip PC2004 LCD.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jun 07, 2010 12:00 pm     Reply with quote

Do a test. Add a large delay at the very beginning of the test program,
before you call lcd_init(). See if that helps.
Quote:

void main()
{
int8 i;
int8 b1, b2, b3, b4;

delay_ms(1000); // 1 second delay

lcd_init();
adamp524



Joined: 06 May 2010
Posts: 22

View user's profile Send private message

PostPosted: Mon Jun 07, 2010 12:13 pm     Reply with quote

Ok,

I've tried that, still no change, the LCD still remains blank
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jun 08, 2010 4:15 pm     Reply with quote

If you can, post a link to a photo of your test setup on a free image
hosting service. Example:
http://imageshack.us/

Then I can look at the wiring between the board and the LCD.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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