I have a love/hate relationship with putting in parts orders. I love to get the parts, but I hate to pay the shipping. So I tend to accumulate large wish-lists before putting in orders. For this project, I built my own robot body with stuff I bought here in Madison. The exceptions are the two gearhead motors, wheels, and the white plastic connectors which were purchased in an earlier parts order. Join me after the break to see how I put it together, and to watch the little bot motor around my shop.
I show off the hardware and what it can do in this video. I had an issue with powering the H-bridge and the Arduino from the same battery (that’s what I get for recording the first test!). To fix this I just added a second 9 Volt battery zip-tied to the first one to feed the regulator board separately.
The H-bridge design passes 9V through from one side of the board to the other. I was trying to pick up that source for the regulator, but there must be too much noise, or the power drain from the motors must dip too much for the regulator. This solution works fine for now. I’ll investigate more later.
Angle bracket and acrylic: my favorite building blocks
I absolutely love using acrylic and aluminum angle bracket. To cut the acrylic I just clamp it between two boards, score three or four times with a utility knife, then snap the piece off. It is easy to drill too, as long as you’re using sharp drill bits.
Aluminum angle bracket can be cut with a hack saw, filed smooth, then drilled and threaded to accept machine screws. Just make sure you’re not tightening them to the point that you strip out the threads.
Putting the frame together
The assembly is relatively easy once you have the parts cut to size. I have a rather large assortment of threaded hardware of various sizes. For most projects I use 6×32 machine screws. I use a tap set to thread holes in the angle bracket. Whenever that’s not feasible I use nuts.
Here you can see the underside of the square chassis. I attached a rectangle of acrylic from this side using four screws through threaded holes. Notice from the previous picture that the screws don’t stick up on the other side. I find it quite easy to cut screws to length with a rotary tool and cutoff wheel.
The motors are also mounted using a piece of acrylic. I took one of them to the hardware store with me so that I could get the correctly sized screw for the mounting holes on the motor gearboxes. I made a stencil out of paper to help lay out the holes I needed in the plate. Once the motors were mounted I drilled and tapped holes to attach the acrylic to the angle bracket. Again, cutting off the screws so they wouldn’t interfere with the spinning of the wheels.
I finished the body by adding a leg to make the bot a tricycle. A long bolt passes through a threaded hole in the front of the chassis. I use a rounded end nut to give it a smooth area in hopes that it will be easy to drag across the floor as the bot moves around. In the video you can hear the noise it makes as the robot switches direction.
Building the motor driver (dual H-bridge)
I built my own dual H-bridge using parts from Radio Shack. This works, but it’s a lot easier to order an IC made for this purpose. But, if you want to build this as a learning experience (as I did) here’s the info.
My circuit is based on designs by David Cook. The hardware needs 9V input, but can be switch with lower voltages applied to four control lines. This design uses a pair of inputs for each H-Bridge. These inputs must never be driven high at the same time! One in each pair drives the motor forward, the other drives it backward. You will burn out the transistors if you drive the forward and backward lines high at the same time.
In addition to the 6-32 fasteners I used for the chassis, the hardware store will also have nyon cylinders which fit over longer screws. These make great spacers as they’re easy to cut with a utility knife (just make sure the cut piece doesn’t go flying across the room). I use the same thing for mounting the protoboard to the acrylic, except I use a smaller 4-40 screw and nuts for this purpose.
Demo
No project is complete without a demonstration. I grabbed my Arduino because the headers make it easy to connect the dual H-bridge I built. This simple code makes the bot move forward, then backward, followed by spinning left and then right. Just remember, the control pins for each of the H-bridges must never be driving high at the same time! Doing so will fry the circuit.
#define MOTOR_L_F 7
#define MOTOR_L_R 6
#define MOTOR_R_F 5
#define MOTOR_R_R 4
#define STOP 0
#define FORWARD 1
#define REVERSE 2
void motors(unsigned char leftDir, unsigned char rightDir){
//Stop all motors
digitalWrite(MOTOR_L_F, LOW);
digitalWrite(MOTOR_L_R, LOW);
digitalWrite(MOTOR_R_F, LOW);
digitalWrite(MOTOR_R_R, LOW);
delay(100);
//Drive motors according to input variables
if (leftDir) {
digitalWrite((MOTOR_L_F + 1 - leftDir), HIGH);
}
if (rightDir) {
digitalWrite((MOTOR_R_F + 1 - rightDir), HIGH);
}
}
void setup() {
pinMode(MOTOR_L_F, OUTPUT);
digitalWrite(MOTOR_L_F, LOW);
pinMode(MOTOR_L_R, OUTPUT);
digitalWrite(MOTOR_L_R, LOW);
pinMode(MOTOR_R_F, OUTPUT);
digitalWrite(MOTOR_R_F, LOW);
pinMode(MOTOR_R_R, OUTPUT);
digitalWrite(MOTOR_R_R, LOW);
}
void loop() {
//Drive Forward
motors(FORWARD,FORWARD);
delay(1000);
//Drive REVERSE
motors(REVERSE,REVERSE);
delay(1000);
//Spin Right
motors(FORWARD,REVERSE);
delay(1000);
//Spin Left
motors(REVERSE,FORWARD);
delay(1000);
}
Conclusion
This robot body took just a couple hours to put together. The H-bridge to a few days! I would recommend going with an motor driver chip next time, but I learned a lot from the project. My future plans include adding sensors to the robot. I figure the next logical step is to make this a line-following robot, but I’m sure I’ll find other things to add along the way too.