Lesson 7 of 15
Node Voltage (KCL)
Kirchhoff's Current Law
Kirchhoff's Current Law (KCL): the sum of all currents entering a node equals the sum leaving. Equivalently, the net current at any node is zero:
Σ I = 0
Solving for an Unknown Node Voltage
Consider a floating node connected to n known voltage sources through resistors:
V1 --[R1]--+
V2 --[R2]--+--- V_node (unknown)
V3 --[R3]--+
Current from source k into the node: Iₖ = (Vₖ − V_node) / Rₖ
By KCL, all these currents sum to zero:
Σ (Vₖ − V_node) / Rₖ = 0
Solving for V_node (the weighted average of the source voltages):
V_node = Σ(Vₖ / Rₖ) / Σ(1 / Rₖ)
Each source is weighted by its conductance (1/R). A lower resistance pulls the node voltage closer to its source.
Examples
| Sources | Resistors | V_node |
|---|---|---|
| [12V, 0V] | [1Ω, 1Ω] | 6V (simple average) |
| [12V, 0V] | [1Ω, 2Ω] | 8V (12V closer — lower R₁) |
| [9V, 3V, 0V] | [1Ω, 1Ω, 1Ω] | 4V (equal weight average) |
Your Task
Implement double node_voltage(double *v, double *r, int n) that returns the unknown node voltage using the KCL formula above.
TCC compiler loading...
Loading...
Click "Run" to execute your code.