LCD using MCP23017 i2C

Hi fellow Arduino'ers,

I'm trying to interface with an LCD screen, via my arduino using i2c by integrating a port extender (mcp23017). I did use the tutorial of "Nick Gammon" well known on this forum of course. (this tutorial: http://www.gammon.com.au/forum/bbshowpost.php?id=10940&page=1 )

I've connected everything as described by Nick, but my lcd screen uses slightly different pin configuration then commonly used lcd's. I've taken these difference into account and adapted my circuit.

http://www.voti.nl/docs/LCD-19-HG1286418C-VA.pdf

Unfortunately i'm not able to get my lcd up and running. I'm however able to change the contrast of the display with the potmeter, which results in a dark background or of course, an empty one.

Any suggestions to get my lcd up and running?

Thank you in advance & kindest regards, Niels

I´ve also tried to connect the display directly to my arduino. By using the glcd library I was able to at least test the display itself, with succes.

I did check my wiring several times using the mcp23017 but can´t find a problem... I guess it´ll be something I need to change in the "i2c lcd" library in order to adapt to my lcd pin mapping (Though this, sounds very unlogic. Since I did adapt the wiring going from lcd to mcp23017, according to the different pin mapping).

Any suggestions?

Niels,

hi, i too am facing the same problem with Pcf8574 I2C interface. did u entered the correct address of the I2C device? there is a sketch called I2c scanner which will provide you with the correct address of the device. here is the linkhttp://arduino.cc/playground/Main/I2cScanner

Yes, i've done a i2c scan by which I was able to communicate with my device... What kind of display are you using?

Oke, I’ve taken a look in the library of Nick gammon in which I found something which could cause my problem.

void I2C_graphical_LCD_display::cmd (const byte data)
{
  startSend ();
    doSend (GPIOA);                      // control port
    doSend (LCD_RESET | LCD_ENABLE | _chipSelect);   // set enable high (D/I is low meaning instruction) 
    doSend (data);                       // (command written to GPIOB)
    doSend (LCD_RESET | _chipSelect);    // (GPIOA again) pull enable low to toggle data 
  endSend ();
} // end of I2C_graphical_LCD_display::cmd

The code before the comment on the 5th line is what takes my attention. When I look at the lcd’s database the pin mapping port D/I is at pin 16, but the comment which follows tells me that low is meaning Data and high is instruction.

Anyone who can tell me how to swap this?
Probably there are more problems in the code in relation to my lcd screen.
Regards,
Niels

Schermafbeelding 2012-08-24 om 20.59.04.png

In the .h file:

#define LCD_DATA   0b00100000   // 1xxxxxxx = data; 0xxxxxxx = instruction  (pin 26)  0x20

If the sense is reversed then you would need to ‘or’ in LCD_DATA in the places it doesn’t currently do it, and not ‘or’ it in, in the other places.

Maybe the simplest fix:

#define LCD_DATA          0b00000000   // 0xxxxxxx = data; 1xxxxxxx = instruction  (pin 26)  0x00
#define LCD_INSTRUCTION   0b00100000   // 0xxxxxxx = data; 1xxxxxxx = instruction  (pin 26)  0x20

Then add to the command function:

void I2C_graphical_LCD_display::cmd (const byte data)
{
  startSend ();
    doSend (GPIOA);                      // control port
    doSend (LCD_RESET | LCD_ENABLE | LCD_INSTRUCTION | _chipSelect);   // set enable high
    doSend (data);                       // (command written to GPIOB)
    doSend (LCD_RESET | LCD_INSTRUCTION | _chipSelect);    // (GPIOA again) pull enable low to toggle data 
  endSend ();
} // end of I2C_graphical_LCD_display::cmd