Sei sulla pagina 1di 56

STEP-BY-STEP ROBOT TUTORIAL

STEP 1: UNDERSTAND THE ROBOT

Build a quality robot for under $50 - on your own!


Motivation
Before we get started, I want to tell you about the motivation behind writing
this tutorial.
I remember back when I began building my very first robot. I had been
wanting to build robots for years, since 3rd grade actually. I was completely
fascinated by them. But unfortunately I never had any outside influence to
do this - none. Not a single person I knew understood what even a resistor
was good for, even through highschool! No one to help me, no one to
explain anything, no guidance from teachers, no SoR either! I bought robot
like toys, dabbled with electronics, but didn't have a clue on where to start.
Nature, failed by nurture . . .

Then in my sophomore year in college, I took my first robotics class. The


professor gave us an optional project to build our own robot, and offered
money to anyone up to the challenge. It was my chance! Still had no idea
what I was doing, but I had money to do it!
I immediately started drawing up plans, and began talking with people. Still
clueless, I spoke to two mechanics, a biochemist, a CS prof. Combined I
knew enough to go to Home Depot and buy a bunch of steel beams that I
knew somehow magically connected together. Soon after, I remember
walking into the CMU Robotics Club and saying 'I have these steel beams
and I want to cut them to size, how do I do it?' At first confused by my high
level of incompetence, they agreed to show me how to use the bandsaw.
From that point on, if I needed help, I knew where to find it. Ok so my first
robot was a complete failure, but its where I learned all the basics to get me
started on my own . . . and the rest is history . . .
The point of that story is that people need just two things to build a robot:
o
o

a chance/opportunity
outside guidance

As you have realized, SoR has been the outside guidance people need. Got a
question? Post it in the forum. Need expertise? Read the many tutorials. But
what I haven't offered, at least up to now, is an opportunity.
About This Tutorial
What I am offering in this tutorial is an opportunity for you to build your
own very first robot, step-by-step, for under $50. I spent the time to design a
robot for you, the beginner, based on three metrics. The first is simplicity - it

has to be something that can be easily done by anyone, where mistakes are
hard to make and easy to fix. The second metric is cost - most people
typically cant spend more than $50 to $100 on projects like this. The robot
kits you can buy, at least the good ones, all cost more than $100 thereby
making them very prohibitive to buy. The last metric is quality. I can design
for you a robot that costs under $25, but it would probably take you 5x
longer to make it, and would be significantly harder for you to understand
anything. I dont want you to be a lemming, I want you to understand, too.
But that's not all I'm offering in this tutorial. I'm also going to teach you the
basic steps to going about designing and building all your future robots. And
I am going to do it in a manner so you can use tools from around your house
and the local hardware store.
Serious About Robotics?
One more thing before we begin. Ask yourself how serious you are about
robots. Do you just want to just try it out? Maybe make something for your
child to learn with? Perhaps encourage your highschool students in the
direction of engineering? Or do you want to study it in college? Maybe you
want robotics to be your professional career? If you fall in the latter two
categories, you need to stop being cheap. Seriously, if you want to be a
professional, you need to go all out. Buy yourself some good equipment,
make investments in robot parts, don't cut corners because of cost. Of
course, you don't need to go out buying $5k laser rangefinders, but don't
spend 10 hours making an accelerometer when you can buy one for $10.

If you are a serious builder, build/buy your robot parts under the assumption
they will be scraped for robots in the future. Beginners often spend between
$100-$400 for their first 2 or 3 robots, while experts spend about $0-$40 for
their robots. Why is this? Its because they made the long-term investment. If
you are going to build robots the rest of your life, spend for the long term.
The investment will pay for itself. In all honesty, you may end up spending
$150+ for this robot, but if you are willing to make the investment, in the
long term it will pay off. Either way, I will give multiple options throughout
the tutorial to match each persons wallet (or lack of).
Speaking of which, are you just too poor to invest? If you want to know
more about paying for robots, read my robot funding tutorial.
And just so you know, I designed this robot in such a way that people who
arent serious wont waste money, and those who are serious get good parts to
scrap for their next robot. A quality robot, for under $50. =P
Beginning the Tutorial - Design and Part Selection
As I mentioned, I will teach you the process of making a robot, as you make
it. The very first step anyone would make would be to design your robot.
Interestingly this is where beginners fail. Beginners spend 90% of their time
building, and 10% designing. Experts are the opposite - 90% designing and
10% building. Of course when you are a beginner its hard to design - you
dont always know what works until you try it. But planning never hurts.
A good example of planning a robot would be the CAD work I did for my
sumo robot, Stampy:

Typically the design phase is an iterative process/cycle between design and


part selection, meaning the designer juggles between the design he would
like, and the affordable parts available on the market. The designer will keep
redesigning until both reach a harmony - often a long and tedious task.
There have been several times where I spent a week designing a circuit, only
to find out a key chip I need has been sold out and no longer exists! It forces
me to redesign the whole darn thing. Pain!

But lucky for you, I designed this robot using highly available, easily
replaceable components. For this tutorial you can mostly skip the
design/part selection phase, but its still a very important skill you will need
to learn. In the future, if you are looking for robot components, I have
written up a robots parts list to save you time.
Parts List
Starting you off, these are the parts you need to purchase. Buy them right
after you read through this tutorial, but before you start building anything.
That way the parts have time to ship while you are building the robot
chassis. Note that some of the parts in the optional list can replace the more
expensive parts in the required list. Also, some members have complained
about shipping practices at Digikey.com, so just search for the parts at
mouser.com instead if you feel you may have a problem.
Required Parts:
Item

