I2C Voltage levels

22 Feb 2011

Hi

I want to connect a MD25 Motor control module to my mbed. The MD25 uses I2C but the control chip on the MD25 is a PIC who uses 5V. Do i need to use some voltage level converters or will some resistors do. I guess the mbed I2C voltage levels is 3.3V and the PIC 5V.

What are the easiest solution?

Thanks

/Mateo

22 Feb 2011

use the level shift method of nxp...

http://www.nxp.com/documents/application_note/AN10441.pdf

Ben

22 Feb 2011
23 Feb 2011

OK, thanks for the suggestions.

Aren't there any rough solotion with just resistors? I guess i can build a level converter just like the NXP App note says but just for testing.... Well i guess you guys know best, i have not so much experience with these things.

Thanks..

/Mateo

14 Mar 2011

I've just connected to the MD25 no problem. The only resistors I used were 2k pullups on both the SCL and SDA lines up to the 'VV' rail of the mBed. Demo code below:

  1. include "mbed.h" 100kHz clock, addr B0, reg 0=speedl, 1=speedr (0 (Full Reverse) 128 (Stop) 255 (Full Forward). 15=mode (set to 0 default)

Serial pc(USBTX, USBRX); I2C i2c(p9, p10); Dont forget the 2.5 k pullup on both wires! int main() { Read from I2C slave at address 0x62

int address = 0xB0,addressr=0xB1; char data[2],data2[2],data3[2],indata[20],reg[2];

data[0]=0x00;data[1]=140; top of board with power at top, above 128 set anticlockwise data2[0]=0x01;data2[1]=140; lower motor, above 128 set clockwise pc.printf("Connected\n"); data3[0]=16;data3[1]=0x20; i2c.write( address, data3, 2, false ) ;Reset encoders while(1){ i2c.write( address, data, 2, false ) ; i2c.write( address, data2, 2, false ) ; wait(0.1);

wait(1); reg[0]=0; i2c.write(address,reg,1,false); i2c.read(addressr, indata, 17); Reads encoder of motor 2 from register pc.printf("%d %d\n\r",indata[9]+indata[8]*256+indata[7]*65536,indata[11]); wait(1);

} }

20 May 2011

Thank you Sam.

1 question, you say you used 2k pullup resistors on both I2C lines. You say you connected them to 'VV' rail?

What do you mean by VV rail, is it the +5V USB out 'VU', or the +3.3V Regulated out 'VOUT'? I guess 5V but i better ask.

/Mateo

21 May 2011

Yes, I mean the 'VU' rail. These need to be pulled up to 5V. When the mBed is running without USB, I have used a 7805 voltage regulator to generate 5V on to this rail so the pullup resistors still get their 5V.

On another note, I was just testing my MD22 today using the above mentioned 7805. I found the MD22 would drive the two motors for a few seconds and then stop even if I keep sending the 'forward' command every second. Its operation seems very intermittent. Any ideas?