personalrobotics.nl

Portal to the world of personal robotics.

Robot news
Spykee Community
Chat with i-Qbot:01
50 Euro Robot stuff

NEW NEW NEW


Part 2


Part 1

Backgrounds





Click on image to see high resolution picture. Then right-click large image and select "Save As" or "Use As Background".

Download RobotWorld simulator
i-Qbot:01 video tutorial
50 Euro Robot - part 2 Print E-mail
Sunday, 09 September 2007


One of the things I'm really good at is starting new projects. Throughout the day I get ideas for new projects in which I want to learn, explore or built. Somehow I get a rush of energy from starting projects. Finishing them is were the best energy comes from: seeing the end result always is the biggest reward you can get when you start something.

Now that you know the psychology behind this article we can finally start finishing our €50 Robot Project! ;) I received many stimulating reactions to the first part of this project from you and this gives me the right energy to write the second and last part. In part 1 of this project I explained the goal of this project: making a mobile and programmable robot for less than €50 using standard components. I also described the parts that I bought for making the robot. To summarize, I bought:

an Arduino controllerboard,
a Tamiya Truck Tire Set,
a Tamiya Twin-Motor Gearbox,
a Tamiya Ball Caster,
a Breadboard,
a battery holder,
a LED, and
an H-Bridge motor driver.

In this second and final article I will describe how to put these components together and how to program the robot.



Assembling the gearbox & ballcaster

I started building the robot by assembling first the Tamiya Twin-Motor Gearbox. The kit comes with a manual explaining that you can configure the gearbox in three different ways, called resp. 'A', 'B' and 'C' type configurations. The first two types gives you a 58:1 gear ratio and a standard speed. The only difference between A and B is the location of the shaft to which the tires are mounted. The C type gives a 203:1 gear ratio. This results in a lower speed and higher torque. An other difference I discovered between the configuration types is that type A/B is a nondifferential configuration (both wheels always turn in the same direction), whereas type C is a differential configuration. Because I want each of the two motors of the gearbox to drive one wheel independently from the other wheel, I followed the instructions to build the type C gearbox configuration. This will give our robot the possibility to drive forward, backwards and to make turns.

Assembling the type C gearbox is easy if you follow the instructions that come with the gearbox kit. After I finished constructing the gearbox I mounted the tires to the shafts and soldered some electrical wires to the motors. Figure 1 displays the end result. As impatient as I'm, I connected the motors to a 1.5V battery to test the gearbox. Result: it works!

Also the ball caster (see figure 1a) came with an instruction manual that is easy to follow. It is important to make the ball caster as heigh as the gearbox, so that once they are mounted to the robot's base the robot stands horizontally.


Figure 1a - Ball caster.


Figure 1b - Top side robot.


Figure 1c - Left side view robot.


Figure 1d - Bottom side view robot.

Robot base

The gearbox and and ball caster are the only two mechanical components that need to be assembled. The next step is to make a robot base and to mount the gearbox, ball caster, Arduino controller board, battery holder and breadboard to the base. I use a piece of leftover wood I had somewhere laying around. This wood is 4mm think. Any other material can be used for the robot base as long as it does not bend and it is easy to handle.

Figure 1d displays the shape and dimensions of the robot base, while figures 1b and 1c shows you were I mounted the different components. The Arduino controller board and the gearbox were mounted using screws and nuts. The battery holder, breadboard and ball caster were mounted using glue.

Of course, you can come up with your own robot base design and you can make your own choices on where to place the components. The reason I placed the breadboard at the front of the robot base is that it is a convenient place for adding and removing sensors.

Building the electronics

So, by now you have a €50 robot that consists of a wooden base with a gearbox, battery holder, breadboard and Arduino board. We are only two steps away of making the robot actually do something. The first step is to make the electronics, and in particular the motor driver, work. The second step is to program the robot. While the last step is described in the next section, this section describes what to do with the SN754410 H-Bridge motor driver.

Before I start explaining how to connect the motor driver let me first explain what a H-bridge motor driver is good for. Controlling a motor is easy, just connect the two wires that are connected to the motor to a battery and your motor will run. Easy! The motor will run however in one particular direction. Suppose you would like to run the motor into the opposite direction, how can you do that? Also easy you would probably say, just reverse the two wires at the battery poles. Right again. This will let the motor rotate into the other direction.


Figure 2 - H-bridge principle: a) h-bridge circuit, b) close switch s1 and s4 and the motor will turn in one direction, c) close switch s2 and s3 and the motor will turn in the other direction.

In many applications it is not practical to disconnect the wires from the battery and reverse them. Therefore a simple solution has been found that uses four switches. This solution is drawn in figure 2a, which shows a battery, a motor and four switches. In fact, the setup shown in figure 2a is called a H-bridge. All four switches in figure 2a are open and as you can see none of the the motor wires is connected to the battery. To activate the motor you could close switch s1 and s4, as illustrated in figure 2b. The motor will now rotate in one particular direction. Notice that the left wire of the motor is connected to the + pole of the battery and the right wire to the – pole. Now, in order to let the motor rotate in the other direction switches s1 and s4 are opened again, while s2 and s4 are closed. This is illustrated in figure 2c. Notice that now the left wire of the motor is connected to the – pole of the battery, while the right wire is connected to the + pole, the wiring the reversed!

The SN754410 is nothing more or less than the H-bridge described above. The only difference is that the SN754410 uses electronic switches that can be controlled by applying 5V (open) or 0V (closed) to the switch. This way, the H-bridge can be controlled by a micro controller, whose only possibility to operate switches is by generating 0V or 5V.

Maybe you are asking yourself whether this is the only thing you need to know about controlling DC motors. Well, it is if you are only interested in having your motor run at maximum speed in one or two directions. However, in some applications it is handy to have your DC motor run at various different speeds. The basic solution for having a motor run at different speed is to change the voltage of the battery. If you connect your motor to a 3V battery it will run faster then when it is connected to a 1.5V battery. The problem with this solution is that your robot often has one set of batteries with a fixed voltage and you don't want to change that!


Figure 3 - PWM principle. By modulating the duration of the on/off moments in a signal that consists of a series of pulses the average voltage of that signal can be changed: a) pulse width = 2ms, Vavg = 2.5V, b) pulse width = 3ms, Vavg = 3.75V, c) pulse width = 1ms, Vavg = 1.25V.

Again a nice and simple solution has been found to vary the speed of a motor while using a battery with a fixed voltage. This solution is called Pulse Width Modulation control, or just PWM. You can simulate this solution with a battery and a motor. Connect one wire of the motor to the – pole of the battery and with the other wire you tap with a constant frequency the + pole. Now try to vary the time the wire is held against the + pole. Although the motor is probably not running smoothly it will have a lower speed than a motor that is fixed to the battery. You can make the motor run smoothly by increasing the frequency of tapping to let's say 100 times per seconds or more. This is too fast to do by hand, but luckily this can be done with a micro controller, such as the Arduino board. Figure 3 shows what happens with a PWM signal when varying the duration of the on/off moments.


Figure 4 - Motor driver schematics.

Now that you know all about how to control DC motors, let us build the motor driver for our robot. Figure 4 shows the schematics that we need to realize. The SN754410 contains two H-bridges, so we only need one chip to control our two motors. The right motor is connected to the pins labelled 1Y and 2Y of the SN754410 chip. Notice that one of the connectors of the motors of the Tamiya Twin-Motor Gearbox kit is marked with a dot. I define this connector as the – pole of the motor. The 1A and 2A pins of the SN754410 chip are used to control the switches of the H-bridge circuit. These pins are connected to the D3 and D4 outputs of the Arduino board. Finally, the PWM signal to vary the speed of the right motor comes from the D9 output of the Arduino board and is connected to the 1,2EN pin of the SN754410 chip. The wiring for the left motor is pretty much the same and I guess you can understand it by just studying figure 4 carefully.

One important thing to mention is the following. In my experiments I connect the Arduino board by USB to the PC. The Arduino board will now get its power from the USB port. The motors are powered by four 1.5V batteries. In order to let the electronics work properly you need to connect the – pole of the battery to the ground of the Arduino board as illustrated in figure 4.

The actual implementation of the schematics in figure 4 is done by using some electrical wires and the breadboard. Figure 5 shows how I did it.


Figure 5 - Actual wiring of the schematics of figure 4.

Programming

The final step in this project is to program the robot. In part 1 of this project I described how to install the software and how to program and upload a simple LED blinking program to the Arduino board using the Wiring programming language. If you have not read part 1 or you forgot how to setup the software, please read part 1 once again. For this part I show you how to write a program that will make the robot blink its LED, drive forward, and turn, and blink its LED, and drive forward, and ...

Listing 1 shows the complete program. The first thing that needs to be done is to configure the Arduino board by telling which I/O pins will be used as either an input or output port. In our example we only use output ports. Lines 2-8 define some handy constants that helps us in making better human-readable code. The actual configuration of the ports is done in lines 11-20. The Arduino system uses the special function setup() for configuration purposes. This function is called before the actual program – defined by the loop() function – is executed.

I created two support functions to make programming the robot easier. The first function is the setMotors() function which is defined on lines 32-56. This function is used to set the speed of both motors. A negative speed means that the motor should rotate in the other direction. You can see from lines 35-36 and 40-41 that the switches of the H-bridge of the right motor are reversed when the motor needs to rotate in the other direction. The Wiring language provides the function digitalWrite() to set the output voltage of a digital (on/off) port to 5V or 0V. The function analogWrite() generates a PWM signal on a port.

The second support function is blink() which is defined on lines 59-63. This function will let the LED blink for a short moment.

The main loop of our program is defined in the function loop() on lines 23-30. By calling the support functions blink() and setMotors() the robot will

1.blink its LED,
2.drive forward for one second,
3.blink its LED,
4.rotate for one second,
5.goto 1 to repeat everything.

Upload listing 1 to your robot and watch it move! You now finished this project!


Listing 1.

How to go from here

If everything worked out well you have now a robot that you programmed what to do! You have a basis that can be used to do many exciting other projects. Let me just give you some ideas:

- Program your robot so that it makes particular shapes, like circles, squares, 8-shape. You can do this by just modifying Listing 1.
- Add sensors to your robot, such as a light or bumper sensors (switches). To make a program for this you should configure some ports as inputs. More on how to do this can be found on the Arduino tutorial page (see references).
- Let your robot run disconnected from the USB port. This is not too difficult, but just don't forget to change the dipswitch on the board!

Resources

Arduino board
Arduino tutorials
Arduino forum
Last Updated ( Monday, 10 September 2007 )
Next >
Comments

kun je hem alstublieft ook naar het nederlands vertalen dat vindt ik wat makkelyker ik moet noch sparen en ik ga hem maken want ik wil al lang zelf een robot maken
ik heb cybot tom en i-qbot al gemaakt dus deze kan er ook bij

Posted by Brian, on 01/28/2008 at 15:26

 1 
Page 1 of 1 ( 1 comments )
©2006 MosCom

You are not authorized to leave comments - please login.
Main Menu
Home
i-Qbot (i-Droid) project
Spykee robot
50 Euro Robot
Robot building
Robot gallery
Robots & Gadgets winkel (NL)
Forum
Chatbox
Engadget
SMO ShoutBox
Name:

Message:

Robotics Book (Dutch)
Robots & Gadgets (NL)

3D Poki Pico €4,95


Trooper €11,95