Cost each ($) Quantity Website, Part #

Hitec HS-311 servo


(modify the servo)

8.99

Servocity.com
31311S

5V Linear Regulator

.50

DigiKey.com
KA7805ETU-ND

ATmega8 AVR

3.66

DigiKey.com
ATMEGA8-16PU-ND

28 pin DIP socket

1.68

DigiKey.com
ED3128-ND

220uF+ Electrolytic
Capacitor

.32

DigiKey.com
565-1038-ND

.1uF Ceramic
Capacitor

.13

DigiKey.com
399-4454-1-ND

36 position
1.74
breakaway male header

DigiKey.com
WM6436-ND

340ohm resistor

.95

5 pack

DigiKey.com
PPC340YCT-ND

1.62Kohm resistor

.49

5 pack

DigiKey.com
1.62KXBK-ND

LED

.19

DigiKey.com
160-1034-ND

CdS Photoresistors

2.99

5 pack

RadioShack

276-1657
Grid-Style PC Board
with 371 Holes

1.99

RadioShack
276-149

And more optional parts.


You will need one of the listed programmers (I will explain the difference
later in part 4).
Enclosed 4 AA Battery
Holder (with On/Off switch)

1.99

9V Battery

.25

1 any store

6v 1400mAh
NiMH Battery

11.95

1 all-battery.com

AVR STK Serial Port


Dongle Programmer

12.95

SparkFun.com
AVR-PG1

AVR ISP2 Programmer

34

DigiKey.com
ATAVRISP2-ND

Pocket AVR Programmer

15

SparkFun.com
PGM-09231

RadioShack
270-409

Part costs may change due to market factors. Last price update Dec 2008 . . .
prices go up with inflation so at some point it'll be over $50 for sure!
Although not necessary, I posted the datasheets of all parts (4mb) for more
information.
If you live in Britain, a generous user has suggested this parts list to save
you money in shipping. Thanks Paula! And if you live in Australia, Smash
has suggested this parts list.
Tools/Misc List
Ok so to be honest, you will probably have to spend more than $50 on your
robot. This robot was designed to use parts you are likely to have around
your house, or that can be borrowed from friends or school . . . but if you
like live in a box, and don't have friends or something, you might have
issues finding these items.
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o

wires
screws
four 1.5V batteries (rechargeable NiMH are best)
cardboard
waterbottle
two rubber bands
chopsticks/popsicle sticks
scotch/duct tape
serial port on your computer
if no serial port, get a usb to serial adaptor cable
sharp scissors
soldering iron
solder roll (22 to 25 gauge)
multimeter (not required, but good to have)
safety goggles (you only have two eyes)

If you cant find any of these items, your local hardware store will have
them. Remember, if you are serious about robotics, make an investment in
good tools and equipment.
What Kind of Robot Are We Going to Build?
In one sentence: we are going to build a differential drive robot, using the
photovore algorithm, with photoresistors, capable of basic object
avoidance. This means your robot can run around your house without
running into objects such as furniture and your cat . . . preferably just the
furniture . . . Please read those tutorials before continuing, as they can give
you a fundamental knowledge of what we will do in this tutorial series.
The Balance - Mechanics, Electronics, and Software
You have probably noticed how I often divide robotics up into these three
separate categories - such as I do in the forum. This is because making
robots involves three independent skills. Only combined, can you make a
functioning robot. When a robot designer makes a robot, he has to account
for all three in the design phase so that each falls into balance. But for this
tutorial, I will do one at a time to make it easier for you to understand. First
will be mechanics where we build the robot, then electronics where we hook
up the brains and sensors, and finally software will be written to program
the robot.

Now that you are ready to start making your very first robot,
continue on to Step 2: Build Your Robot Chassis >>>.
Has this site helped you with your robot? Give us credit - link back, and help others in the forums!
Society of Robots copyright 2005-2010

forum SMF post simple machines

Mechanics - Chassis Construction


In step 2 we will build the chassis of our robot. I didn't use CAD or CNC or
a high precision mill. No space-age materials, either. I built this robot just
using stuff I found around the house, using really common tools. At each
step I will offer ideas of other ways to go about making your chassis,
Chassis Optimization
To optimize anything, you must understand it first. I have assembled a few
additional tutorials that are optional reading to help you understand robotic
mechanical design. The first is on robot chassis construction, giving key
pointers in assembling your robot. The next tutorial is calculating the robot
motor factor, helping you quantitatively choose robot velocity, the motor
torque, and wheel diameter.

If you would like to use or know about more 'professional' materials than
just stuff found around the house, have a look at the list of robot materials.
Chassis Construction
We will now construct the chassis, step by step. When building your robot,
use my example as more of a guide - your imagination is more important.
Remember, I just gathered some things I found in the closet and recycle bin,
and used very basic tools. Do the same, and figure out ways to connect it all
together. Your house has a lot of stuff, be creative! In total, this took me
about one hour of work.
update: Webbot has graciously written up a tutorial on an alternative
method to construct your $50 robot.

The first part is to make the wheels. Either take wheels off an old toy, or get
a sheet of material such as cardboard or plastic. Try to chose a material that
is wide and has high friction. After testing I found that cardboard works fine
on carpet, but slips occasionally on wooden floors. You could also double
up the material, or wrap a rubber band around the rim for better grip. CD's
can make good wheels, too.
Now find a round object, and with a pen trace the object on the material. I
did it the professional way by having my lovely assistant trace a can of
tunafish for me (she requested that I point this out). The recommended
wheel diameter is about 6", but it doesn't really matter. A larger wheel
diameter will allow your robot to go faster and climb bigger objects. We
made a second version of wheels later on using a CD to trace the circle - this
diameter worked really well.

You can also use the lid of a peanutbutter jar, or use a can of tunafish, as
wheels - and wrap rubber bands around them for improved friction.

This is a servo. The HS-311 servo is the most basic, and 2nd cheapest servo
in the market. You could of course buy the cheapest servo in the market,
but its tiny and wont offer much strength to move your robot.
First you must modify your servos so that they can rotate continuously. The
factory default will only allow the servo to rotate 180 degrees.
After modifying your servo, in the servo you will see a screw in the horn.
Take the screw out.
Warning: The screws on these servos are of low quality. Use a fine tip
screwdriver, and be careful not to strip the screw head.

Cut out the traced wheel, and poke a hole into the center using something
sharp (a thumbtack would be fine). Stick the servo screw through the center.
After poking the screw through the wheel you will notice some flange
material sticking up around it. Cut that off using something sharp, like a
razor blade or pointy scissors.

Your servos come with two black box shaped rubber things that have holes
in it. They are called servo mounts.

Using the larger screws that come with the servos, attach the servo mounts

to both servos.

Now find a piece of rigid cardboard or plastic, and cut it into a rectangle
about 3" x 6". Poke 4 holes into it spaced so that the servo mounts can be
screwed into it. Use the screws that come with the servos.
I used my favorite type of robot material, HDPE since I had some laying
around. But you can use wood or even a cereal box if you wanted. If the
material bends too much, duct tape some sticks onto it.

Another method: I didn't try this, but I can imagine just using 'borrowed'
restaurant chopsticks and duct tape, using the chopsticks as sort of a wooden
frame. Put a chopstick on each corner of the servo, then wrap with the tape.
Then connect the other servo in the same manner. Popsicle sticks should
work, too . . .
This is a mockup of what I am thinking. The chopsticks will need to be cut
in half, and I didn't put tape on it, but you get the idea.

Update: Just two months after I posted the idea, a SoR member tried out
the chopstick idea successfully and sent these pics:

"What I did was cut some chopsticks down to about 6 inches, and stuck
them through the screw mounts on the side and taped it up. After that, there
was enough room to put a piece of cardboard in between, put some Velcro
on that, and put a 9 v. on it." - Radiken

This is what it should now look like. I put some black sticky velcro on the
center to attach things, but this is entirely optional and not required for your
robot.

Next, place some tape onto your servo horn. I used folded Scotch tape, but I
found that double-sided foam tape holds better. What this tape does is holds
your wheel to the servo horn to prevent it from spinning independently.

Screw the wheel onto the servo shaft using the screw in the wheel. This is
the completed wheel attached to the servo.

There are also better ways to attach wheels to servos.

Now what you need to do is make a castor. This castor is the 3rd point of
balance for your robot, and needs to be low friction when sliding across
your floor. There are many many ways to do this, but I found this way to
work great.
Get a water bottle, and cut off the mouth.

Cut the bottle in half, but leave the bottom fully attached.

Lay the bottle over your robot as so. The bottom of the bottle will contact
the ground and be the castor.

To attach the bottle to the robot I used two rubber bands. These held really
well, despite how ghetto it looks. You could also use tape or screws to hold
the bottle on.
This is what your final robot chassis should sort of look like.

If you went with the chopstick method, you can get two long sticks that jut
out from the four on the servos, and stick them into a ping pong ball. The
ping pong ball would be the castor.

Optional:
Since I had some basic RC equipment around, I made my robot temporarily
remote controlled just for fun. It is a useful method for testing all new robots
you build to help you work out the mechanical bugs, and truely see what
your robot is capable of. Here is a tutorial on remote control robots.
I attached a battery to the velcro, and put the receiver inside the bottle. Both
servos were attached to the receiver.

Bonus Video!
Just for fun I decided to have a battle between the $50 Dollar Robot (remote
control mode) and Stampy. Ok so it got the crap beaten out of it, but it held
up and didnt break!
(the song used is 'Trip Like I Do' by Filter and Crystal Method )

Now that you have built the chassis for your robot,
lets continue on to Step 3A: Robot Electronics >>>.
Has this site helped you with your robot? Give us credit - link back, and help others in the forums!
Society of Robots copyright 2005-2010

forum SMF post simple machines


 .     
% $ #       !
/  $ .     !,  *.'()
. $ 1$ 1   0 

Electronics
In step 3 of the step-by-step robot tutorial we will now build the brains (electronics systems) of our robot. T
should take you about three to four hours from start to completion.
There are three major electronic systems for all robots, and you will build each of these in this tutorial:
1) Power Regulation - this system ensures your robot always gets enough power and the correct voltages to
other systems without interruption.

2) Microcontroller - this is the actual brain of your robot. It is the device you program, and controls all other

of your robot. For your robot, you will be using the AVR ATmega8 (the big black chip with all the pins stick
of it).

3) Sensors and Actuators - for any control system you need both a sensor for the robot to 'see' the world, bu
actuators to react to what it sees.

Transistioning between mechanical construction and electronics, we need to setup the batteries. There are two
will show you how to do this. The first way I will show you, and also the better yet more expensive method, i
using a 6V RC battery pack. This is the same battery pack I used in Step 2 to test as a remote control robot.

You can probably locate a pack like this from a remote control car you own, buy online for ~$10, or make yo
by putting 5 AA batteries in series. For small robots I recommend NiHM type batteries at 1500mAh and abov
you are serious about robotics, put in the money and buy a battery pack! Its a good investment (I own like 4 o
type of battery, not including all the other types I got).

