# How to write the Kirchoff's voltage equations for this complex circuit?

I am trying to develop a way of finding out how a black box is wired internally, based on multimeter readings of its terminals. I have recently posted a thread about this (here), but I thought I would narrow the problem down to solving an example, in the hope of extracting a pattern applicable to my initial problem.

Consider the following example circuit: simulate this circuit – Schematic created using CircuitLab

Now, imagine the following variants of this circuit:

• Circuit A: a voltage V12 is applied between terminals 1 and 2, the other terminals are open.
• Circuit B: a voltage V24 is applied between terminals 2 and 4, the other terminals are open.
• Circuit C: a voltage V45 is applied between terminals 4 and 5, the other terminals are open.

Note that I need to study any combination of terminal pairs, but this is a subset which should be representative.

Let's solve each circuit using Kirchoff laws. There are N=5 nodes and b=10 branches, which means we need to write 4 current equations, and 6 voltage equations. The current equations are easy to write, I don't have issues with that.

However, I struggle with the voltage equations. I need some kind of method to write those equations, otherwise I end up writing random loop equations. As you can see, there is a pattern in how the resistances are laid out. I'm hoping that when a method is found on this circuit, I can extract an algorithm to generalise to any number of terminals/nodes.

How would you write the voltage equations for these circuits?

I only used as many equations/test cases as I needed to build the square matrix, because I don't remember how to add more equations and do a pseudo inverse (I have looked around on the web a bit, still is unclear).  • Writing loop equations doesn't really make sense here. This problem is easiest solved by inspection. – Matt Young Jan 11 '16 at 14:54
• What do you mean? If you have an easy method to solve this circuit, which can be extrapolated to 6, 7, ... N terminals, I am all ears. – Mister Mystère Jan 11 '16 at 15:10
• It's just a series parallel problem. Get a marker out and trace all the paths from 1-2, 2-4, and 4-5. – Matt Young Jan 11 '16 at 15:29
• I don't think it is. That's exactly what I did for 4 terminals and already then, there were star/delta transformations to make; that's even worse with 5 terminals so I ruled out the usual series/parallel simplification. Please do prove me wrong, but I'm pretty sure "inspection" would take you hours or days and couldn't be programmed in a reasonable amount of time. – Mister Mystère Jan 11 '16 at 15:54
• I feel like there should be an easy way to do this using superposition (assuming the black box network is both linear and passive). You would measure 4 + 3 + 2 + 1 = 10 Thevenin impedances, then sum the individual responses for the voltage at each terminal. I suspect it would turn into Ben's answer if I actually tried to implement it, though. :-) – Adam Haun Jan 11 '16 at 23:37

There's actually a really straightforward way to approach this, if you don't mind using a matrix calculation (Matlab, for example).

In the traditional circuit analysis, the unknown variable is a vector of voltages corresponding to the ports. Choose one of the ports as a reference, I'll use the bottom one since that's where we usually put ground on schematics)

$$\mathbf{x} = \left[ \begin{array}{c} x_1 \\ x_2 \\ x_3 \\ x_4 \end{array} \right] = \left[ \begin{array}{c} V_{15} \\ V_{25} \\ V_{35} \\ V_{45} \end{array} \right]$$

For each port you either have a trivial voltage equation setting that port voltage to the applied input, or a conservation of current equation (net current out of a disconnected port is zero).

For excitation connected to ports 1 and 2, the trivial equation is

$$x_1 - x_2 = V_{input}$$

and the KCL equations are (using conductance G which is the reciprocal of resistance R)

(port 3) $$G_2 (x_3-x_1) + G_5 (x_3-x_2) + G_8 (x_3-x_4) + G_9(x_3) = 0$$ (port 4) $$G_3 (x_4-x_1) + G_6 (x_4-x_2) + G_8 (x_4-x_3) + G_{10}(x_4) = 0$$ (port 5) $$G_4 (-x_1) + G_7 (-x_2) + G_9 (-x_3) + G_{10}(-x_4) = 0$$

