{"id":3455,"date":"2019-07-19T17:57:46","date_gmt":"2019-07-19T21:57:46","guid":{"rendered":"https:\/\/circuitcrush.wpengine.com\/?p=3455"},"modified":"2021-06-30T15:08:43","modified_gmt":"2021-06-30T19:08:43","slug":"logic-gates-tutorial-2-electrical-properties","status":"publish","type":"post","link":"https:\/\/www.circuitcrush.com\/logic-gates-tutorial-2-electrical-properties\/","title":{"rendered":"Tutorial on Logic Gates Part 2: Electrical Properties of Gates"},"content":{"rendered":"<p>A while back I published a tutorial on the <a href=\"https:\/\/circuitcrush.wpengine.com\/logic-gates-basics-tutorial\/\" target=\"_blank\" rel=\"noopener noreferrer\">basics of logic gates<\/a>. The tutorial talks about what logic gates are, truth tables, and active levels.<\/p>\n<p>Then, the tutorial talks about the basic logic gates many of us are familiar with: NOT, AND, OR, NAND, NOR, XOR, and XNOR.<\/p>\n<p>Because of limited space, the post did not cover Boolean algebra, DeMorgan\u2019s theorems, combinational logic, etc. It also leaves out an important and practical part of digital design with gates \u2013 the electrical characteristics of logic gates.<\/p>\n<p>This tutorial on logic gates will with leave the topics of Boolean algebra, DeMorgan, etc. for a future tutorial.<\/p>\n<p>This time, we\u2019re going to focus on the important and practical, yet often overlooked, electrical properties and characteristics of logic gates.<\/p>\n<p><!--more--><\/p>\n<h1><strong>Electrical Properties of Logic Gates<br \/>\n<\/strong><\/h1>\n<p>Logic gates (and other digital logic devices) have their own characteristic voltages and currents.<\/p>\n<p>Toward that end, we\u2019re going to view the inputs and outputs of logic gates as electronic circuits this time rather than from the perspective of truth tables and Boolean expressions.<\/p>\n<p>Knowing the input and output voltages and currents of these devices is essential because things like fan out, power dissipation, noise, and interfacing depend on them.<\/p>\n<p>Let\u2019s start by talking about the differences between two common logic families you\u2019re likely to run into.<\/p>\n<h2><strong>TTL vs CMOS Logic Gates<br \/>\n<\/strong><\/h2>\n<p>The two main logic families that you\u2019re likely to run into, use, and hear about are TTL and CMOS. Each have their own strengths and weaknesses.<\/p>\n<p><strong>Transistor to transistor logic<\/strong>, or <strong>TTL<\/strong> logic gates, are a family of gates which bases itself upon bipolar transistors. It is a mature, robust technology.<\/p>\n<p><strong>CMOS<\/strong>, or <strong>complementary metal oxide semiconductor<\/strong> logic gates are based upon metal oxide semiconductor field effect transistors. These can be fragile. Static electricity on your body can destroy some CMOS gates, so they may require careful handling.<\/p>\n<p>A detailed discussion on bipolar transistors and field effect transistors (or FETs) is beyond the scope of this tutorial, but you can be sure both will eventually show up with their own tutorials.<\/p>\n<p>Let\u2019s quickly gloss over some pros and cons of each.<\/p>\n<p>CMOS logic gates consume less power (this does depend on some factors which we\u2019ll talk about later), have great noise immunity, and work with a wide variety of power supply voltages. However, as we now know, they can be sensitive to static electricity, which can destroy the field effect transistors within the logic gate.<\/p>\n<p>TTL gates have more current-driving capability than CMOS gates and are not sensitive to static electricity. However, they consume more power and have more rigid power supply requirements.<\/p>\n<p>One important takeaway is that transistors are the building blocks of logic gates. Because of this, it is really transistors that are the foundation of all things digital.<\/p>\n<p>On a final note, if you\u2019re not using some of the inputs on a particular gate, you should tie them to the appropriate logic level. This goes for TTL and CMOS. With AND and NAND gates, tie unused inputs to HIGH (use a 1 k\u03a9 resistor with TTL). For OR and NOR gates, tie them to ground.<\/p>\n<h2><strong>Propagation Delay in Logic Gates<br \/>\n<\/strong><\/h2>\n<p><strong>Propagation delay<\/strong> is the time required for the output of a gate (or really any digital circuit) to change states after one or more of its inputs changes states.<\/p>\n<p>This occurs because the output of a logic gate cannot respond instantaneously to changes at its input. There is a small delay &#8212; usually several nanoseconds &#8212; between input changes and output response.<\/p>\n<p>Though the delay is tiny, it can make a difference depending on the number of gates and your application.<\/p>\n<p>Propagation delay is largely due to the charging and discharging of internal capacitances within the transistors that make up the logic gate.<\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone wp-image-3852 size-full\" src=\"http:\/\/www.circuitcrush.com\/wp-content\/uploads\/Logic-Gates-Propagation-Delay-1.png\" alt=\"logic gates propagation delay\" width=\"348\" height=\"145\" srcset=\"https:\/\/www.circuitcrush.com\/wp-content\/uploads\/Logic-Gates-Propagation-Delay-1.png 348w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/Logic-Gates-Propagation-Delay-1-300x125.png 300w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/Logic-Gates-Propagation-Delay-1-150x63.png 150w\" sizes=\"(max-width: 348px) 100vw, 348px\" \/><\/p>\n<p><strong><em>Figure 1: propagation delay of inverter.<\/em><\/strong><\/p>\n<p>Figure 1 illustrates the propagation delay of a simple inverter using a timing diagram.<\/p>\n<p>An ideal inverter would change its output at the very instant its input changes. However, as we can see in figure 1, there is a short delay between the changing of the input from low to high and the changing of the output. This difference is the propagation delay of the inverter.<\/p>\n<h3 style=\"text-align: center;\">Become the Maker you were born to be. Try <a href=\"https:\/\/learnarduinonow.com\">Arduino Academy<\/a> for FREE!<\/h3>\n<p><img decoding=\"async\" class=\"aligncenter  wp-image-4238\" src=\"https:\/\/www.circuitcrush.com\/wp-content\/uploads\/FB_Cover2.png\" alt=\"\" width=\"412\" height=\"157\" srcset=\"https:\/\/www.circuitcrush.com\/wp-content\/uploads\/FB_Cover2.png 828w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/FB_Cover2-300x114.png 300w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/FB_Cover2-150x57.png 150w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/FB_Cover2-768x292.png 768w\" sizes=\"(max-width: 412px) 100vw, 412px\" \/><\/p>\n<p>A digital circuit consisting of two or more logic gates (or other digital devices) has a propagation delay that is the sum of all the delays in the input-to-output path.<\/p>\n<p>Consider the circuit in figure 2.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-3853 size-full\" src=\"http:\/\/www.circuitcrush.com\/wp-content\/uploads\/Propagation-Delay-Multiple-Gates-1.png\" alt=\"Propagation-Delay-Multiple-Gates\" width=\"613\" height=\"502\" srcset=\"https:\/\/www.circuitcrush.com\/wp-content\/uploads\/Propagation-Delay-Multiple-Gates-1.png 613w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/Propagation-Delay-Multiple-Gates-1-300x246.png 300w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/Propagation-Delay-Multiple-Gates-1-150x123.png 150w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/Propagation-Delay-Multiple-Gates-1-600x491.png 600w\" sizes=\"(max-width: 613px) 100vw, 613px\" \/><\/p>\n<p><strong><em>Figure 2: propagation delay in multiple logic gates.<\/em><\/strong><\/p>\n<p>Here we have an AND gate and an OR gate. Changes at the AND gate\u2019s inputs (A and B) must propagate through both gates to affect the output. However, a change in input C only needs to pass through the OR gate. Let\u2019s work through the timing diagram one step at a time.<\/p>\n<p>In the diagram above, <em>t<\/em> is time, the <em>p<\/em> subscript stands for propagation, The <em>HL<\/em> subscript means HIGH to LOW, and the <em>LH<\/em> subscript means LOW to HIGH. So, <em>t<\/em><sub>pHL <\/sub>denotes the propagation delay time of the gate switching from HIGH to LOW.<\/p>\n<p>When A goes LOW, the output AB (A AND B) also goes LOW after a short delay. Input C is already LOW. So, the output Y goes LOW after another short delay in the OR gate. The sum of these two delays is the total propagation delay of the circuit.<\/p>\n<p>The HIGH to LOW transition at input B has no effect; there is no difference between 0 AND-ed with 1 and 0 AND-ed with 0. Either way, the result is 0 or LOW.<\/p>\n<p>Then, the LOW to HIGH transition at input C makes the output go HIGH after one propagation delay &#8211;\u00a0 the delay of the OR gate. At this point what happens at the AND gate doesn\u2019t matter.<\/p>\n<h2><strong>Logic Gate Fanout<br \/>\n<\/strong><\/h2>\n<p>So far, we\u2019ve assumed that logic gates are able to drive any number of other logic gates attached to their output.<\/p>\n<p>The thing is, gates are electrical devices with finite current-driving capabilities. Because of this, there is a limit to the amount of gates a given logic gate can drive.<\/p>\n<p>The number of gates or loads a logic gate can drive is it\u2019s <strong>fanout<\/strong>.<\/p>\n<p>Technically, fanout is simply an application of Kirchhoff\u2019s current law (KCL). KCL says that the algebraic sum of currents entering a node must be zero. So, the maximum current a logic gate\u2019s output can safely supply and the current requirements of the load gate it connects to limits the fanout.<\/p>\n<p>For more on KCL, see this <a href=\"https:\/\/circuitcrush.wpengine.com\/circuit-analysis\/\" target=\"_blank\" rel=\"noopener noreferrer\">circuit analysis tutorial<\/a>.<\/p>\n<p>Let\u2019s say we have an AND gate driving four other gates (load gates). The AND gate must supply current to the inputs of the other four gates.<\/p>\n<p>Each load gates requires a certain amount of input current which depends on what state the gate is in. The sum of these input currents is the current the driving AND gate must supply. The fanout is determined by the amount of current the driving gate can source without degrading its output voltage.<\/p>\n<p>Figure 3 illustrates this concept with one NAND gate driving other NAND gates. I<sub>OH<\/sub> is the output current of the first gate when its output is HIGH. The input current for the other gates is I<sub>IH <\/sub>where the subscript IH means input HIGH.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3854 size-full\" src=\"http:\/\/www.circuitcrush.com\/wp-content\/uploads\/fan-out-of-logic-gates-1.gif\" alt=\"fan-out-of-logic-gates\" width=\"355\" height=\"303\" \/><\/p>\n<p><strong><em>Figure 3: logic gate fanout.<\/em><\/strong><\/p>\n<p>Figure 3 shows a NAND gate driving an arbitrary number of other NAND gates. Here, we assume its output is HIGH. This is important because the fanout values of HIGH and LOW states may be different depending on the gate. If this is the case, the smallest value for fanout is used.<\/p>\n<p>So, what happens if we load a logic gate output beyond its fanout capabilities?<\/p>\n<p>This could destroy the output of the driving gate with excessive heat from the current. More likely the performance of the driving gate will degrade because its output voltage degrades. This can affect other parameters, such as noise margin, which we\u2019ll discuss shortly.<\/p>\n<h2><strong>Logic Gate Power Dissipation<br \/>\n<\/strong><\/h2>\n<p>Logic gates require a certain amount of power to operate.<\/p>\n<p>With TTL devices, the supply current differs when its outputs are HIGH vs when they are LOW. Thus, the supply current and power depend on the state of the gate\u2019s output. The power dissipation of TTL gates also depends on the duty cycle of the output. Duty cycle is just the fraction of time the output is HIGH.<\/p>\n<p>CMOS logic gates require very little power when in a static state. That is, when they are not switching from LOW to HIGH and vice versa.<\/p>\n<p>But when the outputs switch more current is drawn. Because of this, CMOS power dissipation depends on the switching frequency of the outputs. This is why the CPU in your computer gets hot and needs cooling. Millions of gates are switching on and off at a very high frequency.<\/p>\n<p>In a CMOS gate, a change of state requires the charging and discharging of internal capacitances, which results in a greater demand on supply current. The faster the gate switches, the more power it needs.<\/p>\n<h2><strong>Noise Margin of Logic Gates<br \/>\n<\/strong><\/h2>\n<p>Electric circuits are susceptible to noise, which is often other stray electrical signals.<\/p>\n<p>These come from the electromagnetic fields of motors, lighting, high-frequency electronic circuits, and even outer space.<\/p>\n<p>Of course, as any experienced circuit designer will tell you, it is impossible to eliminate all noise from a circuit.<\/p>\n<p>Logic gates are no exception.<\/p>\n<p>Because of this, it is desirable to build a certain amount of tolerance into logic gates and other digital devices.<\/p>\n<p>This is the <strong>noise margin<\/strong> of the gate.<\/p>\n<p>In the world of digital, there are only two possible states: on or off, HIGH or LOW, 1 or 0. They all mean the same thing.<\/p>\n<p>But what defines a HIGH and a LOW?<\/p>\n<p>Different devices have difference specs depending on operating voltage, but let\u2019s assume 5 V operating voltage for the purpose of demonstration.<\/p>\n<p>For a certain logic family a HIGH may be anything from 5 V down to 2.7 V and a LOW may be anything from 0 V up to 0.5 V.<\/p>\n<p>But what about everything in between 0.5 V and 2.7 V?<\/p>\n<p>Voltages in this range are invalid. If a logic gate sees an invalid voltage, its operation becomes unpredictable. Now imagine 10,000 gates inside the CPU on your phone all with invalid voltages. Who knows what will happen? \u00a0Most likely the system will completely crash.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3855 size-full\" src=\"http:\/\/www.circuitcrush.com\/wp-content\/uploads\/Logic-Gate-Noise-Margin-1.jpg\" alt=\"Logic-Gate-Noise-Margin\" width=\"705\" height=\"669\" srcset=\"https:\/\/www.circuitcrush.com\/wp-content\/uploads\/Logic-Gate-Noise-Margin-1.jpg 705w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/Logic-Gate-Noise-Margin-1-300x285.jpg 300w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/Logic-Gate-Noise-Margin-1-150x142.jpg 150w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/Logic-Gate-Noise-Margin-1-600x569.jpg 600w\" sizes=\"(max-width: 705px) 100vw, 705px\" \/><\/p>\n<p><strong><em>Figure 4: logic gate noise margin.<\/em><\/strong><\/p>\n<p>Figure 4 shows this concept.<\/p>\n<p>The gate in part <em>a<\/em> of the figure has noise pushing its operating voltages into the forbidden (or invalid) region because there is no noise margin in the gate.<\/p>\n<p>The gate in part <em>b<\/em> still operates normally even though there is noise because it has a certain amount of noise margin built in.<\/p>\n<h2><strong>It\u2019s Perfectly Logical\u2026<\/strong><\/h2>\n<p>It\u2019s true that a lot of hobbyists these days seldom use discrete logic gates in their designs. After all, we have powerful microcontrollers and things like Arduino.<\/p>\n<p>However, there are some things one can do with discrete gates that may be cheaper and easier than throwing an Arduino or a PIC at it.<\/p>\n<p>And let\u2019s not forget that your microcontroller, including the one on your Arduino, is made of logic gates. Because of this, using discrete logic in some of your projects can be a good lesson on the basics of how microcontrollers and microprocessors work.<\/p>\n<p>Just be sure to keep their electrical properties in mind when using logic gates.<\/p>\n<p>Next time we talk about logic gates, we\u2019ll get back into the theory which can show you how it may be possible to replace your Arduino with a few gates for simpler applications.<\/p>\n<p>Until then, I\u2019ll ask the same question I asked after the first logic gate tutorial\u2026<\/p>\n<p>Can you replace anything you\u2019re doing on an Arduino or microcontroller with a few simple gates? I\u2019d love to know about it. Drop a comment and share it or share your thoughts on this tutorial.<\/p>\n<h2 style=\"text-align: center;\">Become the Maker you were born to be. Try <a href=\"https:\/\/learnarduinonow.com\">Arduino Academy<\/a> for FREE!<\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4238\" src=\"https:\/\/www.circuitcrush.com\/wp-content\/uploads\/FB_Cover2.png\" alt=\"\" width=\"828\" height=\"315\" srcset=\"https:\/\/www.circuitcrush.com\/wp-content\/uploads\/FB_Cover2.png 828w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/FB_Cover2-300x114.png 300w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/FB_Cover2-150x57.png 150w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/FB_Cover2-768x292.png 768w\" sizes=\"(max-width: 828px) 100vw, 828px\" \/><\/p>\n<a target=\"_blank\" href=\"https:\/\/www.drpeterscode.com\/index.php\"><img src=\"https:\/\/www.circuitcrush.com\/wp-content\/plugins\/dpabottomofpostpage\/apixel1x1.jpg\" ><\/a><table><\/table>","protected":false},"excerpt":{"rendered":"<p>A while back I published a tutorial on the basics of logic gates. The tutorial talks about what logic gates are, truth tables, and active levels. Then, the tutorial talks about the basic logic gates many of us are familiar with: NOT, AND, OR, NAND, NOR, XOR, and XNOR. Because of limited space, the post [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3499,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[94],"tags":[],"class_list":{"0":"post-3455","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-digital-electronics","8":"entry"},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/www.circuitcrush.com\/wp-content\/uploads\/Logic-Gates-Tutorial-1.jpg","_links":{"self":[{"href":"https:\/\/www.circuitcrush.com\/wp-json\/wp\/v2\/posts\/3455","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.circuitcrush.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.circuitcrush.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.circuitcrush.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.circuitcrush.com\/wp-json\/wp\/v2\/comments?post=3455"}],"version-history":[{"count":3,"href":"https:\/\/www.circuitcrush.com\/wp-json\/wp\/v2\/posts\/3455\/revisions"}],"predecessor-version":[{"id":4266,"href":"https:\/\/www.circuitcrush.com\/wp-json\/wp\/v2\/posts\/3455\/revisions\/4266"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.circuitcrush.com\/wp-json\/wp\/v2\/media\/3499"}],"wp:attachment":[{"href":"https:\/\/www.circuitcrush.com\/wp-json\/wp\/v2\/media?parent=3455"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.circuitcrush.com\/wp-json\/wp\/v2\/categories?post=3455"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.circuitcrush.com\/wp-json\/wp\/v2\/tags?post=3455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}