Pages: [1] 2   Go Down
Author Topic: How to use this PCF8574 board from "emall-4u"  (Read 2483 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is labeled LCM1602-IIC.

The address and the sample code are, not surprisingly, wrong.  The address of the one that I am using is 0x20, not 0x27, and you do have to set up the pins in order.  My Arduino Serial board has its SCL on A0, and its SDA on A1.

I traced the connections using an ohmmeter, and here is the correct line of code.  First I track all the relevant pins to the chip, then I use the chip's documentation to find out which of the P0 to P7 chips it is.  It is not nearly as easy to trace the pin that controls the backlight, but there are eight possibilities, seven already traced, so it's the one that is left.  I have it working and properly backlit:

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

Just in case anyone might need the information. 

This is the adapter:  http://www.ebay.com/itm/390527380190?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649
Logged

Dallas, TX USA
Offline Offline
Edison Member
*
Karma: 47
Posts: 2341
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Which library?
Based on the constructor, I'm assuming it is fm's library but It would be useful to also say which library is used (a link to the library would be even better).
--- bill
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 26
Posts: 4113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The address of the one that I am using is 0x20, not 0x27, ...

It looks like you may be able to change the address from 0x20 to 0x27, or to any of the other six addresses in between, by dealing with the solder blobs above A0, A1 and A2. 

Don
Logged

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

It is fm's library.  https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads/LiquidCrystal_V1.2.1.zip
Logged

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

Im also using the emall4u board. It's not working with the pins you posted. What screen are you using? Also im using a Nano-board. Wich seems to also cause problems for some people smiley

Since the backlight turns on i gather that the arduino and IIC are talking. Wich leaves 2 options. The pins are wrong or there is something wrong with the IIC-board.

Since i get two out of 4 lines filled with black blobs, im leaining against option number one...
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 26
Posts: 4113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Since i get two out of 4 lines filled with black blobs, im leaining against option number one...
Regardless of the interface used or anything else this symptom signifies that the LCD is getting power, the contrast is OK (but maybe not optimum) and the LCD controller is not initialized correctly.

Don
Logged

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

Quote
Since i get two out of 4 lines filled with black blobs, im leaining against option number one...
Regardless of the interface used or anything else this symptom signifies that the LCD is getting power, the contrast is OK (but maybe not optimum) and the LCD controller is not initialized correctly.

Don

Ok. Not initializing, that could also be wrong pins or pin order in the init command right?
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 26
Posts: 4113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Ok. Not initializing, that could also be wrong pins or pin order in the init command right?
Yes, those are some of the possible reasons.

Of course if you posted a photograph of your connections and a copy of your code we could help you guess.


Don
Logged

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

Quote
Ok. Not initializing, that could also be wrong pins or pin order in the init command right?
Yes, those are some of the possible reasons.

Of course if you posted a photograph of your connections and a copy of your code we could help you guess.


Don

For now im using an example code..

Code:
/* YourDuino.com Example Software Sketch
 20 character 4 line I2C Display
 terry@yourduino.com */

/*-----( Import needed libraries )-----*/

#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>  // F Malpartida's NewLiquidCrystal library

/*-----( Declare Constants )-----*/
#define I2C_ADDR    0x20  // Define I2C Address for the PCF8574A
#define BACKLIGHT_PIN  7
#define En_pin  4
#define Rw_pin  5
#define Rs_pin  6
#define D4_pin  0
#define D5_pin  1
#define D6_pin  2
#define D7_pin  3

#define  LED_OFF  0
#define  LED_ON  1

/*-----( Declare objects )-----*/  

LiquidCrystal_I2C  lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

void setup()
{

  lcd.begin (20,4);  // initialize the lcd
  lcd.setBacklightPin(BACKLIGHT_PIN,NEGATIVE);
  lcd.setBacklight(LED_ON);

}

void loop()

{

// Reset the display  
  lcd.clear();
  delay(1000);
  lcd.home();
  
// Print our characters on the LCD
  lcd.backlight();  //Backlight ON if under program control
  lcd.setCursor(3,0); //Start at character 3 on line 0
  lcd.print("Hello, world!");
  delay(1000);
  lcd.setCursor(2,1);
  lcd.print("From YourDuino");
  delay(1000);  
  lcd.setCursor(0,2);
  lcd.print("20 by 4 Line Display");
  lcd.setCursor(0,3);
  delay(2000);  
  lcd.print("http://YourDuino.com");
  delay(8000);
} // END Loop

This code turns the baklight on and of and displays (as stated before) only blobs on line 1 and 3. I have attached images of my setup.

The display i use comes with this information:

Quote
2004A LCD Screen J204A Character Display LCD Module 20x4 5v LCD / LCM (Blue)
Description:

Type: LCM2004A
Packaging: COB
Physical size: 98 mm x sixty mm
Connection mode: conductive rubber strip
Horizon size: 76 mm x 26 mm
Interface mode: single parallel
Dot size: 0.55 mm x 0.55 mm
Backlight type: EL/LED
Character size: 29.5 mm x 47.5 mm
Display content: twenty character x 4 line
Working voltage: + 5 V / + 3.3 V
Working temperature: -10°c~ +60°c
Controller: SPLC780

The chip on the "emall-4u I2C" says PCF8574T.

Not sure what else to give you..

Edit: Well, if i try to post images the page doesn't even want to try if i hit post. So i will explain my setup.

Arduino nano V3.0 (china-board)

SDA --> Analog 4
SCL --> Analog 5

Both with pullup to 5v
« Last Edit: March 23, 2013, 11:50:08 am by puttelino » Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 26
Posts: 4113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The chip on the "emall-4u I2C" says PCF8574T.

Not sure what else to give you..
Did you read the stuff above the point where you joined the thread, about the I2C address?


Quote
Edit: Well, if i try to post images the page doesn't even want to try if i hit post....
What technique did you try?

Don
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The chip on the "emall-4u I2C" says PCF8574T.

Not sure what else to give you..
Did you read the stuff above the point where you joined the thread, about the I2C address?


Quote
Edit: Well, if i try to post images the page doesn't even want to try if i hit post....
What technique did you try?

Don

Have you declared the address elswhere?

Code:
/*-----( Import needed libraries )-----*/
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>  // F Malpartida's NewLiquidCrystal library
//Download: https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Move original LiquidCrystal library elsewhere, copy this in it's place

/*-----( Declare Constants )-----*/
#define I2C_ADDR    0x20  // Define I2C Address for the PCF8574A
//---(Following are the PCF8574 pin assignments to LCD connections )----
// This are different than earlier/different I2C LCD displays
#define BACKLIGHT_PIN  7
#define En_pin  4
#define Rw_pin  5
#define Rs_pin  6
#define D4_pin  0
#define D5_pin  1
#define D6_pin  2
#define D7_pin  3

#define  LED_OFF  0
#define  LED_ON  1

/*-----( Declare objects )-----*/ 
LiquidCrystal_I2C  lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
Logged

Dallas, TX USA
Offline Offline
Edison Member
*
Karma: 47
Posts: 2341
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Im also using the emall4u board. It's not working with the pins you posted. What screen are you using? Also im using a Nano-board. Wich seems to also cause problems for some people smiley
If your i2c board was the same, then it should work.
This is starting to turn into a thread hyjack.
(A new thread for your issues would be better)



Quote
Since the backlight turns on i gather that the arduino and IIC are talking. Wich leaves 2 options. The pins are wrong or there is something wrong with the IIC-board.
Not necessarily. The backlight may be on by default.
They key to getting it to work, is to do what Tomki did.
Figure how how the i2c chip is wired up to the LCD.
From that, it is fairly easy to determine the proper constructor for fm's library.

With respect to initialization,
I would use the newer larger constructor like Tomki did vs using the legacy lcd.setBacklightPin() function.
fm's latest code now attempts to turn on the backlight by default before lcd.begin() returns.
The backlight will be on when lcd.begin() returns assuming the i2c address and pins in the constructor are correct

My preference is also to use the lcd.backight() and lcd.noBacklight() vs lcd.setBacklight(value)
to turn the LCD backlight on an off since those are compatible with interfaces that support dimming.
Using lcd.setBacklight(1) will be a very dim backlight on interfaces that support dimming.

The sample code you posted is not turning the backlight on and off. So if you see it flickering,
then something is wrong - more than likely incorrect pins in the constructor.

To test the backlight pin and mode in the constructor, all you have to do is
try something like:

Code:
loop()
{
    lcd.backlight();
    delay(1000);
    lcd.nobacklight();
    delay(1000);
}
But guessing is not the answer. The real solution, is trace the wires from the PCF8574 to the LCD interface
you can either to it visually or with an ohm meter.
Once you know where the wires go, then getting the constructor correct is easy.

--- bill

Logged

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

Quote
The chip on the "emall-4u I2C" says PCF8574T.

Not sure what else to give you..
Did you read the stuff above the point where you joined the thread, about the I2C address?


Quote
Edit: Well, if i try to post images the page doesn't even want to try if i hit post....
What technique did you try?

Don

Have you declared the address elswhere?

Code:
/*-----( Import needed libraries )-----*/
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>  // F Malpartida's NewLiquidCrystal library
//Download: https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Move original LiquidCrystal library elsewhere, copy this in it's place

/*-----( Declare Constants )-----*/
#define I2C_ADDR    0x20  // Define I2C Address for the PCF8574A
//---(Following are the PCF8574 pin assignments to LCD connections )----
// This are different than earlier/different I2C LCD displays
#define BACKLIGHT_PIN  7
#define En_pin  4
#define Rw_pin  5
#define Rs_pin  6
#define D4_pin  0
#define D5_pin  1
#define D6_pin  2
#define D7_pin  3

#define  LED_OFF  0
#define  LED_ON  1

/*-----( Declare objects )-----*/ 
LiquidCrystal_I2C  lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

Oh... It's there. I just managed to delete while i cleaned the code for the forum. I will edit the post..
Logged

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

So i traced all the pins. Seems the thread starter has the right combination for my setup aswell. Now what?

Edit: I2C-detec finds an adress att 0x20 aswell...
« Last Edit: March 23, 2013, 02:34:12 pm by puttelino » Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 26
Posts: 4113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
This is starting to turn into a thread hyjack.
(A new thread for your issues would be better)
I originally used that term, but I am mellowing as I age and I went back and changed it to read "...where you joined the thread...".

Quote
Oh... It's there. I just managed to delete while i cleaned the code for the forum. I will edit the post..
AARRGGHH...  We need to see the code that you actually used, not the code that you think you used or that you would have liked to have used.  We need a copy/paste from the IDE.

Don
Logged

Pages: [1] 2   Go Up
Jump to: