I2c with optocoupler

24 Nov 2011

/media/uploads/cicklaus/optocoupler.jpg Hi, i am trying to communicate 2 mbed, by using the I2C lines with optocoupler. But i did not get any result. I am not sure if its the connection. I found the above picture from the internet, and connected it this way. Is it the right connection? or must i reduce the frequency.

Thank you.

24 Nov 2011

What distance are you trying to communicate over? There may be a simpler way ....

24 Nov 2011

They are connected side by side.

24 Nov 2011

Unless you really need the I2C support, the simplest method, over such a small distance, is to just use the Serial port. Connect the TX on one mbed to the RX on the other and vice-versa. Then use some code like this:

// config serial port for connection to other mbed
Serial mbed1Serial(p13,p14);    // tx, rx
char a = 0;

...

mbedSerial.putc(a);  // send char

...

and then on the other mbed, have it waiting for the character to come though:

// config serial port for connection to other mbed
Serial mbed2Serial(p13,p14);    // tx, rx
char char_rx = 0;

...

char_rx=mbed2Serial.getc();  //get char

...


Or instead of sitting there waiting, it could be set up to respond to the interrupt generated when there is a serial character just received.

To go longer distances (in my case 30m of ethernet cable, in a noisy environment) I have used a MAX3232 chip at either end between the two mbeds and that seems to have worked OK (though I need to do some more testing to be sure).

Hope that helps in some way.

26 Nov 2011

hi, i not sure if i can use serial because i am trying to communicate mbed to another board that only has smbus, and i2c is the closest thing to smbus. But thank you for the reply. i will keep trying.

26 Nov 2011

Sorry, I thought you were trying to connect 2 mbed's together.

26 Nov 2011

the board with the smbus run on high voltage, im afraid that if the board has some problem, the mbed might received high voltage and spoil.

26 Nov 2011
04 Dec 2011

Hi, have you used the Avago optocoupler ? They are high speed , digital.

You can also have a look on the i2c isolators from Analog Devices:

http://www.analog.com/en/interface/digital-isolators/products/index.html#Isolated_I2C_Isolators

Peter

04 Dec 2011

Hi, i have successfully connected the I2C with the optocoupler. Reason was that i though the SCLK should only be in 1 direction. So now i connected the SDA and SCLK both bi directional. And yes, i am using the Avago optocoupler. Really thank you all for your help.