Pages: [1]   Go Down
Author Topic: Problem with I2C LCD display  (Read 1547 times)
0 Members and 1 Guest are viewing this topic.
Southampton UK
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I want to drive an HD44780 LC display via a PCF8574T I2C interface adapter from my Uno.

I purchased the display and adapter separately (from China) and soldered them together.  I read that pull-ups on the SDA and SDL lines were a good idea, so I added these.  I set the board address to 0x20.

I downloaded a new LCD Library which supports I2C from www.bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home, and used this to replace the standard IDE LCD library.

I connected up the 4 lines (5v, Gnd, SDA(4) SCL(5) ) and uploaded some simple test code:


# include <Wire.h>
# include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x20);

void setup() {

lcd.begin(16,2);
lcd.print("TEST");
}

void loop (){

lcd.printCursor(1,0);
lcd.print("test");
}

The disappointing result is that only the top row of the display appears to be active, and this shows a running pattern of horizontal bars ramping up and down.

I complained to the Chinese supplier of the display that it must be faulty (I sent them photos of the display operating), but they insist that if it is showing characters it is ok, and that the missing second row is an addressing problem (?)

I'm tempted to junk the display and try another, but before I do that can anyone offer any suggestions as to what might be wrong?

TIA

Mike
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 35
Posts: 4299
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Mike:

Start by moving the two lines of code from loop() to the end of setup() and see what happens.  Otherwise you are rewriting the same information to the LCD over and over again and very quickly.

Are you sure this is the code that you actually used?  I have never run into lcd.printCursor() before (but I have not used FM's library either).


Don
« Last Edit: July 09, 2013, 09:00:03 am by floresta » Logged

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 67
Posts: 2692
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


I'm tempted to junk the display and try another, but before I do that can anyone offer any suggestions as to what might be wrong?
The constructor.
You have not entered the pin mappings into the constructor.
When you don't do this, the code defaults to using the pin mapping for fm's LCD extra i/o board.
My guess is that the wiring for your board is not the same as fm's board.
This is highly likely as I've not seen any other board out there use the
same mapping/wiring as fm's board.

Because if this, I do not recommend ever depending on default pin mapping
and highly encourage everyone to always use the full constructor which
includes mappings for all the io expender output pins as well as the backlight io pin
and its polarity.

Do not be so quick to blame the hardware.

If you enter your full pin mapping including the backlight pin and polarity into the constructor
it will likely work.


Here are two of the many threads out there for i2c backpacks.
(Seems to be a popular subject these days)
While it may not use the same pin wiring as yours, you can get
a good idea of what do from these threads:
http://forum.arduino.cc/index.php?topic=174860.0
http://forum.arduino.cc/index.php?topic=158312.0

Take note of the examples on Terry's site and use the full constructor
which includes the backlight configuration rather than using the deprecated
setBacklightPin()

If you are unable to figure out the wiring of the board you have you can also try the
"guesser" sketch that I supplied in the threads.

--- bill
Logged

Southampton UK
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Bill

Thank you for your very helpful reply.

I have traced out the wiring of my adapter board as best I can, and entered the mappings into the constructor.  This produced more promising results, in that both lines of the display now show up.  However, whatever I try to print and wherever I try to print, unexpected symbols (typically "0"s and arrows) show up, often in the first or last display positions (depending which way is "up" for the display). And once the sketch has uploaded it makes no difference to the display if the I2C lines are unplugged, so clearly the Uno is playing no further part in the proceedings!

It's getting late here now, so I'll leave it until tomorrow and explore some more then.

Where can I find your "guesser" sketch? It didn't seem to be in any of the threads you linked.

Mike
Logged

Southampton UK
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Don

Thank you for your input.  You're right about the lcd.printCursor command.  This was a typo - should have been lcd.setCursor. Apologies.

Mike
Logged

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 67
Posts: 2692
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Bill

Thank you for your very helpful reply.

I have traced out the wiring of my adapter board as best I can, and entered the mappings into the constructor.  This produced more promising results, in that both lines of the display now show up.  However, whatever I try to print and wherever I try to print, unexpected symbols (typically "0"s and arrows) show up, often in the first or last display positions (depending which way is "up" for the display). And once the sketch has uploaded it makes no difference to the display if the I2C lines are unplugged, so clearly the Uno is playing no further part in the proceedings!

It's getting late here now, so I'll leave it until tomorrow and explore some more then.

Where can I find your "guesser" sketch? It didn't seem to be in any of the threads you linked.

Mike
This is a case where you have to get the mappings exactly correct or else it won't work.
The guesser sketch is in the first thread that I provided a link to. Look closer at my responses.


Are you using Terry's test sketch? from his LCD blue web page?
Your backpack might be one of the ones he wrote about.

--- bill
Logged

Southampton UK
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Bill

I couldn't see the "guesser" attachment because I wasn't logged in when I read your message.  New to this, and didn't realise I had to be logged in to see attachments.  Next problem is that my Mac says it can't open the doc because there is no default application to open .pde documents. DOH.  Is there a direct link to the sketch on a webpage, for example?

My backpack is slightly different to all those shown on Terry's blue page, but one of them has a pin permutation that is only 2 pins different to what I thought mine was, so I'll try it out (I assume I can't do any more damage than I might already have done if I get it wrong!).

I've just noticed that the 4k7 pull-up resistors that I had tacked on SCA and SCL have come adrift at some point in the last day.  Don't know how important these are, but I'll reattach and retest recent work in case this had a compounding effect.

Mike
Logged

Southampton UK
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well - I fixed it!

Reattached the pull-ups to SDA and SCL, which eliminated the garbage on the display, but still no sensible response to LCD commands.

Double checked the mapping of adapter pins to display pins. All ok.

In desperation resorted to simple continuity tests, and Eureka!  A short circuit between D4 and D5 on the display module.  Careful examination with a magnifier and a bright light showed a very, very fine stand of solder linking the pcb pads. A stroke with a small screwdriver removed it, and everything now works as it should.

In conclusion my learning is that 1. it's essential to get the pin mapping exactly right for the specific I2C adapter you are using (and the constructor is definitely the way to go).  2. the pull-ups on SDA and SCL are necessary.  3. don't overlook basic electrical connection problems like shorts and open circuits.

Thank you Bill (and the various contributors whose postings you pointed me at).

Mike


 
Logged

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 67
Posts: 2692
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Glad you got it working.

The .pde file is the sketch.
The Arduino team changed the sketch suffix from .pde to .ino in the 1.x release.
The .pde extension still works with the 1.x ide. (it supports both)
I use the .pde extension so that the sketch will work with both
the older releases and the newer 1.x releases.


If you start up the Arduino ide and point it at the .pde sketch file, it should work.

--- bill
Logged

Pages: [1]   Go Up
Jump to: