Need Help Getting Started with Drive System

Hi everyone, I just bought the Arduino and the drive system from the link below:

http://robot-electronics.co.uk/acatalog/Drive_Systems.html

At this point I'd just like to get the wheels moving. I've connected the MD23 - Dual H-Bridge Motor Driver to a 12V battery and my Arduino board seems to be working fine. I was hoping someone could let me know how to connect things up and what code to use, so that I could see the wheels turn. Thanks!!

The motorcontroller you linked to seems to be controlled over a I2C connection.

Just do a search in the forum (use Google) and you will find lot's of inf on how to do that.

Thanks!! I did a search and got a bunch of results. [smiley=dankk2.gif]

How do you do a search in the forum using Google? Do you use the search button, or the box in the upper right corner, or is it something else?

You just go to Google.com, click the "advanced search" and chose only to see results from www.arduino.cc

Alternatively, search for "site:www.arduino.cc my search string" in the standard google search. I use this method from the search field on Safari and Firefox toolbars.

-j

Here is some stuff that may be useful for others out there:

For an I2C connection you can run the following code to find out the address of the device:

#include <Wire.h>

void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600);
}

byte val = 88;

void loop()
{
Wire.beginTransmission(val); // transmit to device #44 (0x2c)

Wire.send(0); // sends instruction byte
Wire.send(val); // sends potentiometer value byte
Wire.send(0);
Wire.endTransmission(); // stop transmitting
Serial.println(val);
val++; increment value
delay(500);
}

For those using the same Devantech drive system the following code may be helpful:

#include <Wire.h>

void setup()
{
Wire.begin(); // join i2c bus (address optional for master)

Serial.begin(9600); // start serial communication at 9600bps
}

int reading = 0;
int count = 0;
int reset = HIGH;

void loop()
{
Wire.onRequest(resetEncA); // reset encoder to zero

// step 1: instruct sensor to read echoes
// Wire.beginTransmission(88); // transmit to device #112 (0x58)
// the address specified in the datasheet is 176 (0xB0)
// but i2c adressing uses the high 7 bits so it’s 88
Wire.send(0x00); // sets register pointer to the command register (0x00)
Wire.send(0x01); // command sensor to measure in “inches” (0x50)
Wire.send(-0x50); // use 0x51 for centimeters
// use 0x52 for ping microseconds
Wire.endTransmission(); // stop transmitting

// step 2: wait for readings to happen
delay(70); // datasheet suggests at least 65 milliseconds

// step 3: instruct sensor to return a particular echo reading
Wire.beginTransmission(88); // transmit to device #112
Wire.send(0x02); // sets register pointer to echo #1 register (0x02)
Wire.endTransmission(); // stop transmitting

// step 4: request reading from sensor
Wire.requestFrom(88, 1); // request 2 bytes from slave device #112

// step 5: receive reading from sensor
if(1 <= Wire.available()) // if two bytes were received
{
reading = Wire.receive(); // receive high byte (overwrites previous reading)
//reading = reading << 8; // shift high byte to be high 8 bits
//reading |= Wire.receive(); // receive low byte as lower 8 bits
Serial.print(reading, DEC); // print the reading
if (reading <= 255)
{
count++;
Serial.print("\t");
Serial.print(“count = “);
Serial.print(count);
Serial.print(”\n”);
}
}

delay(250); // wait a bit since people have to read the output :slight_smile:
}

void resetEncA(int reset)
{
if (reset == HIGH)
{
Wire.beginTransmission(88); // transmit to device #112
Wire.send(0x10); // sets register pointer to echo #1 register (0x02)
Wire.send(0x20); // command register sets encoder to zero (0x20)
}
}

As a building block, I used the code from Nicholas Zambetti’s http://www.zambetti.com and James Tichenor I2C SRF10 or SRF08 Devantech Ultrasonic Ranger Finder. This code will read from the encoder, however I need to somehow increment each reading, because as of now, it will only read up to one rotation.