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:
- 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);
}
}
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