Electricity/Electronics for Hackers: Basics: Part 3 (AC/DC, Ohm's Law, Electric Power).
Hello again, fellow hackers and electronic engineers! Welcome to part 3 of my Electricity/Electronics series. In previous parts, we already talked about what electricity is, the most important units in electricity, and the effects of electricity on the human body, as well as a shorter article where I explain how the electricity grid works. Today, we have quite a few subjects to look at, including:
- The difference between AC/DC. A lot of you have been asking me to talk about this.
- Ohm's law. This is the ABC of electricity. It is the most fundamental law in electric/electronic engineering
- Electric power.
With that out of the way, let's get started! First thing we are going to talk about: direct and alternating current!
Direct current, or DC for short, is the most basic version of electricity. We already covered it a little bit in part 2 of this series. DC has a polarity, positive and negative, and the electrons always go in the same direction, from - to +. The voltage doesn't change either. Unlike Alternating Current (AC), DC is much more stable. And thus, it is used in TV's and computers, because the sensitive electronics inside it require a stable voltage.
The most common source of DC are batteries. Though it is also very common that AC is converted into DC. We will learn how to do that in our RPi power supply project. A perfect example of AC > DC conversion is your phone charger. It takes 220V AC from the outlet, steps it down to a lower voltage, and then turns it into a stable DC supply for your phone battery to use.
Since DC is the most basic form of electricity, there is not much to it. Here are the key things you need to remember about DC:
- DC has a polarity, + and -.
- DC only goes in one direction all the time.
- The voltage of a DC power source always stays the same. (except for batteries when they are empty, of course.)
Here you can see DC in a graph:
And here you can view a simulation of DC I made using Java Circuit Simulator. There is one battery on the left acting as a DC source with a value of 12V, and a resistor of 100 ohm acting as a consumer. You can clearly see the current keeps going in the same direction, and that the voltage stays the same (12V).
Let's now move on to Alternating Current, or AC for short. It is this form of electricity that comes out of your outlet in your house. The main difference between AC and DC is that AC, unlike DC, has no permanent polarity. The current of AC changes direction at a certain frequency. This frequency is expressed in Hertz, which means "cycles per second". In Europe, the frequency of the AC coming out of your outlet is 50 Hz (Hertz), in the US, it is 60 Hz. What this means is that if you live in Europe, the polarity of your outlet changes 100 times per second, and in the US, it changes 120 times per second.
To understand this more, let's look at a graph of how 230V AC at 50 Hz looks like, the default standard in Europe.
Remember how 1.5V DC (the voltage of an AA battery) looked like in a graph. The horizontal line once again represents the time, in miliseconds (ms) in this case, and the vertical line represents the voltage. To better understand how AC works, we can view it in steps:
1.) The voltage starts at 0V, and climbs up to 325V in 5 ms. You may be thinking: "But I thought that in the EU the voltage of an outlet was 230V, not 325V!". Technically, this is correct. The effective voltage (which can be compared to "average voltage"), is 230V, but it's peak is 325V. We call this peak the "amplitude". More on amplitude later.
2.) The voltage goes from it's peak voltage of 325V back to 0V, again in 5ms. Because the voltage went to a positive voltage (325V) and back to 0V, we call this part of the cycle the positive alternation, because the voltage is positive (pretty obvious, not?)
3.) Now, the voltage goes negative. To -325V. Then it goes back to 0V. This part of the cycle is known as the negative alternation, because the voltage is negative in this alternation (again, pretty obvious). In the negative alternation, the current goes the other way as it went in the positive alternation. The current goes "backwards".
4.) Now, we are back at step 1. We just completed a cycle. The amount of cycles per second is expressed in hertz or Hz for short.
Here I made a simulation of an AC circuit. The AC source on the left (the circle with the sine-wave in it) generates an effective voltage of 230V with an amplitude of 325V, and at a frequency (cycles per second) of 50Hz. Again, the standard in Europe. Here you can see how AC works: first, we read a positive voltage that increases and then again decreases. Then we get a negative voltage that decreases all the way to it's negative amplitude, and then again rises to 0V and so on... You can also see that when the voltage goes from positive to negative and vice versa, the current also changes directions. Here are a few key things to memorize about AC:
- Has a changing polarity and voltage.
- Has a frequency.
- The direction in which the electrons flow changes.
- Unlike DC, AC can only be generated using kinetic energy.
- The voltage can be changed using transformers, unlike DC.
- AC can not be stored, unlike DC (batteries).
There is much more to AC, but I will keep it at the basics for now. You now understand what AC is essentially, and that is enough for now. I just want you all to know that AC not only powers our homes, but that is also the thing that allows wireless communications! I will cover how that works in a later article.
Yes, AC literally drives the world!
Alright, we've reached the most important part of this entire series: Ohm's law. Ohm's law is the ABC of electricity, so it is VERY important for us to know! Let's begin:
We've already seen what voltage, current, and resistance is. But until now, we've seen them as 3 independant units. The thing is, there is a relation between voltage, current and resistance. This relation is known as "Ohm's law". Ohm's law says:
If voltage increases, so does current. If resistance increases, however, the amount of current drops.
To better help you understand this, I'll give you an example of a cyclist climbing a mountain. The speed of the cyclist is the current, the force he puts on his pedals is the voltage, and the pitch of the mountain he is climbing is the resistance. If the cyclist wants to mantain the same speed when the pitch increases, he will need to increase the force he puts on his pedals, or else he will slow down. When the cyclist wants to maintain the same speed when the pitch decreases, he will need to decrease the force he puts on his pedals, or he will go faster.
The same can be applied to electricity: say that we want to increase the amount of current in our circuit, we have 2 options: either we lower the resistance, or we increase the voltage. If we want to decrease the amount of current, we either need to decrease the amount of voltage, or increase the resistance. Here is a picture that you can use to better understand Ohm's law if you still don't get the concept:
As you can see, voltage is the force that pushes the electrons forward (or pulls them, in case of negative voltage), and the resistance is the thing that is slowing down the flow of electrons.
Alright, let's now see how we can calculate voltage, current, and resistance in a circuit! The basic formula for Ohm's law is:
U = I*R
Which means: voltage (U) equals current (I) multiplied by resistance (R). Let's calculate the amount of voltage needed for 1 ampere to flow in a circuit with a resistance of 1 ohm:
U = 1A * 1ohm = 1V.
Let's now apply this formula to something more practical.
Q: a lamp with an internal resistance of 766 ohm draws 0.3A. What is the voltage applied to this lamp?
A: U = I*R = 0.3A * 766ohm = 229,8V. When we round that up, we get 230V, the voltage used in residential homes in Europe.
There are other formulas too. You can also calculate resistance using this formula:
R = U/I.
Or current, using this formula:
I = U/R
You can remember all these formulas using the, what I call, "URIne pyramid" (a little bit innapropriate, but effective!).
Take not that "V" is the same as "U" in this picture: both stand for voltage.
You all most certainly heard the term "Watt" once in your life. But what is it? Watt is the unit that is used to express electric power. The symbol for electric power is "P", and the unit is Watt (W). So what is the formula for electric power? The formula for electric power is really simple:
P = U*I. Electric power equals voltage multiplied by current.
Let's again use a lamp, but this time one that draws 0.4A at 230V...
P = U*I = 230V * 0.4A = 92W.
The formula for electric power can also be used to calculate current:
I = P/U.
U = P/I.
Ohm's law and electric power can be combined to perform advanced calculations. Here is an example:
Q: A lamp of 102W uses 120V. Calculate the resistance of the lamp.
Alright, there are 2 things we already know:
P = 102W.
U = 120V.
And to get the resistance of the lamp, we would apply Ohm's law like this:
R = U/I.
But there is a problem... We do not know the current! Therefor, we must first calculate the current from the 2 parts of the electric power formula we can already use: wattage and voltage.
I = P/U = 102W/120V = 0.85A.
And now, we can apply Ohm's law:
R = U/I = 120V/0.85A = 141 ohm.
That was it for this part. In the next part, I will talk about some basic components that are used in pretty much every electric circuit. Like capacitors, diodes...
And sorry for anyone who has been waiting for this part for so long. I was studying the effects of electromagnetic induction for our EMP bomb. Good news: I will give the EMP bomb a try! Part 4 will not take as long as part 3.
Lastly, I am on twitter now! I will post updates about my articles and projects on my twitter page. If you wish to have a look, go here.
I hope everyone enjoyed the read! If you have any questions or feedback, feel free to comment below, or send me a PM!