Arduino and picaxe-LCD in i2c mode

hello! I have a picaxe LCD which support I2C and serial communication. You can see it here, datasheet here

Now i’m trying to use my Arduino Diecimila to display something, using i2c, but the LCD is not working.
Some stuff i’ve observed:

  • the LCD works correctly with a picaxe board, always with i2c.
  • with arduino, the board works ok in “clock” mode (a mode that doesn’t communicate with the board but just show the current time).
  • putting some debug println in the code, i can see that the program blocks in the Wire.endTransmission(); instruction.

The code i’m using is:

#include <Wire.h>

// C6 63 46
byte addr = 0x63;

void setup()
{

Serial.begin(9600);

Serial.println(“Init”);

delay(500);
Wire.begin(); // join i2c bus (address optional for master)
delay(500);
}

void loop()
{
Serial.println(addr, HEX);
Wire.beginTransmission(addr);
Serial.println(“A”);
Wire.send(0);
Wire.send(254);
Wire.send(128);
Wire.send(255);
Serial.println(“B”);
Wire.endTransmission();
Serial.println(“C”);
delay(20);

Wire.beginTransmission(addr);
Wire.send(0);
Wire.send(“Hello”);
Wire.send(255);

Wire.endTransmission(); // stop transmitting

delay(50000);

}

I have some doubt about the address i should write to. The LCD has an address of 0xC6 (as in the datasheet), but it is in 8 bits, while, if i have understood correctly, the arduino wants a 7 bit address.
I tryed the same with 0x63 (discarding the low bit) and 0x46 (discarding the high bit).

The original Picaxe code for reference is:

init: pause 500
i2cslave $C6,i2cslow,i2cbyte
main: writei2c 0,(254,128,255)
pause 10
writei2c 0,(“Hello!123”,255)
end

It includes a “i2cslave” command that setups the device, is it something i should translate in arduino? it looks like it’s not necessary but who knows…

Any help is greatly appreciated :slight_smile:

I'm a tad confused on this myself, eventually put some code into the sketches to serial print where in the routine it was getting to.

As soon as Wire.endTranssmission is reached the Arduino Diecimila does no more and stops at that point.

So essentially the program is either a) Waiting or b) Crashed.

If its waiting I do not know what needs to be acknowledge if its crashed then I assume something in the Wire.h is at fault ?

LCD is connected running @ 5v / correct wires SDA/SCL to appropriate Analog 4/5 pins header /4.7K Pull up Resisters at the LCD.

:-/

edit// Seems to be waiting I pulled the data wire and it skipped past Wire.endTransmission

So making assumptions... poss ? Data I2C to quick (unsure how to change) / Issue with the voltages on the lines potentially not knowing its 0s & 1s

hmmm

I'm a tad confused on this myself, eventually put some code into the sketches to serial print where in the routine it was getting to.

As soon as Wire.endTranssmission is reached the Arduino Diecimila does no more and stops at that point.

So essentially the program is either a) Waiting or b) Crashed.

If its waiting I do not know what needs to be acknowledge if its crashed then I assume something in the Wire.h is at fault ?

LCD is connected running @ 5v / correct wires SDA/SCL to appropriate Analog 4/5 pins header /4.7K Pull up Resisters at the LCD.

:-/

edit// Seems to be waiting I pulled the data wire and it skipped past Wire.endTransmission

So making assumptions... poss ? Data I2C to quick (unsure how to change) / Issue with the voltages on the lines potentially not knowing its 0s & 1s

hmmm

It shouldn't be that it's going too fast, i looked at the Wire sources and it runs at 100k, not 400k (you can change it there, btw). I think the problem is that the LCD is not aknowledging or possibly not even answering at all. With Picaxe it works, and i read that it should be waiting for aknowledg too, behind the curtains. Btw what i2c address are you using ?

Hi msx,

I had problems as well, but your post helped me. Your idea of using a 7 bit addres in stead of an 8 bit worked for me. I used 0x63. I am using a Devantech LCD03 with an Arduino Mini. Did you look at the tutorial on changing the wire-library? I did that as well:

http://www.nearfuturelaboratory.com/2007/01/11/arduino-and-twi/

I changed the line in twi.h to #define atmega168

I did not check whether it is really necessary now I have got it working thanks to your suggestion.

I have some problems sending commands to the LCD screen though. It seems I have to sent an empty character first before the screen accepts commands: wire.send("").

Thanks again.

Is your LCD working now by the way?

Hans.

yes my LCD works correctly. I don't know about the empty char, but with my LCD i have to wait 30 millis after a "clear screen" and 10 millis after each command or "write" to let the lcd update, or the commang gets lost. Also it needs 500 ms at startup before it accepts anything. I don't know if your LCD wants the delay() too, but it's worth a try :)

Hi msx,

I have my graphics working as well. :) And I really have to send a space " " to the arduino each time I sent some sort of control command. I also discovered that my LCD (devantech) updates the screen continuously. That means that custom ASCII chars already printed to the screen change when you try to make another one in the same memory position.

Anyway. Thanks again for your tip.

Best, Hans.

Hi Does anyone know how to display numerical value in the space of "Hello" i tried it directly and i got a ascii character according to the value. (Im trying to read a potentiometer value on the LCD screen).

any help will be great full. :)