MD25 Motor Controller

Does anyone have a working sketch for interfacing the MD25 motor controller using I2C with an Arduino Mega or Duemilanove?

I've tried the one mentioned elsewhere on this forum but it hangs while waiting for a reply from the MD25.

I've connected grounds, SCL and SDA lines, the Arduino is powered via USB and the MD25 with a 12V battery, no other connections.

What is the frequency on the SCL of the Arduinos? the MD25 says it will work with up to 100KHz.

Thanks, Richard.

By the way, I should mention that I've got this working using the MD25's serial interface, it's jsut the I2C I can't get to work. So I don't htink there are any hardware faults.

What is the frequency on the SCL of the Arduinos?

100KHz is the standard arduino frequency. Make sure:-

  1. You are using analogue pins 4 & 5 not the digital ones for the I2C bus lines.
  2. Use a 4k7 pull up resistor on each line.
  3. Get the address right, use the address format where the read / write bit is not the least significant bit. That is just the address.
  4. Make sure the grounds are connected together.

Thanks for the tips:
Make sure:-

  1. You are using analogue pins 4 & 5 not the digital ones for the I2C bus lines.
    I used analogue in 4 and 5 on the duemilanove but the mega has dedicated I2C pins so I used those on there.
  2. Use a 4k7 pull up resistor on each line.
    I've read several places that this is not necessary for a single I2C device as the arduino's internal pullups suffice. is this not the case? Is there some way I need to activate the internal pullups?
  3. Get the address right, use the address format where the read / write bit is not the least significant bit. That is just the address.
    Address is 0xBO which is flashed out by the MD25 on power on for verifiaction. Does that sound sensible?
  4. Make sure the grounds are connected together.
    Yep, did that.

) Use a 4k7 pull up resistor on each line.
I've read several places that this is not necessary for a single I2C device as the arduino's internal pullups suffice. is this not the case? Is there some way I need to activate the internal pullups?

In order to activate the internal pullups you have to write a HIGH to the pin(s)

If the pin is configured as an INPUT, writing a HIGH value with digitalWrite() will enable an internal 20K pullup resistor

see arduino.cc/en/Reference/DigitalWrite

Excellent! thanks, I'll give that a go.

Although, just read somewhere else that using the Wire library (which I am) automatically enables the internal pull ups on SDA and SCL lines.

Thanks all for your help, working now! In case it helps anyone else here's what I've learnt about this device:
The I2C address for the MD25 is indeed 0xBO however the Wire Library only uses 7 bit addresses so you need to shift that one bit to the right i.e. 0x58
You don't need pull up resistors if just using one close by I2C device from the duemilanove or mega.
You don't need to enable the internal pull up resistors by setting the I2C pins HIGH if using the Wire library as this is done for you by calling Wire.begin().
All the wiring you need is to connect the arduino to MD25 sda, scl and ground.
You can just power the arduino by usb and the MD25 by a 12V battery, no 5V battery required anywhere.
:slight_smile: