i2c LCD...

Cactusface:
Hi A.R.TY,
That backpack has the same component layout as mine, the printing is slighty different,

Mel,
While we don't know for sure which board A.R.Ty has since we haven't see an actual photo
of the board he is using, the one in the photo we have seen is slightly different from yours.
The layout of the components on the left of the PCF8574 are different.
You can see the placing of the transistor and jumper is different and also
the location of the LED.

A.R.Ty,
I think at this point, there will need be a careful visual done on the board
to follow all the traces to create the schematic of the board,
or at least figure which where each of Px pins on the PCF8574 are connected on the LCD.
Check a datasheet for the PCF8574 pinout but the
the Px pins are: P0=4, P1=5, P2=6, P3=7, P4=9, P5=10, P6=11, P7=12
It only takes a minute or so. An ohm meter can be helpful if the traces are not fully visible.
Once we know which PCF output pins are connected to which LCD pins,
coming up with the constructor is very easy.

The jumper should be easy to tell what it does, just follow the traces
and see what it is connected to.
Normally on most of these boards the jumper breaks the connected to the
transistor base. i.e. it will force the backlight to be off.

--- bill

I surely know, that there are 3 different of these boards, and all look the same (more or less).
The routes on the board maby different, in case of how direction the chip is soldered :stuck_out_tongue_closed_eyes:

Then the layout (as written by Catusface) differents in some parts, too.

I already tried to follow the routes, and i think its is correctly installed.
Maybe the timing of this "exotic" display is so different that it won't work with pure standard parameters.
My multimeter was broken last saturday (as i wrote in another thread) so i cant measure anything until the new one has arrived (hope tomorrow).

When i got the i2c-ready 4*20 i can compare the one on that board with mine and can run some additional tests with the lcd guesser sketch.

A.R.Ty:
Maybe the timing of this "exotic" display is so different that it won't work with pure standard parameters.

i2c is quit slow. It is very unlikely that there is a timing issue given
how slow i2c is and that timing issues are related to doing things
too fast vs not fast enough.

Earlier you said:

lcd is initialized, 2. row with dark bars as usual.

If that means you are seeing 2 rows of dark bars that is not "as usual"
for a 16x2 display.
This indicates a constast voltage issue.

I think it is time for you to start posting some photos of your board
and your display so we can see exactly what you have and
what the display is showing.

--- bill

Earlier you said:
lcd is initialized, 2. row with dark bars as usual.

Yes, and that meant that the second row shows the bars

P.S.: i know what you mean - we are both wrong (or right)
it seems that my display stands upside down :smiley: :smiley: :smiley:

Hey guys,

I´m using a HD 44.. (20 04) compatible display and a mjkdz i2c adapter :


I got a problem to setup my pins correctly and tried the guesser sketch, but i can only identify the pin 7 as backlight pin when using NEGATIVE (bl blinks and stays on after)

Bperrybap you said you updated your sktech to do brute force detection, can you post this newer version, because i have tried like 30 possibilities now and I am out of ideas right now :frowning:

I have been using different adapters before and it got it working very fast but the new module i got drives me crazy :slight_smile:

I don't know if this is any help but FYI:
http://forum.arduino.cc/index.php?topic=200061.0

smithy:
Hey guys,

I´m using a HD 44.. (20 04) compatible display and a mjkdz i2c adapter :

Dropbox - Error - Simplify your life
Dropbox - Error - Simplify your life

That "mjkdz" board is different from mine. But like I've said in several of these threads,
there are several different "mjkdz" boards and the wiring on them is not all the same.
What is that wire on the lcd? Did you add that wire or did it come that way?
And is that black duct tape on the back? Any specific reason for this?

I got a problem to setup my pins correctly and tried the guesser sketch, but i can only identify the pin 7 as backlight pin when using NEGATIVE (bl blinks and stays on after)

Bperrybap you said you updated your sktech to do brute force detection, can you post this newer version, because i have tried like 30 possibilities now and I am out of ideas right now :frowning:

The two most common wirings are:

  { 4,  5,  6,  0,  1,  2,  3,  7, NEGATIVE }, // MJKDZ board

{ 2,  1,  0,  4,  5,  6,  7,  3, NEGATIVE }, // Robot Arduino LCM1602/2004



**And the guesser sketch tries them both.**
**Unfortunately, it does not appear possible to be able to detect the correct wiring.**
**I spent quite a bit of time trying to come up with a way to do it, but never could**
**figure out a way to do it.**
**The sketch I've posted trys a half dozen of the actual wirings I've seen.**
**The number of total permutations for all 8 wires is 40320 so there are way too many**
**to try them all since only the user can tell when it is correct by visually looking.**
**If each permutation in the guesser sketch took 2 seconds**
**(1.5 seconds for the blink and .5 seconds for the user to respond)**
**then it would take 80640 seconds or 1344 minutes or 22 hours 24 minutes.**
**And that doesn't take into consideratoin the backlight polarity, which will double**
**that number.**
**Knowing that bit 7 is for the backlight and its polarity helps but** 
**that still leaves 5040 permutation which would take over an hour at the 2 second rate.**

If the guesser sketch does not guess the needed permutation, then
you are going to have to look at the board, to come up with the wiring.
It isn't that difficult and usually takes less than 5 minutes.
However, in your case, there is no access to the front of the i2c board.
Do you happen to have any photos of the front side of the board?
If not it probably means unsoldering the i2c board to get access to the other side.

Before you desolder the board, there is one last thing to check.
The pots used on these boards is sometimes a multi turn pot.
So you may have to turn the pot many times to get it to the point
where the contrast is right. Without doing this, you will see nothing but
blocks.
Make sure you can adjust the pot down to where the pixels go off, then
turn it just enough to get them to turn back on.

--- bill

Thank you for the fast replies !

What is that wire on the lcd? Did you add that wire or did it come that way?

Well, thats just a "fix" because after too much desoldering one lcd pin header (backlight +) got loose so we wired it up to where the according trace ends (i think its a resistor but im not sure). The display works fine when i connect it via parallel in 4 bit mode.
The tape is simply protection.

I dont need to desolder anything because we soldered a 16 pin header on top of the lcd header so we can just plug the adapter in.
Unfortunately my smartphone began bugging really hard after posting the pictures here i cant provide them to you, but ill ask a buddy.

I tried changing the pot like you said but that´s not the problem i think, because i changed your sketch to treat the lcd as 20 04 so i would at least see 4 rows of blocks ?

Thanks for your time

smithy:
Thank you for the fast replies !

What is that wire on the lcd? Did you add that wire or did it come that way?

Well, thats just a "fix" because after too much desoldering one lcd pin header (backlight +) got loose so we wired it up to where the according trace ends (i think its a resistor but im not sure). The display works fine when i connect it via parallel in 4 bit mode.
The tape is simply protection.

Great. So that confirms that the LCD does work.

I dont need to desolder anything because we soldered a 16 pin header on top of the lcd header so we can just plug the adapter in.
Unfortunately my smartphone began bugging really hard after posting the pictures here i cant provide them to you, but ill ask a buddy.

That is good news. I couldn't see the header in the photos.
You should be able to make out quite a few of the traces if not all of them
on that board.
Do you have an ohm meter?
if so you could ohm out the signals to figure out where each of the
PCF8574 output Px pins go.
The Px pins are pins 4,5,6,7, 9, 10, 11 and 12 of the PCF8574 IC.
You need to figure out which LCD pin each of those pins are connected to

I tried changing the pot like you said but that´s not the problem i think, because i changed your sketch to treat the lcd as 20 04 so i would at least see 4 rows of blocks ?

But by turning the pot were you able to make the blocks go off/on?
No you won't see 4 rows of blocks.
The blocks are done by the controller on the LCD module after power up.
i.e. they will show up when the LCD has power, but before it is initialized.
If the sketch was initializing the LCD, they would go away.
The Sketch output was intentionally designed to allow it to work on a 20x4 display
without having to modify the sketch to set the geometry to 20x4.
This works because the column 0 addresses for line 0 and line 1
for a 16x2 display are the same as a 20x4 display.

