Devantech's MD25

I have an Arduino Duemilanove (with ATMega328P), and I also have an I2C device to interface with, the MD25 motor controller from Devantech.

On the Devantech's page though i can't seem to find an Arduino example for the MD25...

Can someone help me with this ?

Thanks !

Example of how to connect and also the sketch to control it:
Arduino Examples RD01 Motor Controller
You are welcome :slight_smile:

Hi,

thank you for your quick reply.

I used the example you are referring to, but it doesn't work.
After wiring as the scheme shows and uploading the sketch there is no connection between arduino and the MD25. It doesn't even read the software version. That's why I thought I should use another sketch since this one is for the MD23. For example: the address for the MD23 in the sketch is "#define md23Address 0x58 // Address of the MD22", and in the tech specs it says the MD25 is shipped with the default address 0xB0.
There is an inconsistancy in the information.
Should MD25 work with the MD23 sketch ?

Thanks again.

Then change the address to 0xB0. The code should work, it looks pretty straightforward use of the Wire library.
Basically, when you call this sequence

    Wire.beginTransmission(0xB0);
    Wire.send(speed2);
    Wire.send(x);                                           
    Wire.endTransmission();

a command is send over I2C to the device.
Try different commands, according to the datasheet, something must happen.

Hi everyone

I'm also new to Arduino & having trouble interface with MD25.

As what I understand;

Wire.beginTransmission(0xB0); //initiate address of MD25
Wire.send(speed2); //speed2 means Motor2 speed (mode 0,1)
Wire.send(x); //can you explain why 'x'??
Wire.endTransmission();

Just one silly question :). What does 'x' means in Wire.send(x)?

Cheers

What does 'x' means in Wire.send(x)?

Just a dumb-ass guess, but I suspect this is setting the speed to the value stored in x. Somewhere prior to this code, you would need to define x, and assign it a value.

Yup, 'x' must be declare earlier in the code. Sorry, I'm new to programming.. :slight_smile:

Anyway, I just want to test my Arduino Mega & interface it with MD25 to control my robot. For a start, I only want Arduino to talk with MD25 ie; asking for Battery volts. I guess this will be the simplest i2c code for testing. So, this is my code;

#include <Wire.h>

void setup()
{
Wire.begin();
Serial.begin(9600);
}

int batt = 0;

void loop()
{
Wire.beginTransmission(0xB0);
Wire.send(0x00);
Wire.send(10);
batt |= Wire.receive();
Serial.println(batt);
Wire.endTransmission();

delay(500);
}

However, only zero value '0' on Serial Monitor. Help me please

I have no idea if that is the proper data to send to get the information that you want. But, this looks unusual to me:

batt |= Wire.receive();

What are you expecting this to do?

typo error

Its actually

batt = Wire.receive();

but the output is still the same. I get confuse with several i2c command especially Wire.requestForm() and Wire.available()

My main reference is Arduino example SFRRanger_reader.

just want to check my wiring

SDA on arduino connect to SDA on MD25
SCL on arduino connect to SCL on MD25
GND to GND
Vcc on MD25 leave not conneted.

MD25 supplied voltage is 12V (from battery)

Am I right?