Kirchhoff's Laws for Makers

This is the second article in a series to teach you all the EE you need to know for working with and designing microcontroller based circuits.

In 1845, German physicist Gustav Kirchhoff came up with two equations that generalized the application of Ohm’s law. Kirchhoff’s Current Law (KCL) says the sum of all current going into a node must be zero. Kirchhoff’s Voltage Law (KVL) states that the sum of all voltages around a closed loop is zero. Let’s look at how these are applied to a simple circuit.

Kirchhoff’s Current Law or KCL

KCL says the sum of all currents into a node is zero. So, what is a node? A node is any point on a wire in a schematic. It is more useful if the point has more than 2 places for current to go. Check out node A below.

1kΩ
1k<b>Ω</b>
5V
5V
1kΩ
1k<b>Ω</b>
1kΩ
1k<b>Ω</b>
A
A
i1
[Not supported by viewer]
i2
[Not supported by viewer]
i3
[Not supported by viewer]

In the circuit above, three wires meet at node A. KCL says all three currents will sum to zero.

$$ I_1 + I_1 + I_3 = 0A $$

Notice the arrows indicating the direction of all three currents. Positive current flows in the direction of the arrow. If an arrow is going into the node, it is positive. If it is leaving the node, it is negative. If we flipped the direction of \(I_3\), our equation would be:

\[ I_1 + I_2 - I_3 = 0A \]

And with a little algebra.

$$ I_1 + I_2 = I_3 $$

The above equation should be intuitive if you think about the physical flow of electrons.

Now we can use some Ohm’s law substitutions to actually solve for the current values. We will let the voltage at node A be \(V_A\).

$$ I_1 = \frac{5V - V_A}{1k \Omega} $$ $$ I_2 = \frac{5V - V_A}{1k \Omega} $$ $$ I_3 = \frac{V_A - 0V}{1k \Omega} $$ $$ \frac{5V - V_N}{1k \Omega} + \frac{5V - V_N}{1k \Omega} = \frac{V_N - 0V}{1k \Omega} $$

With this we have one equation and one unknown variable. So we solve for \(V_A\).

$$ V_A = \frac{10V}{3 \cdot 1k \Omega} \cdot 1 $$ $$ V_A = \frac{10V}{3} = 3.3V $$

We can now use Ohm’s law to get the current values.

$$ I_1 = \frac{5V - 3.3V}{1k \Omega} = 0.0017A = 1.7mA $$ $$ I_2 = \frac{5V - 3.3V}{1k \Omega} 0.0017A = 1.7mA $$ $$ I_3 = \frac{3.3V - 0V}{1k \Omega} 0.0033A = 3.3mA $$

We have a little rounding error \(10V / 3 \approx 3.3V \). If we used \(V_A = 3.\overline{3}V \), then we wouldn’t have the error. But in most digital circuits, we aren’t worried about things like that.

Our original equation is then.

$$ 1.7mA + 1.7mA = 3.3mA $$

KCL is pretty simply but it can be applied to all kinds or circuits. Let’s see how KVL works.

Kirchhoff’s Voltage Law or KVL

KVL is basically KCL but with voltages and loops rather than currents and nodes. It states that sum of the voltages around a closed loop in a circuit is zero.

1kΩ
1k<b>Ω</b>
5V
5V
1kΩ
1k<b>Ω</b>
1kΩ
1k<b>Ω</b>
B
B
A
A
+
V1
-
[Not supported by viewer]
+
V2
-
[Not supported by viewer]
+
V3
-
[Not supported by viewer]
C
C
+

-
[Not supported by viewer]

In the circuit above, we have 3 loops labelled A, B, and C. We will use the convention where a voltage polarity is positive if it follows the loop direction. Loop A flows from the - side of 5V to +, so 5V is positive. KVL for each loop is:

$$ A: 5V + -V_1 + -V_3 = 0 $$

$$ B: 5V + -V_2 + -V_3 = 0 $$

$$ C: -V_1 + V_2 = 0 $$

Notice \(V_1\) in loops A and C. In these loops, \(V_1\) has opposite polarity because of the flow of the loop through \(V_1\).

We need some additional information to solve these equations because when we substitute \(V_2 = V_1\), we end up with one equation and two unknowns. From KCL above we know that \(V_A = 3.3V \). In this case \(V_A\) is equivalent to \(V_3\).

$$ A: 5V + -V_1 + -3.3V = 0 $$ $$ A: 5V - 3.3V = V_1 = 1.7V $$

$$ V_1 = V_2 = 1.7V $$ $$ V_3 = 3.3V $$

Voltage Divider Circuit

The voltage divider is a very common circuit. Analyzing a voltage divider is a great way to apply KCL and KVL. The following circuit needs to take a 4.2V battery voltage and scale it down to be read by a 3.3V ADC converter.

R2
R2
4.2V
4.2V
R1
R1
VADC
[Not supported by viewer]

We use KVL and Ohm’s law to calculate the values for R1 and R2 in order for \(V_{ADC}\) to be a maximum of 3.3V.

$$ V_{ADC} = V_2 $$

$$ 4.2V - V_1 - V_2 = 0V $$

Now some algebra.

$$ 4.2V - 3.3V = V_1 $$ $$ 0.9V = V_1 $$

Now we know the voltage split from KVL we can use KCL to analyze the current.

$$ I_1 - I_2 = 0 $$ $$ I_1 = I_2 $$

And now Ohm’s law.

$$ \frac{0.9V}{R_1} = \frac{3.3V}{R_2} $$ $$ \frac{R_2}{R_1} = \frac{3.3V}{0.9V} $$

For our case, let’s say \(R_2\) is \(3.3k \Omega\). So then \(R_1\) would be \(900 \Omega\).

The voltage divider distills this analysis into a single equation using the input voltage (4.2V) and the output voltage (3.3V).

$$ \frac{R_2}{R_1} = \frac{V_O}{V_I - V_O} $$

Then solve for \(V_O\).

$$ \frac{R_2}{R_1} \cdot (V_I - V_O) = V_O $$ $$ V_I \frac{R_2}{R_1} - V_O \frac{R_2}{R_1} = V_O $$ $$ V_I \frac{R_2}{R_1} = V_O + V_O \frac{R_2}{R_1}$$ $$ V_I \frac{R_2}{R_1} = V_O (1 + \frac{R_2}{R_1})$$ $$ V_I \frac{\frac{R_2}{R_1}}{1 + \frac{R_2}{R_1}} = V_O$$ Finally, we get the voltage divider equation. $$ V_I \frac{R_2}{R_1 + R_2} = V_O$$

If we plug in the values we found above, we get:

$$ 4.2V \frac{3.3k \Omega}{0.9k \Omega + 3.3k \Omega} = 3.3V $$

This is a good equation to become very familiar with. I use it all the time when developing and debugging firmware.

What Now?

While studying engineering in college, we had to use KCL and KVL to solve for some complex (and arbitrary) resistive circuits. It wasn’t very fun, but I got a good grasp. Today, I use KCL and KVL intuitively without thinking about the equations. And I never use them to analyze complex circuits (there is software for that).

A good exercise is to look at some circuits you have dealt with before and think about how KCL and KVL can be applied. These equations will pop up again and again when analyzing microcontroller based circuits. Especially keep an eye out for voltage divider circuits.

X

Thanks for Coming!

Subscribe to news and updates