My CatBot project is built atop the 2WD Arduino Compatible Mobile Platform. I have yet to see any build notes on the 'Net for getting the 2WD up and going, and it does not come with instructions other than the very basic ones at the Makershed store. This is my attempt to fill in that gap. I've tried to read-between-the-lines and figure out the intentions of the manufacturer and put together as close to a "stock" build as possible, so others can plan and implement their own builds. I would welcome corrections from those more in the know. (send to: flippy.qa76 AT gmail DOT com)
The Makershed catalog page for the 2WD kit says you need an Arduino and "Motor Shield" (though it doesn't specify which one) to get it working. Since the only motor shield it carries as of this writing is the Adafruit one, I went with the following materials list:
If you choose, as I did, to give the Arduino a separate power supply from the Motor Shield, you'll also need:
If you want to expand on the 'bot by adding sensors, etc., you will probably also want some extra header pins (breakaway-style). The Motor Shield exposes pins 2 and 14 through 19 of the Arduino, but does so with a solder hole. The header pins will give you something nicer to play with.
A word about power: According to the catalog page for the 2WD kit, each motor is 3-to-6 VDC, with a stall current of 470 mA at 6V and 270 at 3V. The Adafruit Motor Shield can supply a maximum of 600 mA per motor, more than enough to not burn out on those motors. This is another clue it is the intended controller for a stock build. Further, the battery holder that is shipped with the 2WD kit is a 5-cell AA holder. AA NiMH cells are 1.2 volts each; five wired in series gives us 6V total. This tells me the intention is to run the 'bot at 6 VDC. Again, I'm speculating on the manufacturer's intention for the kit, but so far all the pieces are leading to this conclusion.
The catalog page isn't very specific. My version of the kit had:
Attach the motors to the bottom frame piece. Use the long screws with the appropriate nut & washer to attach the motors. You can go ahead and press the wheels on now if you like (I did).
Attach the ball caster to the bottom frame piece. Hopefully it's obvious where that one goes. :)
Install the battery housing over top of the ball caster. There should be two counter-sunk screws for doing this. The frame is pre-tapped to receive them, so no nut required.
I did it later, but now would be a good time to go ahead and solder your wires to the motor leads. Otherwise it'll be harder once you get the top frame piece on. Learn from my pain. :)
I cut the included 2-conductor cable into three roughly-equal lengths, one each for the motors and one for supplying power to the motor shield (more on this later). The cabling worked well with those lengths of wire. On both motors I soldered the red wire to the top terminal and the black wire to the bottom terminal. If you assume the red wire is positive, this wires one motor to run in the opposite direction from the other -- except that it is physically rotated already so now both are moving in the same direction with respect to the 'bot. In the end it doesn't matter, since the motors are reversible, I just though it would be handy later. I'd rather set my orientation correctly in hardware than fix it later in software.
Supposedly the top frame piece comes pre-drilled for everything you need. Mine had two minor problems that required surgery:
Follow Lady Ada's instructions. They're good ones.
Put the on/off switch and power jack in the appropriate holes. In the picture below, the switch is at the top left, with the power jack just below it.
Attach the Arduino Uno using the four stand-offs. Mine are a little tall -- I was just using what I had. You may want to use shorter ones. If using metal standoffs (like I did), be very careful that the stand-offs don't touch anything that looks like a solder point, exposed trace, etc. If they do, you'll need to add an insulating washer between the stand-off and the board. I made some by drilling screw-size holes in a piece of polyethylene scrap, then trimming around the holes until I had a tiny washer.
Plug the Motor Shield on top of the Uno.
Even though I show the top attached to the bottom in this picture, I recommend not attaching them until after you wire everything up.
(I have an extension frame piece attached in this photo. As I said before, it's optional. I have other nefarious purposes for it...)
The included wire was stranded, so, to keep the ends from fraying, I melted a little solder on the ends that go in the Motor Shield's screw terminals.
Per Lady Ada's recommendation, I'm going with a dual power supply scheme: the 5-AA pack will power the motors and a 9-volt battery will power the Arduino. For my money, wiring the 9-volt through the Arduino's power plug is the easiest way to go. You'll probably want to include a 2nd on/off switch for the Arduino (the switch included with the 2WD kit will be needed for the motor supply).
CAUTION: This wiring set-up is particular to the parts they sent me. Assume you will get whatever variants they were able to source when they packed your kit. Check and double-check the continuity of terminals with a ohm-meter before proceeding.
I assumed the power jack included with the 2WD kit was for recharging the AA batteries, so it is wired in parallel with the battery holder (see diagram below). The on/off switch is between the power jack and the Motor Shield so as to isolate the shield from the battery charger. (Probably overkill, but it doesn't hurt to be safe.) Run the third piece of 2-conductor cable from the switch (red/positive conductor) and ground (black/negative conductor) to the PWR_EXT jack on the motor shield. CHECK AND DOUBLE-CHECK CONTINUITY WITH AN OHM-METER:
The jack I received had three terminals, as looking at it from underneath, in the 9 o'clock, 12 o'clock, and 3 o'clock positions. 9 o'clock is the center pin and should be connected to the positive battery terminal. 12 and 3 o'clock are connected internally and should be used for ground.
(I just had a thought -- I could have wired the toggle switch such that it breaks the power jack's connection when the 'bot is "on". I may need to do some re-soldering...)
Attach the wires from the motors to either the M1 and M2 jacks or the M3 and M4 jacks on the Motor Shield (M1 and M2 have more flexibility).
The vertical supports are pre-tapped for this, so no nuts required.
Here's a basic "move in a square" test program. It is also available as a .pde file attached to this page.
Test Code
#include <AFMotor.h>
AF_DCMotor m_driver(1, MOTOR12_64KHZ); // driver-side motor
AF_DCMotor m_passenger(2, MOTOR12_64KHZ); // passenger-side motor
// which way we're facing
#define NORTH (0) /* "north" (straight ahead) */
#define EAST (1) /* "east" (right) */
#define SOUTH (2) /* "south" (backward) */
#define WEST (3) /* "west" (left) */
int facing = NORTH;
// tweak these values as needed
// these are pretty close to values that produce 90-degree turns
#define velocity (80) /* how fast the wheels spin */
#define turn_time (1000) /* how long it takes to turn 90-degrees */
#define move_time (2000) /* how long it takes to move forward 1 "space" */
void turn_90_clockwise()
{
m_driver.run(BACKWARD);
m_passenger.run(BACKWARD);
delay(turn_time);
}
void turn_to(int direction)
{
while(direction != facing)
{
turn_90_clockwise();
facing = (facing + 1) % 4;
}
}
void forward_one_unit()
{
m_driver.run(BACKWARD);
m_passenger.run(FORWARD);
delay(move_time);
full_stop();
}
void full_stop()
{
m_driver.run(RELEASE);
m_passenger.run(RELEASE);
}
void move_north()
{
turn_to(NORTH);
forward_one_unit();
}
void move_east()
{
turn_to(EAST);
forward_one_unit();
}
void move_south()
{
turn_to(SOUTH);
forward_one_unit();
}
void move_west()
{
turn_to(WEST);
forward_one_unit();
}
void test_squaredance()
{
// simple square movement pattern
move_north();
move_east();
move_south();
move_west();
}
void setup()
{
m_driver.setSpeed(velocity);
m_passenger.setSpeed(velocity);
// for safety, wait 10 seconds before starting
delay(10000);
test_squaredance();
delay(15000);
full_stop();
}
void loop()
{
}