I got a multimeter, so i can do signal testing but i don´t quite understand what you mean with Px pins.

Pins should be RS/EN/ and backlight positive i guess ( 4, 6, 10-14, 15) that makes 7 for me but you name 8.
edit just saw the constuctor needs RW aswell but still different pins

To detect initialisation RS/EN/RW and BL should be enough ?

Even if I trace the pins to the chip connection, what does that tell me since i have no datasheet of the pcb nor the chip that is installed ?

Another option would be that the chip is soldered wrong and the pins are inverted :slight_smile:

Yes I got the blocks on and off.

I guess I should do a write up on how to create the schematic wiring from looking at the i2c board.
The point of this type of excersize is derive the schematic from examining the board, since
the schematic is not available.
This type of excersize is quite common for low cost import boards, since the vendors
often don't supply any technical information.

For these i2c to LCD backpacks it is fairly easy since these are very simple dual sided boards
with large components with very few traces.

Here is an overview.
First you must identify the chip used.
Most of the i2c boards use a PCF8574.
A few like the adafruit lcd backpack use the MCP23008 but those are fairly uncommon.
Look at the board, and see if you can read the chip numbers on it.
If it says PCF8574 or some slight variation like PCF8574A on it then
it is a "PCF8574 based board.
IF has the numbers sanded off it, then don't dispare, you can still identify
it by the number of pins.
If it has 16 pins then it is more than likely a PCF8574 and if it has
18 pins then it is MCP23008.

The currently released fm liquidCrystal library only supports
the PCF8574 (a future update will support others).

For a PCF8574:
See the data sheet: (here is a link to one):
http://www.nxp.com/documents/data_sheet/PCF8574.pdf
The PCF8574 has an 8 bit i/o port.
The pins are called P0 to P7 and are PCF8574 IC pins 4,5,6,7,9,10,11, and 12
(see page 5 of the datasheet).
Each Pn corresponds to a bit number in the 8574 output port.
P0 is bit 0, P1 is bit 1, etc...
These Pn pins are wired up to the HD44780 LCD interface.
The LiquidCrystal_I2C class must be told how these 8574 Pn pins are wired up
to the HD44780 LCD.
The numbers in the constructor represent the bit numbers in the output port
and thus represent a Pn (or Px) pin.

In order to properly fill in the constructror you have to know how the
8574 pins are connected to the LCD pins
along with which 8574 pin is attached to the backlight circuit.
That is what you must now figure out.
The LCD interface will be put into 4 bit mode and be using:
EN, RS, RW, D4, D5, D5, D6, D7
and then there is potentially backlight control.

So now you must look at the PCF8574 Px pins and figure out where
each pin goes.
Trace the connections by following from the PCF8574 Pn pins
rather than from the LCD modules pins.
Start with P0 (PCF8574 pin 4) . Where does it go?
If it connects to LCD module pin 11, then you now know that P0 is connected to LCD D4
because pin 11 of a typical HD44780 LCD modules is D4.

Then go down each Pn pin on the 8574 to identify where it goes.
One of the Pn pins will connect over to the base of a transistor instead
of connecting to a LCD module pin.
That is for backlight control.

After you have identified where all the Pn pins go, you can then fill in the
LiquidCrystal_I2C constructor.
The one tricky part relates to the LCD module RW pin. (lcd module pin 5)
Some i2c backpacks hardware the LCD RW pin directly to ground.
Others wire the LCD RW pin to one of the Pn pins on the PCF8574.
The library expects to be told which PCF8574 Pn pin is connected
to the RW line. So if you find that the LCD module RW pin is not connected to
one of the Pn pins on the PCF8574, then when filling in the LCD constructor,
simply pick an unused 8574 Pn pin/bit that is not used for that constructor parameter.

I'm curious how your LCD backpack is wired up.
Post back as to how your lcd backpack is wired up
and I'm sure we can get it up and going.

--- bill

smithy,
can you post a clear photo, like your other one but of the top side of the backpack?

--- bill

Sorry i did not take a look into the sheet, I just did and read ur answer, ill post my measurings.

LCD Pin I2C Adapter pin
11 P0
12 P1
13 P2
14 P3
6 P4
5 P5
4 P6
nc P7
1 A0
2 VDD
3 Poti
7 nc
8 nc
9 nc
10 nc
15 pnp
16 A1

I traced without having it connected to the lcd.
LCD pin should be interpreted like i showed how it is plugged in my pictures.
P7 is completely missing, i guess thats the RW pin ?
7-10 not connected to the chip aswell.
Sorry my phone can´t boot the cache.img seems gone and i don´t really know how to fix that yet.

The backpack "smithy" has is visually identical - including the visible PCB tracks - to one I have operating on the shelf next to me using the descriptor:

       // addr, EN, RW, RS, D4, D5, D6, D7, Backlight, POLARITY
LiquidCrystal_I2C lcd(lcdAddr, 4, 5, 6, 0, 1, 2, 3, 7, NEGATIVE);

Smithy, you have so far failed to mention what I2C address you have found for the module - on mine it is 0x20 - and we haven't seen the code that is not successful to verify that you have actually inserted the correct address.

Unless you have the correct address, it certainly will not work and you may have overlooked that in the output of the i2cguesser sketch.

Paul,
If his pin connections he reported are correct, the constructor will not match yours.

smithy,
you reported:
You should lookup the HD44780 pinout as it will show what the LCD pin functions are.
I inserted them here, but you should familarize yourself with them by looking at
a pinout diagram.
Here is a nice photo/link:

LCD     8574
11(D4)  P0
12(D5)  P1
13(D6)  P2
14(D7)  P3
6 (EN)  P4
5 (RW)  P5
4 (RS)  P6
nc      P7
1       A0
2       VDD
3       Poti
7       nc
8       nc
9       nc      
10      nc
15      pnp
16      A1

We really need a photo of your board.

I'll toss out the "nc" for P7 which probably goes to a backlight control circuit (transistor)
since you said in response #24 that the backlight blinks.
In order for the backlight not be on or off all the time, something from the 8574 has
to be connected to a backlight circuit.

LCD connections on pins 1 and pin 16 are A0 and A1. What is A0 and A1???
LCD pins 1 and 16 must be connected to ground for the LCD and
the backlight to work.

So you are saying lcd pin 15 goes to "pnp" does that mean a pnp transistor?
If so what type is it and what leg/pin of the transistor does it go to?

If the pins you have are correct,
this translates into a constructor of:

                     // addr, EN,RW,RS,D4,D5,D6,D7,BL, POLARITY
LiquidCrystal_I2C lcd(lcdAddr, 6, 5, 4, 0, 1, 2, 3, 7, ??);

NOTE: (update 2013-11-24)
The above constructor above is incorrect given the pin information
provided.
(The 8574 bit numbers were transposed with the LCD pin numbers)
The correct consructor is:

                     // addr, EN,RW,RS,D4,D5,D6,D7,BL, POLARITY

LiquidCrystal_I2C lcd(lcdAddr, 4, 5, 6, 0, 1, 2, 3, 7, ??);



(I've left the rest of the post here to maintain the thread)

That pinout matches the pins used for fm's ElectroFun extra i/o backpack.
The current guesser sketch tries that pinout but only with a polarity of NEGATIVE.
It does not try a polarity of POSITIVE.
Given your LCD which is an inverted display, and if you really have a pnp transistor
on your board, then the polarity would need to be POSITIVE.
But then I'd think that LCD pin 15 would be connected to VCC (maybe through a resistor)
and LCD pin 16 would connect to the transistor.

Anway, I've updated the guesser sketch in the post to include

LiquidCrystal_I2C lcd(lcdAddr, 6, 5, 4, 0, 1, 2, 3, 7, POSITIVE);

http://forum.arduino.cc/index.php?topic=157817.msg1235230#msg1235230

But we really still need to get the proper wiring for your board.
You need figure out where P7 goes.
It would also help to show a photo of the top side of your board
The photo will allow us to see the traces and see what type of transistor is on your board.

--- bill

The Analog pins refer to the PFC chip (http://www.nxp.com/documents/data_sheet/PCF8574.pdf) to alter the address ?

The address of my adapter is 0x25 and the sktech itself finds it out, i even tested the adress with a different i2c lib which supports bus lockup detection.

Pin 15 leads to the 1st pnp connection (is labeled as pnp, so i guess it´s the transistor) and splits in two after.

I told a buddy to post a picture, meanwhile ill try figuring out if i can trace P7.
I just updated my measurings, hope this is more clear to you :

Adapter Pin PCF pin
11 P0
12 P1
13 P2
14 P3
6 P4
5 P5
4 P6
Res after pnp P7
1 A1- A3, GND, POT-, VSS
2 VDD, POT+, 5V
3 POT out (middle)
7 nc
8 nc
9 nc
10 nc
15 pnp
16 A1- A3, GND, POT-, VSS

7-10 simply have no PCB tracks.

You don´t need to update your sketch and upload it, i can just fill in the line in your struct but thanks anyways.

Using POSITIVE, will always result in the display staying off after blink and since i tried all possible backlight pins (0-16) it only blinks when i use 7 and stays on only using NEGATIVE.

Pics arrived :


hi i'm the one who gave smithy the blue i2c adapter... Got 4, gave one to smithy. I tested another blue module with the guesser tool (thx for that!))

my blue adapter works with setting 0x20, 4, 5, 6, 0, 1, 2, 3, 7, NEGATIVE

The thing that bothers me most is that my address is 0x25 even though my address pins are all low and it should be 0x20. The 4 boards even look like the same xD
Using the wire lockup lib i can even get a response from the device brain hurts

Paul,
Does the top/front of your PCB look like smithy's with no way
to set the i2c address and all the Address pins hard coded to ground?


Paul, smithy, (and others following this thread).

The information I posted in reponse #34 for the constructor was incorrect.
(I'll put a note about this in that response)
I accidentally mistranslated the bit numbers into the constructor for the
EN and RS pins.
EN is on LCD pin 6 but is P4, which is bit 4 not bit 6
RS is on LCD pin 4 but is P6, which is bit 6 not bit 4

So the proper constructor will use the same LCD bits as the constructor that Paul provided
which is also what I use on the mjkdz board that I have as well.
(Although my mjkdz board is a very different design than smithy's)

From the more recent photos,you can make out the transistor.
It is a 2TY (same as what is on mjkdz board) and that is PNP
transistor.
Given how it is wired, the backlight polarity will be NEGATIVE.

For a final constructor of:

                     // addr, EN,RW,RS,D4,D5,D6,D7,BL, POLARITY
LiquidCrystal_I2C lcd(i2cAddr, 4, 5, 6, 0, 1, 2, 3, 7, NEGATIVE);

smithy,
This constructor is in the guess list of the guesser sketch so it should have been found.

One thing that does concern me is the overall design,
in that there appears to be no way to set the address for the chip.
From looking at the photo, it appears that all 3 address pins
are connected together and then connected to ground.

There are also no bypass/decoupling caps on the board
along with no i2c pullups which could also cause issues
particuarly if there are no i2c pullups on the i2c bus somewhere
else.

smithy,
Can you confirm that the soldering of the 3 Address pins to the PCB look ok.
Also, do you have i2c pullups somewhere else on the i2c bus wires?
While it often works without them since the AVR has some internal ones,
they are required by the spec and the ones built into the AVR are too large and
so depending on the internal AVR pullups is not guaranteed to work.

--- bill

Can you confirm that the soldering of the 3 Address pins to the PCB look ok.

Yes they look like the others and i used them directly when i did my signal testing

There are also no bypass/decoupling caps on the board
along with no i2c pullups which could also cause issues
particuarly if there are no i2c pullups on the i2c bus somewhere
else.

I guess the Wire lib uses them automatically ? We didnt use any extra since it worked with all the devices we tried to communicate with.

I´m pretty sure that there is something wrong with the board since all addresses are connected to ground for sure and i have 0x25, crossbreak has the 3 other modules and all have 0x20 and work with your guesser, modules look exactly the same.