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

New CCS user with LCD problem
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 17, 2005 4:41 pm     Reply with quote

1. Who is the manufacturer and what is the part number of the LCD ?

2. What is your compiler version ? This will be a number like 3.191
or 3.236, etc., and can be found at the top of the .LST file, which
is in your project directory.
Harry Mueller



Joined: 17 Oct 2005
Posts: 116

View user's profile Send private message

PostPosted: Mon Oct 17, 2005 4:56 pm     Reply with quote

PCM programmer wrote:
1. Who is the manufacturer and what is the part number of the LCD ?

The LCD was originally made by Data Vision and was called the 16400. After a lot of searching I found a data sheet put out by Three-Five Systems who apparently bought DV. It's a simple one pager that has the pinouts and physical size.
Quote:

2. What is your compiler version ? This will be a number like 3.191
or 3.236, etc., and can be found at the top of the .LST file, which
is in your project directory.

Compiler version is 3.219

Regards....Harry
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 17, 2005 5:27 pm     Reply with quote

If you go to the DataVision website, and click on Product and LCM/DV
it shows a table of LCDs. The DV-16400 uses a KS0066 or equivalent
controller. http://www.datavision.com.tw/english/index.html

The controller data sheet is here:
http://www.hantronix.com/down/ks0066u.pdf
On page 27, it shows a block diagram of the init process for 4-bit mode.
It says to wait at least 30ms after power-up for the unit to initialize.
This is longer than the standard 15 ms for a HD44780u controller.
See page 46 of the following document for that spec.
http://web.media.mit.edu/~ayah/documents/hd44780u.pdf


So first try to change the initial delay shown below. I suggest increasing
it to 50 ms, just to give it plenty of time to initialize.

If that doesn't work, then also add the 5m delay and braces shown at
the bottom of the routine.

Code:
void lcd_init() {
    BYTE i;
    set_tris_lcd(LCD_WRITE);
    lcd.rs = 0;
    lcd.rw = 0;
    lcd.enable = 0;
    delay_ms(50);        // Change to 50 ms  (was 15 ms)
    for(i=1;i<=3;++i) {
       lcd_send_nibble(3);
       delay_ms(5);
    }
    lcd_send_nibble(2);
    for(i=0;i<=3;++i)
        {                  // Add this brace
         lcd_send_byte(0,LCD_INIT_STRING[i]);
         delay_ms(5);      // Add this line
        }                  // Add this brace
}
Harry Mueller



Joined: 17 Oct 2005
Posts: 116

View user's profile Send private message

PostPosted: Mon Oct 17, 2005 6:57 pm     Reply with quote

PCM programmer wrote:

So first try to change the initial delay shown below. I suggest increasing
it to 50 ms, just to give it plenty of time to initialize.

If that doesn't work, then also add the 5m delay and braces shown at
the bottom of the routine.


Sorry to say that those changes didn't work either....I was sure optimistic! But I do want to thank you for all the effort you've put into my problem and for all you've taught me already. I've got some good info to look over.

I really wanted to get an LCD going for debugging purposes because I've got to rewrite some robotics programs and want to start developing others in C. Not really sure where this leaves me now.

Thanks again.....Harry
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 17, 2005 7:05 pm     Reply with quote

If you have the PicBasicPro Compiler source code that works, then post it.
Harry Mueller



Joined: 17 Oct 2005
Posts: 116

View user's profile Send private message

PostPosted: Mon Oct 17, 2005 7:37 pm     Reply with quote

PCM programmer wrote:
If you have the PicBasicPro Compiler source code that works, then post it.


This is starting to hurt. I'm a regular packrat and I'd kept every bit of code I had written in the last 5 years. Then when I was installing my new compiler yesterday I found I was "out of memory". I cleared out everything I had since I was starting fresh.

What I do remember is that the code took about 10 minutes to write and worked the first time. There was nothing technical involved at all...no drivers, no inits,...everything happened behind the scene. I just did a search on the net and I think I found the program that I modelled mine from.

Code:

DEFINE OSC 4 ' Using 4 MHZ crystal
DEFINE LCD_LINES 4 ' Using a 4 lines LCD

