Pages: [1] 2   Go Down
Author Topic: problem interfacing LCD using I2C bus (Solved :) )  (Read 3895 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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
« Last Edit: August 27, 2012, 06:54:54 am by sushant » Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 437
Posts: 23718
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

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.

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 437
Posts: 23718
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

http://arduino.cc/en/Reference/Wire
Logged

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.

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 437
Posts: 23718
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 "
Logged

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.

Australia
Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: August 22, 2012, 12:06:53 am by m12lrpv » Logged

Australia
Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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.
« Last Edit: August 22, 2012, 12:23:36 am by m12lrpv » Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 437
Posts: 23718
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

"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.
Logged

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.

Australia
Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 43
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 43
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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
Logged

Australia
Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: August 27, 2012, 01:06:39 am by m12lrpv » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 43
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

[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..
Logged

Australia
Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

...

Logged

Pages: [1] 2   Go Up
Jump to: