Go Down

Topic: Troubleshooting an i2c 16x2 LCD - no data seen (Read 845 times) previous topic - next topic

anishkgt

Hi All,

i am trying to troubleshoot my PCB which has 16x2 LCD on an i2c bus. Not very good at it.


Any help would be appreciated.


The code does work when I used a prebuilt one from eBay. I've replaced the I/O expander, the transistor and checked SDA and SCL for continuity, all looks good but still nothing seems to be working. The back light just blinks and goes OFF and the first row in the LCD just shows thick blocks leaving the second row blank.My I/O expander reads as PCF8547AT.

My Display initialization code is as follows:
Code: [Select]
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h>
hd44780_I2Cexp lcd;

Paul__B

i am trying to troubleshoot my PCB which has 16x2 LCD on an i2c bus. Not very good at it.
Right, so you built your own PCB.  From where did you get that circuit or is it your own invention?  Otherwise put, how did you know which connections to make between the PCF8574 and the LCD?

The code does work when I used a prebuilt one from eBay.
So you have tested it with one.

I've replaced the I/O expander, the transistor and checked SDA and SCL for continuity, all looks good but still nothing seems to be working. The back light just blinks and goes OFF and the first row in the LCD just shows thick blocks leaving the second row blank.My I/O expander reads as PCF8547AT.
What does "reads as PCF8547AT" mean?

My Display initialization code is as follows:
Code: [Select]
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h>
hd44780_I2Cexp lcd;

OK, I gather you are - correctly - using bperrybap's hd44780_I2Cexp library - and that is how you identify the PCF8547.  Well, if you are doing that, you will need to use one of the connection arrangements which it recognises, which are based on the known library of these interface boards.  If you made up your own connection plan or copied it wrongly from another, it may not work.

He will likely come past and look at your schematic to verify this.

In the meantime, you may care to correct a blunder which has been inherited by less-than-competent designers of many of these boards.  Do not connect the potentiometer which connects to Vo pin 3, to 5 V - either leave that end of the potentiometer unconnected or better, connect it back to the wiper.  This is not your present problem at all (because all the boards in use with this error do work), but it will make contrast setting easier and save 500 µA of current.  You should of course do this where possible, on all the devices you have.


anishkgt

initiall i started with the circuit from here. This was advised by TerryKing228 on his website. So followed it.

It worked on my previous revision of the board but for some reason it does not seem to be working now.

groundFungus

Does the I2C expander (PCF8574) show up in an I2C scanner?

The hd44780 library comes with a diagnostic sketch.  It is in the examples for the hd44789I2Cexp ioclass examples.  Load and run that sketch and post the results. 

anishkgt

Here is the output

Quote
********************************************************************
Serial Initialized
--------------------------------------------------------------------
I2CexpDiag - i2c LCD i/o expander backpack diagnostic tool
--------------------------------------------------------------------
hd44780 lib version: 1.0.1
--------------------------------------------------------------------
Reported Arduino Revision: 1.8.5
CPU ARCH: AVR - F_CPU: 16000000
--------------------------------------------------------------------
SDA digital pin: 18 A4
SCL digital pin: 19 A5
--------------------------------------------------------------------
Checking for required external I2C pull-up on SDA - YES
Checking for required external I2C pull-up on SCL - STUCK LOW
Checking for I2C pins shorted together - Shorted
********************************************************************
ERROR: SDA and SCL shorted together
********************************************************************
I2C bus not usable

anishkgt

Not sure why the SCL lines reads low at boot up. When i reset manually via the reset button it reads HIGH on both pins.
Quote
Reported Arduino Revision: 1.8.5
CPU ARCH: AVR - F_CPU: 16000000
--------------------------------------------------------------------
SDA digital pin: 18 A4
SCL digital pin: 19 A5
--------------------------------------------------------------------
Checking for required external I2C pull-up on SDA - YES
Checking for required external I2C pull-up on SCL - YES
Checking for I2C pins shorted together - Not Shorted
--------------------------------------------------------------------
Scanning i2c bus for devices..
 i2c device found at address 0x20