You should also consider getting an ON/OFF switch for your battery pack, although it isnt really required (yo
just unplug your battery). I got this one for ~$2. Plug your battery into one end, and the other end can go to th
battery connection on your robot. Also, notice the velcro on the bottom of the battery. I will talk about this in
following section.

Now just place the battery pack on the velcro already on your robot. You could also use long cable ties or tap
don't recommend it. What I like about the water bottle on the robot is that I can put stuff into it - batteries, sen

baby squirrels, etc. You could also mount a small box on top of your robot to store the batteries. As a matter o
the Olimex programmer you bought for this project comes in a box that is just the right size. You are only lim
your imagination and what you have available to scrap.

And you're done! (with batteries)


For more battery information, check out the batteries tutorial.

But suppose you don't have the money or don't want to buy a battery pack. There is another way.

The other battery method is to get a battery holder, use the AA's that you have in your digital camera to powe
and a 9V battery to power the AVR microcontroller.

These are three different types of battery holders I own, but the middle one is best because its encased and ha
in ON/OFF switch. All three can be bought from RadioShack (buy the middle one!!!).

Opening the battery holder up, I put four AA NiMH type batteries into it. Make sure you use rechargeable b
as they last much longer and supply much better power to your robot servos (thereby making Al Gore happy)
need four batteries.

If you dont own AA batteries (cause you're weird or something), you can buy them for like $5 at any conveni
store. Get the ones with the highest number for mAh and that say NiMH. Buy a charger if you don't already o
too - or continue reading later on how to make your own battery charger. I assume you have batteries already
most people own a digital camera (so I didnt include it in the $50).

I like to use velcro to attach batteries to small and medium sized robots. This allows me to easily remove batt
recharging, or to quickly put on other robots I've made that share the same battery pack.
Cut a small sheet of velcro into a square as shown.

Remove the protective backing from the velcro and stick the velcro on to the bottom of your battery pack. I re
least one person out there is going to make the dumb mistake of covering up the screw with the velcro - don't
=P

Then just simply attach the velcro to the velcro already on the robot.

If you don't have velcro, you can also drill a small hole inside the plastic, and put a screw through it. Then dri
another hole in your robot, and pass the same screw through that hole too. Lastly, use a nut to tighten the scre
This is a demonstration of me doing it, although I didn't actually drill a hole (pretend, please!).

If you plan to build many robots in the future, I recommend going out to buy a 25 foot roll of velcro for like ~
use it all the time for attaching batteries, and it will last you like 5+ years. Definitely a good investment.

Before we continue, I want to show you a cheap way to recharge your batteries. Search around for a power su
your house that you are no longer using. They are fairly easy to find and/or scrap.

Make sure it outputs the same voltage as your batteries. For example, if you have a 6V RC battery pack, mak
the power supply says 6V. If you put four battery cells together, make sure it says 4.8V (because 4 cells at 1.2
equals 4.8V). Make sure it outputs a low current (trickle charge). 100mA seems to work fine for me. If the ou
current is too high, your batteries could overheat and as a consequence become damaged (or start a fire).

Typical recharge times will be about 10+ hours. The more professional chargers out there that you can bu
take significantly less time, as they are designed to charge as fast as possible without damaging the battery. T

chargers range from $10 to $60, dependent on features.

Now cut off the adaptor end of the long wire. There are two ways you can attach it to your battery. You could
aligator clips to connect the power supply to your battery pack wires (make sure ground and power aren't rev
The method I used is to attach a male header to the wires so it goes right into the RC pack plug. I will talk mo
male headers towards the end of this page.

Now lets go over the components you will need for your first robot. If you would like to learn more about bas
electronics, have a look at the electronics basics tutorial.

This is a 5 pack of photoresistors I bought from RadioShack. This variety is great, cause now I can choose th
photoresistors I like best (aka, give the best sensor readings). For more information on photoresistors, read th
photoresistor tutorial.

This is a prototyping board (known by RadioShack as a 'Component PC Board,' wherever they got that from
To use it, stick your components into the board and solder them in according to the schematic, as I will soon
These boards are also known as 'perf boards', short for perforated boards (has lots of holes in it).

You can also get what is called a breadboard. It works in a similar way to a prototyping board, but none of t
connections are permanent. The benefits are that it doesn't require any soldering, and that you can quickly cha
your circuit as you please (great for experimenting!). The one shown here is a mini-breadboard, small enough
your robot, and it has a sticky backing that you can stick right on to your robot with no effort.

There are two disadvantages to the breadboard: they can be a little costly, and the connections aren't as secure
a prototyping board. I wont be using the mini-bread board for this project, but if you plan to build more robot
future, I suggest you to make an investment =P

These are the parts I got from the DigiKey Order. Note the two grayish bags labeled 'Static Shielding Bag' on
bright yellow warning labels. This basically means that the components inside these bags are static sensitive,
careful. Keep these bags, as they could be useful for your future electronics projects, or at least a good storag
for sensitive electronics.

Your battery is never a fixed voltage. Just because it says 6V doesn't mean it couldn't be 7V or 5V. This volta
always changes, and can cause havoc on your microcontroller and sensors. To correct for this, you need a 5V
regulator. What this does is ensures 5V will always be supplied to your sensitive electronics.

The voltage regulator will have three pins: Unregulated Input, Ground, and Regulated output.

The large capacitor is not entirely necessary, but is good to help reduce electric noise and keep the system po
during sudden power drains. Even a short lived sudden drop in power could reset your robot microcontroller
The value of this capacitor doesn't really matter, but 100uF and above is a good starting point. More servos y
the higher you want it to be. It should also always be rated twice that of your input voltage. Your input voltag
~6V, so you would want it rated for 10V or 15V.

A second 0.1uF capacitor must go between GND and AVCC, as close to the microcontroller pins as you can
This capacitor is required to create a low pass filter for the analog-to-digital (ADC) converter.

If you ever do high precision ADC measurements (unlikely), put a 0.1 uF cap in between AREF and ground a
The point behind having the AREF pin is so you can feed it an input from a super-stable voltage source, and i
scale the ADC inputs from ground up to AREF with the full 10 bits of precision. Of course, you need to make
none of your analog inputs go over AREF if you are using it like that.

The LED will be used as a status indicator. The LED is useful for knowing if your microcontroller is powere
properly, and can output other useful information for testing purposes. A resistor wired in series is required so
the LED from frying. Any resistor value from 10 ohm to 1 kohm will probably work. Higher resistance value

the power drain (good), but also decrease brightness (bad).

Note that the two wires on the LED are different lengths. The longer wire is always + and the shorter is -. The
polarized, meaning they will only work if current goes the correct way. If you connect it in reverse, they will
fry, or just simply not work.

The long black thing with pointy metal pins sticking out of it is called a male breakaway header. These thin
useful for plugging in servos and sensors, can be easily broken to your custom length requirements.

To break them, you can either use your hands, or a pair of sharp snips or scissors also works. Break three of l
five of length 5, and one of length 3.

Click to continue to Step 3B >>>.


This part will involve soldering of components to the perf board.

Has this site helped you with your robot? Give us credit - link back, and help others in the forums!
Society of Robots copyright 2005-2010

forum SMF post simple machines

Electronics, Continued
Continuing from Step 3A, I will now show you the schematic we will use to build the circuit, followed by ste
step instructions on how to wire your robot controller together.

Now you need a schematic. A schematic is a wiring diagram that tells you where to attach wires to all the pa
your circuit. A schematic, to the uninitiated, can be a little overwhelming at first.

So instead of possibly confusing you, I invented what I call a colored dot schematic. I'm willing to bet a 3 ye
can understand this enough to build the circuit . . . (apologies to all 3 year olds reading this tutorial)

Click the below image to open up an enlarged version. As you can see, I color coded each of the pins to deter
which wire goes where. For example, all red dots should be connected to the + of your battery, and all purple
should be connected together. If you're saying, 'gasp! I'm color blind!' Well, I numbered/labeled the pins too.
assume you know how to connect the dots, so I wont go into much detail into which wire goes where. =P

Note: If you are a dot-o-phobe, you can find a visual $50 Robot schematic on this forum post.

Now I must point out that this schematic (and the following tutorial instructions) is for if you decided to use a
battery pack (or an assembly of batteries equal to 6V or greater). But if you went with the battery holder meth
must make the following changes:
o
o
o

A 9V battery must connect to the battery + of the voltage regulator and ground of the voltage regulat
The 4.8V from the battery holder must connect to the ground of the black capacitor and the servo pow
DO NOT connect the battery + end of the capacitor to the battery + end of 4.8V battery!!!!

This is the slightly modified schematic for battery holder users. The blue circles with a red dot in the center
represent the 4.8V, while the red only dots represent the 9V battery connection. All this means is that the serv
power from the 4.8V pack (which can supply a lot of power), while the sensitive low power electronics use th
regulated voltage from the 9V battery. Remember that all grounds need to be common.

If you have never soldered before, check google for soldering tutorials first. I've had a lot of practice solderi
make it look a bit too easy. Feel free to practice on an unused part of your board first with scrap components.
recommended YouTube solder tutorial videos.
Now lets begin building our controller!

As shown, place the DIP socket into your perf board. DO NOT add the microcontroller IC to the socket yet.

It is not required, but I recommend copying the placement of all my components. If you look on the perf boar
will notice a number and letter grid system. This should be used as a guide to help you.

Turn the board over and solder it in. To do so, heat up the pin for about a second or two, then add the solder s
Make sure each and every pin is soldered. Also, make sure the side you are soldering has the copper padding
makes it much easier!

If you don't own a soldering iron, you can get a cheap one for around ~$10. RadioShack also sells them. If yo
to make an investment, get a soldering iron that you can adjust the temperature on, and get nice tips. Rememb
you overheat the iron and apply pressure on the tip, the tip will dull and bend.

Place three of the 6 pin male headers as shown. These pins will be used in the future to plug in your robot sen

Then turn it over and solder each pin in.

In this step we will add more headers and a resistor (do one at a time!).

READ THIS POST before continuing!!! I designed the programmer header for an older programmer version
chances are you will need to convert it to the new 6 pin header. It is easier to wire, it just requires a bit more o
thought. Just check the number of pins on your programmer cable to know if you need 6 pins or 10 pins.

First add the three 5 pin male headers and solder them in. Also, I want you to connect all the pins as you see i
image (or schematic). For the pins closest to the DIP socket, connect each one individually. For the outer row
connect them in parallel, as shown. These parallel rows are your power buses (they 'bus' power around).

Click on the image for an enlarged close-up. The pins will be color-coded to show how to connect them. Noti
skipped a row for the 5 pin headers.

Next add two more rows of the 5 pin headers at the bottom right. Solder those in (pic not included). This will
the ICSP connector of the programmer. Note that if you are using the more expensive programmer, you shou
out this post concerning the different pinouts of the programmer.
Now bend the leads on the resistor into perfect 90 degree angles.

Add the resistor to the perf board, and bend the leads again as shown. Solder both leads, but DO NOT cut the
(not yet)

Now add the LED as shown, slightly above the board. Make sure the longer lead (+) of the polarized LED is
side closer to the DIP socket. Solder it in, but DO NOT cut the leads! (not yet)

Turn the board over, and solder as shown. Click the image for an enlarged close-up. Red represents wires, an
represents a connection with a pin. Reference the schematic if unsure. Notice how I bent the LED wire and re
wire to connect several pins together? You can also use normal wire, but I use this method out of laziness and
ness all rolled into one. Make sure the wire doesn't touch the copper padding.

You may now trim the leads.

Now we will connect all grounds together. I like to use black wire to represent ground because it can save me
confusion if my wiring gets messy. Click the image if you need an enlarged close-up. The blue coloring repre
connections.

Relax, you are already half-way done!

Add the big capacitor and solder the pins in. Make sure that the longer lead is on the side closest to the DIP so
Notice the (-) sign on the capacitor? This is the negative side, which should have the shorter lead. This is imp
because the capacitor, just like the LED, is polarized and only works plugged in the right way. Make sure the
capacitor negative lead is inline with the male header row farthest to the perf board edge. Check the schemati
unsure. (DO NOT CUT LEADS YET!)

Add in the voltage regulator. Make sure you do it as shown! The middle pin of the regulator (ground) should
with the negative lead of the capacitor (ground). You may trim the three voltage regulator leads after solderin
in.

Now add the 3 pin header. If you are using the single cell batteries (ie 4.8V battery holder), you would not ne
header. But if you are going to use a RC battery pack, you could plug it directly into this three pin header. DO
CUT THE LEADS YET!

note: There is a minor mistake I made here that I want to point out. For the 3 pin header, shift it one hole ove
right (from holes CDE to DEF). Have it so the farthest left pin is connected to ground and the middle pin is c

to power.

Now turn the board over and solder as shown. I bent the leads of the capacitor to use as connecting wires, but
also make the connections using real wires. Be aware that these two wires will receive 100% of all current in
circuit - it could be several amps! Click the image to see an enlarged close-up (red for wires and blue for conn
to pins).

Note for those using the 4.8 battery holder:


You want the power from the 9V only going to the electronics, and the power from your AA battery holder go
to the servos. They both share ground, but the + voltages are different and so shouldnt be connected. As such

need to make a small correction to the circuit.

Please see this graphical representation. First, dont solder where the green X is. This seperates the two diffe
power sources. Second, you want the large black capacitor to connect between ground and the servo power b
not have it connected to the voltage regulator input pin. Third, attach the AA power and ground as shown in
graphical representation.
If you are using a 6V battery pack, you can ignore this note.

While you are at it, add in this purple wire. This wire will transfer the output 5V from your regulator to the m
row of the sensor power bus.

Now we want wire up the Programmer ICSP Header (see schematic). I used thin yellow wire for this, so as no
confuse with ground or 5V power. Click to enlarge.

Finally, we will add a ceramic capacitor (non-polarized) between pins AVCC and GND, and connect AVCC
to AREF.

Flipping it over, here is a close-up of the connections.

You are almost done (yaaaaay!)

Click to continue to Step 3C >>>.


We will then test your circuit, connect it to your PC, and build the robot sensors.
Has this site helped you with your robot? Give us credit - link back, and help others in the forums!
Society of Robots copyright 2005-2010

forum SMF post simple machines

Electronics, Continued
Continuing from Step 3B, I will now show you how to test your circuit to
avoid serious failure, how to connect it to your computer for programming,
and how to make your sensors.

If you don't have the proper testing equipment, plug in your battery pack and
pray to the robot gods that your circuit doesn't melt in a pretty fire . . .
The first test is called a connectivity test. Get out a multi-meter and do a
connectivity test to make sure the pins that aren't supposed to be connected
aren't connected. If by chance you accidentally bridged power and ground,
your circuit could spark and your batteries melt. If you put the multi-meter
on the resistance setting, make sure all non-connected pins have at least 5
kohm resistance or you may have power issues. You may need to get your
soldering iron back out to fix any potential problems you find.

Then do what I like to call a 'smoke test.' This is when you power up your
circuit with a power supply. Plug your circuit in, start the voltage at 1V and
work your way up slowly to 6.5V. The current draw should be under 50mA.
If you see a huge current draw (or smoke), there is a mistake in your circuit
so turn off power immediately. Otherwise, at 6.5V, get out your multi-meter
again and check voltages on all the pins to make sure everything is working.

The sensor bus should read 5V (as long as the input is greater than 6V),
while the servo bus should equal your battery voltage.

Plug in the black ATmega8 IC (finally, eh?). Be careful of static electricity.


You may also have to bend in the pins so that they all go in. Be patient

while doing this. After the pins are in, push the IC into the socket carefully.

Plug in the battery. For the 6V battery pack, just plug it in to the 3 pin male
header. Remember to verify that the black wire is going to ground and the
red wire to power! I was dumb and didn't . . . but was also lucky that nothing
fried (the regulator provides some reverse polarity protection, apparently).
Check the schematic for reference.

For the battery holder method at 4.8V:


Solder in the black wire to ground and solder the red wire to the servo power
bus. Check the modified schematic if you aren't sure.

For the battery holder method at 4.8V:


Then with a 9V battery, attach the - to ground and the + to the voltage
regulator input. A good method is to remove a 9V battery connector from an
old toy (or buy cheap from RadioShack) and directly solder the wires onto
your perf board.

Now we will plug in the programmer. On the end of the programmer is the
ICSP header (the black boxy thing). Look for a triangle on the front of it, as
in this picture. This arrow marks pin 1.

Plug in the header as shown. As always, if you aren't sure, check the
schematic. The arrow side should be closest to the ATmega8 IC.

To finish the connection, plug in the other end of the programmer into a
serial port of your computer. If your PC does not have a serial port (such as
my Dell laptop), you will need to buy a serial-to-USB adaptor cable (~$15,
left cable in picture). Optionally, you may also want to buy a serial
extension cable (~$5, right cable in picture).

The extension cable is great if you want to keep your robot plugged in while
it runs around (for sensor output by serial, etc).

Your servo should have three colored wires: red goes to the + of your
battery, black goes to - of your battery, and white (or sometimes yellow)
goes to a digital output pin on your microcontroller (for the control signal).
Again, if you would like to learn more about servos, check out the servo
tutorial.

And if you haven't figured it out yet already, plug your servos into PD0 and

PD1 (pin 2 and pin 3). The black wire of the servo goes to the ground power
bus (the one furthest away from the ATmega8).

Congratulations, you now have functional robot brains! Yum!

Now you must make two photoresistor sensors. Go to the photoresistor


tutorial and follow the detailed instructions. I used a 1.5kohm resistor for R
with the middle sized photoresistors in the RadioShack kit, but your
situation might be different so you might want to recalculate your R value.

You dont need to do the crimping method described to make this sensor, but
its a more professional method and makes your sensor more modular (can
be scrapped for future robots). The disadvantage to it is that the crimping
tool can be a little expensive.

Now attach your photoresistor sensors to the robot. I used packaging tape,
but any method would work. Make sure the sensors are evenly spaced and at
a decent angle. Later, when testing your robot, you will probably need to
adjust the position of the sensors. I also tried poking holes into the bottle for
the sensors to stick out of, but the sensors didn't stay put.

Now plug your sensors into your circuit board, and mount your board onto
your robot. Personally, I recommend using the four big holes in the perf
board corners to screw your board into your robot. But I was lazy and just
stuck it into the water bottle. The problem with this lazy method is that its
difficult to attach your programming cable to your robot when the circuit
board isn't mounted properly. I expect you to mount it properly =P

You will probably have a huge jumble of wires sticking out above your
robot. This is bad design because wires could jostle loose or get tangled on
something. Get a twist-tie from a bag of bread and use it to tie the wires
together, as shown in the above image.
Your robot is almost complete! We just need to program it now . . .

Click to continue on to Step 4 >>>.


In step 4 we will learn how to program the robot.
Has this site helped you with your robot? Give us credit - link back, and help others in the forums!
Society of Robots copyright 2005-2010

forum SMF post simple machines

Build a quality robot for under $50 - on your own!


Programming Your Robot
In step 4 of the step-by-step robot tutorial we will learn how to program
your robot. There are three major steps to programming a robot:
1) Write the program. Cant program you say? No problem, I've written it
already for you! But don't worry you wont get off the hook that easy. I've
written the program so that a beginner can edit and change it to how you
like. In the future, hopefully others will write source code and share for you
to use.
2) Compile the program. Again, this is as easy as pushing the button labeled
'build'. Seriously. Compiling converts your program into a file that your
microcontroller can understand.
3) Upload the program to your microcontroller. Again, just plug in the
programmer, and push the button that says 'program'. Easy, no?

Installing Software
But before we can start programming your robot, you need some software.
Ideally, I would like to give you just one single program to download and
everything will work right away. This is the idea of WinAVR (22.8mb), as
when you download it (yes, please download and install it), you get
everything you need in one go. It will install a bunch of useful programs all
in one location, including GNU Compiler Collection (GCC), GNU Binutils,
avr-libc, avrdude, avrice, and a few others. Its all seamlessly built in, so I
wont even bother you about them. For more information, check out the
WinAVR user manual.
Don't install Programmers Notepad, its useless if you use AVR Studio, and
has been know to be buggy in previous versions.

The next program I will have you download is an IDE (Integrated


Development Environment). Atmel (the producer of the microcontroller you
are using) offers this software, AVR Studio, for free. This IDE has a built in
editor, compiler, uploader, etc all in one package.

Atmel normally requires you to enter annoying registration info like your
email address and phone number, but lucky you I bypassed it to offer you
the direct link (suckers!).
Please download and install in this order:
1 AVR Studio, version 4.13, build 528 (73.8mb)
2 AVR Studio 4.13 SP1 (build 557) (37mb)
3 AVR Studio 4.13 SP2 (build 571) (45mb)
If that link breaks, or if you don't mind telling Atmel your home address for
no reason at all, go here to download the latest AVR Studio software.
And the untested v4.14 build 589 here (89mb).

Now that we have installed all the essential software, lets set up AVR
Studio. Find the new AVR Studio 4 icon in your start menu, click, and you
should immediately see this window come up:

Select 'New Project'

The next window that comes up will look like this:

Copy the options that I have chosen. Make sure there are NO spaces in the
file name.
For example, do not do 'C:\Documents and Settings\User\Desktop . . .'
Also, the project file name must be the same name as the initial file. There is
a 'feature' (bug) in AVR Studio that will cause you problems otherwise.
After clicking Next, another window should come up:

Select AVR Simulator, and choose ATmega8 on the right. Click Finish.
AVR Studio should now load and look something like this:

SOURCE CODE
Now you need to download the source code. Currently, I offer just one
program for your robot, but plan to come out with others later:
Photovore v1.zip (March 10th, 2007) - Case-based photovore program

Empty the contents into the proper folder. For example, for Photovore v1,
empty all files into C:\My_Robots\Photovore_1
Optional: You can also download AVRlib (1.5mb), which is a huge library
of free AVR source code to make your life easier. For more information,
view the online documentation for AVRlib.

Now we need to add in the source code that you downloaded for AVR
Studio. Right click 'Source Files' and left click 'Add Existing Source
File(s)...'.

Locate Photovore_v1.c in your Photovore folder, and add it. You could also
just drag and drop. The source code file is the one you would want to edit if
you wanted to reprogram what actions your robot takes.
Just like with the source files, now right click 'Header Files' and left click
'Add Existing Header File(s)...'.
Locate SoR_Utils.h in your Photovore folder, and add it. This header file is
filled with a lot of useful functions I wrote up for you.

