Go Down

Topic: problem interfacing LCD using I2C bus (Solved :) ) (Read 5 times) previous topic - next topic

sushant

Aug 21, 2012, 06:07 pm Last Edit: Aug 27, 2012, 01:54 pm by sushant Reason: 1
hi,
i was trying to interface 16x2 LCD to the Arduino using I2C bus, but despite all the efforts was unable to Display "Hello world" example.

informations:

1) i'm using pfc8574AP, the circuit is theone demonstrated herehttp://dangerousprototypes.com/2009/08/13/bus-pirate-hd44780-character-lcd-adapter/

2)A2,A1,A0 is connected to ground .so have assigned the address as 0x38 w.r.t the datasheet
3) have connected pull-down resistors of 4.7K (as per the instruction on various forums)

4)code used is:

Code: [Select]

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

LiquidCrystal_I2C lcd(0x38,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display

void setup()
{
 lcd.init();                      // initialize the lcd

 // Print a message to the LCD.
 lcd.backlight();
 lcd.print("Hello, world!");
 Serial.begin(57600);
}

void loop()
{
}

(code tags fixed by moderator - you were pretty close!)

need help in getting this thing working.

thanks,
Sushant

CrossRoads

Isn't there usually a part where you define the pins you are using with the library?

I didn't see any software or links to software at dangerous prototypes
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

CrossRoads

Oh, I2C = so you are connected to SCL/SDA?
You need this too then:
Wire.begin(address);

http://arduino.cc/en/Reference/Wire
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

CrossRoads

Check this too

http://arduino.cc/playground/Code/LCDi2c

"09-14-2009 Mario added support for using a standard HD44780 compatible LCD using the PCF8574 . The new library named "LiquidCrystal_I2C" and can be found here http://www.arduino.cc/playground/Code/LCDAPI "
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

m12lrpv

#4
Aug 22, 2012, 06:45 am Last Edit: Aug 22, 2012, 07:06 am by m12lrpv Reason: 1
Just quickly... I2C needs pullups not pulldowns


Also i'm looking at the TI datasheet for the PCF8574 and it suggests that the full address is not 0x32 (32 is actually the decimal value from the table)

According to page 4 it should be combined with the read write.

If I was you I'd forget the LCD for the moment and just connect the PCF8574 to some LED's. Once you get the address and the communication worked out connect it to the LCD.

m12lrpv

#5
Aug 22, 2012, 07:20 am Last Edit: Aug 22, 2012, 07:23 am by m12lrpv Reason: 1
Looking more at the datasheet the address almost seems to differ when you want to read or write to the device? Damn confusing the way it's written but you get that with some datasheets.

For a write the address could actually be 0x40 and for a read it could be 0x41.

Worth trying.

Something like this should give you alternating LED's
Code: [Select]

Wire.beginTransmission(0x40);
Wire.write(0xAA);
Wire.endTransmission();


Finally the arduino shouldn't need pullups. The internal ones are enabled by default and are usually sufficient.

CrossRoads

"the arduino shouldn't need [I2C] pullups.  The internal ones are enabled by default and are usually sufficient."

Barely. If you want decent rise times on the edges you need the 4.7K pullups.  I missed the reference to 4.7K pulldowns. See what you expect to see sometimes.
If you looked at the signals with a 'scope you would really appreciate the difference.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

m12lrpv

I don't have a scope so I simply rely on whether it works or not.

For arduino I didn't need them. For the attiny85 10k pullups worked nicely.

ReSiStAnCe


hi,
i was trying to interface 16x2 LCD to the Arduino using I2C bus, but despite all the efforts was unable to Display "Hello world" example.

informations:

1) i'm using pfc8574AP, the circuit is theone demonstrated herehttp://dangerousprototypes.com/2009/08/13/bus-pirate-hd44780-character-lcd-adapter/

2)A2,A1,A0 is connected to ground .so have assigned the address as 0x38 w.r.t the datasheet
3) have connected pull-down resistors of 4.7K (as per the instruction on various forums)


LiquidCrystal_I2C lcd(0x38,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display




When you look at the datasheet http://www.nxp.com/documents/data_sheet/PCF8574.pdf on page 10 you can see that the device-adress is 7 bits long.
Starting from A0,A1 and A2, then 0,0,1,0. So your adress is somewhere between b0100000 and b0100111 or between 0x20 and 0x27.
So if you set A0 - A1 low this is 0x20. You declare it as being 0x38. I assume the comment was not edited by you, so the original code adressed the device with A0 - A1 set high...


sushant

actually i wrongly wrote "pull down" instead of pull-up.

sushant



When you look at the datasheet http://www.nxp.com/documents/data_sheet/PCF8574.pdf on page 10 you can see that the device-adress is 7 bits long.
Starting from A0,A1 and A2, then 0,0,1,0. So your adress is somewhere between b0100000 and b0100111 or between 0x20 and 0x27.
So if you set A0 - A1 low this is 0x20. You declare it as being 0x38. I assume the comment was not edited by you, so the original code adressed the device with A0 - A1 set high...




the chip i'm using is PCF8574 AP and the datasheet gives below value for the address:

For PCF8574A the addressing is:
                  
A2   A1   A0   Dec   Hex   
L   L   L   56   0x38
L   L   H   57   0x39
L   H   L   64   0x40
L   H   H   74   0x4A
H   L   L   75   0x4B
H   L   H   76   0x4C
H   H   L   77   0x4D
H   H   H   78   0x4E

ReSiStAnCe


Quote


the chip i'm using is PCF8574 AP and the datasheet gives below value for the address:

For PCF8574A the addressing is:
                  
A2   A1   A0   Dec   Hex   
L   L   L   56   0x38
L   L   H   57   0x39
L   H   L   64   0x40
L   H   H   74   0x4A
H   L   L   75   0x4B
H   L   H   76   0x4C
H   H   L   77   0x4D
H   H   H   78   0x4E



My bad. You are right.
The table however should be 0x39,0x3A,0x3b etc.. ending with 0x3F

m12lrpv

#12
Aug 23, 2012, 12:27 am Last Edit: Aug 27, 2012, 08:06 am by m12lrpv Reason: 1

the chip i'm using is PCF8574 AP and the datasheet gives below value for the address:

For PCF8574A the addressing is:
                  
A2   A1   A0   Dec   Hex   
L   L   L   56   0x38
L   L   H   57   0x39
L   H   L   64   0x40
L   H   H   74   0x4A
H   L   L   75   0x4B
H   L   H   76   0x4C
H   H   L   77   0x4D
H   H   H   78   0x4E

The TI sheet I looked at didn't have the A version.

Are you using the NXP chip?

If so check the datasheet again, Page 9 specifically, and see that it tells you to include the LSB which you needed to do anyway and haven't, as you can see on pages 10 and 11.

Your address should be 0b01110000 = 0x70 = 112


Edit: i'm wrong. Wire adds the LSB

ReSiStAnCe

[quote ]
Are you using the NXP chip?

If so check the datasheet again, Page 9 specifically, and see that it tells you to include the LSB which you needed to do anyway and haven't, as you can see on pages 10 and 11.

Your address should be 0b01110000 = 0x70 = 112

[/quote]

The LSB from this byte is the R/W bit and has nothing to do with the adress off the device. You do have to send it though..

m12lrpv


The LSB from this byte is the R/W bit and has nothing to do with the adress off the device. You do have to send it though..


It has everything to do with the address value that you send to a library that expects an 8 bit address.

Lets see you use the wire library beginning with the transmission of a 7 bit address followed by the transmission of a single read/write bit.

...


Go Up