Total I2C devices found: 1
--------------------------------------------------------------------
Scanning i2c bus for all lcd displays

anishkgt

#6
Oct 10, 2018, 11:04 pm Last Edit: Oct 10, 2018, 11:05 pm by anishkgt
My schematic is as follows, the only difference from the previous is i've added pullup resistors to the SDA and SCL lines.

bperrybap

I noticed a couple of things.
The pin mapping you are now using is different than before
Your current mapping is:
RS P4
RW P5
EN P6
D4 P0
D5 P1
D6 P2
D7 P3
BL P7
BL active Level  HIGH


This is the pin mapping for the ElectroFun LCDxIO board with an added NPN transistor for backlight control.
http://www.electrofunltd.com/2011/10/i2c-lcd-extra-io.html
No other backpack uses that pin mapping.
While it should work, I haven't tested it with a NPN transistor (active HIGH).
There may be an auto detect issue there.

The pin mapping you showed in the IB schematic in the other thread is:
RS P6
RW P5
EN P4
D4 P0
D5 P1
D6 P2
D7 P3
BL P7
BL  Active Level HIGH


This pin mapping is fairly common and is used in several backpacks like those labeled
mjkdz or GY-I2CLCD.


Note that these two pin mappings are not the same.
The RS and EN pin assignments are flipped.

In looking at post #4 there may be some kind of wiring/soldering issue.
When using an AVR based Arduino, the only way I can think of to get a reported short between SDA and SCL is a wiring issue or a soldering issue.

The schematic in the original post has pullups shown.
So I don't understand your comment in post #6
Quote
My schematic is as follows, the only difference from the previous is i've added pullup resistors to the SDA and SCL lines.
Am I missing something? I don't see any difference in the two schematics.


In post #5 the diag output was cut off.
The missing portion of the diagnostic contains useful information about the detected pin mapping.



Can you post some photos of your board?

Given pre-made backpacks are so inexpensive, unless this is part of a larger PCB for a project, why not use an off the shelf backpack?

--- bill







anishkgt

#8
Oct 11, 2018, 11:56 am Last Edit: Oct 11, 2018, 11:59 am by anishkgt
These are just prototypes. I may use the pre-made ones with another PCB that would hold the buttons. This design i just had the pull-up resistors added in the schematic which was not there in the previous.




Paul__B

First schematic:


Second schematic:


The illegibility of the second prevents me from figuring out what the extra four pins added to the interface socket do, if indeed anything, and The pull-ups are shown in both.

You have apparently ignored my correction regarding the contrast potentiometer.

bperrybap

What about the missing diagnostic output?
Can you post that?

anishkgt

here power the main PCB and then connect the LCD and it shows SDA and SCL are pulled up
Quote
********************************************************************
Serial Initialized
--------------------------------------------------------------------
I2CexpDiag - i2c LCD i/o expander backpack diagnostic tool
--------------------------------------------------------------------
hd44780 lib version: 1.0.1
--------------------------------------------------------------------
Reported Arduino Revision: 1.8.5
CPU ARCH: AVR - F_CPU: 16000000
--------------------------------------------------------------------
SDA digital pin: 18 A4
SCL digital pin: 19 A5
--------------------------------------------------------------------
Checking for required external I2C pull-up on SDA - YES
Checking for required external I2C pull-up on SCL - YES
Checking for I2C pins shorted together - Not Shorted
--------------------------------------------------------------------
Scanning i2c bus for devices..
 i2c device found at address 0x20
 i2c device found at address 0x24
Total I2C devices found: 2
--------------------------------------------------------------------
Scanning i2c bus for all lcd displays
No working LCD devices
Now i leave the LCD connected and reset the board and i get SCL - Stuck LOW
Quote
********************************************************************
Serial Initialized
--------------------------------------------------------------------
I2CexpDiag - i2c LCD i/o expander backpack diagnostic tool
--------------------------------------------------------------------
hd44780 lib version: 1.0.1
--------------------------------------------------------------------
Reported Arduino Revision: 1.8.5
CPU ARCH: AVR - F_CPU: 16000000
--------------------------------------------------------------------
SDA digital pin: 18 A4
SCL digital pin: 19 A5
--------------------------------------------------------------------
Checking for required external I2C pull-up on SDA - YES
Checking for required external I2C pull-up on SCL - STUCK LOW
Checking for I2C pins shorted together - Shorted
********************************************************************
ERROR: SDA and SCL shorted together
********************************************************************
I2C bus not usable

anishkgt

First schematic:


Second schematic:


The illegibility of the second prevents me from figuring out what the extra four pins added to the interface socket do, if indeed anything, and The pull-ups are shown in both.

You have apparently ignored my correction regarding the contrast potentiometer.

I've not ignored your correction on the contrast pot. I've not left any pin floating one connected to 5v and the other pin to GND. The sweep is connected to pin Vo

bperrybap

So it appears that you have two custom PCBs.
- a main processor board
- an i/o board with the PCF8574 and the LCD.
A 10 pin cable between them.

A few more questions.
Where does the AVR and LCD get is power?
Is it always from mains? from USB? or can it from either mains or USB?


Are you using auto reset with a bootloader to program the AVR or are you using ISP programming?
The reason I ask is that auto reset can hold the reset down on the AVR for a bit of extra time at power up.
If that isn't there, then the AVR can start running before the 5V supply is stable and all the way up to 5v.
This could cause issues on the i2c lines.
Actually this is a normal occurrence but auto reset tends to hold off the AVR for a few extra milliseconds which can allow the 5v supply to rise up a bit more during this time period.
Also the AVR fuse settings can affect how long the AVR holds off at powerup before starting.

How long is the 10 pin cable between the two boards?

A potential issue is that the 5v power supply used by the AVR and the LCD may not be stable before the AVR is off and running.
This is quite common including on typical Arduino boards.
I do have an added delay to account for this potential in the library but the delay in the diag code is only 5ms before it starts probing the I2C signals which likely is not enough in certain environments.

Have you looked at the 5v supply voltage going to the AVR and LCD to see if there is a long rise time before it reaches 5v?
I've seen some power supplies take many 10s of milliseconds to stabilize up to full voltage.

As a test could  you put a small tweak in the I2CexpDiag code?
Change line 289 in setup() from a delay(5) to delay(500)
That should be more than enough time to guarantee that the 5v supply voltage is all the way up.



--- bill

anishkgt

Quote
Where does the AVR and LCD get is power?
Always from the mains.
Quote
Are you using auto reset with a bootloader to program the AVR or are you using ISP programming?
Yes it uses arduino Bootloader and sketches are uploaded via the USB.
Quote
How long is the 10 pin cable between the two boards?
5 to 10cm
Quote
Have you looked at the 5v supply voltage going to the AVR and LCD to see if there is a long rise time before it reaches 5v?
Nope never had to, I could have look though.
Quote
As a test could  you put a small tweak in the I2CexpDiag code?
Change it to 500

and the SCL pin still shows STUCK LOW

Quote
********************************************************************
Serial Initialized
--------------------------------------------------------------------
I2CexpDiag - i2c LCD i/o expander backpack diagnostic tool
--------------------------------------------------------------------
hd44780 lib version: 1.0.1
--------------------------------------------------------------------
Reported Arduino Revision: 1.8.5
CPU ARCH: AVR - F_CPU: 16000000
--------------------------------------------------------------------
SDA digital pin: 18 A4
SCL digital pin: 19 A5
--------------------------------------------------------------------
Checking for required external I2C pull-up on SDA - YES
Checking for required external I2C pull-up on SCL - STUCK LOW
Checking for I2C pins shorted together - Shorted
********************************************************************
ERROR: SDA and SCL shorted together
********************************************************************
I2C bus not usable

Go Up