
{"id":345,"date":"2017-06-11T19:45:59","date_gmt":"2017-06-11T09:45:59","guid":{"rendered":"http:\/\/bakke.online\/?p=345"},"modified":"2022-01-22T20:10:55","modified_gmt":"2022-01-22T09:10:55","slug":"electronics-basics-ohms-law","status":"publish","type":"post","link":"https:\/\/www.bakke.online\/index.php\/2017\/06\/11\/electronics-basics-ohms-law\/","title":{"rendered":"Electronics basics: Ohm&#039;s law"},"content":{"rendered":"<p>This is a post to explain the basics of electronics, starting with Ohm&#8217;s law.<\/p>\n<p>Ohm&#8217;s law describes the relationship between the voltage, current and resistance in a circuit, and it is one of the basic physical laws that controls how circuits work.<\/p>\n<p>We need to understand this law in order to select the correct resistors to use in our circuits and to control how much current will flow. \u00a0We also need to know how much power our circuit will draw and how much power each component will dissipate. \u00a0Too much power and things will heat up too much, burning out.<\/p>\n<p>And yes, this post does contain garden hoses&#8230;<\/p>\n<p><!--more--><\/p>\n<h3>Ohm&#8217;s law<\/h3>\n<p>Ohm&#8217;s law is usually expressed as <img decoding=\"async\" class=\"mathtex-equation-editor\" src=\"http:\/\/chart.apis.google.com\/chart?cht=tx&amp;chl=I%3D%7B%5Cfrac%7BV%7D%7BR%7D%7D\" alt=\"I={\\frac{V}{R}}\" align=\"absmiddle\" \/>, where <img decoding=\"async\" class=\"mathtex-equation-editor\" src=\"http:\/\/chart.apis.google.com\/chart?cht=tx&amp;chl=I\" alt=\"I\" align=\"absmiddle\" \/> is current, measured in Amperes (often just called &#8220;Amps&#8221;) and with a unit of A. <img decoding=\"async\" class=\"mathtex-equation-editor\" src=\"http:\/\/chart.apis.google.com\/chart?cht=tx&amp;chl=V\" alt=\"V\" align=\"absmiddle\" \/> is the voltage (also called &#8220;Electric potential&#8221;), measured in Volts and with a unit of V. <img decoding=\"async\" class=\"mathtex-equation-editor\" src=\"http:\/\/chart.apis.google.com\/chart?cht=tx&amp;chl=R\" alt=\"R\" align=\"absmiddle\" \/> is the resistance, measured in Ohms and with a unit of\u00a0\u03a9.<\/p>\n<p>This means that with a given voltage, the current that will flow is inversely proportional to the resistance it has to flow through.<\/p>\n<p>Imagine a garden water hose. \u00a0You open the tap fully and the water will flow, as fast as the hose will allow. \u00a0The water pressure is like the voltage in a circuit and the flow of water is like the current. \u00a0Now start squeezing the hose and the flow of water will decrease. \u00a0Your squeezing of the hose acts as a resistance to the water, and a resistor in an electric circuit works the same way. \u00a0The harder you squeeze, the less water will flow. \u00a0The higher the resistance, the less current will flow.<\/p>\n<p>Given any two of the 3 components, voltage, current or resistance, we can calculate the last one. \u00a0We can rearrange the formula in different ways, depending on what we need to calculate, so you will some times use it as <img decoding=\"async\" class=\"mathtex-equation-editor\" src=\"http:\/\/chart.apis.google.com\/chart?cht=tx&amp;chl=R%3D%7B%5Cfrac%7BV%7D%7BI%7D%7D\" alt=\"R={\\frac{V}{I}}\" align=\"absmiddle\" \/> to find the resistance from the voltage and current, or <img decoding=\"async\" class=\"mathtex-equation-editor\" src=\"http:\/\/chart.apis.google.com\/chart?cht=tx&amp;chl=V%3DIR\" alt=\"V=IR\" align=\"absmiddle\" \/>\u00a0to find the voltage across a resistance at a certain voltage.<\/p>\n<h3>Application with a single resistor<\/h3>\n<p>Let&#8217;s apply this to a simple circuit with a single resistor:<a href=\"https:\/\/www.bakke.online\/wp-content\/uploads\/2017\/06\/resistor-1K.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-347\" src=\"https:\/\/www.bakke.online\/wp-content\/uploads\/2017\/06\/resistor-1K.png\" alt=\"\" width=\"162\" height=\"351\" \/><\/a><\/p>\n<p>Here we have a known voltage, 5V and a known resistance of 1000\u03a9 (Usually written as 1K\u03a9, for 1 kilo-Ohm). \u00a0Putting these numbers into the formula <img decoding=\"async\" class=\"mathtex-equation-editor\" src=\"http:\/\/chart.apis.google.com\/chart?cht=tx&amp;chl=I%3D%7B%5Cfrac%7BV%7D%7BR%7D%7D\" alt=\"I={\\frac{V}{R}}\" align=\"absmiddle\" \/> gives us <img decoding=\"async\" class=\"mathtex-equation-editor\" src=\"http:\/\/chart.apis.google.com\/chart?cht=tx&amp;chl=I%3D%7B%5Cfrac%7B5%7D%7B1000%7D%7D%3D0.005\" alt=\"R={\\frac{5}{1000}}=0.005\" align=\"absmiddle\" \/>. \u00a00.005 Amperes is usually written as 5 milliAmperes, or just 5mA. \u00a0In low-power electronics, we&#8217;re dealing with mA most of the time so you&#8217;ll get familiar with these units soon enough.<\/p>\n<p>But what do we need resistors for? \u00a0Can&#8217;t we just connect the wires and start having fun?<\/p>\n<h3>Practical example, LED<\/h3>\n<p>As mentioned in <a href=\"https:\/\/www.bakke.online\/index.php\/2017\/04\/08\/arduino-traffic-lights-simulator-part-1\/\">one of my earlier posts<\/a>, LEDs have a limit to how much current they can safely pass. \u00a0The more current you send through an LED, the brighter it will glow, but pass the maximum limit and it will burn out, and quite quickly.<\/p>\n<p>To limit the current, we need a resistor connected in series with the LED. \u00a0This means that the resistor is connected between the LED and either the power source or ground. \u00a0The same current will flow through all parts of a circuit that are connected in series, so it doesn&#8217;t matter which side of the LED you connect the resistor to.<\/p>\n<p><a href=\"https:\/\/www.bakke.online\/wp-content\/uploads\/2017\/06\/basic-LED.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-349\" src=\"https:\/\/www.bakke.online\/wp-content\/uploads\/2017\/06\/basic-LED.png\" alt=\"\" width=\"141\" height=\"375\" \/><\/a><\/p>\n<p>A typical red LED has a forward voltage of 1.8 volts, which leaves 3.2 volts across the resistor. \u00a0With a maximum current limit for the LED of 20 mA, or 0.020 Amps, we put\u00a0this into the formula <img decoding=\"async\" class=\"mathtex-equation-editor\" src=\"http:\/\/chart.apis.google.com\/chart?cht=tx&amp;chl=R%3D%7B%5Cfrac%7BV%7D%7BI%7D%7D\" alt=\"R={\\frac{V}{I}}\" align=\"absmiddle\" \/> to find the resistance that will give us 20 mA. <img decoding=\"async\" class=\"mathtex-equation-editor\" src=\"http:\/\/chart.apis.google.com\/chart?cht=tx&amp;chl=R%3D%7B%5Cfrac%7B3.2%7D%7B0.020%7D%7D%3D160%5COmega\" alt=\"R={\\frac{3.2}{0.020}}=160\\Omega\" align=\"absmiddle\" \/>. \u00a0For LEDs, we&#8217;ll normally select a resistor that is a bit higher than that, as resistors have a tolerance, for example 5% or 10% accuracy. \u00a0If our resistor is a 10% tolerance variety, it can be as low as 144\u03a9 and still be within tolerance. \u00a0However, that 144\u03a9 resistor would allow <img decoding=\"async\" class=\"mathtex-equation-editor\" src=\"http:\/\/chart.apis.google.com\/chart?cht=tx&amp;chl=I%3D%7B%5Cfrac%7B3.2%7D%7B144%7D%7D%3D0.02222\" alt=\"I={\\frac{3.2}{144}}=0.02222\" align=\"absmiddle\" \/>. That might just work, depending on the LED, but it would certainly reduce the life of the LED. \u00a0By moving up to a 180\u03a9 resistor instead, we&#8217;ll be safely within the maximum limit of the LED, and the difference in brightness would be imperceptible to most eyes. \u00a0According to the same formula, 180\u03a9 gives us a current of <img decoding=\"async\" class=\"mathtex-equation-editor\" src=\"http:\/\/chart.apis.google.com\/chart?cht=tx&amp;chl=I%3D%7B%5Cfrac%7B3.2%7D%7B180%7D%7D%3D0.01778\" alt=\"I={\\frac{3.2}{180}}=0.01778\" align=\"absmiddle\" \/>, or 17.78mA.<\/p>\n<p><a href=\"https:\/\/www.bakke.online\/wp-content\/uploads\/2017\/06\/basic-LED-with-current.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-350\" src=\"https:\/\/www.bakke.online\/wp-content\/uploads\/2017\/06\/basic-LED-with-current.png\" alt=\"\" width=\"136\" height=\"345\" \/><\/a><\/p>\n<h3>Another practical example, Arduino current limits<\/h3>\n<p>On an AVR-based Arduino you should not exceed 40 mA current in or out of any IO pin. \u00a0However, this is an absolute, DO-NOT-EXCEED limit, so instead 20 mA is recommended as a limit as it gives a safe margin to the 40 mA, and it reduces any power dissipation issues as well. \u00a0Remember resistors have tolerances, so always stay clear of such absolute limits.<\/p>\n<p>Imagine a GPIO pin connected directly to 5V:<\/p>\n<p><a href=\"https:\/\/www.bakke.online\/wp-content\/uploads\/2017\/06\/5v-to-gpio.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-352\" src=\"https:\/\/www.bakke.online\/wp-content\/uploads\/2017\/06\/5v-to-gpio.png\" alt=\"\" width=\"192\" height=\"96\" \/><\/a><\/p>\n<p>Depending on how the pin gets configured, for example as a LOW output, this lets a nearly unlimited (completely unlimited as far as our poor little chip is concerned&#8230;) current flow from +5V, through the GPIO pin and to ground. \u00a0This could well be the default state of the pin upon startup, meaning this high current will start to flow as soon as power is applied.<\/p>\n<p>This is a fast and easy way to let the magic smoke out of your Arduino, and unfortunately&#8230; Arduinos don&#8217;t work without the smoke, so once you let it out, the Arduino will stop working. \u00a0So, to make sure we don&#8217;t blow up the chip, we&#8217;ll need to add a resistor between the GPIO pin and 5V, to limit how much current can flow. \u00a0Remember the recommended limit is 20 mA, so we&#8217;ll find a resistor that gives us no more than that:<\/p>\n<p><img decoding=\"async\" class=\"mathtex-equation-editor\" src=\"http:\/\/chart.apis.google.com\/chart?cht=tx&amp;chl=R%3D%7B%5Cfrac%7BV%7D%7BI%7D%7D\" alt=\"R={\\frac{V}{I}}\" align=\"absmiddle\" \/>, <img decoding=\"async\" class=\"mathtex-equation-editor\" src=\"http:\/\/chart.apis.google.com\/chart?cht=tx&amp;chl=R%3D%7B%5Cfrac%7B5.0%7D%7B0.020%7D%7D%3D250%5COmega\" alt=\"R={\\frac{5.0}{0.020}}=250\\Omega\" align=\"absmiddle\" \/>. So, any resistor of at least 250\u03a9 will be safe to use, just check the tolerance and make sure you&#8217;re still good even at the bottom end of the range. \u00a0 Sticking to common resistor values makes the job of finding a suitable one much easier. \u00a0330\u03a9 or\u00a0470\u03a9 are very common values, and at 5V they allow 15.15mA or 10.64mA current, respectively.<\/p>\n<p>Note that with a microcontroller like the ones in the Arduinos, they do not need much current in order to detect a signal, and most of the time you do not need much current out of the microcontroller, either, so you will typically use resistors much higher than this, perhaps even 10 or 100 times higher.<\/p>\n<h3>Resistors in series<\/h3>\n<p>Resistors can be connected in series, which means that you&#8217;ll connect two or more of them back to back. \u00a0The same current will flow through both resistors and will be restricted by both of them. \u00a0Remember the garden hose. \u00a0This time you&#8217;re squeezing with two hands. \u00a0This means that the resistance will add up, so a 150\u03a9 and a 470\u03a9 resistor would work the same as a single 620\u03a9 resistor. \u00a0One important difference, though, is that the two resistors connected in series will have a larger surface area and can thus dissipate more power safely. \u00a0I will get back to practical applications of this in another post. \u00a0For now, think of this as an easy way to build resistor values. \u00a0For example, if you need a 620\u03a9 resistor, but don&#8217;t have one (hint: it&#8217;s not a standard resistor value&#8230;), you can easily build one by connecting a 150\u03a9 and a 470\u03a9 in series.<\/p>\n<p>Looking back at our LED example earlier, let&#8217;s see what happens when we place two 180\u03a9 resistors in series with the LED:<\/p>\n<p><a href=\"https:\/\/www.bakke.online\/wp-content\/uploads\/2017\/06\/led-with-2-series-resistors.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-353\" src=\"https:\/\/www.bakke.online\/wp-content\/uploads\/2017\/06\/led-with-2-series-resistors.png\" alt=\"\" width=\"164\" height=\"382\" \/><\/a><\/p>\n<p>The two resistors add up to 360\u03a9, which limits the current through the resistors and LED to <img decoding=\"async\" class=\"mathtex-equation-editor\" src=\"http:\/\/chart.apis.google.com\/chart?cht=tx&amp;chl=I%3D%7B%5Cfrac%7B3.2%7D%7B360%7D%7D%3D0.00889\" alt=\"I={\\frac{3.2}{360}}=0.00889\" align=\"absmiddle\" \/>. 8.89mA is still enough to light up that LED, and the brightness is almost indistinguishable from when we were passing 17.78mA through it. \u00a0However, this time it&#8217;s only using half the power.<\/p>\n<h3>Resistors in parallel<\/h3>\n<p>Resistors can also be connected in parallel. \u00a0In that case, the current will be split between them, according to their relative values, and the resulting resistance will be\u00a0<strong>lower<\/strong> than the resistance of the individual resistors.<\/p>\n<p>If it is counter-intuitive that the resistance becomes lower, let&#8217;s go back to the garden hose again. \u00a0You&#8217;re holding one garden hose and squeezing it to limit how much water is flowing through it. \u00a0Now fully open up a second tap, pick up a second garden hose and squeeze exactly as hard as on the first one. \u00a0How much water is flowing now? \u00a0Twice as much water as before. \u00a0That means the current (water current in this case) is twice as large. \u00a0Remember the formula <img decoding=\"async\" class=\"mathtex-equation-editor\" src=\"http:\/\/chart.apis.google.com\/chart?cht=tx&amp;chl=I%3D%7B%5Cfrac%7BV%7D%7BR%7D%7D\" alt=\"I={\\frac{V}{R}}\" align=\"absmiddle\" \/>, in order for the current (I) to be twice as large, the voltage (V) would need to double or the resistance (R) would need to be halved. \u00a0You haven&#8217;t done anything to the water pressure, which is analogous to the voltage, so letting the water run through 2 hoses has effectively halved the resistance.<\/p>\n<p>The same holds true for resistance in a circuit as well, and if you have two parallel resistors of the same value, it is very easy, you end up with half the resistance. \u00a0For example two 470\u03a9 resistors in parallel will give you 235\u03a9 resistance. \u00a0The main difference between a single 235\u03a9 resistor and two 470\u03a9 resistors is that in the latter case, the current is split between two resistors, with each passing only half of the current. \u00a0This results in a lower voltage drop across the resistors, which could be important. \u00a0This, in turn, also means that there is less power to be dissipated by each resistor.<\/p>\n<p>Let&#8217;s go back to the LED example again, but this time put two 470\u03a9 resistors in parallel.<\/p>\n<p><a href=\"https:\/\/www.bakke.online\/wp-content\/uploads\/2017\/06\/led-with-2-parallel-resistors.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-355\" src=\"https:\/\/www.bakke.online\/wp-content\/uploads\/2017\/06\/led-with-2-parallel-resistors.png\" alt=\"\" width=\"314\" height=\"359\" \/><\/a><\/p>\n<p>This time, each of the resistors will pass <img decoding=\"async\" class=\"mathtex-equation-editor\" src=\"http:\/\/chart.apis.google.com\/chart?cht=tx&amp;chl=I%3D%7B%5Cfrac%7B3.2%7D%7B470%7D%7D%3D0.00681\" alt=\"I={\\frac{3.2}{470}}=0.00681\" align=\"absmiddle\" \/>, 6.81mA. There are two of them in parallel, so in total they will pass 13.62mA.<\/p>\n<p>But how about parallel resistors where the resistors are not all the same value?<\/p>\n<p>This is where things start to get complicated. \u00a0Back to the garden hose&#8230; \u00a0This time you&#8217;ve got your whole yard full of garden hoses, and all your friends are coming over to help squeeze them. \u00a0Problem is, they don&#8217;t all squeeze with the same force as you do, so how much water will flow in total? \u00a0 Now, before your whole property gets water damaged, let&#8217;s crack this one by considering a general case, and let&#8217;s use 1 volt to make the calculation easier:<\/p>\n<p><a href=\"https:\/\/www.bakke.online\/wp-content\/uploads\/2017\/06\/parallel-general-case.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-358\" src=\"https:\/\/www.bakke.online\/wp-content\/uploads\/2017\/06\/parallel-general-case.png\" alt=\"\" width=\"539\" height=\"331\" \/><\/a><\/p>\n<p>Each of the resistors will pass <img decoding=\"async\" class=\"mathtex-equation-editor\" src=\"http:\/\/chart.apis.google.com\/chart?cht=tx&amp;chl=I_%7Bn%7D%3D%7B%5Cfrac%7B1%7D%7BR_%7Bn%7D%7D%7D\" alt=\"I_{n}={\\frac{1}{R_{n}}}\" align=\"absmiddle\" \/>, and the total will be <img decoding=\"async\" class=\"mathtex-equation-editor\" src=\"http:\/\/chart.apis.google.com\/chart?cht=tx&amp;chl=I%3D%7B%5Cfrac%7B1%7D%7BR_%7B1%7D%7D%7D%2B%7B%5Cfrac%7B1%7D%7BR_%7B2%7D%7D%7D%2B%7B%5Cfrac%7B1%7D%7BR_%7B3%7D%7D%7D%2B%7B%5Cfrac%7B1%7D%7BR_%7B4%7D%7D%7D%2B%5Cldots\" alt=\"I={\\frac{1}{R_{1}}}+{\\frac{1}{R_{2}}}+{\\frac{1}{R_{3}}}+{\\frac{1}{R_{4}}}+\\ldots\" align=\"absmiddle\" \/><\/p>\n<p>To find out what resistance that works out to, we&#8217;ll plug this and the voltage into the formula to calculate resistance from voltage and current<img decoding=\"async\" class=\"mathtex-equation-editor\" src=\"http:\/\/chart.apis.google.com\/chart?cht=tx&amp;chl=R%3D%7B%5Cfrac%7BV%7D%7BI%7D%7D\" alt=\"R={\\frac{V}{I}}\" align=\"absmiddle\" \/>:<\/p>\n<p><img decoding=\"async\" class=\"mathtex-equation-editor\" src=\"http:\/\/chart.apis.google.com\/chart?cht=tx&amp;chl=R%3D%7B%5Cfrac%7B1%7D%7B%5Cleft(%7B%5Cfrac%7B1%7D%7BR_%7B1%7D%7D%7D%2B%7B%5Cfrac%7B1%7D%7BR_%7B2%7D%7D%7D%2B%7B%5Cfrac%7B1%7D%7BR_%7B3%7D%7D%7D%2B%7B%5Cfrac%7B1%7D%7BR_%7B4%7D%7D%7D%2B%5Cldots%5cright)%7D%7D\" alt=\"R={\\frac{1}{\\left({\\frac{1}{R_{1}}}+{\\frac{1}{R_{2}}}+{\\frac{1}{R_{3}}}+{\\frac{1}{R_{4}}}+\\ldots\\right)}}\" align=\"absmiddle\" \/><\/p>\n<p>Some good news for you: \u00a0There will\u00a0<strong>not<\/strong> be a pop-quiz or test at the end of this post. \u00a0In my next post I will get to some more practical applications of this.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a post to explain the basics of electronics, starting with Ohm&#8217;s law. Ohm&#8217;s law describes the relationship between the voltage, current and resistance in a circuit, and it is one of the basic physical laws that controls how circuits work. We need to understand this law in order to select the correct resistors &hellip; <a href=\"https:\/\/www.bakke.online\/index.php\/2017\/06\/11\/electronics-basics-ohms-law\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Electronics basics: Ohm&#039;s law&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,14,1],"tags":[8,13,15,17],"class_list":["post-345","post","type-post","status-publish","format-standard","hentry","category-arduino","category-electronics","category-uncategorized","tag-arduino","tag-beginners","tag-electronics","tag-resistors"],"_links":{"self":[{"href":"https:\/\/www.bakke.online\/index.php\/wp-json\/wp\/v2\/posts\/345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bakke.online\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bakke.online\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bakke.online\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bakke.online\/index.php\/wp-json\/wp\/v2\/comments?post=345"}],"version-history":[{"count":1,"href":"https:\/\/www.bakke.online\/index.php\/wp-json\/wp\/v2\/posts\/345\/revisions"}],"predecessor-version":[{"id":1334,"href":"https:\/\/www.bakke.online\/index.php\/wp-json\/wp\/v2\/posts\/345\/revisions\/1334"}],"wp:attachment":[{"href":"https:\/\/www.bakke.online\/index.php\/wp-json\/wp\/v2\/media?parent=345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bakke.online\/index.php\/wp-json\/wp\/v2\/categories?post=345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bakke.online\/index.php\/wp-json\/wp\/v2\/tags?post=345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}