but when you cannot measure it, when you cannot express it in numbers, your knowledge is of a meagre and unsatisfactory kind;" physicist Lord Kelvin
Our robots work off electricity. To make them work correctly, we have to be the masters of electricity. Before we can master that electricity, we have to understand how it works. My goal with this tip is to help you understand the basics of electricity and electronics and know how to apply it in your creations. Along the way, we will learn how to use some tools we will need. This will be a very long post, but it covers a semester or two of college. So take it in small chunks at a time rather than all at once. We have a lot of ground to cover, so let's roll.
Here is our plan. First, we have to find out what electricity is. Then we will figure out what it's characteristics and effects are. Then we will devise a plan to use its own features against it to make it do our bidding. All with as little math as we can reasonably get away with. But a warning about the math: the more you get into electronics, and robots in general, the more math you will need, so you really should go ahead and start doing it now. Believe me, you WILL need it later! And remember, this is a beginners' tutorial, so I will leave out a lot of the finer points. That is ok for now. Just keep in mind that there is more to the story and hope the purists don't get too upset.
To work with electronics you will need some specialized tools. The first, and probably most important, is a multimeter. A multimeter is a multi-purpose tool that usually combines three instruments: a voltmeter, an ammeter, and an ohmmeter. I recommend you get one now. They can be picked up for under $10 US if you shop around. That won't be a high quality instrument, but it will serve the purpose for now. You can buy very high quality instruments and spend as much as you like, but it is probably a good idea to wait until you know what you really need. Then you can keep the cheap one in your car as a backup. There are two basic types of multimeter: the old style analog ones with a moving needle and the newer digital ones with a numeric display. The analog ones still have their place, but the digital is what you want. We will cover some basics of it's use in this tutorial. When you get one, read the instruction manual and then use it with this tutorial to increase your understanding.
What is electricity? For our purposes here, electricity will mostly mean electrons. You probably already know all matter is made of atoms. Atoms are made of protons, neutrons, and electrons. Protons have a positive electric charge, neutrons have no charge, and electrons have a negative electric charge. The electrons are most interesting to us since they fly around in a cloud outside the atom. Kind of like tiny little space ships orbiting the atom. With a little bit of persuasion we can knock them loose from their atom and send them off to do our work. How can we persuade them to do that? Let's find out?
Those little electrons are pretty happy where they are, just flying around in empty space around their atoms. If we want them to do work for us, we have to get them out of their comfort zone and send them off to where the work needs to be done. We could ask them nicely, but that has never worked for me. So let's use force. That seems to work pretty well. But what kind of force? How about electric force? They are electrons, right? Like charges (negative to negative or positive to positive) repel each other so if we push one electron close another the other will move away. When it gets close to another, it gets pushed away, and on down the line. We need a name for this force and it has several. The first is potential. Because this force has the potential to do some work for us. Like a can of gas. The gas doesn't do any work sitting in the can, but it has the potential to get us somewhere if we put it in our car and burn it. An even better name is electromotive force, abbreviated emf. Electromotive Force, an electron moving force. That's pretty descriptive. Sounds good? Makes sense. Of course, that's why physicists decided to give it another name. Those physicists really like to name things after each other, just to confuse us. So they renamed electromotive force volts after Alessandro Volta. He was some guy that invented a battery. Volts is just a measure of force pushing on electrons. Three volts pushes three times as hard as one volt. The more volts you have, the harder you can push. Like when your car burns up all that gas you put in and you have to push it home, two friends helping you makes it go quicker and easier.
There is one very important point about voltage. No matter what else you forget about voltage, always remember this: Volts are always measured relative to some reference point! There really is not any zero volts. When measuring or calculating volts, it is always understood that it is compared to some point. If I say I have a 9 volt battery, that means the positive terminal of the battery is 9 volts more than the negative terminal. The negative terminal is the reference point. In our electronic devices, we normally connect all our reference points together to make one, and call it ground. ( I will explain later why we call it that.) Then all of our voltage measurements are relative to that reference, or ground. You can't measure volts with one wire. A voltmeter (a device to measure volts) has two wires. One gets connected to the reference point and the other to the place you are interested in. The meter then tells you the difference between the two points. Remember that. It is critical.
Go find a battery. Doesn't matter what kind, any will do. Take out your handy multimeter and turn it to the voltage measuring range. If it is autoranging, you don't have to worry about the scale. If it is manual ranging you will need to select the proper voltage range, which will be the lowest range that is higher than your battery voltage. So if you have a 12 volt battery and your meter has 2 volt and 20 volt scales, choose the 20 volt scale. Make sure the wires (probes) are plugged into the proper holes for measuring voltage. BAD THINGS happen if you have them in the wrong holes. Don't ask how I know. Without the probes touching anything, it may show zero but more likely it will show some small numbers. Don't worry about that, it is just an arifact of how the meter works. The negative probe is probably black. Touch it to the negative terminal of the battery. Then touch the other to the positive terminal. The meter should read something close to the battery voltage. It probably won't be exact, but it should be something close. You have just made your first voltage measurement. Now switch the probes to the opposite terminals. The display should show a negative number. That is because voltage measurements are always relative to the reference point, which is measured from the common (black) wire of the meter. Congratulations!
We are making progress. Now we know that electricity is electrons. We know to make them work for us we have to get them moving by use of force. We know to call that force voltage and that volts are always measured relative to some reference. But how much work can they do? Those electrons are pretty small. We probably can't expect to get much work out of each one. We are going to need a lot of them to get much work done. If we count up how many of those little guys we send off to work in, say, one second, then we should be able to figure out how much work we can expect out of them. When we look at a river, we talk about how much water is flowing and how fast by calling it the current. Same with electricity. We call the amount of electrons passing by in one second current. The name, of course, comes from some dead guy named Andre-Marie Ampere. He figured out a lot about how to get these electrons to do work for us, so maybe that's ok. We measure current in amperes, or just amps for short. Amperes, or amps, tells us how many electrons pass by in one second. One amp turns out to be about 6.23 * 10^23 ( or 623,000,000,000,000,000,000,000) electrons in one second. I told you we needed a lot of them! You aren't likely to need to know that, but I think it's interesting. Most of our circuits will need much less than an amp. Milliamps ( .001 amp) and microamps (.000001 amp) are common in most of our circuits, and sometimes even nanoamps( .000000001 amp) and picoamps( .000000000001 amp). When we control motors or other devices that do real work, we might need amps, but most of the time we will need much less. Like a river that flows from high elevation to low elevation, current in our circuits flows from high voltage to low voltage. If there is no difference in voltage between two points, no current will flow between them. That's important, so remember it.
Ben Franklin and the Party Poopers
No, that isn't the name of the latest punk rock band. Let's have a (short) history lesson. It seems Ben Franklin wasn't just a politician, but also a scientist. He studied electricity a lot. You've probably heard about his kite flying adventure. He is the guy that figured out there were positive charges and negative charges. It doesn't really matter which is which, just that they are different. But he had to call one positive and one negative, so he made a choice. Well, being a politician, he got it wrong. I just told you that current goes from high voltage to low voltage. It seems electrons actually go the other way. Then how can we say current goes from positive to negative if current is electrons and they move the other way? Well, when an electron leaves it's atom, it leaves behind an empty spot, called a hole. Since the atom was electrically balanced before, with equal numbers of protons (positive charge) and electrons (negative charge), they canceled each other out. But when an electron goes missing leaving a hole, the atom then has a positive charge. The positive charged holes "appear" to move in the right direction as the electrons scurry from atom to atom trying to rest while we are trying to get work out of them. This really doesn't matter to us for the most part. I mention it here for two reasons. One, because it is technically accurate. Two, and much more important, is because there is a religion, I call them electron flowists, that hold Ben Franklin as their prophet. Even though the whole world, the physicists, chemists, electrical engineers and technicians, electricians, battery makers, hobbysists, and everyone else who deals with electicity have decided that current goes from positive to negative, the electron flowists demand that it goes the other way. They will fight you over it. They always seem to pop up when someone is trying to learn electronics. They argue, quote the Book of Ben, and generally create a nuisance. They write nasty letters to the editor, they make ugly remarks in Internet forums, they start arguments and fights at parties. They are trouble. They are radicals, trying to change the world to suit them. Stay away from them. Don't talk to them. Don't invite them to parties. They are party poopers, trying to steal our fun. Heed my warning or you will live to regret it.
When we used our multimeter to measure voltage, we just connected it to two convenient points where we needed to know the voltage. We didn't need to disturb anything since the meter was not part of the circuit. Measuring current is different. Since we are trying to measure how much current is flowing through our circuit, we have to actually make the meter part of the circuit. To do that, a connection has to be disconnected, or broken, and one probe of the meter connected to each side of the break. Then, the current flows through the meter just as it flows through the rest of the circuit. Make sure you move the probe connections on the meter to the proper holes or it won't work. And make sure you select the proper range. The meter normally has a fuse or two inside and if more current goes through it than it is rated for, the fuse blows. I learned a long time ago to keep a stock of multimeter fuses! Many meters have two probe connections for measuring current: a low range for all the ranges up to 200 milliamps, and a high range for something like 10 amps. If you use the low range to measure high current it is possible to damage the meter. Start out on the high range if you are unsure.
If you run a factory with lots of workers, you send them off to work each day, but you have to let them go home when they have finished their work. If you don't let them go home at the end of the day, you would have to send a new batch of workers the next day. Soon, the factory would be full of used-up workers and no more would be able to fit to do their work. Electrons are the same way. They have to be able to get back home after they have done their work. Since electrons can only work when they are moving, they have to have a continous path: They follow it to their place of work, do their work, and keep following the path back home. Like a two lane highway. One lane to get to work, one lane to get home. If you break that path, the electrons start to pile up and quit working. We don't want that. They always have to have a continuous path to and from work, or they won't work. That is another one of those "gotta remember it" things. One side of that path is often connected to the common reference point that we call ground. Since the electrons make a continuous loop, we call it a circuit.
Now is as good a time as any to explain why it is called ground. Seems the Earth itself is a huge conductor. Since it is a convenient reference point for all of us ( I assume if you are reading this you are not an astronaut), we often base our voltage measurements on it. Sometimes, but not usually with robots, we actually connect our circuit to the Earth. The electric power coming into your house is like that. Radio transmissions (normally) use the Earth as one side of their circuit. Often, if a circuit is actually connected to the Earth, it will be called an earth ground to make that clear. Like I said, with our circuits, and especially robots, we probably won't do that. But we still call the common point ground, or sometimes just circuit common or even just common.
Join the Resistance!
Enough talking. Let's get our hands dirty and make a circuit and see what happens. Well, actually, let's make it on paper. We don't really want to make this circuit and you will see why soon. Take a battery. Doesn't matter what battery. Any battery will do. We need a power source to provide voltage ( electromotive force, remember?) and make current flow (amps). Get a piece of wire. We need that to connect the positive terminal of the battery to the negative and make a circuit. The terminals are connected inside the battery ( with some nasty, gooey stuff usually) to make the other half of the circuit. The chemicals inside the battery are what create the voltage. Let's skip the chemistry lesson and just call it magic for now. The wizards at Duracell put magic in there for us. We just accept that. So we have our battery, we have our wire, we are ready. This is going to be exciting. Our first circuit! Hmmm, might want to get a camera and video this. The moment of truth. Here we go. Ready?
We want current to flow from the battery into the wire. Since current flows from positive to negative (go away electron flowists!) take the wire and touch one end to the positive terminal of the battery. Hmmm, that wasn't very exciting. Nothing happened. Oh, yeah. We have to make a circuit, or a continuous loop. So...
Do NOT connect the other side. Electricity can be very dangerous. This is the first lesson in that. Depending on the battery and wire you use, a few things could happen. It might only make the wire and battery a little warm. It might melt the wire. It might even blow up the battery. Many years ago I was playing with a very powerful lithium battery. It was so powerful, the maker put a fuse in it to keep it from exploding. I managed to blow the fuse. Undaunted, I decided to replace the fuse with a paper clip. I had to hold the paper clip with my finger and thumb. It got so hot the metal evaporated in my hand. I had a scar on my finger and thumb in the shape of a paper clip for many years to remind me of my stupidity.
If you are not absolutely certain something is safe, ask someone who knows!
If we did connect the wire to both terminals, we would have a circuit. Current could flow out the positive terminal, through the wire, and back into the battery. The electrons would be happy to work for us, knowing they could get back home when they were finished. We are not going to do that, because it can be dangerous and nothing useful to us right now would happen. But here is a question. We have a voltage from the battery. We can make a circuit with the wire. How much work can be done? That depends on how much current there is. So the real question is, how much current will flow through the wire. To answer that we need to know about resistance. Resistance is what slows down the flow of electrons. If nothing prevented you from doing so, you would probably drive as fast as possible to and from work. But quite a few things slow you down. Traffic, road conditions, that cool guy with the fancy hat, sunglasses, and the fast car with blue ( or green, or whatever) lights on top. Those things provide resistance and slow you down. All materials provide resistance to electrons moving about. The ones that don't have much resistance are called conductors. The ones with lots of resistance are called insulators. Some are in between. Most metals, especially copper, gold, silver, and aluminum, are good conductors. Most plastics are good insulators. Air is usually a pretty good insulator, too. And water is usually a pretty good conductor. But not distilled water. It needs to have impurities in it. But it is important to remember that all materials, even conductors, have resistance. There are superconductors that don't have resistance, but unless you are going to put a tank of liquid nitrogen on your robot you don't need to worry about that. Besides, resistance is often a good thing. The more resistance in a circuit, the less current can flow. If you want less current, add more resistance. If you want more current, take away some resistance. You know how those scientists like to name stuff after each other? This German dude named Georg Ohm figured this resistance stuff out, so guess what units we use to measure resistance. Surprise. Ohms. A circuit might have 1 ohm of resistance, another might have 100 ohms or even 47 kilohms (47000 kilo means multiply by 1000). The most common component used in electronics is a device whose only function is to add resistance to the circuit. In a flash of creativity, scientists name it a resistor.
The third thing that almost all multimeters measure is resistance. When measuring voltage or current, the meter was measuring the electricity already present. To measure resistance, the meter provides the voltage and measures how much current flows. If there is already any electricity in the circuit, it will change the meter readings and possibly damage the meter. You almost never want to try to measure resistance of something that has power applied. You can sometimes measure resistance of a part that is in a circuit, but remove all power first. Likewise, it is sometimes useful to measure the resistance of an entire circuit, but again remove power first. Typically, we measure the resistance of a part all by itself, often not connected to anything. If you have a resistor nearby, set your meter on the Ohms scale and touch one probe to each side of the resistor. You may have to change the scale to get a good reading. It should be close to the stated resistance. Now set the meter to a high range, say 2 megaohm, and hold a probe tip tightly in each hand, between your finger and thumb. Do you get a reading? You are measuring the resistance of your body, from one hand to the other. Now lick your fingers and thumb (oooh, gross!) where you hold the probes and measure again. When dry, the resistance is probably somewhere around 200,000 Ohms. When wet, it may go down as low as 10,000. That is one way lie detectors work. They measure your skin resistance. When you lie, you sweat a little, moistening the skin. The lie detector measures that change. Try measuring the resistance of things you have around. Maybe a paper clip, or a wire, or a motor, or a pencil lead. Get a feel for the resistances of different items.
It's the Law
We learned about resistance, but we still don't know how much current is going to flow through our circuit. Mr. Ohm figured it out for us, so they named the law after him, too. Ohm's law. It isn't so much a law as a guide, since it isn't always true. But it's close enough, and that's what it is called, so who am I to try to change things. We will call it Ohm's law like everybody else and move on. We have come a long way and I hope you have a pretty good understanding of what voltage, current, and resistance are. So far, we haven't used ANY math! Can you believe it? Party's over. Here it comes. But for now some simple arithmetic is all we need. You made it through fifth grade, didn't you? That is about all the math we need for a while.
I can't stress how important this is. You will (or should!) use it EVERY time you deal with electronics. Everything else is based on it. It is the foundation. Without Ohm's law nothing else will make sense. Ok, ok. I will get on with it. Here is Ohm's law in all it's glory:
E = I x R
That wasn't so bad, was it? Pretty simple. What does it mean? Here is a cheat sheet:
E = Electromotive force ( voltage, remember?) in volts.
I = Current (don't ask why they use I, just go with it. C is used for other things) in amps (amperes if you want to be fussy.)
R = Resistance in ohms.
That tells us that Voltage (E) is equal to Current (I) times Resistance (R). We can rearrange the equation two other ways, so as long as we know two of the terms, we can find the third:
I = E / R
R = E / I
or use this triange to remember it.
Cover the one you don't know and it gives you the formula to find it. Now we can answer the question "how much current will flow in my circuit?" Let's try an example. Suppose we take a 6 volt battery. We are going to connect a resistance of 2 ohms across the terminals. How much current will flow through that resistance? Current, or I, is the term we don't know. So go to the triangle above and cover the I with your finger. That leaves an E over an R exposed. So our formula is E (volts) divided by R (ohms) or 6 volts / 2 ohms = 3 amps. Remember your units. Always. That wasn't too hard. Here is another. You have a resistance in a circuit that isn't marked. You know it is connected across a 12 Volt car battery and you use your multimeter to measure the current. You find the current is 2 amps. What is the resistance? Cover the R in the triangle and that leaves E over I. So divide 12 volts / 2 amps = 6 ohms. One more before we move on. We have a "muscle wire" we want to use in a robot arm. A muscle wire gets shorter when you pass a current through it to heat it up. The data sheet says we need to pass 200 milliamps (0.2 amps) through it to activate it. We know the muscle wire has almost zero resistance so we have to add some to limit the current. The only suitable resistor we have is 10 ohms, so we use that. How much voltage do we need to apply to make 0.2 amps flow? This one is a bit harder, but more realistic. A milliamp is .001 amp, so 200 of them is 0.2 amp. These are commonly used units. We know the resistance (10 ohms) and the current (0.2 amps). We need to find E. Cover the E in the triangle. That leaves I x R. Multiply 0.2 amps times ten ohms = 2 volts. Applying 2 volts to the muscle wire will make the proper current flow to activate the wire. Pretty neat, huh?
I've got the power
We have covered the three basic measurements in electronics, and we are almost finished. There is one more fundamental measurement we need to cover before we move to more advanced stuff: power. We talk about power all the time, but what is it? Before we can define power, we have to define energy. Energy is the ability to do work. It might be kinetic energy (something in motion) or potential energy (a weight on a table) or chemical energy (gasoline) or, the case we are most interested in, electrical energy. We can't create or destroy energy. All we can do is transform it from one form to another. Eventually, most energy gets transformed into heat. Energy is measured in several different units, but the best and easiest (and standard!) unit is the Joule. You may have heard of a joule thief. Now you know where the funny name comes from. Bet you can't guess why it is called a Joule? Yep, the physicist James Prescott Joule. Those physicists are so original. OK, that's nice. Now what is power? Well, power is how fast we can transform energy from one form to another. Power is measured in watts. This one is named after a Scottish engineer, James Watt. One watt means we are converting energy from one form to another at the rate of one joule per second. So a 1000 watt electric heater is converting 1000 joules of electric energy to heat energy every second. Many people get confused about the difference between energy and power, or joules and watts. It is important to understand the difference. Consider a battery. A single AA battery may hold 10,000 joules of energy just sitting there doing nothing. When it is just sitting there, not connected to anything, the energy is stored but it isn't being used, or converted. So there are not watts involved. When you connect it into a circuit and starting using the energy, you can measure the watts to find out how fast the energy is being used.
Where does that leave us? We know that energy is the ability to work, and comes in lots of different forms. We know that power is how fast we convert that energy from one form to another. How does that apply to electricity? It turns out that we can calculate power from what we have already learned. What a coincidence, huh? There is a simple formula for it.
P = E x I
This tells us that Power (P) is equal to Voltage (E, remember electromotive force?) times Current (I). As a quick example, say we have a 12 volt battery powering a circuit that takes 3 amps. The power is 12 volts times 3 amps = 36 watts of energy being converted to some other form. Thats a lot of power. You wouldn't want to touch the business end of a 36 watt soldering iron! That electrical energy may be converted to mechanical energy in a motor, or radiated (light) energy in an LED, or sound energy in a speaker, or something else, but most will be converted to (or dissipated as) heat. That is why electronics get hot, and why your components can "burn out." Let's go back to the simple circuit of a battery and a resistor. With a 2 ohm resistor connected across a six volt battery, we find that 6 volts / 2 ohms gives us 3 amps from ohm's law. Put the 6 volts and 3 amps into the power formula, 6 volts x 3 amps = 18 watts. As far as I know, the physicists haven't found anybody to name the power formula after. There are a couple shortcuts we can take. Since we often know the voltage across a resistance or the current through a resistance and need to know the power it dissipates, we can feed ohm's law and the power formula into the magic algebra machine that I keep in the basement and get these two formulas:
P = I x I x R
P = E x E / R.
Resistors have power ratings, like 1/8 watt or 1/4 watt or even 5 watts. Now you know why. When you use it in a circuit it will dissipate some of the energy as heat. You need to make sure you use a resistor with a wattage rating higher than it will dissipate.
Finally, a real circuit
We have come a long way. So far we have mostly covered a lot of background theory. It is time to actually put it to practice. Gather up some parts and equipment. Here is what you need: A 9 volt battery, an led, a couple resistors close to 1000 ohms (1K), and your trusty multimeter. You also need some stuff to connect it all together. You need some wire at least. You should also get a battery snap connector for the battery and a breadboard will be handy. You can get by with just the wire, but the other stuff makes it easier. If you can't find 1K resistors, you can use anything from 470 ohms to about 4700 ohms (4.7 K).
Got everything gathered up? Good. Let's build it. Here is the schematic diagram of the circuit.
Connect the plus side of the battery to one end of one resistor. Connect the other end of that resistor to one lead (wire) of the LED. Now the LED is special. It only works one way. Most LEDs have one lead longer than the other and that is the + side. Connect that side to the resistor. Then connect the other side of the LED to the negative (-) terminal of the battery. The LED should light up! AWESOME! You have built a working circuit! If it did not light up, try turning the LED around by swapping it's connections. If that doesn't work, make sure you have a complete circuit. Remember, those electrons won't go to work if they can't get back home! If that still doesn't work, check all your connections to make sure they are good, make sure you have a good battery, and try a different LED and resistor.
Now that you have it working, let's take some measurements with the multimeter and test what we have learned. Leave the circuit all connected up and working for these measurements. First, set your meter to volts and measure the battery voltage. Connect the leads of the meter directly to the battery plus (red) and minus (black). Write down what you get. It should be pretty close to 9V if the battery is new. It probably will be a little more or a little less, depending on how old it is. If it is really old it may be as low as about 7V. Whatever you get, write that number down. Now, leave the negative (black) lead connected to the battery and move the positive (red) lead to where the LED and resistor are connected. Write down what you got. It was probably somewhere between 1.5V and 5V depending on what color your LED is. That's interesting. We will come back to it. For now, just write the voltage down. Then, measure the voltage across the resistor. Connect the plus lead of the meter to the plus terminal of the battery and connect the negative lead of the meter to connection (junction) of the resistor and LED and write down the voltage. What did you get? Now add that voltage to the voltage you measured across the LED. It should be almost exactly what you measured across the battery alone! MAGIC!
OK, so it isn't magic. Let's figure out what is going on. Voltage is pressure pushing on the electrons, right? Well, they get up in the morning and head to work. They are eager and ready to go. So out the door they run on their way to work trying to get it done. They are pushing hard. Then they meet Mr. Resistor and have to push through him to get to the LED. They lose some of that pressure pushing through the resistor, but they still have some left. But now the voltage (pressure) is lower than it was. Finally they get to the LED where they push photons (light) out into space and make the LED light up. They use up all the energy they have left doing that , saving just enough to get home. So their voltage is all gone. The change in voltage as the electrons go through a component is called voltage drop. Every resistance causes voltage drop. All the voltage drops ALWAYS add up to the applied voltage (the battery voltage).
to be continued