[Solved] LCD 1x40 display - only first 20 chars show up..

Hi Folks,

I bought a 1 row, 40 column LCD from ebay, specifically this one (datasheet attached)

I've hooked it up to my arduino (4 bit mode) and it sort of works, but I only seem to be able to address the first 20 characters of the screen, so if I do

//either this
lcd.setCursor(21,0)
lcd.print("X");
// or this
lcd.setCursor(0,0)
lcd.print("I am a string longer than 20 characters")

Then in the first case, I don't see the X, and in the second, the string truncates after the 20th character on the screen.

Whilst I understand that it could be a defective screen, I wondered if anyone knows if there are limitations of the LiquidCrystal arduino library that mean that only the first 20 characters on a row are addressable?

Thanks, Ace

4dmc[1].pdf (621 KB)

Your 40x1 display could be configured internally as a 20x2 display in a manner similar to the way most 16x1s are configured as 8x2. Follow the LCD Addressing link at http://web.alfredstate.edu/weimandn for more information about what may be going on.

Try changing your code from lcd.begin(40, 1); to lcd.begin(20, 2); which should let you write to the other half of the screen after resetting the cursor with lcd.setCursor(0,1);.

Please return to this forum thread and let us know how you made out.

Don

Thanks for responding - a quick try of that didn't yield any luck - if I change the begin() call to be begin(20,2) - I don't see anything on the screen.

However, I'm not giving up yet, now that you mentioned memory layout, I'll go back and stare at the datasheet a bit more and see if I can work out if thats the issue.

--Ace

Thanks for responding - a quick try of that didn't yield any luck - if I change the begin() call to be begin(20,2) - I don't see anything on the screen.

You have to readjust the contrast when going from a 1 line configuration to a 2 line configuration.

With just the power leads connected what does your display look like as you adjust the contrast? You should have a blank screen at one end of the potentiometer range and you should see rectangular boxes at the other extreme, probably 20 of them on the left half of the screen.

After you see the rectangular boxes then connect the rest of the wires and run this sketch (don't forget to connect LCD pin 5 to GND):

#include <LiquidCrystal.h>

//LiquidCrystal lcd(rs,en,d4,d5,d6,d7);
  LiquidCrystal lcd(12, 11, 5, 4, 3, 2);       // put your pin numbers here

void setup()
  {
    lcd.begin(20, 2);                          // put your LCD parameters here
    for (char i=47; i<127; i++)                // send 80 consecutive displayable characters to the LCD
      {
        lcd.print(i);
        delay(100);                            // this delay allows you to observe the addressing sequence
      }
  }


void loop()
  {  
  }

However, I'm not giving up yet, now that you mentioned memory layout, I'll go back and stare at the datasheet a bit more and see if I can work out if thats the issue.

I couldn't find anything about the addressing in your datasheet but the results of running the sketch above, assuming something shows up, should give us the information we need.

Don

I have had another look at your datasheet and the information on page 11 verifies my suspicion that your device is internally configured as 20x2.

The Block Diagram shows that there are 16 common lines (labeled C16) coming from the controller. This means that the controller is set up to display two rows of characters each having 8 rows of pixels.

It also shows that there are 40 segment lines (S40) coming from the controller and another 60 coming from the driver (auxiliary controller) for a total of 100 segments. This means that between the two chips they can display 20 characters each having 5 columns of pixels.

As a result the display is, as far as the controller is concerned, set up with 2 rows of 20 characters and that is what you have to tell the library.

The sketch that I provided should display characters in every position if the contrast is adjusted properly.

Don

You are a star - the contrast was exactly the problem. Tweaked this, and put back the code you originally suggested and it works beautifully!

Thanks also for the guidance on how to interpret the data sheet - that will help for the future.

Not sure where in the world you are, but I'd send you a beer if I could. Thanks much for helping.

--ace

Posting again to change subject to solved.

Thanks for all the help

-Ace

It doesn't work that way.

You have to go back and modify the Subject on your first posting, not add one. You could then delete that last one which has no purpose (and I will then delete this!).

It doesn't work that way.

The whole forum works like a typical mobile phone app. There are few, if any, instructions available so you just have to muddle through.

Don

done - sorry for not understanding.

Thanks again for the help, Ace

floresta:
The whole forum works like a typical mobile phone app. There are few, if any, instructions available so you just have to muddle through.

Well as it happens, not only is that not quite true, but it turns out to be dead wrong!

At the top of each topic page is a "sticky" by Nick Gammon entitled "How to use this forum - please read" This has been there since February 2013. It is a single message which points you to a second or master "how to use this forum" which is an extensive and quite easy to follow instruction set for using the forum effectively.

In particular, in this section, it details:

14. Once you have a response ...

  • If you consider the issue solved, please edit your original post (the first one in the thread) and add "[solved]" to the subject line. That helps people know the issue is resolved. Also please post the solution, whether you worked it out yourself, or if someone else helped you. A note that "this was solved by doing X" is very helpful to other people with the same problem. Thanks!

It could not be a great deal clearer. No doubt you yourself have not actually felt the need to read these instructions - and I would not really expect you to have done so either, but it is inappropriate to suggest they are not there. :grinning: