- A 9V battery must connect to the battery + of the voltage regulator andground of the voltage regulator.
- The 4.8V from the battery holder must connect to the ground of the black capacitor and the servo power bus.
- DO NOT connect the battery + end of the capacitor to the battery + end of 4.8V battery!!!!

Transistioning between mechanical construction and electronics, we need to setup the batteries. There are two ways I will show you how to do this. The first way I will show you, and also the better yet more expensive method, is by using a 6V RC battery pack. This is the same battery pack I used in Step 2 to test as a remote control robot.
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 power servos, 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 has a built-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 batteries, as they last much longer and supply much better power to your robot servos (thereby making Al Gore happy). You need four batteries.If you dont own AA batteries (cause you're weird or something), you can buy them for like $5 at any convenience store. Get the ones with the highest number for mAh and that say NiMH. Buy a charger if you don't already own one, too - or continue reading later on how to make your own battery charger. I assume you have batteries already cause 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 batteries for 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.
Then just simply attach the velcro to the velcro already on the robot.
Before we continue, I want to show you a cheap way to recharge your batteries. Search around for a power supply in your house that you are no longer using. They are fairly easy to find and/or scrap.
Now lets go over the components you will need for your first robot. If you would like to learn more about basic 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 the 2 photoresistors I like best (aka, give the best sensor readings). For more information on photoresistors, read the 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 show. These boards are also known as 'perf boards', short for perforated boards (has lots of holes in it).
These are the parts I got from the DigiKey Order. Note the two grayish bags labeled 'Static Shielding Bag' on the bright yellow warning labels. This basically means that the components inside these bags are static sensitive, so be careful. Keep these bags, as they could be useful for your future electronics projects, or at least a good storage place 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 voltage always changes, and can cause havoc on your microcontroller and sensors. To correct for this, you need a 5V voltage regulator. What this does is ensures 5V will always be supplied to your sensitive electronics.
The large capacitor is not entirely necessary, but is good to help reduce electric noise and keep the system powered during sudden power drains. Even a short lived sudden drop in power could reset your robot microcontroller (bad). The value of this capacitor doesn't really matter, but 100uF and above is a good starting point. More servos you use, the higher you want it to be. It should also always be rated twice that of your input voltage. Your input voltage is ~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 make it. 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 as well. The point behind having the AREF pin is so you can feed it an input from a super-stable voltage source, and it will scale the ADC inputs from ground up to AREF with the full 10 bits of precision. Of course, you need to make sure 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 powered properly, and can output other useful information for testing purposes. A resistor wired in series is required so keep the LED from frying. Any resistor value from 10 ohm to 1 kohm will probably work. Higher resistance values reduce the power drain (good), but also decrease brightness (bad).
The long black thing with pointy metal pins sticking out of it is called a male breakaway header. These things, useful for plugging in servos and sensors, can be easily broken to your custom length requirements.

Now you need a schematic. A schematic is a wiring diagram that tells you where to attach wires to all the parts in 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 year old 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 determine which wire goes where. For example, all red dots should be connected to the + of your battery, and all purple dots should be connected together. If you're saying, 'gasp! I'm color blind!' Well, I numbered/labeled the pins too. Ill assume you know how to connect the dots, so I wont go into much detail into which wire goes where. =P

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 board, you will notice a number and letter grid system. This should be used as a guide to help you.
Place three of the 6 pin male headers as shown. These pins will be used in the future to plug in your robot sensors.
In this step we will add more headers and a resistor (do one at a time!). I designed the programmer header for an older programmer version, so 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 of thought. Just check the number of pins on your programmer cable to know if you need 6 pins or 10 pins.
Now add the LED as shown, slightly above the board. Make sure the longer lead (+) of the polarized LED is on the side closer to the DIP socket. Solder it in, but DO NOT cut the leads! (not yet)
Now we will connect all grounds together. I like to use black wire to represent ground because it can save me a lot of confusion if my wiring gets messy. Click the image if you need an enlarged close-up. The blue coloring represents connections.
Add the big capacitor and solder the pins in. Make sure that the longer lead is on the side closest to the DIP socket. Notice the (-) sign on the capacitor? This is the negative side, which should have the shorter lead. This is important 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 schematic if unsure. (DO NOT CUT LEADS YET!)
While you are at it, add in this purple wire. This wire will transfer the output 5V from your regulator to the middle 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 not to 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 directly to AREF.

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.
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.
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.
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.
Now you must make two photoresistor sensors. Go to the photoresistor tutorialand 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.
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.
0 comments:
Post a Comment