Tutorial, Arduino 4x4 Robot
Blog entry by online123 on Sun, 2014-08-17 02:59
Many people ask me about making a small robot. The truth is it's a bit of a difficult question to answer as there are many ways to do it and of course many different types of robots. In most cases, type robots are typically mounted drive servomotors or DC motors. This is what I am going to show you today, a robot with four-wheel drive with DC motors. The idea here is not to make a big intelligent robot that is able to bring us breakfast in bed (although it would be milk!), But the basis for creating a small robot with four-wheel drive based on Arduino that I could be the basis for a more complete and intelligent robot, including various types of sensors such as distance, GPS or telemetry.
It is a very basic tutorial that everyone can do easily and in no time. After having the base, we can add more complexity. Of course do not hesitate to leave your comments, questions and suggestions!
Tutorial, Arduino 4x4 Robot
As I said before, this little tutorial aims to provide a basis of locomotion for a robot, with its chassis, engines, engine driver and Arduino. Say it is the fundamental part for a robot can move. Once we have a system which are able to control (forward, backward and turns), we can go including some additional sensors depending on the type of robot you want. At this point, and depends largely on the imagination of each, which can range from a simple robot to circulate with predetermined and fixed patterns to a complete robot can avoid obstacles using distance sensors or GPS guided.
Without further ado, we begin!
The key parts to a robot of these characteristics are:
2. Programmable control system (Arduino)
3. Motor Controller
Of course, we can make a frame as either wood, PVC or other light materials, but need more time and planning. Also, do not always know exactly what components are to be used with their respective dimensions and possible drawbacks that arise. Then if we choose to build the chassis from scratch, we need tools and often not at hand. In my case, I chose to use a ready-made chassis is also compatible with Arduino Duemilanove or Arduino UNO new. This case is very sturdy and is made of aluminum, includes four DC motors with built 6V gearbox, wheels, screws, add platform for sensors, power switch, battery box and some wires 5xAA. With him we have practically solved mechanical part and we can spend the next phase of the project.
Programmable control system (Arduino)
Obviously, we need something that allows us to program the robot at will. Since the chassis and has holes for screwing a USB Arduino, I used that model. In my case it is an Arduino Duemilanove, but you can also use an Arduino UNO or Sparkfun Arduino Pro 328, because the characteristics are the same and the code is fully compatible.
An Arduino can not directly manage DC motors, since the maximum current that is capable of providing its output pins is 20mA scarce. Therefore, we need a motor controller which is able to support the load of the engine. This driver will be managed in turn by the Arduino. We always select a controller with engines powerful enough to us to go to use. The four motors included with the chassis work to 6 V and consume about 300 mA at full load. Since we have four engines, we get a total consumption of approximately 4 x 300 = about 1.2 Amps.
A good candidate because of its size and its performance is the dual H-bridge driver based on the popular L298 driver. With two outs, has enough power (25W) to feed the four engines. Wait ... how two outputs? but if we have four engines, then how do?
Well do not worry, because even though this driver only has two outputs, each will use to power the motors in pairs. Group the motors so that the two corresponding to the left of the chassis pararelo be wired and the same for the two corresponding to the right of the chassis motors. With this, we can connect the two left to output engines and the two right engines to output B, as shown in the image:
We must pay attention to how cableamos engines because as you can see, each pair is in the opposite direction, so we cross the wires to rotate in the same direction when we feed. Before continuing, it is advisable to apply tension once wired to check the direction of rotation.
The food is simple because we have a base 5 AA batteries which give us a total of 7.5 volts. This shall be sufficient to power the motors and our Arduino. The atronillada leave the base chassis from the bottom.
Meanwhile, assemble the Arduino and the motor controller in place. Use metal brackets with screws, as we give you a safe and reliable installation.
Then cableamos all well placed with the length of the cables just do not bother. Notice that when wiring the motors in groups of two, only have four wires, which are those that go to the controller.
Do not forget to solder the wires to the ignition switch. The chassis includes one of three contacts, but I preferred to ride one of six.
After connecting the motor to the controller, it's time to connect the Arduino. In the above image is not shown, but do not forget to also contact the power wires coming from the switch! Iran VMS and connected to GND.
The connections to the Arduino will be as follows:
Arduino PIN 8 -> I1
Arduino PIN 9 -> I2
Arduino PIN 11 -> EA
Arduino pin 6 -> I3
Arduino PIN 7 -> I4
Arduino PIN 10 -> EB
These are the control signals are also used as the PWM pin can then vary the motor speed. Also you will need to connect the output of the controller marked as + 5V pin of the Arduino out as VIN. This causes the engine controller to provide power to the Arduino board. Do not forget also to unite the masses with the GND pin.
I used prototype cables male / female to make it easy:
Not much to say about the source code. I made a small set of functions that let you move forward or backward at the speed and direction you want. At the start of the program in the Setup () function I set the pins as outputs and then in the main loop in the Loop () function, I've put a forward sequence for two seconds, kick for another two seconds, turn left and giroderecha two second well. Then the program starts again. It's a good way of doing the first tests and see how the robot behaves. Notice that for rotation needed to rotate the left side as opposed to the right. It is the same system that the tanks. With different speeds we can rotate more or less as needed.