Hello 0x00'ers, I am back at writing hardware related articles! In this article, we will take important steps. We will first of all be looking at AC vs DC, since there seems to be a lot of confusion about it amongst you software peeps . After that, I will cover new concepts: the "amount" of electricity (charge), electrical resistance & Ohm's law, and finally electrical power. Let's get started!
Direct current, or DC for short, is the most basic version of electricity. We already covered it a little bit in part 1 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, because the direction of current depends on the polarity of the voltage. 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 a phone charger project. A perfect example of AC > DC conversion is your phone charger. It takes 230V (or 120 in North America) 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).
"But I thought current went from - to +, why does it go to + to - in your simulation?!" Well, in the early beginnings we electrical engineers were not so smart and we thought current went from + to - initially. Only later did we discover it was actually the other way around. But there is one problem: every formula was built on the idea of + going to -! So what was decided is that we'd have 2 types of current: the real current from - to +, and to keep things simple without changing the entire world of EE, we introduced the classic idea of + to - as "conventional current", and it is what electrical engineers use to keep things simple. I'll also use conventional current all the time in my projects, just know that in reality it is the other way around.
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 (hence why it is called "alternating current"). 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!
Ever wondered what it would be called if you would put all the electrons that flowed through a wire for a certain time in one glass? Well, that is called electric charge! Electric charge is essentially the amount of electrons that flow in a specific time. The unit for electric charge is "Coulomb (C)", and it's symbol in formula's is "Q". From the description I gave, we can say that this formula is true:
Q = I * t
Q is the electric charge in Coulomb, or A.s/A.h (1C = 1A.s, 1A.h = 3600 A.s/C).
I is the electrical current, measured in Ampere as always.
t is the time that the current flows. Note: it is NOT a capital "T"! a capital "T" means temperature and is not needed in this formula). The time is expressed in seconds.
We can also draw other formulas from here now:
I = Q / t
t = Q/I
So, where does this come in practically? You will mostly find this in batteries, but it is not limited to that. For example, I have a phone that has a battery with a charge of 2700mAh (2.7Ah or ). Now we know that this battery can deliver 2.7A for an entire hour straight! (Remember that A.h stands for "Ampere-hour", which means that it can deliver X amount of amperes in a hour). Now, since we are hardware hackers, we open up the phone and utilize the battery for our own projects, and it will draw 4A maximum. So how do we know how long the battery will last without recharging? We apply our formula of course!
t = Q / I
If you did the maths, you'll see that the battery will last 2430 seconds or 40,5 minutes when we draw a current of 4A
Write down these formulas because they're very important!
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.
Using Ohm's Law
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.
Combining Ohm's Law and Electric Power
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! Therefore, 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.
Now of course, all formulas can be combined they have at least one parameter in common. You'll experience that yourself later.
Alright guys, I hope you all enjoyed the read! In my next article on the basics, we will cover electromagnetism & electromagnetic induction (he thing that makes wireless possible), and the article after that we'll discuss some common components.
Don't forget to give feedback in the comments!
Stay snappy, hardware hackers!