HD44780 strange behaviour

Hi guys.

I am facing a strange behaviour with 20x4 HD44780 lcd I hooked to Arduino via i2c breakout and 4k7 pullups on clock and data.

For a test I have a small sketch that just writes ascii table to lcd starting with '!'.
Initially, display is as expected.

But after few resets, lcd displays garbage. Well, not exactly garbage, because:

  • 'garbage' on LCD is always the same, even after I remove power and reset Arduino few times. So it's not random.
  • writing identical text on all 4 lines produces identical 'garbage' on all 4 lines.
  • there is definitely some pattern in this 'garbage'

It is as though LCD switched to some strange character encoding that is value and x position dependant. Writing 'AAA' at position 0 always produces something like '$4T'

Tried this with mega and nano. Unfortunately I don't have a spare 2004 lying around to try with a different one.

Any ideas?

Thanks,
DonLuigi

Initially, display is as expected.

  • there is definitely some pattern in this 'garbage'

We really can't help you analyze what is going on if you don't tell us what data you sent to the display and what characters you saw on the display.

Some information about the particular I2C adapter that you are using might be pertinent as well.

Don

Have you looked at the LCD character set? Do you know that the LCD character set is not the same as the ASCII character set?

As always, the answer is - if you want help,
Post Your Code!
In "code" tags.

And photos - no more than 1024 pixels wide, perfectly focused, less than 500 kB size - of the complete board setup and the problem result.

Ok, here is the rather trivial code:

#include <Arduino.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd (0x27, 20, 4);

void setup ()
{
    lcd.init ();
    lcd.backlight ();
    lcd.clear ();
}

void loop ()
{
    for (int i = 0; i < 4; i++)
    {
        lcd.setCursor (0, i);
        lcd.print ("ABCDEFG------123456");
    }
    delay (500);
}

I also attached expected and garbled output. It takes about 10 resets to reach garbled output.

As for the wiring, I use I2C <-> HD44780 module from ebay. I connected SCL <-> SCL, SDA <-> SDA, and two 4K7pullups on SCL and SDA lines. I also removed pullups with no difference.

Thanks,
DonLuigi

Since it does work correctly most of the time that pretty much rules out any problems with the I2C communication, the constructor, and the wiring.

Although it could conceivably be the LCD module itself I would tend to blame the library - which you have not identified.

Don

I use the latest version of a library located here GitHub - fdebrabander/Arduino-LiquidCrystal-I2C-library: Library for the LiquidCrystal LCD display connected to an Arduino board.

Unfortunately I don’t have a scope to determine what’s really going on on the bus.

I will try a different library though…

Thanks

Try this one: --> https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home

Don

floresta:
Try this one: --> https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home

Don

Tried this library, with exact same results. So it's not the library.

And it's not i2c because everything else works - cursor positioning, clearing screen, backlight...

It's either PCF8574 extender or lcd.

Thanks

I believe that you have an out of tolerance LCD, one that takes longer than it should to process some of it's instructions.

We have seen similar problems with the regular LiquidCrystal library where such an LCD would work properly in 8-bit mode but not in 4-bit mode.

Basically the device is getting 'out-of-sync' with the library by dropping one of the nibbles.

This is easiest to see if you look at the binary values for the last four characters that you are displaying, and compare them with the binary values for the last four characters that you are sending.

# 3 C S --> 0010 0011 0011 0011 0100 0011 0101 0011

 3 4 5 6 -->     0011 0011 0011 0100 0011 0101 0011 0110

Don

Don, your comment is spot on.

Since lcd in my case always got out of sync at the beginning, I added a small delay after lcd.init and it solved the problem :smiley:

Thanks again for your insight.