{"id":8481,"date":"2023-02-13T10:57:45","date_gmt":"2023-02-13T09:57:45","guid":{"rendered":"https:\/\/playembedded.org\/?p=8481"},"modified":"2024-10-13T23:42:31","modified_gmt":"2024-10-13T21:42:31","slug":"fundamentals-of-digital-circuitry","status":"publish","type":"post","link":"https:\/\/playembedded.org\/blog\/fundamentals-of-digital-circuitry\/","title":{"rendered":"Fundamentals of Digital Circuitry"},"content":{"rendered":"<h2 class=\"wp-block-heading level_1\" id=\"1_Introduction\">Introduction<\/h2>\n\n\n\n<p>In this piece, we will explore the fundamental concepts of digital electronics, including logic levels, push-pull and open-drain configurations, pull-up and pull-down resistors, and the Schmitt trigger. Our objective is to provide a comprehensive and in-depth understanding of these essential concepts and their practical applications in GPIOs of microcontrollers and digital communication protocols such as I<sup>2<\/sup>C and SPI. Through clear explanations and practical examples, we aim to equip readers with the knowledge and expertise needed to understand the workings of digital ports and buses and effectively utilize their capabilities in different electronic systems.<\/p>\n\n\n\n<h2 class=\"wp-block-heading level_1\" id=\"2_Logic_Levels\">Logic Levels<\/h2>\n\n\n\n<p>In digital electronics, information is represented and processed using binary voltage levels: everything hence boils down to the voltage being or not being present. To accomplish that, two voltage levels are used to distinguish between the two binary states, typically represented as <strong>0<\/strong> and <strong>1<\/strong>, or <strong><strong>Logical Low<\/strong><\/strong> and&nbsp;<strong><strong>Logical High<\/strong><\/strong>.<\/p>\n\n\n\n<p>The specific voltage ranges that represent each of these states are defined by the threshold or trip points of the logic. To ensure the accuracy of digital signals, the trip points are chosen to be far apart from each other and to minimize the chance of errors due to noise or signal distortions. For example, in a CMOS microcontroller, the logic levels are defined such that a voltage of 0V represents a <em>logical 0<\/em> and a V<sub>DD<\/sub> represents a <em>logical 1<\/em>. However, to account for variations in voltage levels, a margin of acceptable voltage levels is also defined. <\/p>\n\n\n\n<p>If in this example the supply voltage (V<sub>DD<\/sub>) is 3.3V, any voltage between 2.9V and 3.3V would be considered a <em>logical 1<\/em> and any voltage between 0V and 0.4V would be considered a <em>logical 0<\/em>. In case the voltage should land in the indeterminate region, the behavior of the logic would be unpredictable, hence, signals in this area are not acceptable.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"391\" src=\"https:\/\/playembedded.org\/wp-content\/uploads\/2023\/02\/Digital-Levels-PE-1024x391.png\" alt=\"Logic level bands of a CMOS microcontroller\" class=\"wp-image-8485\" srcset=\"https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Digital-Levels-PE-1024x391.png 1024w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Digital-Levels-PE-300x115.png 300w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Digital-Levels-PE-150x57.png 150w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Digital-Levels-PE-1200x459.png 1200w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Digital-Levels-PE.png 1266w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">An example of the logic level bands of a CMOS microcontroller<\/figcaption><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading level_1\" id=\"3_Switch_level_models\">Switch level models<\/h2>\n\n\n\n<p>The implementation of digital circuits relies mostly on transistors being used as switches. In this scenario, a transistor can be seen as a switch driven by a digital signal often in conjunction with capacitors or resistors to model loads, losses and transients. From this perspective, a transistor can be modeled as an active high or active low switch. These special switches will then have three terminals, one of which is used to electrically control it.<\/p>\n\n\n\n<p>An <strong>active high switch<\/strong> operates by closing when a <em>logical 1<\/em> is applied to its control terminal and opening when a <em>logical 0<\/em> is applied. This type of switch is typically implemented using an NMOS transistor.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"246\" src=\"https:\/\/playembedded.org\/wp-content\/uploads\/2023\/04\/Switch-active-high-1024x246.png\" alt=\"\" class=\"wp-image-8517\" srcset=\"https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/04\/Switch-active-high-1024x246.png 1024w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/04\/Switch-active-high-300x72.png 300w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/04\/Switch-active-high-150x36.png 150w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/04\/Switch-active-high-1536x368.png 1536w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/04\/Switch-active-high-1200x288.png 1200w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/04\/Switch-active-high.png 1684w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">An NMOS used as active high switch<\/figcaption><\/figure>\n<\/div>\n\n\n<p>Similarly, an <strong>active low switch<\/strong> operates by closing when a <em>logical 0<\/em> is applied to its control terminal and opening when a <em>logical 1<\/em> is applied. This type of switch is typically implemented using a PMOS transistor. Note that the circle on the control terminal highlights the inverted logic of this type of switch and will be used throughout this article to highlight the nature of the switch.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"246\" src=\"https:\/\/playembedded.org\/wp-content\/uploads\/2023\/02\/Switch-active-low-PE-1-1024x246.png\" alt=\"\" class=\"wp-image-8518\" srcset=\"https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Switch-active-low-PE-1-1024x246.png 1024w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Switch-active-low-PE-1-300x72.png 300w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Switch-active-low-PE-1-150x36.png 150w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Switch-active-low-PE-1-1536x368.png 1536w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Switch-active-low-PE-1-1200x288.png 1200w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Switch-active-low-PE-1.png 1684w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">A PMOS used as an active low switch<\/figcaption><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading level_1\" id=\"4_Push_pull_configuration\">Push-pull configuration<\/h2>\n\n\n\n<p>The simplest and most used configuration that can be implemented by combining two switches of different natures is the <strong>push-pull<\/strong> configuration. In this configuration one switch is &ldquo;pushing&rdquo; current in one direction and the other switch is &ldquo;pulling&rdquo; current in the opposite direction. This arrangement allows a bi-directional current flow while providing isolation between the control and output signals. <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"440\" src=\"https:\/\/playembedded.org\/wp-content\/uploads\/2023\/02\/Switch-level-CMOS-PE-1-1024x440.png\" alt=\"\" class=\"wp-image-8519\" srcset=\"https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Switch-level-CMOS-PE-1-1024x440.png 1024w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Switch-level-CMOS-PE-1-300x129.png 300w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Switch-level-CMOS-PE-1-150x64.png 150w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Switch-level-CMOS-PE-1-1536x660.png 1536w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Switch-level-CMOS-PE-1-1200x516.png 1200w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Switch-level-CMOS-PE-1.png 1684w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">A push-pull configuration represented using switches<\/figcaption><\/figure>\n<\/div>\n\n\n<p>In this configuration, the control inputs of the two switches are connected together and driven by the same signal. Depending on the logic level applied to the control input, we have two possible outcomes:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>If the input is low then the high side switch is closed and the low side is open. Consequently, a current is pushed in the load until the output reaches the high logical state<\/li>\n\n\n\n<li>If the input is high then the low side switch is closed and the high side is open. In this case, a current is pulled out from the load until the output reaches the low logical state<\/li>\n<\/ol>\n\n\n\n<p>The push-pull configuration is often used as a NOT gate, as it outputs the negation of the input. This configuration offers isolation between the control signal and the output signal, as the current that flows into the load is sourced from the supply. This mechanism relies on the transistor effect where a small current flow allows to control of a large current flow. For example, the input signal may only draw micro or nano-amperes of current, while the output can drive a milli-ampere-consuming LED without affecting the control signal.<\/p>\n\n\n\n<h2 class=\"wp-block-heading level_1\" id=\"5_Open_drain_configuration\">Open-drain configuration<\/h2>\n\n\n\n<p>The <strong>open-drain<\/strong> configuration is used in scenarios where multiple devices are connected on a shared line for communication purposes. In this case, using a push-pull configuration to drive the line to a logic 1 or 0 is not feasible, as it can result in a short circuit if two devices try to drive the line high and low simultaneously. <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"440\" src=\"https:\/\/playembedded.org\/wp-content\/uploads\/2023\/01\/Switch-level-lightning-PE-1024x440.png\" alt=\"\" class=\"wp-image-8520\" srcset=\"https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/01\/Switch-level-lightning-PE-1024x440.png 1024w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/01\/Switch-level-lightning-PE-300x129.png 300w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/01\/Switch-level-lightning-PE-150x64.png 150w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/01\/Switch-level-lightning-PE-1536x660.png 1536w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/01\/Switch-level-lightning-PE-1200x515.png 1200w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/01\/Switch-level-lightning-PE.png 1686w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">The consequences of contending a bus with two Push-Pull devices: A cautionary tale of a short circuit<\/figcaption><\/figure>\n<\/div>\n\n\n<p>The open-drain configuration solves this issue by eliminating the high side switch and leaving the drain of the NMOS open (from here the name open-drain or sometimes open-collector with reference to the BJT transistor). This allows each device to pull the signal low by connecting it to the ground, while, when none of the devices are pulling low, the signal line is left floating and can be pulled high by a pull-up resistor. <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"440\" src=\"https:\/\/playembedded.org\/wp-content\/uploads\/2023\/02\/Open-drain-PE-1-1024x440.png\" alt=\"\" class=\"wp-image-8516\" srcset=\"https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Open-drain-PE-1-1024x440.png 1024w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Open-drain-PE-1-300x129.png 300w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Open-drain-PE-1-150x64.png 150w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Open-drain-PE-1-1536x660.png 1536w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Open-drain-PE-1-1200x516.png 1200w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Open-drain-PE-1.png 1684w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">The open-drain configuration as a solution to contended busses<\/figcaption><\/figure>\n<\/div>\n\n\n<p>The open-drain configuration is commonly used in half-duplex digital communication buses such as I<sup>2<\/sup>C, as it allows multiple devices to communicate on the same bus without interfering with each other.<\/p>\n\n\n\n<h2 class=\"wp-block-heading level_1\" id=\"6_Pull_up_and_Pull_down_resistors\">Pull-up and Pull-down resistors<\/h2>\n\n\n\n<p>In digital circuits, resistors are sometimes used to maintain a defined logic level on a signal line. If an active pull is not suitable (e.g in the previously shown open-drain configuration) these resistors can be utilized. They are called pull-up resistors when connected to the V<sub>DD<\/sub> side of the line and pull-down resistors when connected to the GND side. For example, a pull-up resistor on the input port can ensure that the line stays high even when nothing is connected to the bus.<\/p>\n\n\n\n<p>A common application of pull-up and pull-down resistors is in conjunction with buttons. In the following illustration, a push button is connected to an input pin in two possible configurations. The left diagram shows the button connected on the low side:  when it is pressed, the line is pulled low and when released, the line is pulled up by the pull-up resistor. In contrast, the right diagram depicts the button on the high side and the resistor on the low side: in this case, the resistor is responsible for pulling down the line when the button is not pressed.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"489\" src=\"https:\/\/playembedded.org\/wp-content\/uploads\/2023\/02\/Pull-resistors-PE-1024x489.png\" alt=\"\" class=\"wp-image-8604\" srcset=\"https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Pull-resistors-PE-1024x489.png 1024w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Pull-resistors-PE-300x143.png 300w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Pull-resistors-PE-150x72.png 150w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Pull-resistors-PE-1536x733.png 1536w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Pull-resistors-PE-1200x573.png 1200w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Pull-resistors-PE.png 1684w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">A typical use case of pull-up and pull-down resistors<\/figcaption><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading level_2\" id=\"7_Determining_the_pull_resistor_size\">Determining the pull resistor size<\/h3>\n\n\n\n<p>The choice of the size of a pull resistor is influenced by several constraints. Firstly, it must be strong enough to pull the signal to the desired voltage level when the line is not actively driven by a device. On the other hand, it must be weak enough to allow a device to drive the signal to the opposite level when needed. Additionally, the size of the pull resistor affects the rise and fall time of the signal: this is an important consideration to make when designing the system in order to ensure that it meets the timing requirements. Finally, the power consumption must be taken into account so the value should be chosen such that it does not exceed the power dissipation limit of the resistor or the device.<\/p>\n\n\n\n<p>To analyze the problem let us consider the button example with a pull-up resistor. In this scenario, the GPIO can be modeled as an equivalent capacitor C<sub>EQ<\/sub> in parallel to a load resistor R<sub>EQ<\/sub>: more specifically this capacitor will take into account both the input capacitance of the GPIO (C<sub>INT<\/sub>) and the parasitic capacitance of the line (C<sub>EXT<\/sub>); the equivalent resistor instead models the internal losses. The voltage on the capacitor represents the voltage read by the GPIO: the game is to load the capacitor to V<sub>DD<\/sub> to get a <em>logical 1<\/em> or discharge it to Ground to get a <em>logical 0<\/em>. The button can be modeled as an ideal switch in series with a resistor R<sub>BTN<\/sub> that represents the resistance offered by the button when closed.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"536\" src=\"https:\/\/playembedded.org\/wp-content\/uploads\/2023\/02\/Pull-resistors-equivalent-circuit-PE-1-1024x536.png\" alt=\"\" class=\"wp-image-8606\" srcset=\"https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Pull-resistors-equivalent-circuit-PE-1-1024x536.png 1024w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Pull-resistors-equivalent-circuit-PE-1-300x157.png 300w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Pull-resistors-equivalent-circuit-PE-1-150x79.png 150w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Pull-resistors-equivalent-circuit-PE-1-1536x805.png 1536w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Pull-resistors-equivalent-circuit-PE-1-1200x629.png 1200w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Pull-resistors-equivalent-circuit-PE-1.png 1680w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">Charge and discharge of the equivalent capacitor<\/figcaption><\/figure>\n<\/div>\n\n\n<h4 class=\"wp-block-heading level_3\" id=\"8_Strength_and_weakness\">Strength and weakness<\/h4>\n\n\n\n<p>In a real-world scenario, the resistance value of R<sub>EQ<\/sub> is usually so high that it can be considered open, and the resistance value of R<sub>BTN<\/sub> is so low that it can be considered a short circuit. However, for the purpose of this analysis, let us examine their contribution when the button is pressed or released.<\/p>\n\n\n\n<p>When the button is not pressed, the capacitor is charged through the pull-up resistor R<sub>PU<\/sub> to <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=V_%7BDD%7D+%5Ccdot+R_%7BEQ%7D+%2F+%28R_%7BPU%7D+%2B+R_%7BEQ%7D%29+&amp;bg=ffffff&amp;fg=00313c&amp;s=0&amp;c=20201002\" alt=\"V_{DD} \\cdot R_{EQ} \/ (R_{PU} + R_{EQ}) \" class=\"latex\">. In the ideal case where the resistance of R<sub>EQ<\/sub> is infinite, the equation results in V<sub>DD<\/sub>.<\/p>\n\n\n\n<p>On the other hand, when the button is pressed, the capacitor discharges to <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=V_%7BDD%7D+%5Ccdot+R_%7BBTN%7D+%2F+%28R_%7BPU%7D+%2B+R_%7BBTN%7D%29+&amp;bg=ffffff&amp;fg=00313c&amp;s=0&amp;c=20201002\" alt=\"V_{DD} \\cdot R_{BTN} \/ (R_{PU} + R_{BTN}) \" class=\"latex\">. In the ideal case where R<sub>BTN<\/sub> is a short circuit, the equation results in Ground.<\/p>\n\n\n\n<p>Let us now consider the non-ideal case where R<sub>BTN<\/sub> is 150&Omega; and R<sub>EQ<\/sub> is 1M&Omega; and see how V<sub>LOW<\/sub> and V<sub>HIGH<\/sub> change depending on the value of R<sub>PU<\/sub> if V<sub>DD<\/sub> were 3.3V.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-black-color has-text-color has-fixed-layout\"><thead><tr><th class=\"has-text-align-center\" data-align=\"center\">R<sub>PU<\/sub> [&Omega;]<\/th><th class=\"has-text-align-center\" data-align=\"center\">V<sub>LOW<\/sub> [V]<\/th><th class=\"has-text-align-center\" data-align=\"center\">V<sub>HIGH<\/sub> [V]<\/th><\/tr><\/thead><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">500<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.76<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.30<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">600<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.66<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.30<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">700<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.58<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.30<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">800<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.52<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.30<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">900<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.47<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.30<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">1k<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.43<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.30<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">2k<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.23<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.29<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">5k<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.10<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.28<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">10k<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.05<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.27<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">100k<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.00<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.00<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">150k<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.00<\/td><td class=\"has-text-align-center\" data-align=\"center\">2.87<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">200k<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.00<\/td><td class=\"has-text-align-center\" data-align=\"center\">2.75<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">300k<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.00<\/td><td class=\"has-text-align-center\" data-align=\"center\">2.54<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">400k<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.00<\/td><td class=\"has-text-align-center\" data-align=\"center\">2.36<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">Calculation of the logical values when V<sub>DD<\/sub> is 3.3V, R<sub>BTN<\/sub> 150&Omega; and R<sub>EQ<\/sub> 1M&Omega; over a range of R<sub>PU<\/sub> values<\/figcaption><\/figure>\n\n\n\n<p>This table illustrates the concept of classifying a pull resistor as weak or strong. <\/p>\n\n\n\n<p>A low-value resistor exerts a strong pull towards its side. In this scenario, where our poor button is pressed, a 1K&Omega; pull-up resistor is strong enough to move the V<sub>LOW<\/sub> into the indeterminate region (we defined it in the first chapter as being between 0.4 and 2.9V). On the other hand, when the button is not pressed, a strong pull-up resistor maintains the V<sub>HIGH<\/sub> quite healthy even if our GPIO exhibits a large current loss of 3.3uA (<img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=V_%7BDD%7D+%2F+%28R_%7BEQ%7D+&amp;bg=ffffff&amp;fg=00313c&amp;s=0&amp;c=20201002\" alt=\"V_{DD} \/ (R_{EQ} \" class=\"latex\">).<\/p>\n\n\n\n<p>Conversely, a high-value resistor pulls weakly towards its side. It struggles to keep the V<sub>HIGH<\/sub> when the button is open due to the high current loss (i.e. R<sub>EQ<\/sub> is too small). For instance, a 150K&Omega; pull-up resistor is already too weak in this scenario. On the other hand, a weak pull-up resistor makes it easier for the button to pull down the line when it is pressed.<\/p>\n\n\n\n<p>This use case was quite exaggerated for the purpose of the analysis. In reality, we can easily expect a button resistance (R<sub>BTN<\/sub>) as small as 10&Omega; and a GPIO parasitic resistance (R<sub>EQ<\/sub>) as large as 10M&Omega;. In such a case, our calculation would yield as follow.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th class=\"has-text-align-center\" data-align=\"center\">R<sub>PU<\/sub> [&Omega;]<\/th><th class=\"has-text-align-center\" data-align=\"center\">V<sub>LOW<\/sub> [V]<\/th><th class=\"has-text-align-center\" data-align=\"center\">V<sub>HIGH<\/sub> [V]<\/th><\/tr><\/thead><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">500<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.065<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.300<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">600<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.054<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.300<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">700<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.046<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.300<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">800<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.041<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.300<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">900<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.036<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.300<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">1k<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.033<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.30<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">2k<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.016<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.299<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">5k<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.007<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.298<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">10k<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.003<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.297<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">100k<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.000<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.267<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">150k<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.000<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.251<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">200k<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.000<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.235<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">300k<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.000<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.204<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">400k<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.000<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.173<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">Calculation of the logical values when V<sub>DD<\/sub> is 3.3V, R<sub>BTN<\/sub> 10&Omega; and R<sub>EQ<\/sub> 10M&Omega; over a range of R<sub>PU<\/sub> values<\/figcaption><\/figure>\n\n\n\n<p>This table shows that, even with the weakest (400 k&Omega;) and strongest (500 &Omega;) pull-up resistors that we have considered, the thresholds are good enough in terms of voltage levels.<\/p>\n\n\n\n<h4 class=\"wp-block-heading level_3\" id=\"9_Transient_speed_and_current\">Transient speed and current <\/h4>\n\n\n\n<p>For the subsequent portion of the analysis, we will examine the impact of the pull-up resistor on the rising time and power consumption. Note that the same analysis would apply to the falling time in the case of a pull-down resistor. This analysis will be based on a fully discharged capacitor (worst-case scenario) and disregards the effect of R<sub>EQ<\/sub>. Our focus will be solely on the rising time, which is the parameter influenced by the choice of the pull-up resistor. The relevant equations, which are derived in the appendix, are:<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=v_C%28t%29+%3D+%28V_%7BC0%7D++-+V_%7BC+%5Cinfty%7D%29e%5E%7B-%5Cfrac%7Bt%7D%7BRC%7D%7D+%2B++V_%7BC+%5Cinfty%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"v_C(t) = (V_{C0}  - V_{C \\infty})e^{-\\frac{t}{RC}} +  V_{C \\infty}\" class=\"latex\"><\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=I_%7BMAX%7D+%3D+%5Cfrac%7BV_%7BC+%5Cinfty%7D+-+V_%7BC0%7D%7D%7BR%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"I_{MAX} = \\frac{V_{C \\infty} - V_{C0}}{R}\" class=\"latex\"><\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=P_%7BMAX%7D+%3D+%5Cfrac%7B%28V_%7BC+%5Cinfty%7D+-+V_%7BC0%7D%29%5E2%7D%7BR%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"P_{MAX} = \\frac{(V_{C \\infty} - V_{C0})^2}{R}\" class=\"latex\"><\/p>\n\n\n\n<p>In the context of our case study, these equations become:<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=v_C%28t%29+%3D+V_%7BDD%7D+%5Ccdot+%281+-+e%5E%7B-%5Cfrac%7Bt%7D%7BR_%7BPU%7DC_%7BEQ%7D%7D%7D%29&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"v_C(t) = V_{DD} \\cdot (1 - e^{-\\frac{t}{R_{PU}C_{EQ}}})\" class=\"latex\"><\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=I_%7BMAX%7D+%3D+%5Cfrac%7BV_%7BDD%7D%7D%7BR_%7BPU%7D%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"I_{MAX} = \\frac{V_{DD}}{R_{PU}}\" class=\"latex\"><\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=P_%7BMAX%7D+%3D+%5Cfrac%7BV_%7BDD%7D%5E2%7D%7BR_%7BPU%7D%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"P_{MAX} = \\frac{V_{DD}^2}{R_{PU}}\" class=\"latex\"><\/p>\n\n\n\n<p>Before proceeding with the analysis some details about C<sub>EQ<\/sub> need to be discussed. As mentioned before, this capacitance takes into account both the input capacitance of the GPIO (C<sub>INT<\/sub>) and the parasitic capacitance of the line (C<sub>EXT<\/sub>). Hence, its total value would be <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=C_%7BEQ%7D+%3D+C_%7BINT%7D+%2B+C_%7BEXT%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=0&amp;c=20201002\" alt=\"C_{EQ} = C_{INT} + C_{EXT}\" class=\"latex\"><\/p>\n\n\n\n<p>The first,  C<sub>INT<\/sub>, depends on the technology and the manufacturer of the MCU whose GPIO is being considered. To provide some references, examples of input capacitance values for popular microcontrollers are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Atmel ATmega328P (Arduino Uno): 6-8 pF<\/li>\n\n\n\n<li>STMicroelectronics STM32F030F4P6: 6-9 pF<\/li>\n\n\n\n<li>NXP Semiconductors LPC11U24F: 4-7 pF<\/li>\n<\/ul>\n\n\n\n<p>The second,  C<sub>EXT<\/sub>, depends on several factors such as the trace width, dielectric constant, and the material used as a substrate when the MCU is soldered on a PCB. For a standard FR-4 substrate with a dielectric constant of 4.5 and a trace width of 10mil (0.25mm), the line capacitance can be estimated to be around 3-5pF per cm. So, for a 5cm trace, the capacitance would be around 15-25pF.<\/p>\n\n\n\n<p>In summary, if we consider a C<sub>EQ<\/sub> of 50pF, we have been very conservative about the quality of both our MCU and PCB.<\/p>\n\n\n\n<p>The following table reports the time it takes for the GPIO to reach 95% (i.e. 3 time-constants) and 99% (i.e. 5 time-constants) of the steady-state voltage with a V<sub>DD<\/sub> of 3.3V and C<sub>EQ<\/sub> of 50pF. It also includes the maximum current and power drawn over the pull-up resistor R<sub>PU<\/sub>, as the value of the resistor varies.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th class=\"has-text-align-center\" data-align=\"center\">R<sub>PU<\/sub> [&Omega;]<\/th><th class=\"has-text-align-center\" data-align=\"center\">95% transient (3 RC) [uS]<\/th><th class=\"has-text-align-center\" data-align=\"center\">99% transient (5 RC) [uS]<\/th><th class=\"has-text-align-center\" data-align=\"center\">I<sub>MAX<\/sub> [mA]<\/th><th class=\"has-text-align-center\" data-align=\"center\">P<sub>MAX<\/sub> [mW]<\/th><\/tr><\/thead><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">500<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.075<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.125<\/td><td class=\"has-text-align-center\" data-align=\"center\">6.6<\/td><td class=\"has-text-align-center\" data-align=\"center\">21.78<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">600<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.09<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.15<\/td><td class=\"has-text-align-center\" data-align=\"center\">5.5<\/td><td class=\"has-text-align-center\" data-align=\"center\">18.15<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">700<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.105<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.175<\/td><td class=\"has-text-align-center\" data-align=\"center\">4.71<\/td><td class=\"has-text-align-center\" data-align=\"center\">15.56<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">800<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.12<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.2<\/td><td class=\"has-text-align-center\" data-align=\"center\">4.12<\/td><td class=\"has-text-align-center\" data-align=\"center\">13.61<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">900<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.135<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.225<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.67<\/td><td class=\"has-text-align-center\" data-align=\"center\">12.10<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">1k<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.15<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.25<\/td><td class=\"has-text-align-center\" data-align=\"center\">3.30<\/td><td class=\"has-text-align-center\" data-align=\"center\">10.89<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">2k<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.3<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.5<\/td><td class=\"has-text-align-center\" data-align=\"center\">1.65<\/td><td class=\"has-text-align-center\" data-align=\"center\">5.45<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">5k<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.75<\/td><td class=\"has-text-align-center\" data-align=\"center\">1.25<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.66<\/td><td class=\"has-text-align-center\" data-align=\"center\">2.18<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">10k<\/td><td class=\"has-text-align-center\" data-align=\"center\">1.5<\/td><td class=\"has-text-align-center\" data-align=\"center\">2.5<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.33<\/td><td class=\"has-text-align-center\" data-align=\"center\">1.09<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">100k<\/td><td class=\"has-text-align-center\" data-align=\"center\">15.00<\/td><td class=\"has-text-align-center\" data-align=\"center\">25<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.033<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.11<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">150k<\/td><td class=\"has-text-align-center\" data-align=\"center\">22.5<\/td><td class=\"has-text-align-center\" data-align=\"center\">37.5<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.022<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.07<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">200k<\/td><td class=\"has-text-align-center\" data-align=\"center\">30<\/td><td class=\"has-text-align-center\" data-align=\"center\">50<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.017<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.05<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">300k<\/td><td class=\"has-text-align-center\" data-align=\"center\">45<\/td><td class=\"has-text-align-center\" data-align=\"center\">75<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.011<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.04<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">400k<\/td><td class=\"has-text-align-center\" data-align=\"center\">60<\/td><td class=\"has-text-align-center\" data-align=\"center\">100<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.008<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.03<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">Calculation of the transient times, max current and power when V<sub>DD<\/sub> is 3.3V and C<sub>EQ <\/sub>is 50 pF over a range of R<sub>PU<\/sub> values<\/figcaption><\/figure>\n\n\n\n<p>At the extreme of this analysis, there is a very strong 500&Omega; pull-up resistor that consumes nearly 1\/4 watt and allows the line to reach 95% of its final value within 125 nanoseconds. Opting for this resistor means prioritizing speed over using larger components capable of handling the resulting high current.<\/p>\n\n\n\n<p>On the other hand, a pull-up resistor of 400k&Omega; is extremely weak and takes 60us for the line to reach 95% of its final value, with a negligible current. A rising time of 60us may not be an issue if the application involves a button, however, if we are considering an I<sup>2<\/sup>C bus running at a minimum of 100kHz, the 10us period of the clock line combined with a CEQ of 50pF makes it unsuitable.<\/p>\n\n\n\n<p>So what is the best choice? It ultimately depends on the specific application, but in general, pull resistors in the range of 1k&Omega; to 10k&Omega; are acceptable for a wide range of applications.<\/p>\n\n\n\n<h2 class=\"wp-block-heading level_1\" id=\"10_The_benefits_of_using_a_Schmitt_Trigger\">The benefits of using a Schmitt Trigger<\/h2>\n\n\n\n<p>In the world of digital electronics, signals often suffer from noise and interference, causing them to be unreliable. To tackle this issue, engineers often turn to a circuit called a Schmitt Trigger. The Schmitt Trigger acts as a filter, cleaning up a noisy digital signal and providing a reliable output. In this paragraph, we will delve into the details of how a Schmitt Trigger works and the benefits it offers in improving the quality of digital signals.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"622\" src=\"https:\/\/playembedded.org\/wp-content\/uploads\/2023\/02\/Single-rail-non-inverting-Schmitt-Trigger-PE-1024x622.png\" alt=\"\" class=\"wp-image-8641\" srcset=\"https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Single-rail-non-inverting-Schmitt-Trigger-PE-1024x622.png 1024w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Single-rail-non-inverting-Schmitt-Trigger-PE-300x182.png 300w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Single-rail-non-inverting-Schmitt-Trigger-PE-150x91.png 150w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Single-rail-non-inverting-Schmitt-Trigger-PE.png 1120w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">The schematic of a non-inverting single-rail Schmitt Trigger<\/figcaption><\/figure>\n<\/div>\n\n\n<p>This circuit is implemented using an operational amplifier and a positive feedback loop. The output of this circuit can be only in two states: if the input is greater than the upper threshold (V<sub>TH<\/sub>) the output will be V<sub>DD<\/sub>. Conversely, if the input is less than the lower threshold (V<sub>TL<\/sub>) the output will be Ground. The following formulas can be used to calculate the thresholds.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"has-text-align-center\" style=\"font-size:18px\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=V_%7BTH%7D+%3D+%5Cfrac%7BR_1+%2B+R_2%7D%7BR_2%7D+%5Cfrac%7BV_%7BDD%7D%7D%7B2%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"V_{TH} = \\frac{R_1 + R_2}{R_2} \\frac{V_{DD}}{2}\" class=\"latex\"><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"has-text-align-center\" style=\"font-size:18px\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=V_%7BTH%7D+%3D+%5Cfrac%7BR_2+-+R_1%7D%7BR_2%7D+%5Cfrac%7BV_%7BDD%7D%7D%7B2%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"V_{TH} = \\frac{R_2 - R_1}{R_2} \\frac{V_{DD}}{2}\" class=\"latex\"><\/p>\n<\/div>\n<\/div>\n\n\n\n<p class=\"has-text-align-left\">If we set R<sub>2<\/sub> to 3k&Omega; and R1 to 1k&Omega; the thresholds will then be<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=V_%7BTH%7D+%3D+%5Cfrac%7B4%7D%7B3%7D+%5Ccdot+%5Cfrac%7B3.3%7D%7B2%7D+%3D2.2+V&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"V_{TH} = \\frac{4}{3} \\cdot \\frac{3.3}{2} =2.2 V\" class=\"latex\"><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=V_%7BTH%7D+%3D+%5Cfrac%7B2%7D%7B3%7D+%5Ccdot+%5Cfrac%7B3.3%7D%7B2%7D%3D1.1+V&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"V_{TH} = \\frac{2}{3} \\cdot \\frac{3.3}{2}=1.1 V\" class=\"latex\"><\/p>\n<\/div>\n<\/div>\n\n\n\n<p>The following picture shows the output of the Schmitt trigger when the input is a sinusoid with an offset of V<sub>DD<\/sub>\/2 and a peak-to-peak value of V<sub>DD<\/sub>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"461\" src=\"https:\/\/playembedded.org\/wp-content\/uploads\/2023\/02\/Schmitt-Trigger-sine-as-inputPE-1024x461.png\" alt=\"\" class=\"wp-image-8655\" srcset=\"https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Schmitt-Trigger-sine-as-inputPE-1024x461.png 1024w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Schmitt-Trigger-sine-as-inputPE-300x135.png 300w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Schmitt-Trigger-sine-as-inputPE-150x68.png 150w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Schmitt-Trigger-sine-as-inputPE-1200x541.png 1200w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Schmitt-Trigger-sine-as-inputPE.png 1456w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">Example of the output of a Schmitt trigger with a Sinusoid as input<\/figcaption><\/figure>\n<\/div>\n\n\n<p>This brings us to a real case scenario where an input port of a microcontroller receives a quite noisy signal. The following figure shows how the Schmitt Trigger tackles this issue (move the slider to do a comparison with and without the trigger).<\/p>\n\n\n\n<figure class=\"wp-block-jetpack-image-compare\"><div class=\"juxtapose\" data-mode=\"horizontal\"><img loading=\"lazy\" decoding=\"async\" id=\"8659\" src=\"https:\/\/i1.wp.com\/playembedded.org\/wp-content\/uploads\/2023\/02\/Noisy-input-thresholds-PE-1.png?ssl=1\" alt=\"\" width=\"1566\" height=\"616\" class=\"image-compare__image-before\"><img loading=\"lazy\" decoding=\"async\" id=\"8660\" src=\"https:\/\/i2.wp.com\/playembedded.org\/wp-content\/uploads\/2023\/02\/Noisy-input-with-Schmitt-Trigger-PE-1.png?ssl=1\" alt=\"\" width=\"1566\" height=\"616\" class=\"image-compare__image-after\"><\/div><figcaption>Comparison of a noisy digital filter with and without a Schmitt trigger as a filter<\/figcaption><\/figure>\n\n\n\n<p>Concluding, is quite typical nowadays that many microcontrollers filter digital inputs using a Schmitt Trigger to clean up a noisy digital signal and provide reliable behavior of their GPIO.<\/p>\n\n\n\n<h2 class=\"wp-block-heading level_1\" id=\"11_Appendix_A\">Appendix A<\/h2>\n\n\n\n<p>In this appendix, we are going to solve the equation of an RC circuit and draw some conclusions.<\/p>\n\n\n\n<h3 class=\"wp-block-heading level_2\" id=\"12_First_order_non_homogenous_differential_equation_with_constant_coefficients\">First-order non-homogenous differential equation with constant coefficients<\/h3>\n\n\n\n<p>Let us consider the equation<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=y%27+%2B+ay+%2B+b&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"y' + ay + b\" class=\"latex\"><\/p>\n\n\n\n<p>that is a first-order non-homogenous differential equation with constant coefficients. <\/p>\n\n\n\n<p>The solution to this equation is a family of functions. To find a unique solution, a boundary condition is needed such as the value of y at a specific time. For convenience, the time chosen is 0 as we will see it simplifies the math.<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=y%28t+%3D+0%29+%3D+y_0&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"y(t = 0) = y_0\" class=\"latex\"><\/p>\n\n\n\n<p>The homogeneous solution can be found by rearranging the homogenous equation (b = 0), integrating both sides, and using some properties of logarithms and exponentials.<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=%5Cfrac%7Bdy%28t%29%7D%7Bdt%7D+%2Bay+%3D+0&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"\\frac{dy(t)}{dt} +ay = 0\" class=\"latex\"><\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=%5Cint%7B%5Cfrac%7Bdy%28t%29%7D%7By%28t%29%7D%7D+%3D+-%5Cint%7Ba+dt%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"\\int{\\frac{dy(t)}{y(t)}} = -\\int{a dt}\" class=\"latex\"><\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=ln%28y%28t%29%29+%3D+-at+%2B+c&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"ln(y(t)) = -at + c\" class=\"latex\"><\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=y%28t%29+%3D+e%5E%7B-at%7D+e%5Ec+%3D+k_1e%5E%7B-at%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"y(t) = e^{-at} e^c = k_1e^{-at}\" class=\"latex\"><\/p>\n\n\n\n<p>The complete solution of the original equation however is the sum of the homogeneous solution plus a particular solution. For the method of the similarities, as <em>b<\/em> is a polynomial of order zero (i.e. a constant) the particular solution is expected to be a polynomial of the same order (let us call it k<sub>2<\/sub>)<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=y%28t%29+%3D+k_1e%5E%7B-at%7D+%2B+k_2&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"y(t) = k_1e^{-at} + k_2\" class=\"latex\"><\/p>\n\n\n\n<p>The first constant can be found substituting the solution in the original equation we have<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=%5Cfrac%7Bd%28k_1e%5E%7B-at%7D+%2B+k_2%29%7D%7Bdt%7D+%2B+a+%5Ccdot+%28k_1e%5E%7B-at%7D+%2B+k_2%29+%2B+b+%3D+0&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"\\frac{d(k_1e^{-at} + k_2)}{dt} + a \\cdot (k_1e^{-at} + k_2) + b = 0\" class=\"latex\"><\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=-ak_1e%5E%7B-at%7D++%2B+ak_1e%5E%7B-at%7D+%2B+ak_2+%2B+b+%3D+0&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"-ak_1e^{-at}  + ak_1e^{-at} + ak_2 + b = 0\" class=\"latex\"><\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=k_2+%3D+-%5Cfrac%7Bb%7D%7Ba%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"k_2 = -\\frac{b}{a}\" class=\"latex\"><\/p>\n\n\n\n<p>The second constant can be found using the boundary condition. So imposing t = 0 yields to<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=y%28t+%3D+0%29+%3D+y_0+%3D+k_1e%5E%7B-a+%5Ccdot+0%7D+-+b%2Fa&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"y(t = 0) = y_0 = k_1e^{-a \\cdot 0} - b\/a\" class=\"latex\"><\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=y_0+%3D+k_1+-+b%2Fa&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"y_0 = k_1 - b\/a\" class=\"latex\"><\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=k_1+%3D+y_0+%2B+b%2Fa&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"k_1 = y_0 + b\/a\" class=\"latex\"><\/p>\n\n\n\n<p>hence the solution we were looking for is<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=y%28t%29+%3D+%28y_0+%2B+b%2Fa%29e%5E%7B-at%7D+-+b%2Fa&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"y(t) = (y_0 + b\/a)e^{-at} - b\/a\" class=\"latex\"><\/p>\n\n\n\n<h3 class=\"wp-block-heading level_2\" id=\"13_First_order_RC_circuit\">First-order RC circuit<\/h3>\n\n\n\n<p>Let us consider an RC network and a voltage generator as shown in the figure.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"866\" height=\"426\" src=\"https:\/\/playembedded.org\/wp-content\/uploads\/2023\/02\/RC-circuit-PE.png\" alt=\"\" class=\"wp-image-8591\" style=\"width:503px;height:247px\" srcset=\"https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/RC-circuit-PE.png 866w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/RC-circuit-PE-300x148.png 300w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/RC-circuit-PE-150x74.png 150w\" sizes=\"auto, (max-width: 866px) 100vw, 866px\"><figcaption class=\"wp-element-caption\">A first-order RC circuit<\/figcaption><\/figure>\n<\/div>\n\n\n<p>the following statements are all true:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The DC voltage generator has an amplitude of V<sub>G<\/sub><\/li>\n\n\n\n<li>The switch gets closed at the time t = 0<\/li>\n\n\n\n<li>The capacitor is preloaded to a specific voltage level V<sub>C0<\/sub> before the switch gets closed  <\/li>\n\n\n\n<li>As in the absence of infinite current, the voltage across a capacitor cannot change instantaneously we can state that in the moment the switch gets closed V<sub>c<\/sub>(t = 0) is still V<sub>C0<\/sub><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading level_3\" id=\"14_Deriving_the_equation\">Deriving the equation<\/h4>\n\n\n\n<p>To solve this circuit we start with the law of a capacitor<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=i_C%28t%29+%3D+C+%5Cfrac%7Bdv_C%28t%29%7D%7Bdt%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"i_C(t) = C \\frac{dv_C(t)}{dt}\" class=\"latex\"><\/p>\n\n\n\n<p>For the Kirchoff Voltage Law when the switch is closed we have<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=V_G+%3D+Ri_c%28t%29+%2B+v_C%28t%29&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"V_G = Ri_c(t) + v_C(t)\" class=\"latex\"><\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=v%27_C%28t%29+%2B+%5Cfrac%7Bv_C%28t%29%7D%7BRC%7D+-+%5Cfrac%7BV_G%7D%7BRC%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"v'_C(t) + \\frac{v_C(t)}{RC} - \\frac{V_G}{RC}\" class=\"latex\"><\/p>\n\n\n\n<p>This equation is in the form<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=y%27+%2B+ay+%2B+b&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"y' + ay + b\" class=\"latex\"><\/p>\n\n\n\n<p>As seen in the previous paragraph, the solution to this equation is given by<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=y%28t%29+%3D+%28y_0+%2B+b%2Fa%29e%5E%7B-at%7D+-+b%2Fa&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"y(t) = (y_0 + b\/a)e^{-at} - b\/a\" class=\"latex\"><\/p>\n\n\n\n<p>that particularized to our specific case brings to<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=v_C%28t%29+%3D+%28V_%7BC0%7D++-+V_G%29e%5E%7B-%5Cfrac%7Bt%7D%7BRC%7D%7D+%2B++V_G&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"v_C(t) = (V_{C0}  - V_G)e^{-\\frac{t}{RC}} +  V_G\" class=\"latex\"><\/p>\n\n\n\n<p>The equation can be further generalized if we consider that<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=v_C%28t+%3D+%5Cinfty%29+%3D+V_%7BC+%5Cinfty%7D+%3D+V_G&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"v_C(t = \\infty) = V_{C \\infty} = V_G\" class=\"latex\"><\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=v_C%28t%29+%3D+%28V_%7BC0%7D++-+V_%7BC+%5Cinfty%7D%29e%5E%7B-%5Cfrac%7Bt%7D%7BRC%7D%7D+%2B++V_%7BC+%5Cinfty%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"v_C(t) = (V_{C0}  - V_{C \\infty})e^{-\\frac{t}{RC}} +  V_{C \\infty}\" class=\"latex\"><\/p>\n\n\n\n<h4 class=\"wp-block-heading level_3\" id=\"15_Transient_time\">Transient time<\/h4>\n\n\n\n<p>Let us plot the equation on a time chart for a fixed value of RC.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"501\" src=\"https:\/\/playembedded.org\/wp-content\/uploads\/2023\/02\/RC-voltage-transient-PE-1024x501.png\" alt=\"\" class=\"wp-image-8594\" srcset=\"https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/RC-voltage-transient-PE-1024x501.png 1024w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/RC-voltage-transient-PE-300x147.png 300w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/RC-voltage-transient-PE-150x73.png 150w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/RC-voltage-transient-PE.png 1156w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">The voltage transient of a first-order RC circuit<\/figcaption><\/figure>\n<\/div>\n\n\n<p>We can easily notice that the voltage goes from the initial value to the final value asymptotically. The slope of the exponential and hence the duration of the transient depends directly on the RC value. Indeed the transient is over when t &gt;&gt; RC and the exponential term tends to 0. For this reason, RC is often referred to as tau or time-constant. The following table shows the elapsed percentage of the transient assuming t to be multiples of RC.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th class=\"has-text-align-center\" data-align=\"center\">t<\/th><th class=\"has-text-align-center\" data-align=\"center\">Exponential<\/th><th class=\"has-text-align-center\" data-align=\"center\">Exponential value<\/th><th class=\"has-text-align-center\" data-align=\"center\">Transient percentage<\/th><\/tr><\/thead><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">1RC<\/td><td class=\"has-text-align-center\" data-align=\"center\">e<sup>-1<\/sup><\/td><td class=\"has-text-align-center\" data-align=\"center\">0.367879<\/td><td class=\"has-text-align-center\" data-align=\"center\">63.21 %<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">2RC<\/td><td class=\"has-text-align-center\" data-align=\"center\">e<sup>-2<\/sup><\/td><td class=\"has-text-align-center\" data-align=\"center\">0.135335<\/td><td class=\"has-text-align-center\" data-align=\"center\">86.47 %<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">3RC<\/td><td class=\"has-text-align-center\" data-align=\"center\">e<sup>-3<\/sup><\/td><td class=\"has-text-align-center\" data-align=\"center\">0.049787<\/td><td class=\"has-text-align-center\" data-align=\"center\">95.02 %<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">4RC<\/td><td class=\"has-text-align-center\" data-align=\"center\">e<sup>-4<\/sup><\/td><td class=\"has-text-align-center\" data-align=\"center\">0.018316<\/td><td class=\"has-text-align-center\" data-align=\"center\">98.17 %<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">5RC<\/td><td class=\"has-text-align-center\" data-align=\"center\">e<sup>-5<\/sup><\/td><td class=\"has-text-align-center\" data-align=\"center\">0.006738<\/td><td class=\"has-text-align-center\" data-align=\"center\">99.33 %<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">6RC<\/td><td class=\"has-text-align-center\" data-align=\"center\">e<sup>-6<\/sup><\/td><td class=\"has-text-align-center\" data-align=\"center\">0.002479<\/td><td class=\"has-text-align-center\" data-align=\"center\">99.75 %<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">7RC<\/td><td class=\"has-text-align-center\" data-align=\"center\">e<sup>-7<\/sup><\/td><td class=\"has-text-align-center\" data-align=\"center\">0.000912<\/td><td class=\"has-text-align-center\" data-align=\"center\">99.91 %<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">8RC<\/td><td class=\"has-text-align-center\" data-align=\"center\">e<sup>-8<\/sup><\/td><td class=\"has-text-align-center\" data-align=\"center\">0.000335<\/td><td class=\"has-text-align-center\" data-align=\"center\">99.97 %<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">How long does it take to complete a transient?<\/figcaption><\/figure>\n\n\n\n<p>Looking at the table with good approximation the transient may be considered concluded after 5 time-constants. It goes without saying that having a smaller time constant (e.g. with a fixed capacitance, a smaller resistance value) shortens the transient time. <\/p>\n\n\n\n<h4 class=\"wp-block-heading level_3\" id=\"16_Current\">Current<\/h4>\n\n\n\n<p>The current that flows in the circuit depends on time and can be calculated in various ways. One is to derive the current of the capacitor and this results in the following equation<\/p>\n\n\n\n<p class=\"has-text-align-center\"> <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=i%28t%29+%3D+%5Cfrac%7B1%7D%7BR%7D%28V_G+-+V_%7BC0%7D%29e%5E%7B-%5Cfrac%7Bt%7D%7BRC%7D%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"i(t) = \\frac{1}{R}(V_G - V_{C0})e^{-\\frac{t}{RC}}\" class=\"latex\"><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"500\" src=\"https:\/\/playembedded.org\/wp-content\/uploads\/2023\/02\/RC-current-transient-PE-1024x500.png\" alt=\"\" class=\"wp-image-8593\" srcset=\"https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/RC-current-transient-PE-1024x500.png 1024w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/RC-current-transient-PE-300x146.png 300w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/RC-current-transient-PE-150x73.png 150w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/RC-current-transient-PE.png 1156w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">The current transient of a first-order RC circuit<\/figcaption><\/figure>\n<\/div>\n\n\n<p>The current hits its maximum value at the beginning of the transient when the capacitor is completely discharged.<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=I_%7BMAX%7D+%3D+%5Cfrac%7BV_G%7D%7BR%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"I_{MAX} = \\frac{V_G}{R}\" class=\"latex\"><\/p>\n\n\n\n<p>In general, during a transient period of an RC circuit, a current flows through the circuit. At the start of the transient, the current is at its highest, as the voltage across the capacitor is further from the eventual steady-state voltage. The direction of the current flow is dependent on the type of transient: if the capacitor is being charged, the current flows toward the capacitor, and if the capacitor is being discharged, the current flows away from the capacitor.<\/p>\n\n\n\n<p>The duration of the transient depends on the resistor: this component indeed limits the amount of charge that flows in and out from the capacitor (current) and ultimately the speed of the charge and discharge.<\/p>\n\n\n\n<h4 class=\"wp-block-heading level_3\" id=\"17_Power_and_Energy\">Power and Energy<\/h4>\n\n\n\n<p>In the previous chapter we have seen that when charging the capacitor, a current flows through the resistor into the capacitor. It should come as no surprise that some power is dissipated over the resistor in the process. To calculate this power let us consider once again the equation of the capacitor voltage and as we know that steady-state voltage is V<sub>G<\/sub> let us rewrite it<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=v_C%28t%29+%3D+%28V_%7BC0%7D++-+V_%7BC+%5Cinfty%7D%29e%5E%7B-%5Cfrac%7Bt%7D%7BRC%7D%7D+%2B++V_%7BC+%5Cinfty%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"v_C(t) = (V_{C0}  - V_{C \\infty})e^{-\\frac{t}{RC}} +  V_{C \\infty}\" class=\"latex\"><\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=v_C%28t%29+%3D+%28V_%7BC0%7D++-+V_%7BG%7D%29e%5E%7B-%5Cfrac%7Bt%7D%7BRC%7D%7D+%2B++V_%7BG%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"v_C(t) = (V_{C0}  - V_{G})e^{-\\frac{t}{RC}} +  V_{G}\" class=\"latex\"><\/p>\n\n\n\n<p>Reapplying Kirkoff voltages law we have<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=v_R%28t%29+%3D+%28V_%7BG%7D++-+v_%7BC%7D%28t%29%29&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"v_R(t) = (V_{G}  - v_{C}(t))\" class=\"latex\"><\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=v_R%28t%29+%3D+%28V_%7BG%7D+-+V_%7BC0%7D%29e%5E%7B-%5Cfrac%7Bt%7D%7BRC%7D%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"v_R(t) = (V_{G} - V_{C0})e^{-\\frac{t}{RC}}\" class=\"latex\"><\/p>\n\n\n\n<p>The power dissipated on the resistor can be calculated as <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=p_%7BR%7D%28t%29+%3D+%28v_%7BR%7D%28t%29++%5Ccdot+i%28t%29%29&amp;bg=ffffff&amp;fg=00313c&amp;s=0&amp;c=20201002\" alt=\"p_{R}(t) = (v_{R}(t)  \\cdot i(t))\" class=\"latex\"> that yield to<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=p_%7BR%7D%28t%29+%3D+%5Cfrac%7B1%7D%7BR%7D%28V_G+-+V_%7BC0%7D%29%5E2e%5E%7B-%5Cfrac%7B2t%7D%7BRC%7D%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"p_{R}(t) = \\frac{1}{R}(V_G - V_{C0})^2e^{-\\frac{2t}{RC}}\" class=\"latex\"><\/p>\n\n\n\n<p>And predictably the maximum power consumption is at the beginning of the transition (t = 0) when the capacitor is totally discharged (V<sub>C0<\/sub> = 0)<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=P_%7BMAX%7D+%3D+%5Cfrac%7BV_G%5E2%7D%7BR%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"P_{MAX} = \\frac{V_G^2}{R}\" class=\"latex\"><\/p>\n\n\n\n<p>So, while a small resistor provides faster transients, it also requires the resistor to withstand higher power consumption. The energy on the other hand can be seen as the integral of the power in the transient<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=E+%3D+%5Cint_%7B0%7D%5E%7B%5Cinfty%7D%5Cfrac%7B%28V_G+-+V_%7BC0%7D%29%5E2e%5E%7B-%5Cfrac%7B2t%7D%7BRC%7D%7D%7D%7BR%7Ddt&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"E = \\int_{0}^{\\infty}\\frac{(V_G - V_{C0})^2e^{-\\frac{2t}{RC}}}{R}dt\" class=\"latex\"><\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=E+%3D+-%5Cfrac%7BRC%7D%7B2%7D+%5Ccdot+%5Cfrac%7B%28V_G+-+V_%7BC0%7D%29%5E2e%5E%7B-%5Cfrac%7B2t%7D%7BRC%7D%7D%7D%7BR%7D%5Crvert%5E%7B%5Cinfty%7D_%7B0%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"E = -\\frac{RC}{2} \\cdot \\frac{(V_G - V_{C0})^2e^{-\\frac{2t}{RC}}}{R}\\rvert^{\\infty}_{0}\" class=\"latex\"><\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=E+%3D+%5Cfrac%7BRC%7D%7B2%7D+%5Ccdot+%5Cfrac%7B%28V_G+-+V_%7BC0%7D%29%5E2%7D%7BR%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"E = \\frac{RC}{2} \\cdot \\frac{(V_G - V_{C0})^2}{R}\" class=\"latex\"><\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=E+%3D+%5Cfrac%7BC%7D%7B2%7D+%5Ccdot+%28V_G+-+V_%7BC0%7D%29%5E2&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"E = \\frac{C}{2} \\cdot (V_G - V_{C0})^2\" class=\"latex\"><\/p>\n\n\n\n<p>That finally shows that the amount of energy stored in the capacitor depends on its size only, while the resistance influences only the speed with which the capacitor is loaded and the overall power dissipation.<\/p>\n\n\n\n<h4 class=\"wp-block-heading level_3\" id=\"18_Conclusions\">Conclusions<\/h4>\n\n\n\n<p>We can conclude this discussion with the following points. In an RC circuit:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Smaller resistance results in a faster transient and larger resistance results in a slower transient.<\/li>\n\n\n\n<li>Faster transient leads to higher circuit current and thus higher maximum power dissipation.<\/li>\n\n\n\n<li>However, the energy of the transient is solely dependent on the capacitor and not the resistance.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading level_1\" id=\"19_Appendix_B\">Appendix B<\/h2>\n\n\n\n<h3 class=\"wp-block-heading level_2\" id=\"20_Non_inverting_single_supply_Schmitt_Trigger\">Non-inverting single-supply Schmitt Trigger<\/h3>\n\n\n\n<p>Let us consider the following circuit composed of a single-rail operational amplifier. The non-inverting input is offset to half the rail voltage (<img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=V_%7BINV%7D+%3D+V_%7BDD%7D+%5Ccdot+R%2F%28R%2BR%29%3DV_%7BDD%7D%2F2&amp;bg=ffffff&amp;fg=00313c&amp;s=0&amp;c=20201002\" alt=\"V_{INV} = V_{DD} \\cdot R\/(R+R)=V_{DD}\/2\" class=\"latex\">). The non-inverting pin is connected to V<sub>IN<\/sub> via R<sub>1<\/sub> and to V<sub>OUT<\/sub> via R<sub>2<\/sub>. <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"622\" src=\"https:\/\/playembedded.org\/wp-content\/uploads\/2023\/02\/Single-rail-non-inverting-Schmitt-Trigger-PE-1024x622.png\" alt=\"\" class=\"wp-image-8641\" srcset=\"https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Single-rail-non-inverting-Schmitt-Trigger-PE-1024x622.png 1024w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Single-rail-non-inverting-Schmitt-Trigger-PE-300x182.png 300w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Single-rail-non-inverting-Schmitt-Trigger-PE-150x91.png 150w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Single-rail-non-inverting-Schmitt-Trigger-PE.png 1120w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">The schematic of a non-inverting single-rail Schmitt Trigger<\/figcaption><\/figure>\n<\/div>\n\n\n<p>The working principle of this circuit is that when V<sub>+<\/sub> is greater than V<sub>&ndash;<\/sub>, the output V<sub>OUT<\/sub> will reach its maximum value of V<sub>DD<\/sub>. Conversely, when V<sub>+<\/sub> is less than V<sub>&ndash;<\/sub> the output will converge to Ground. This is due to the positive feedback loop that maintains saturation. The voltage level at which the output of the trigger switches, is dependent on the slope of V<sub>IN<\/sub>. This results in a hysteretic behavior that has many practical applications.<\/p>\n\n\n\n<p>To determine the transfer characteristic of this circuit, we can apply the principle of superposition to the linear circuit consisting of R<sub>1<\/sub> and R<sub>2<\/sub>. This calculation involves finding the contribution to V<sub>+<\/sub> from both V<sub>IN<\/sub> and V<sub>OUT<\/sub> individually and then summing it. The math is quite trivial if we consider that no current flows in the non-inverting terminal and that a voltage generator behaves as a short circuit when turned off. The resulting equation is hence the sum of two voltage dividers:<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=V_%2B+%3D+%5Cfrac%7BR_2%7D%7BR_1+%2B+R_2%7D+V_%7BIN%7D+%2B+%5Cfrac%7BR_1%7D%7BR_1+%2B+R_2%7D+V_%7BOUT%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"V_+ = \\frac{R_2}{R_1 + R_2} V_{IN} + \\frac{R_1}{R_1 + R_2} V_{OUT}\" class=\"latex\"><\/p>\n\n\n\n<p>The value of V<sub>IN<\/sub> that will trigger output change from low to high will be called the upper threshold (V<sub>TH<\/sub>). To calculate this value we need to impose some conditions on the previous equation. In this case, V<sub>OUT<\/sub> would be replaced with 0V, V<sub>+<\/sub> to V<sub>DD<\/sub>\/2 and V<sub>IN<\/sub> will represent our V<sub>TH<\/sub>. This yields:<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=V_%7BDD%7D%2F2+%3D+%5Cfrac%7BR_2%7D%7BR_1+%2B+R_2%7D+V_%7BTH%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"V_{DD}\/2 = \\frac{R_2}{R_1 + R_2} V_{TH}\" class=\"latex\"><\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=V_%7BTH%7D+%3D+%5Cfrac%7BR_1+%2B+R_2%7D%7BR_2%7D+%5Cfrac%7BV_%7BDD%7D%7D%7B2%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"V_{TH} = \\frac{R_1 + R_2}{R_2} \\frac{V_{DD}}{2}\" class=\"latex\"><\/p>\n\n\n\n<p>Similarly to obtain V<sub>TL<\/sub> V<sub>OUT<\/sub> would be replaced with V<sub>DD<\/sub>. This yields:<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=V_%7BDD%7D%2F2+%3D+%5Cfrac%7BR_2%7D%7BR_1+%2B+R_2%7D+V_%7BTL%7D+%2B+%5Cfrac%7BR_1%7D%7BR_1+%2B+R_2%7D+V_%7BDD%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"V_{DD}\/2 = \\frac{R_2}{R_1 + R_2} V_{TL} + \\frac{R_1}{R_1 + R_2} V_{DD}\" class=\"latex\"><\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=V_%7BTL%7D+%3D+%5Cfrac%7BR_2+-+R_1%7D%7BR_2%7D+%5Cfrac%7BV_%7BDD%7D%7D%7B2%7D&amp;bg=ffffff&amp;fg=00313c&amp;s=3&amp;c=20201002\" alt=\"V_{TL} = \\frac{R_2 - R_1}{R_2} \\frac{V_{DD}}{2}\" class=\"latex\"><\/p>\n\n\n\n<p>The following picture shows the transfer function of this circuit. The yellow arrows represent the positive slope of the input signal: in this case, the input needs to reach V<sub>TH<\/sub> before the output switches from 0 to V<sub>DD<\/sub>. Conversely, when the input has a negative slope (azure arrows) the input needs to reach V<sub>TL<\/sub> before the output switches from V<sub>DD<\/sub> to 0.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"956\" height=\"870\" src=\"https:\/\/playembedded.org\/wp-content\/uploads\/2023\/02\/Single-rail-non-inverting-Schmitt-Trigger-transfer-functionPE-1.png\" alt=\"\" class=\"wp-image-8647\" style=\"width:956px;height:870px\" srcset=\"https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Single-rail-non-inverting-Schmitt-Trigger-transfer-functionPE-1.png 956w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Single-rail-non-inverting-Schmitt-Trigger-transfer-functionPE-1-300x273.png 300w, https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Single-rail-non-inverting-Schmitt-Trigger-transfer-functionPE-1-150x137.png 150w\" sizes=\"auto, (max-width: 956px) 100vw, 956px\"><figcaption class=\"wp-element-caption\">The transfer function of a non-inverting single-rail Schmitt Trigger<\/figcaption><\/figure>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This article provides a comprehensive understanding of essential digital electronics concepts, including logic levels, push-pull\/open-drain configurations, pull-up\/pull-down resistors, and the Schmitt trigger. With clear explanations and relevant examples, readers will gain the knowledge and skills necessary to effectively utilize digital ports and communication buses in electronic systems.<\/p>\n","protected":false},"author":3,"featured_media":8601,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1219],"tags":[1293,1300],"coauthors":[241],"class_list":["post-8481","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-fundamentals","tag-1293","tag-electronics","cobalt"],"views":4887,"jetpack_featured_media_url":"https:\/\/playembedded.org\/blog\/wp-content\/uploads\/2023\/02\/Fundamentals-of-Digital-Circuitry-PE.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/playembedded.org\/blog\/wp-json\/wp\/v2\/posts\/8481","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/playembedded.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/playembedded.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/playembedded.org\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/playembedded.org\/blog\/wp-json\/wp\/v2\/comments?post=8481"}],"version-history":[{"count":0,"href":"https:\/\/playembedded.org\/blog\/wp-json\/wp\/v2\/posts\/8481\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/playembedded.org\/blog\/wp-json\/wp\/v2\/media\/8601"}],"wp:attachment":[{"href":"https:\/\/playembedded.org\/blog\/wp-json\/wp\/v2\/media?parent=8481"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/playembedded.org\/blog\/wp-json\/wp\/v2\/categories?post=8481"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/playembedded.org\/blog\/wp-json\/wp\/v2\/tags?post=8481"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/playembedded.org\/blog\/wp-json\/wp\/v2\/coauthors?post=8481"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}