Introduction: Robotic Rover
Hi, I'm Proxy303, a robotics specialist. In this tutorial, I will be teaching you how to build your own robot like one of mine.
I'm not talking about one of those over-glorified remote-control cars that people call robots. One of the very definitions of a robot is that it can't be remote control. The robot you will build today is one that you build, wire, and program. Then it's autonomous. That means it isn't controlled externally. It controls itself. After it's built and programmed, the robot does everything else itself.
There are five main components of any robot:
- A chassis, which is the body of your robot. You can buy these online pre-assembled, or you can make your own from a kit or from scratch.
- A micro-controller, which is the "brain" of your robot. This is a versatile circuit that can be programmed to do pretty much anything.
- Some motors, which allow your robot to move. You can't effectively control motors directly with a micro-controller, so you need...
- A motor driver, which allows you to control a higher-voltage motor with a low-voltage logic signal.
- A power source, which powers everything. For portable robots or ones that move around, use batteries. Otherwise, you could use a power supply module, like one from a computer.
You will need:
- A robot chassis (I suggest the Actobotics Runt Rover Whippersnapper, because it has so many good aspects, like a universal micro-controller mount, or sensor mounts, or the fact that everything just snaps together.) Any material works, so try out plastic, wood, or even cardboard. Be careful while using metal, as it could short out the solder joints under circuit boards, but if you know what you're doing, then go ahead and give it a try. Robot chassis can be pretty expensive, unning anywhere from 15 to a few hundred dollars.
- A micro-controller (I used an Arduino Mega 2560, but a Raspberry Pi works well too.) These can be bought at electronics stores, hobbyist stores, online, or any where else that sells robot parts. Although they are one of the most important part of a robot, they are actually pretty cheap, being anywhere between 10-40 dollars.
- A motor driver (I used the L298N dual motor driver) These can be rather expensive, so treat yours carefully. These bad boys are designed for pumping lots of power into motors, and so they heat up a lot. Make sure the one you buy has a heatsink, or if it doesn't, stick one on. You certainly don't want the motor driver to overheat and break, costing you anywhere from 20 to a few hundred dollars for a new one.
- A few breadboard wires. Not much explanation is needed here, because you can find these pretty much anywhere.
- Some M-F DuPont wires. Rather than breadboard wires, which have metal "needles" on both ends, these have a "needle" on one end, and a socket on the other end.
- A handful of mounting screws. Again, not much explanation required. Get small Phillips-head screws, standard size.
- A primary power source to power the micro-controller (You can find pretty cheap rechargeable lithium-ion batteries online. I typically use power banks used to charge phones.)
- A motor power source (6 AA batteries will work great for this, but you could use another power source if you'd like. DON'T use a 9V battery; they simply don't have the current for this sort of thing. Keep in mind that they're designed to run smoke detectors, not robots.) If possible, try to get a rechargeable power source. It is a bit more expensive at first, but trust me. If you use single-use batteries, you'll find yourself going through them very quickly, and the cost of that many batteries quickly overpowers the cost of some rechargeable ones.
You may want:
- An ultrasonic sensor. Lets your robot see objects in front of it.
- Some servo motors. Rather than constantly spinning, these useful motors can be programmed to move to a specific angle and stay there.
- A handful of LEDs. No explanation required. You put in power, they light up. Simple.
- Or any other attachments. Why not add a robot arm? Or some other sensor?
Step 1: Build the Robot Chassis
Assemble the robot chassis you bought. Make sure everything is assembled properly.
With the Runt Rover Whippersnapper, everything just snaps together. If your chassis is held together by screws, then make sure that they are tight, and that your bot is sturdy. Trust me, there's nothing worse that having your project just fall apart on you - sometimes literally! Also, make sure that there's room inside the chassis. Imagine buying everything, spending over 70 dollars, only to find that one of your major components doesn't fit inside the bot!
Also, make sure the motors are attached properly and can turn freely. Sometimes, a piece of the chassis sticking out can block the motors, so make sure there's nothing that could stop the motors from turning.
Step 2: Basic Wiring
Connect the left side motors to each other, in parallel. Do the same for the right motors. Make sure the left side red wires are grouped with the left side black wires, and same for the right side. Connect a red wire to both RED wires of the right side. Connect another red wire to both of the BLACK wires of the left side (I know, it seems backwards on the left side, but this is to accommodate for the fact that opposite-sided motors spin the opposite direction.) Repeat for the black wires. Be sure to keep the wires for the sides grouped together. Also, be sure that the LEFT side motors are reversed from how you would normally wire it.
Step 3: Connect the Motor Driver
Before you use a motor driver, you NEED to know how it works. IF YOU CONNECT IT WRONG, YOU CAN DESTROY THE MICRO-CONTROLLER AND/OR THE MOTOR DRIVER!
A motor driver is a type of isolated circuit controller, meaning that there is no physical connection between the motor power area and the logic control area. Most good ones are designed to avoid any electrical leakage into the micro-controller (that could damage or destroy it.) Also, most good ones are usually at least $15, so if you spot a $2 one online, don't buy it! I personally found one like that, and just as an experment, I stuck a heatsink on it and hooked it up. The seller said the driver was rated for 12V. I connected it to 9V, and it started smoking. Turns out, the chip they used was only rated for 3V!
A motor driver has 2 input areas: The power inputs and the logic inputs. It also has two output areas: the right and left sides. Here are all of the pins and what they do:
- The logic inputs:
- These take a 3.3v logic signal and use it to control the motors. Never connect a high voltage to these pins.
- Connect these to the digital logic outputs on the micro-controller.
- The Power In pin, used for powering the motors. The amount of power you put in here is the amount of power the driver will pump into the motors.
- The GND pin, used as a common ground connection. Used both for power and as the return for the logic inputs. The GND pin is usually wired with diodes, in order to prevent electrical leakage into the logic and power pins.
- The 5V pin, used for powering certain types of motors. It OUTPUTS 5 volts, so don't mistake it for a power input. All it takes is one burst of power into the wrong pin on your micro-controller to silently and instantly destroy it.
- 1A and 1B, for one motor or set of motors.
- 2A and 2B, for the other motor or set of them.
A motor driver lets you control a high-voltage motor with a low-voltage logic signal. The reason there are two inputs per motor is so that you can also control the direction.
Connect outputs 1A and 1B of your motor driver to the right-side motors. Connect outputs 2A and 2B to the left-side motors (Remember! BACKWARDS!)
Install the motor battery somewhere inside your robot chassis, and connect it to the power input of your motor driver, with + to power input and - to GND.
If you are using a pre-assembled module, then you're good.
If you are just using an IC, be sure it's wired properly, and be sure to put a heatsink on it! These chips heat up a lot, which is why most good drivers have heatsinks.
Step 4: Attach the Micro-controller
Attach your micro-controller to the robot. I used the Arduino Uno Rev3. Connect four digital outputs of the micro-controller to the logic input of the motor driver. Connect the micro-controller's ground pin to the GND slot of the motor driver. Do not connect the 5V pin on the motor driver to the micro-controller! This is used for powering certain types of motors, not as a power input, and certainly not for a micro-controller. If you do this, you could damage the micro-controller. You should only connect the logic pins and the common ground pin on the motor driver to the micro-controller.
These connections are used to control the motors, using the logic inputs of the driver.
Step 5: Make Sure Everything's Good
Go back and make sure everything is good. Check your wiring, make sure the left motors are connected backward, be sure your 5V output on the micro-controller is not connected to the 5V out on the motor driver, and check for any other issues. Be sure all your screws are tight, your wires are plugged in, your motors aren't blocked, and no wires are broken.
If everything's good, then go on to the next step.
Step 6: Install the Battery
Insert the batteries into the robot chassis. If they fall out, they could slow down or stop your robot, so be sure to secure them inside the chassis. Use a mounting bracket, some glue, or just tape them in place if you plan on taking them out often. Also, make sure your battery connections are good. I once had a robot that refused to move, and I went in circles for hours, checking my programming, rewiring the motors, and being unable to find the problem. I even ended up buying a new micro-controller, only to find that one of the wires to my motor battery had come loose inside the chassis. This is a perfect example why you should always check for other issues before replacing a part!
Step 7: Attach Everything
Use small mounting screws to securely attach everything. Screw the motor driver and micro-controller onto the robot chassis, and be sure that the motors are secure. Be sure that the breadboard is securely attached too.
Use zip ties or small pieces of tape to organize your wires. You don't need to do this, but it certainly makes the robot look better, and makes it easier to keep track of what wires go to what. Also, if you don't have zip ties, or need to easily replace the wires, you could group them by color. For instance, you could use green wires from the micro-controller to the motor driver, red wires for power, black wires for GND, and blue wires from the motor driver to the motors.
Step 8: Program
Hook up the micro-controller to a computer and program it. Start simple, and don't overwhelm yourself. Begin with something as simple as making the robot move forward. Can you make it turn? Go backward? Spin in circles? Beware, the programming requires a lot of patience, and usually takes the longest. Refer to the graph above.
It's up to you!
Step 9: Attachments
Now that you have a simple robot set up, it's time to add some extra features. Attach an ultrasonic sensor to allow the robot to avoid obstacles. Or a servo motor, with something cool on top. Or some blinking LEDS to brighten up the bot. Remember, it's your robot, so its up to you!
Step 10: You're Done!
Congrats! You now have a working robot! Please post in the comments if you built it, and what attachments you added.
If anything goes wrong, please refer to the troubleshooting help below:
The robot doesn't turn on at all
You know that the robot is on because most motor drivers and micro-controllers have lights that indicate that they are on. If they don't turn on, then:
- The main battery may be low or empty. If you are using a rechargeable battery, then charge it up. If you're using a regular battery, then replace it.
- The wires may be connected wrong. Check your connections. A single misplaced wire can cut off power for the entire robot.
- The wires may be broken. It seems like something you wouldn't expect to find, but I have found that broken wires are actually pretty common. Look for broken or frayed insulation, small metal "needles" sticking out of wire sockets (when the pin at the end of the wire comes off and gets stuck), or split wires.
- There may be a problem with the motor driver or micro-controller. Manufacturing defects can cause the systems to not turn on. In that case, replace the micro-controller or motor driver. This is the last resort, because micro-controllers and especially motor drivers can sometimes be rather expensive.
The robot turns on but doesn't move
If you have confirmed that the robot is on, but it doesn't move at all, then:
- The motor power source may be low or empty. Replace the battery. In my experience, these batteries run out pretty fast, because it takes a lot of current to run motors.
- There may be a wiring problem. Look at the section above and check for misplaced or broken wires.
- The motors may be shorted or burned out. This is pretty common, so its worth looking for. Apply direct power to the motors and see if they move.
- The motor driver may be damaged. Check for voltage at the outputs. If the light on the driver is off, it's a clear sign of a defective unit. BE SURE TO CHECK EVERYTHING ELSE! Aside from the chassis, the motor driver is typically the most expensive piece of a robot.
- There may be a programming issue. For me, this is the most common problem. In the case-sensitive language of C (used in Arduino), a single mistake can ruin your whole program. Python (the language of the Raspberry Pi) can also have some issues.
- The micro-controller may be damaged. Sometimes, the logic signal doesn't even reach the motor driver (there's a reason not to jump right to the conclusion of a bad driver). In that case, just replace it.
The robot turns on but moves in an abnormal way
If the robot turns on, but starts moving in an unintended way (for instance, goes in circles when it should be going forward), then:
- There is probably a wiring issue. CHECK THIS FIRST! Did you remember to wire one side reversed?
- There may be a programming error. Check your code for issues.
- Sometimes, a damaged micro-controller can go crazy, repeatedly sending random signals. If a micro-controller does this, then don't bother trying to fix it. It's a clear sign of a chip that's damaged beyond repair, so just go ahead and replace the whole thing. Trust me, those chips are made by robots in a lab. They simply can't be fixed by humans.
- A motor may be damaged. If a motor isn't running, or running at a slower speed, then the robot will slowly "drift" to one side as it moves. There are three ways to solve this. If you are able to, just boost the voltage to that specific motor to bring it up to the same speed as all the others. If not, then try placing resistors on all the motors except for the damaged one. This slows down the other motors to the speed of the damaged one. Finally, you could just replace it. Robot gear motors tend to be pretty cheap, usually at 2-3 dollars. Compare that to a motor driver, which can be anywhere between 10-200 dollars.
If the robot doesn't respond to sensors
If the robot turns on and moves around in a normal way, but doesn't "listen" to sensors or doesn't respond in the right way, it's almost always one of two things.
- There is probably a programming error. Sensors have to be carefully calibrated and programmed. I once had a robot spin around uncontrollably, only to find that I accidentally set it to turn when it sees something within 100 meters instead of 100 centimeters. It constantly saw the walls, making it constantly turn.
- The other most common problem is bad wiring. Even one missing wire can make the sensor nonfunctional.
For any other help, see the above sections or google the specific problem you have. Also, you could contact me at firstname.lastname@example.org if you have any questions.
Please comment about it!