Offline
Newbie
Karma: 0
Posts: 11
|
 |
« on: August 21, 2012, 11:07:27 am » |
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 here http://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: #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
Brattain Member
Karma: 249
Posts: 16572
Available for Design & Build services
|
 |
« Reply #1 on: August 21, 2012, 01:36:36 pm » |
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
|
|
|
|
|
Global Moderator
Boston area, metrowest
Offline
Brattain Member
Karma: 249
Posts: 16572
Available for Design & Build services
|
 |
« Reply #2 on: August 21, 2012, 01:41:14 pm » |
Oh, I2C = so you are connected to SCL/SDA? You need this too then: Wire.begin(address); http://arduino.cc/en/Reference/Wire
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Boston area, metrowest
Offline
Brattain Member
Karma: 249
Posts: 16572
Available for Design & Build services
|
 |
« Reply #3 on: August 21, 2012, 01:43:02 pm » |
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
|
|
|
|
|
Australia
Offline
Jr. Member
Karma: 0
Posts: 61
|
 |
« Reply #4 on: August 21, 2012, 11:45:59 pm » |
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
Jr. Member
Karma: 0
Posts: 61
|
 |
« Reply #5 on: August 22, 2012, 12:20:17 am » |
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 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
Brattain Member
Karma: 249
Posts: 16572
Available for Design & Build services
|
 |
« Reply #6 on: August 22, 2012, 12:33:23 am » |
"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
|
|
|
|
|
Australia
Offline
Jr. Member
Karma: 0
Posts: 61
|
 |
« Reply #7 on: August 22, 2012, 01:15:12 am » |
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
Newbie
Karma: 0
Posts: 43
Arduino rocks
|
 |
« Reply #8 on: August 22, 2012, 11:04:48 am » |
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 here http://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
Newbie
Karma: 0
Posts: 11
|
 |
« Reply #9 on: August 22, 2012, 01:11:33 pm » |
actually i wrongly wrote "pull down" instead of pull-up.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 11
|
 |
« Reply #10 on: August 22, 2012, 01:14:59 pm » |
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
Newbie
Karma: 0
Posts: 43
Arduino rocks
|
 |
« Reply #11 on: August 22, 2012, 03:41:22 pm » |
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
Jr. Member
Karma: 0
Posts: 61
|
 |
« Reply #12 on: August 22, 2012, 05:27:39 pm » |
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 0b0111 0000 = 0x70 = 112 Edit: i'm wrong. Wire adds the LSB
|
|
|
|
« Last Edit: August 27, 2012, 01:06:39 am by m12lrpv »
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 43
Arduino rocks
|
 |
« Reply #13 on: August 23, 2012, 12:58:36 am » |
[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
Jr. Member
Karma: 0
Posts: 61
|
 |
« Reply #14 on: August 23, 2012, 01:16:25 am » |
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
|
|
|
|
|
|