The Arduino Uno with Adafruit Motorshield |
Arduino UNO R3 board with DIP ATmega328P
The first thing I noticed about a lot of the robots I saw online is that people were spending a hundred dollars or more on them to get very basic functionality. I wanted to spend no more than I already had from the Arduino and MotorShield purchase. The second thing I noticed was everyone was slapping everything together with no regard for how the poor little robot looked. I understand once you get it working your proud and have a feeling of accomplishment and want to share it, but I think a couple minutes and a clean looking robot are better combinations. Last but not least is the Robot should do something useful. I am not exactly sure what useful function my robot will be asked to do, but I will complete the chassis, get it performing well and decide then. The only thing I know for sure is that I want to incorporate a camera into the mix and have the bot interact with the surroundings with no intervention on my part. Should be fun.
The Woody Bot
Supplies
- 1-Arduino - I used an Uno, your free to use whatever you have lying around. $22 from Amazon
- 1-SainSmart L293D Motor Drive Shield - this is the same as the Adafruit Version 1 of this shield, they have just released the V2 and I have not checked it out at all. This project could easily be done using a couple motor drives instead, but I had the shield on the shelf. It will also allow me to add more servo controls later for a camera. I gave $12 for it on Amazon.
- 2-Hobby Servo Motors-Modified to be 360 degree motors. No servo anymore. I had a couple old servo motors from my RC car racing days that had bit the dust. They wouldn't work with the RC controller but the motors were still good. One was an Airtronics and the other a Futaba. The conversion makes them a very useful bot drive motor with loads of torque. I will try and write a tutorial for this too. $0.00 (find a friend with burned out servos they will probably work for this)
- 2-wheels - I made mine from scratch using a hole saw and a drill press. This may be beyond your capability, which is fine. Wheels for servo motors don't cost a whole lot. $0.00
- 1-Front Pivot Wheel - I used an old pivoting wheel from a rolling storage bin. It works great and is free. $0.00
- 1-Chassis - I made mine from a flat piece of 1/2" plastic like material I had laying around. this one could easily be made using plywood or any other material. $0.00
- 1-Battery- I decided upon and old Black and Decker VPX battery pack I had from an old drill. They are compact, 7v, last forever and I had chargers a for it. You can use anything you have available though. $0.00
- 1-Switch- I used a small 10amp micro toggle switch I had laying around. But any switch capable of the current draw the servos you use is fine. $0.00
- Misc Screws - depending on the materials you use you will need a couple dozen screws. $0.99
- Zip ties - I am using Zip Ties to hold the battery in just because I want to. I may come up with a reusable design for a hold down in the future. $0.25
Total Price so far = $35.24. Not bad for a basic robot chassis that actually moves.
Chassis before wheel cutouts |
I decided on a flat 2 wheel chassis with independent drive. Much like the 2 wheeled Smart Car chassis you find for $20 everywhere. But for those you have to buy the special geared wheel/motor combos and if they fail you buy them again. I am using 2 servos I modified to be 360 degree gear motors. Check out youtube for videos on hos to do this.
I started with a rectangular piece of plastic I cut 8 inches by about 6 inches. No reason, it was just a size I cut on the saw. I then cut the corners on the front off to give an impression of a front end. I measured in 1" and back 4" and cut them off. If you look closely you
Basic Chassis Outline |
cutting the wheel |
Next I made 2 wheels using a 2 1/2" hole saw and a drill press. First I did it with the pilot bit in the hole saw, but I found out the diameter of the servos' gear mount was a little less than 1/4" so it wasn't tight enough. So I removed the pilot bit and clamped the material to the table and cut it using just the saw. The end result was a better wheel anyway since you have to cut really slow. I used a wheel I had cut with the pilot bit to mark the middle of the other wheels. Then I drilled a 3/16 hole clear through the wheel and the using a drill bit that was .225" I drilled
Bare wheel |
Chassis Assembly
Servo attached to mounts |
I chose the modified servos for a couple of reasons. First I had them already, duh. But mainly because of their low current draw. Both servos running simultaneously only draw about .150 amps or 150 Milli-Amps at 7 volts. Even under heavy load the current was really low. This is huge as far as battery life and not smoking your motor shield and/or Arduino.
I found it easiest to assemble the servos and their mounts first. I just sat the mount in place and marked the servo holes with a pencil, pre-drilled a pilot hole and then screwed them together with sheet metal screws. The design is made with the drive shaft towards the front and the shorter motor mount towards the rear.
Align the back edge of the mount with the back of the chassis |
Wheels and servos in place |
Pay attention to where the other screws are located before you drill. 2 screws cannot occupy the same space, I promise.I found one screw in each mount was sufficient to make it solid. Repeat for the other side and your almost rolling.
Front wheel pivot pin sticking up too far |
Front Wheel
The front wheel I selected is from a rolling storage bin. With 1" wheels it is about the perfect height to set the front level with the rear wheels. If your wheel is a different size, just adjust the diameter of the rear wheels to compensate. This wheel had a 1/4" shaft that was a little too long so I shortened it with a hack saw in the bench vise. Next I drilled a 1/4" hole centered 1 1/2" back from the front. You might need to glue or epoxy it in place. I have found
Rolling Chassis Ready for Electronics |
Battery
Zip ties for battery mounts |
Arduino Mounts
Arduino mount from scraps on front of chassis |
Arduino and battery mounted |
Wiring
The wiring is going to be largely dependent on what other equipment your using. I chose a micro toggle
Servos run from underneath to M1 and M2 |
The positive I ran from the battery to the Switch and then from the switch to the +M port on the motor shield. Make sure you leave the PWR jumper in place. The Arduino is powered by the battery through the Motorshield.
The battery connectors are just the basic crimp on spade connectors that I reshaped to point the wires where I wanted them to go. I did however solder the connectors to the wires. I prefer to solder all connections if possible but bread boards work fine too if they are strong enough for your current load.
Code
Go here for the Adafruit Motor Shield LibrariesAdafruit-Motor-Shield-library
The code I loaded to test everything out is just a series of movements to put it through its paces. It runs the Woody Bot forward for 2 seconds, rotates right and left for 2 seconds each way, then pauses for 2 seconds before repeating the loop in the other direction. It is just the lines from the Motor Party Sketch modified for this test.It gives you an idea of how it will move and perform.
You may have to adjust your code for speed differences in the servos. Even identical servos can run at slightly different speeds which will give a curve to your path when the bot moves.
Next time I want to add a switch that will activate the sketch. This way it sets idle until I press the switch, runs through it and stops awaiting another press.
((((CODE BEGIN))))
#include <AFMotor.h> //Must have Adafruit MotorShield Library installed. // //Check out wooodystime.blogspot.com for more info. // //Kevin Woodyard - Str8shotPhoto.com //2013 AF_DCMotor motor(1, MOTOR12_64KHZ); // create motor #1, 64KHz pwm AF_DCMotor motor2(2, MOTOR12_64KHZ); // create motor #2, 64KHz pwm void setup() { Serial.begin(9600); // set up Serial library at 9600 bps Serial.println("Woody Bot test!"); motor.setSpeed(225); motor2.setSpeed(225); // set the speed to 200/255 } void loop() { Serial.print("Move forward"); motor.run(FORWARD); motor2.run(FORWARD); // turn both wheels forward, should go in a straight line. //adjust individual motor speed to correct for any curving in travel delay(3000); Serial.print("Spin to the left"); motor.run(BACKWARD); motor2.run(FORWARD); // Spin to the left for 2 seconds by counter rotating the motors delay(2000); Serial.print("Spin to the right"); motor.run(FORWARD); motor2.run(BACKWARD); // Spin to the right using the oposite rotations. delay(2000); Serial.println("Pause"); motor.run(RELEASE); motor2.run(RELEASE); // Release the motors and wait 2 seconds before starting again. delay(2000); // REPEAT OF first part of SKETCH with spins reversed Serial.print("Move Forward 2"); motor.run(FORWARD); motor2.run(FORWARD); // Turn on both wheels going forward delay(3000); Serial.print("Spin to the Right"); motor.run(FORWARD); motor2.run(BACKWARD); // Spin to the right for 2 seconds by counter rotating the motors delay(2000); Serial.print("Spin to the Left"); motor.run(BACKWARD); motor2.run(FORWARD); // Spin to the Left using the oposite rotations. delay(2000); Serial.println("tack"); motor.run(RELEASE); motor2.run(RELEASE); // stopped delay(2000); }
((((CODE END))))
Final Results
So here we have a simple starter chassis for an Arduino and an Adafruit Motor Shield. From here we can add anything we want, all kinds of sensors and code to make it do amazing things. I will warn you, your wife, girlfriend, mom or about anyone else that know nothing about robotics and Arduino's are NOT going to be impressed by this version of the Bot. They may smile and say "Nice job Honey", but you'll know they are less than amazed. But stick around for future articles and we will be upgrading and adding things that they WILL be impressed by. When this things chases the cat into the bedroom while barking like a dog, then we'll see who's impressed.
Good luck and Keep on wasting time.
Comments