Using I2C - Question

Go To Last Post
12 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I was using a lcd 2x16 in a parallel mode (4bit) in a PORTC of ATmega32. with lcd.h file.

As i want to convert the communication in i2c level, i tried several times with this libraries without positive results.

http://davidegironi.blogspot.it/...

A few minutes before i see this mistake in my code:

DDRC = 0xFF; // for lcd

But i didn't see anything about error or warning.
SDA and SCL signals are contained in PORTC. More specific in PC0 and PC1.

The lcd.h which using before its a base library for i2c lcd library, for communication through i2c. so it isn't need to change the methods in my main program (both libraries use same methods). So i change just the header.
DDRC=0xFF it was necessary for my lcd program with lcd.h (without i2c).
but i forget to delete this line.

The question is: could is this the problem?

PS: this is my module
http://www.ebay.com/itm/31056536...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The common problem with I2C is that the punter can not afford to buy two external pull-up resistors.

It looks as if your module has got built-in 4k7 pull-ups.

No, I have not looked at the Girone code. If it uses the hardware TWI, the state of DDRC is irrelevant. (a 30k internal pull-up is unnoticeable with an external 4k7 in parallel)

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i had tried 10k pull-up resistor.

whats the diference between 4k7 10k 30k pull-up?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quite honestly, if you only have one or two I2C devices on the bus, there will not be much capacitance.
So 30k will probably 'work' at 100kHz bus.

I suggest that you identify how your adapter is wired.
Most adapters connect LCD_RS to P0 and LCD_D4-D7 to P4-P7
Some adapters connect LCD_RS to P4 and LCD_D4-D7 to P0-P3
Girone connects LCD_RS to P6 and LCD_D4-D7 to P0-P3

Likewise, some use PCF8574 and others use PCF8574A.
You appear to have 7-bit Slave address of 0x27

I have not looked at Girone's code. But it is probably specifically written for his 'unusual' wiring.

I suggest that you test your LCD with an Arduino. The Arduino library allows you to configure the PCF pins in any order, and select any Slave address.

Once you have identified your particular wiring, it is easy to write a suitable C driver.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i tried my hardware directly in arduino leonardo.
My hardware:
-Arduino
http://www.ebay.com/itm/31063477...
-i2c lcd module
http://www.ebay.com/itm/31056536...

i put pull-up resistors 4k7 on SDA SCL lines.
power spply through USB.

Software:
i take library from here:
http://hmario.home.xs4all.nl/ard...
example its from zip file which i download.
i add the library sketch->import library ->add->zip file.

//DFRobot.com
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include  
#include 

LiquidCrystal_I2C lcd(0x27,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!");
}

void loop()
{
}

i had burned the code to my arduino but nothing its working :(
i see a black solid blocks in the first line.
i adjusting the contrast but "hello world" its not here.

the module has PCF8574T, A0,A1,A2 are unconnected and i measure with meter 4.65V so i thing its 111, 0x27 adress

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Look at this tutorial http://magnusglad.wordpress.com/2013/03/16/arduino-lcd/

Install the "Second Library" to run the example program.
i.e. your library does not have this constructor:

   /*!
    @method     
    @abstract   Class constructor. 
    @discussion Initializes class variables and defines the I2C address of the
    LCD. The constructor does not initialize the LCD.
    
    @param      lcd_Addr[in] I2C address of the IO expansion module. For I2CLCDextraIO,
    the address can be configured using the on board jumpers.
    @param      En[in] LCD En (Enable) pin connected to the IO extender module
    @param      Rw[in] LCD Rw (Read/write) pin connected to the IO extender module
    @param      Rs[in] LCD Rs (Reset) pin connected to the IO extender module
    @param      d4[in] LCD data 0 pin map on IO extender module
    @param      d5[in] LCD data 1 pin map on IO extender module
    @param      d6[in] LCD data 2 pin map on IO extender module
    @param      d7[in] LCD data 3 pin map on IO extender module
    */
  LiquidCrystal_I2C(uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs, 
                     uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
                     uint8_t backlighPin, t_backlighPol pol);
 

You don't even need a multimeter. You can follow the pcb traces from the PCF to the LCD.

I am on a different PC at the moment. There are several Libraries with the 'full-featured' constructor.

There is also another Arduino Tutorial that explains the different adapter modules. You might find it from my previous posts.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

it works!
thanks.

so this mean my hardware its ok!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

1. Most adapters connect LCD_RS to P0 and LCD_D4-D7 to P4-P7
2. Some adapters connect LCD_RS to P4 and LCD_D4-D7 to P0-P3
3. Girone connects LCD_RS to P6 and LCD_D4-D7 to P0-P3

So is your adapter type #1 or #2?
Or something completely different.

If you find the Arduino tutorial that describes the different Ebay adapters, it would be worth adding your photo.

It is nice that 99% Arduino LCD libraries have the same API for the class methods.
Unfortunately, they seem to vary in their constructors!

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

this is my pins diagram, pcf3 not connected anywhere

-------LCD------   ---PCF8574T----
1	gnd		
2	vcc		
3	contrast	
4	rs		pcf0		
5	rw		pcf1
6	e		pcf2
7	db0
8	db1
9	db2		
10	db3		
11	db4		pcf4
12	db5		pcf5
13	db6		pcf6
14	db7		pcf7
15	+led		led_jumper
16	-led		led_jumper
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are you sure?
You appear to have a type#1 adapter. They tend to have the backlight connected to pcf3 via a transistor.

Hence the Arduino diagnostic program can turn the backlight on and off.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
Are you sure?
You appear to have a type#1 adapter. They tend to have the backlight connected to pcf3 via a transistor.

Hence the Arduino diagnostic program can turn the backlight on and off.

David.


the backlight controlled by jumper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

there's already lcd.setBacklight(HIGH); function on my arduino program. but the backlight its off while jumper is out

EDIT: Yes, its controlled by software while jumper is on