Now we must set up the options to compile your source code. Go to Project
-> Configuration Options.

Check the box that says 'Use External Makefile' and then browse to locate
the makefile (the file in the downloaded source code labeled 'makefile').
Then push OK.

The final programming step is to compile the code. This converts your code
written in C to machine code in a .hex that only your specific
microcontroller can read. You should do a Rebuild All the first time you
compile the downloaded source code. But after that, if you only make
changes to the .c source file, you only need to do the faster Build command.

If all went well, you should see this message after compiling:

If you get errors, and you are new to programming, it may be a little difficult
to debug at first.

Now we need to upload the .hex file you just compiled to the
microcontroller via the AVR STK Serial Port Dongle Programmer. To do
this, you need to download the newest version of PonyProg2000: v2.06f
BETA. For more info on the program, check the PonyProg
Documentation.

After loading up PonyProg2000 again, you want to select 'Open Device


File.' This is the beige folder looking button at the top left. Then go to your
folder that has all your source code, and select/open the .hex file.

You might also need to configure which COM port you have the
programmer plugged in to (serial port), as well as select ATmega8 as the
microcontroller. My laptop has like 8 different USB ports so I had to try a
few before it worked (I'm using a USB to serial adaptor).

If you aren't sure which COM port to use, click:


Start->Settings->Control Panel->System
A new window will come up called 'System Properties'. Open the Hardware
tab and click device manager. You should see this:

Plug in your AVR STK Serial Port Dongle Programmer to both your
computer and your robot if it isn't already from Step 3C. AFTER plugging
your robot in, turn on the microcontroller by flipping the ON/OFF switch, or
plugging in the battery if it doesn't have one. If you were to unplug the
programmer, make sure you turn off your robot first.
Now select 'Write All' from the drop down menu. A Yes/No window will
come up, select Yes. Wait while the program uploads.

If you didn't select the correct port to use for your programmer (because you
still aren't sure), or you forgot to turn your robot on, you will get this error:

Try plugging in your programmer to a different port of your computer and


then push Retry. Try each COM port until it works.
What the error means is that it is not detecting the programmer for at least
one of these reasons:
A) programmer not powered up (check voltages)
B) you are telling it to use the wrong port (check device manager)
C) you have another program running that is using the same port (close
other programs)

update: There is a known problem with PonyProg2000 that it won't work


with a USB to serial adaptor. You might also be interested in this forum
post,
After programming, hopefully, your robot now suddenly tries to commit
suicide by driving off your table. Your are done! Congratulations!
Optional: Dont want to risk the problems some are having with
PonyProg2000? Want to upload your program to your robot in under 30
seconds? You could buy the much more expensive (~$34) AVR ISP 2
programmer that is supported by Atmel (Digikey part # ATAVRISP2-ND).
Its a much better programmer and supports many other Atmel
microcontrollers. You also wouldn't need the PonyProg software and instead
could directly connect with AVR Studio:

If you decide to use this programmer, please check out this post concerning
pinouts of the programmer.
update 2009: You can also try the cheaper but less functional Pocket
Programmer at sparkfun (see parts list on first page). It uses a 10 pin
connection, but most microcontrollers today only come with 6 pin
connections (including the Axon). Just keep that in mind. update 2010:
Users have reported using the more affordable 6-pin ISP programmer by
Pololu successfully. It works fine in AVR Studio, and includes a basic
oscope, too.

Common Compiling Error


I repeatedly see this question asked in the forum. If you see the below error
when you compile, it is because you didn't follow the directions carefully
enough. Make sure you name your files and folders properly.
Photovore_v1.c:108: fatal error: opening dependency file
.dep/Photovore_v1.o.d: No such file or directory
compilation terminated.
make: *** [Photovore_v1.o] Error 1
Build failed with 1 errors and 0 warnings...

Further Reading, More Source Code, and Upgrades


To begin your quest for changing my source code, you may be interested in
reading my robot programming tutorials. You may also be interested in
reading this great post that explains really well on how I programmed the
servos. I wish you luck!
Many of my future robots will now use this microcontroller, so everyone
can benefit from source code that I plan to post for future robots. If you
would like to document and share your robot and source code, or see what
others have done, feel free to check out the member written tutorials.
Questions?
Got questions or comments? Post them on the robot forum! Try a forum
search on '$50' to read questions that have already been asked before
posting your question. I also highly recommend reading this post, as he
seems to have found several problems I havent had time to address yet . . .
Have you finished making your $50 Robot and want to share your
experiences? Or want to see what others have done for ideas? Check out this
$50 robot forum post.

Was that too easy? Want to upgrade your $50 robot?


Go check out how to add sharp IR to your $50 Robot >>>
Or how to upgrade your $50 Robot microcontroller >>>
Or how to add UART functionality to your $50 Robot >>>
Or how to add a bootloader to your $50 Robot >>>
Has this site helped you with your robot? Give us credit - link back, and help others in the forums!
Society of Robots copyright 2005-2010

forum SMF post simple machines

special thanks to http://www.societyofrobots.com


pages downloaded then converted
to pdf format by king of black list
I hope you enjoyed of these

Potrebbero piacerti anche