Because there is one equation for each port and one unknown for each port, you immediately have a system of linear equations. As long as this system isn't degenerate (which it never is with the fully-connected graph of resistors, if all resistor values are finite) there will be a unique solution.

$$\left[ \begin{array}{c c c c} 1 & -1 & -0 & 0 \\ -G_2 & -G_5 & G_2+G_5+G_8+G_9 & -G_8 \\ -G_3 & -G_6 & -G_8 & G_3+G_6+G_8+G_{10} \\ -G_4 & -G_7 & -G_9 & -G_{10} \end{array} \right] \mathbf{x} = \left[ \begin{array}{c} V_{input} \\ 0 \\ 0 \\ 0 \end{array} \right]$$

A simple matrix inversion, which is easily automated, yields all the port voltages in terms of the resistances.

Unlike the traditional analysis, you want the resistances, so we'll organize the matrix multiply the other way, and also include the excitation current:

$$G_1 (x_1-x_2) + G_2 (x_1-x_3) + G_3 (x_1 - x_4) + G_4 (x_1) = i_{exc}$$

$$\left[ \begin{array}{c c c c c c c c c c} x_1-x_2 & x_1-x_3 & x_1-x_4 & x_1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & x_3-x_1 & 0 & 0 & x_3-x_1 & 0 & 0 & x_3-x_4 & x_3 & 0 \\ 0 & 0 & x_4-x_1 & 0 & 0 & x_4-x_2 & 0 & x_4-x_3 & 0 & x_4 \\ 0 & 0 & 0 & -x_1 & 0 & 0 & -x_2 & 0 & -x_3 & -x_4 \end{array} \right] \left[ \begin{array}{c} G_1 \\ G_2 \\ G_3 \\ G_4 \\ G_5 \\ G_6 \\ G_7 \\ G_8 \\ G_9 \\ G_{10} \end{array} \right] = \left[ \begin{array}{c} i_{exc} \\ 0 \\ 0 \\ 0 \end{array} \right]$$

Now you'll have to take all of those results together and get your conductances, which lead easily to resistances.

Let's calculate the size of that final step. There are (k choose 2) total resistances, and you have (k choose 2) ways to energize the system, with (k-2) intermediate voltage measurements from each. Plus one measurement of energizing current for each, if you choose to use it. That's (k-1)*(k choose 2) equations, which should be plenty for solving (k choose 2) unknown resistances. The system will be overconstrained, but you'll have some measurement error, so a pseudo-inverse will give the set of resistances that is most consistent (in a least-squares error sense) with your measurements.

You can presumably get away with just using the equation for input current for each of the (k choose 2) excitation patterns, and have enough equations, but without redundancy any measurement inaccuracy can lead to a big discrepancy in the end... the redundant equations help protect against that.

The key to a systematic approach is to not write loop equations at all, let the matrix algebra system derive them automatically.

• Thank you very much for your answer. It sounds like you have it figured all out, I agree with you that if it can be done using linear algebra I am more than happy to implement it in Matlab. I thought the equations would allow me to build the matrix equation. However, I have read your answer 3 times and I am unsure about how to proceed. For starters, do you mean the unknown is a vector of POTENTIALS of the ports? – Mister Mystère Jan 11 '16 at 17:29
• The input voltage is just a trick I used, but ultimately I'd like to be able to make resistance measurements between the ports to figure out what the internal resistances are. – Mister Mystère Jan 11 '16 at 17:30
• Could you give an example of port equations? – Mister Mystère Jan 11 '16 at 17:37
• @MisterMystère: Does that help? – Ben Voigt Jan 11 '16 at 18:14
• It helps a lot, thanks (+1). I have tried to follow that method with the simplistic 3-ports circuit (there are only 3 excitation cases), but after building the gigantic matrix how do you get the resistances by just inverting it? I've updated my question with a picture of what I've done to illustrate. – Mister Mystère Jan 11 '16 at 19:41