Sub topic 7
Writing a KVL Equation Step by Step
This chapter assumes you know Ohm's law, the passive sign convention, and the statement of Kirchhoff's voltage law (KVL): the algebraic sum of voltages around any closed loop is zero. You should also be comfortable solving a small linear system. Here you turn those ideas into a repeatable procedure for writing correct loop equations.
Why a procedure matters
Most KVL mistakes are sign mistakes. They happen when you decide signs one element at a time, by intuition. A fixed procedure removes the guesswork. You make three choices up front (the loop, the direction of travel, and the current directions). After that, every sign follows from a rule.
The procedure
- Pick a closed loop. Choose a path that starts at one node, passes through elements, and returns to the same node without visiting any other node twice.
- Pick a direction of travel. Clockwise is the usual choice. The direction only sets your sign bookkeeping. It does not change the physics.
- Label a current in every resistor. If you do not know the true direction, guess. A negative answer later means the real current runs the other way.
- Mark polarity on every resistor. By the passive sign convention, current enters the + terminal. So the + mark goes at the end where your labeled current enters.
- Walk the loop and add up voltages. Use the sign of the terminal you reach first (the sign rule below).
- Set the sum to zero and rearrange into a form you can solve.
The sign rule
As you walk through an element, look at which terminal you meet first.
| You enter the element at | Voltage term | Meaning |
|---|---|---|
| + terminal, leave at − | +V | You go from high to low potential |
| − terminal, leave at + | −V | You go from low to high potential |
This version of the rule says that a term is positive if you enter at +. It is one of two common conventions. The other writes "rises" as positive and "drops" as negative. Both give the same physics, but they give equations with opposite overall signs. Pick one and keep it for the whole problem.
This chapter uses the first convention: enter at +, write +V. Under it, a resistor traversed in the direction of its current gives +IR. A resistor traversed against its current gives −IR. A source traversed from − to + gives a negative term, and a source traversed from + to − gives a positive term.
Worked example: one loop, one source
Take a 12 V source in series with R1 = 100 Ω, R2 = 220 Ω, and R3 = 330 Ω. Walk clockwise, starting at the bottom of the source.
The source has its + terminal at the top. Walking clockwise, you travel up through the source, entering at − and leaving at +. By the sign rule, that is −12 V. Current flows clockwise out of the + terminal, so each resistor is entered at its + end. Each resistor contributes +IR.
The KVL equation is:
−12 + I·R1 + I·R2 + I·R3 = 0
Substituting values:
I (100 + 220 + 330) = 12, so I = 12 / 650 = 18.46 mA.
Each drop is then I·R: 1.846 V, 4.062 V, and 6.092 V. These add to 12.000 V, which equals the source rise.
The code below does the same calculation and checks the loop sum.
# Series loop: 12 V source with three resistors.
# KVL around the loop (clockwise, source is a rise):
# +12 - I*R1 - I*R2 - I*R3 = 0
V_s = 12.0
resistors = [100.0, 220.0, 330.0] # ohms
I = V_s / sum(resistors) # amperes
drops = [I * r for r in resistors] # voltage across each resistor
print(f"I = {I * 1000:.2f} mA")
for r, v in zip(resistors, drops):
print(f"V across {r:.0f} ohm = {v:.3f} V")
# KVL check: rise minus the sum of drops should be zero.
print(f"Loop sum = {V_s - sum(drops):.12f} V")The comment in the code writes the equation as "rise minus drops", which is the opposite convention from the text. The two forms are the same equation multiplied by −1. The loop sum printed at the end should be zero, or within floating-point rounding of zero.
A diagram of the decision flow
Handling elements that are not simple
Voltage sources in the "wrong" direction
A source does not need to push current the way you walk. You only care about which terminal you enter. If you enter a 5 V source at its + terminal, write +5. If you enter at −, write −5. The current direction through the source does not change this term, because the source voltage is fixed by its polarity mark.
Resistors shared between loops
When two loops share a resistor, you write the voltage across it from the loop you are currently walking. The current through the shared resistor is the net of both loop currents when you use mesh currents. This is the subject of the mesh analysis chapter. For now, note that the same resistor appears in two equations, and its sign can differ between them.
Unknown voltages across non-resistive elements
Some elements, such as a current source, do not have a voltage you can state from Ohm's law. Give the unknown voltage its own symbol and polarity mark, include it in the KVL sum like any other term, and solve for it. The equation then has one more unknown, which you resolve with another equation.
Worked example: two loops
Consider two meshes with clockwise mesh currents I1 and I2. Mesh 1 contains a 10 V source, R1 = 2 Ω, and a shared R2 = 4 Ω. Mesh 2 contains the shared R2, R3 = 6 Ω, and a 4 V source that appears as a voltage drop in the clockwise direction.
Mesh 1, walking clockwise. The source is entered at − and gives −10. R1 carries I1 and gives +2·I1. The shared R2 carries I1 in the walking direction and I2 against it, so its net current is (I1 − I2) and it gives +4(I1 − I2):
−10 + 2·I1 + 4(I1 − I2) = 0, which simplifies to 6·I1 − 4·I2 = 10.
Mesh 2, walking clockwise. R2 is now traversed in the direction of I2, so the net current is (I2 − I1) and it gives +4(I2 − I1). R3 gives +6·I2. The 4 V source is a drop, entered at +, so it gives +4:
4(I2 − I1) + 6·I2 + 4 = 0, which simplifies to −4·I1 + 10·I2 = −4.
The two equations form a linear system.
import numpy as np
# Two meshes, both with clockwise mesh currents I1 and I2.
# Mesh 1: 10 V source, R1 = 2 ohm, shared R2 = 4 ohm.
# Mesh 2: shared R2 = 4 ohm, R3 = 6 ohm, and a 4 V source that is a
# voltage drop in the clockwise direction.
#
# KVL mesh 1: -10 + 2*I1 + 4*(I1 - I2) = 0 -> 6*I1 - 4*I2 = 10
# KVL mesh 2: 4*(I2 - I1) + 6*I2 + 4 = 0 -> -4*I1 + 10*I2 = -4
A = np.array([[6.0, -4.0],
[-4.0, 10.0]])
b = np.array([10.0, -4.0])
I1, I2 = np.linalg.solve(A, b)
print(f"I1 = {I1:.4f} A, I2 = {I2:.4f} A") # about 1.9091 A and 0.3636 A
print(f"Current in shared R2 = {I1 - I2:.4f} A") # about 1.5455 A
# Residual of each mesh equation should be zero.
print(A @ np.array([I1, I2]) - b)The solution is I1 ≈ 1.909 A and I2 ≈ 0.364 A. The shared resistor carries I1 − I2 ≈ 1.545 A in the direction of I1. Substituting back into mesh 1 gives −10 + 3.818 + 6.182 = 0, so the equation balances.
Checking the equation before you solve
Check each equation with these quick tests before you spend time solving.
- Count the terms. There should be one term per element on the loop. A missing term usually means you skipped an element.
- Check each source. Compare the sign of every source term against the polarity marks, not against what you expect the current to do.
- Check every resistor term. A resistor on a single mesh carries only that mesh current. A shared resistor carries a difference of two mesh currents.
- Substitute known values after solving. The sum around every loop, including loops you did not write an equation for, must be zero.
The last check is strong. A circuit with two meshes also has an outer loop that goes around both. Its KVL sum is not independent of the first two, but it does give a useful test of your answer.
Common ways this goes wrong
| Symptom | Likely cause |
|---|---|
| Source current comes out with the wrong sign | The source term was signed from the expected current, not from the terminal entered first |
| Two equations are identical up to a factor | You wrote the same loop twice, or one loop is a combination of the other two |
| A resistor voltage has the wrong sign | The polarity mark does not match the current arrow, so the passive sign convention was broken |
| The loop sum is not zero after substitution | A term was missed or a sign flipped when rearranging |
Exercise
A loop is walked clockwise. It contains a 9 V source entered at its − terminal, a resistor R1 = 3 Ω with current I flowing in the walking direction, and a resistor R2 = 6 Ω with the same current I in the walking direction. Using the "enter at +, write +V" convention, write the KVL equation and solve for I.
Show answer
The source is entered at − so it contributes −9. Both resistors are traversed along the current, so they contribute +3I and +6I. The equation is −9 + 3I + 6I = 0, so 9I = 9 and I = 1 A.
Exercise
In the two-mesh example, the 4 V source is reversed so that it is entered at its − terminal in mesh 2 when walking clockwise. Rewrite the mesh 2 equation in the form a·I1 + b·I2 = c.
Show answer
The source term changes from +4 to −4. The equation is 4(I2 − I1) + 6·I2 − 4 = 0, which simplifies to −4·I1 + 10·I2 = 4.