pause 1000 ' wait LCD start-up delay
           '
           ' P.S.: it can be higher or lower depending of
           '       the model you're using
           
Start:
      lcdout $fe,  1,"Line 1",_
             $fe,$c0,"Line 2",_
             $fe,$94,"Line 3",_
             $fe,$d4,"Line 4"
Here:
     goto here


I just found the other site that I used to set up my LCD in PBP....I notice they have a resistor on the RS line.

http://www.rentron.com/PicBasic-LCD.htm

Regards....Harry
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 17, 2005 9:23 pm     Reply with quote

They use the following init string. Substitute it for the
one in the CCS driver file, LCD.C:
Code:

// Init string for DV16400 20x4 LCD.
BYTE const LCD_INIT_STRING[4] = {0x22, 0x28, 0x0c, 6};
Harry Mueller



Joined: 17 Oct 2005
Posts: 116

View user's profile Send private message

PostPosted: Tue Oct 18, 2005 8:53 am     Reply with quote

Tried this change and although the program compiled and ran normally..the LED flashed twice...the LCD failed to light up.

I notice that you remarked in the code that the statement was for a 20 x 4 LCD. The 16400 is a 16 x 4....could this be a factor in it not working?

Thanks....Harry
Harry Mueller



Joined: 17 Oct 2005
Posts: 116

View user's profile Send private message

PostPosted: Tue Oct 18, 2005 11:56 am     Reply with quote

I've done some reading on how the Hitachi HD44780 and Samsung KS0066 might differ and the consensus seems to be that the KS0066 is an exact clone of the 44780. A couple of sources suggest that there may be some small timing differences.

I've taken the LCD off the 16F877 breadboard and reinstalled it on my 16F84 where it prints the output from an IR range detector. Still works perfectly.

The only thing that might make sense at this point is that the 16F877 is having some kind of problem.

I've got a 16F628 that I could breadboard if someone has a hex file that presently works with a 16F628 and a HD44780/KS0066 LCD.

Thanks....Harry
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Oct 18, 2005 12:37 pm     Reply with quote

Re the 20x4, I think that's a typo.

I probably have done as much as I can on this.
Harry Mueller



Joined: 17 Oct 2005
Posts: 116

View user's profile Send private message

PostPosted: Tue Oct 18, 2005 1:01 pm     Reply with quote

PCM programmer wrote:

I probably have done as much as I can on this.


Thanks for all the help you've given me. I agree that this exercise has come to a dead end but do I have to get an LCD going with CCS C.

I'm going to try breadboarding a 16F628 and I want to confirm that the following code should work.

Code:
#include <16F628.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)

#include <lcd.c> //set this file up to use port B

void main()
{
  lcd_init();
  printf(lcd_putc,"\fHello");
 while(1);
}   


Thanks....Harry
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Oct 18, 2005 1:10 pm     Reply with quote

That should work.
Harry Mueller



Joined: 17 Oct 2005
Posts: 116

View user's profile Send private message

PostPosted: Tue Oct 18, 2005 4:12 pm     Reply with quote

No problem getting it to work on the 16F628. My problem is that I want to use the LCD on a 16F877a! Crying or Very sad I hadn't taken out the changes that PCM programmer had suggested, perhaps I'll try removing them one by one to see it they're required.

Thanks again for all the help.....Harry
Harry Mueller



Joined: 17 Oct 2005
Posts: 116

View user's profile Send private message

PostPosted: Tue Oct 18, 2005 4:13 pm     Reply with quote

No problem getting it to work on the 16F628. My problem is that I want to use the LCD on a 16F877a! Crying or Very sad

I hadn't taken out the changes that PCM programmer (you) had suggested, perhaps I'll try removing them one by one to see it they're required.

Thanks again for all the help.....Harry
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Oct 18, 2005 8:18 pm     Reply with quote

Since it works on a 16F628, then wire it up to Port B of the 16F877A
in exactly the same way. Use the same program -- just change the
#include line to 16F877A.H. Make sure the LCD.C driver is enabled
for Port B. It should work.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
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