1

enter image description here

I am a bit confused as to where I have gone wrong in my nodal analysis calculation:

For the first node v1:

$$-3=(v1-v3)/2 +(v1-v2)$$

v2:

$$-(v1-v2)-(v3-v2)/4 = v2/3$$

v3:

$$7=(v3-v4)/5+(v3-v2)/4+(v3-v1)/2$$

v4:

$$-7=(v4-v3)/5$$

From this I get v1=6.42, v2=9, v3=7.29, v4=-27.7 which is incorrect according to my textbook. Any help with regards to where I have gone wrong in my calculation will be greatly appreciated.

Ahmed
  • 11
  • 2

2 Answers2

5

Suggestions

The first thing I do before attempting to analyze a circuit is to redraw that circuit. The process of just doing it helps me think and gather up a few details that I may not notice so easily, just staring at someone's depiction. But I can often help the readability, too, which improves understanding and reduces chances for mistakes, later.

It takes lots of practice to accumulate a good sense about it. But that practice is well worth your time.

You should use the built-in schematic editor here. It will add part numbers and this is very important for saving time and confusion when communicating in comments or in answers. In your specific case, the values of the resistors can be used to identify them. But in general, you should assign separate designations as it won't always be the case that the values are all different from each other.

And finally, keep in mind that you get to call one node "ground." If you select a really convenient one, it can greatly simplify the analysis and reduce chances for mistakes, as well. (This doesn't always have to be the obvious choice or the one that the writer chose. You can move it to a different location if that helps your analysis.)

Analysis

Here is my re-drawing of the schematic:

schematic

simulate this circuit – Schematic created using CircuitLab

I've numbered the resistors by their values and I've picked a ground (the same one as indicated on your schematic) which does simplify the analysis as \$V_4=0\:\text{V}\$. Note also that the ends of current sources going to known voltage references can be dropped. And since the ground reference is, by definition, a voltage source there's no need to show those ends of \$I_1\$ and \$I_2\$.

You only have three voltages to solve: \$V_1\$, \$V_2\$, and \$V_3\$. So, just three equations are needed:

$$\begin{align*} \overbrace{\begin{array}{r} \frac{V_1}{R_1} + \frac{V_1}{R_2} + I_1 \vphantom{\frac{V_1}{R_1} + \frac{V_1}{R_2} + I_1 = \frac{V_2}{R_1} + \frac{V_3}{R_2}} \\\\ \frac{V_2}{R_1} + \frac{V_2}{R_3} + \frac{V_2}{R_4} \vphantom{\frac{V_2}{R_1} + \frac{V_2}{R_3} + \frac{V_2}{R_4} = \frac{V_1}{R_1} + \frac{0\:\text{V}}{R_3} + \frac{V_3}{R_4}} \\\\ \frac{V_3}{R_2} + \frac{V_3}{R_4} + \frac{V_3}{R_5} \vphantom{\frac{V_3}{R_2} + \frac{V_3}{R_4} + \frac{V_3}{R_5} = I_2 + \frac{V_1}{R_2} + \frac{V_2}{R_4} + \frac{0\:\text{V}}{R_5}} \end{array}}^{\text{outward directed currents}} &{\begin{array}{c} \vphantom{\frac{V_1}{R_1} + \frac{V_1}{R_2} + I_1 = \frac{V_2}{R_1} + \frac{V_3}{R_2}} =\quad \\\\ \vphantom{\frac{V_2}{R_1} + \frac{V_2}{R_3} + \frac{V_2}{R_4} = \frac{V_1}{R_1} + \frac{0\:\text{V}}{R_3} + \frac{V_3}{R_4}} =\quad \\\\ \vphantom{\frac{V_3}{R_2} + \frac{V_3}{R_4} + \frac{V_3}{R_5} = I_2 + \frac{V_1}{R_2} + \frac{V_2}{R_4} + \frac{0\:\text{V}}{R_5}} =\quad \end{array}} \overbrace{\begin{array}{l} \vphantom{\frac{V_1}{R_1} + \frac{V_1}{R_2} + I_1 = \frac{V_2}{R_1} + \frac{V_3}{R_2}}\frac{V_2}{R_1} + \frac{V_3}{R_2} \\\\ \vphantom{\frac{V_2}{R_1} + \frac{V_2}{R_3} + \frac{V_2}{R_4} = \frac{V_1}{R_1} + \frac{0\:\text{V}}{R_3} + \frac{V_3}{R_4}} \frac{V_1}{R_1} + \frac{0\:\text{V}}{R_3} + \frac{V_3}{R_4} \\\\ \vphantom{\frac{V_3}{R_2} + \frac{V_3}{R_4} + \frac{V_3}{R_5} = I_2 + \frac{V_1}{R_2} + \frac{V_2}{R_4} + \frac{0\:\text{V}}{R_5}} I_2 + \frac{V_1}{R_2} + \frac{V_2}{R_4} + \frac{0\:\text{V}}{R_5} \end{array}}^{\text{inward directed currents}} \end{align*}$$

Note: Voltage spills away from a node via available paths and voltage spills into a node from nearby nodes via the same available paths. The only caveat is that a current source can only flow into, or flow out of, a node. But not both directions. (Current sources only work one way. So it will either appear on the outward-flowing side or on the inward-flowing side -- but not both sides.)

Another Note: If you think about adding \$V_4\$ such that it would add one more equation, it will yield a singular matrix. A way to understand this is to note that voltages are not absolute values, but always with reference to another node. Or put still another way, what would be the difference between a solution with \$V_1=50\:\text{V}\$, \$V_2=60\:\text{V}\$, \$V_3=70\:\text{V}\$, and \$V_4=25\:\text{V}\$ and a solution with \$V_1=1050\:\text{V}\$, \$V_2=1060\:\text{V}\$, \$V_3=1070\:\text{V}\$, and \$V_4=1025\:\text{V}\$? There would be no difference. It's just offset. But against what, exactly? So you always need a reference when solving. Keep it in mind. It's not just a good idea, it's the law!

Summary

At this point, you should be able to compare your own equations with those I've shown above and see where there are any differences. Once you have that in hand, the results should be correct.

Below here I'm including two important addendums.

One is about re-drawing schematics and the rules I learned when drawing schematics as a Tektronix employee.

The other is about a simpler view about developing KCL equations that is much less error-prone than the usual method. It's exactly the same thing (easily discovered by re-arranging the equations to prove it to yourself), but it is just a lot easier to mentally apply with fewer mistakes being made.

It's also the technique used by software algorithms inside Spice, itself, despite the fact that it's not often found in textbooks. You can still find it in books such as "The SPICE Book" by Andrei Vladimirescu (starting, for example, on page 15.) So it has good pedigree, even if textbooks often fail to present the easier-to-use concept. (I've no idea why -- but I think it is historical inertia and a lack of imagination or exposure to alternative views.)

And at the very bottom of this answer you can find the sympy code required to solve your problem as well as the disclosed results, too. I think a good friend of mine whom I respect and value has expended his sole downvote about an hour ago. So there's no longer any remaining reason to hold that back. Besides, you've provided adequate effort and deserve to see the results.


Redrawing Schematic Addendum

Rules to live by are:

  • Arrange the schematic so that conventional current appears to flow from the top towards the bottom of the schematic sheet. I like to imagine this as a kind of curtain (if you prefer a more static concept) or waterfall (if you prefer a more dynamic concept) of charges moving from the top edge down to the bottom edge. This is a kind of flow of energy that doesn't do any useful work by itself, but provides the environment for useful work to get done.
  • Arrange the schematic so that signals of interest flow from the left side of the schematic to the right side. Inputs will then generally be on the left, outputs generally will be on the right.
  • Do not "bus" power around. In short, if a lead of a component goes to ground or some other voltage rail, do not use a wire to connect it to other component leads that also go to the same rail/ground. Instead, simply show a node name like "Vcc" and stop. Busing power around on a schematic is almost guaranteed to make the schematic less understandable, not more. (There are times when professionals need to communicate something unique about a voltage rail bus to other professionals. So there are exceptions at times to this rule. But when trying to understand a confusing schematic, the situation isn't that one and such an argument "by professionals, to professionals" still fails here. So just don't do it.) This one takes a moment to grasp fully. There is a strong tendency to want to show all of the wires that are involved in soldering up a circuit. Resist that tendency. The idea here is that wires needed to make a circuit can be distracting. And while they may be needed to make the circuit work, they do NOT help you understand the circuit. In fact, they do the exact opposite. So remove such wires and just show connections to the rails and stop.
  • Try to organize the schematic around cohesion. It is almost always possible to "tease apart" a schematic so that there are knots of components that are tightly connected, each to another, separated then by only a few wires going to other knots. If you can find these, emphasize them by isolating the knots and focusing on drawing each one in some meaningful way, first. Don't even think about the whole schematic. Just focus on getting each cohesive section "looking right" by itself. Then add in the spare wiring or few components separating these "natural divisions" in the schematic. This will often tend to almost magically find distinct functions that are easier to understand, which then "communicate" with each other via relatively easier to understand connections between them.
  • You get to choose exactly one node and call it "ground." If the purpose of redrawing the schematic is for understanding it, then choose a node that helps achieve that. When signals are single-ended, they share a common node and you should select this common node as "ground." If the purpose is for analysis, then you can select this for the purpose of reducing the equation complexity. Often, this will mean the node that is "busiest" (has the most terminals attached to it.) Either way, make this choice wisely and it will help a great deal.

The above rules aren't hard and fast. But if you struggle to follow them, you'll find that it does help a lot.

You can read a snippet of my own education by those schematic draftsmen at Tektronix who trained me by reading here.


KCL Addendum

The KCL equations may appear to treat node voltages as if they don't have to be differences, but can be absolute values. However, that's not really the case here. In fact, I'm just using superposition (which is easily seen once you've really had the concepts deepened into you.) This is, in fact, the same technique used within Spice programs (those where I've directly looked over the code used to generate these.)

Perhaps the easiest way to imagine is that absolute voltage at a node spills away from that node through the available paths. But also that absolute voltages spill into that node from surrounding nodes through those same paths. So long as you treat them all as absolute values, the result is the application of a simple superposition concept that results in, effectively, the potential differences controlling the result.

You can test this, easily, by rearranging the resulting equation(s), moving the right side over to the left side and then combining terms. You'll then see the usual potential differences that you expect. So it really is the same result.

The reason I very much prefer this method is that it is simple to visualize and very difficult to make mistakes. You can easily orient yourself to a node and then work out the terms for out-flowing currents for the left side of the equation. Then all you have to do is position yourself at each surrounding node and work out the terms for in-flowing currents for the right side. It's almost impossible to screw that up.

Conversely, when you are instead struggling to work out the potential differences in your mind (using the more traditionally taught method) and just write those terms, you often find yourself not entirely sure if you have the sign right as you try and add them up, correctly. I find, time and time again that not only others wind up messing up somewhere and making an uncaught mistake.. but that I also make those mistakes, as well. Even with lots of experience, you just aren't 100% sure and you often find yourself double and triple checking your work, just in case.

That doesn't ever happen, once you start using the superposition method. It just works. It just works right. It just works right each and every time. I've never, not once, screwed up. (I make typos. But not sign errors.) It's too easy to use.

So voltage spills away from a node via available paths and voltage spills into a node from nearby nodes via the same available paths. The only caveat is that a current source or sink can only flow in, or flow out, but not both directions. It's one way. So it will either appear on the out-flowing side or on the in-flowing side -- but not both sides.

This also works perfectly well with capacitors and inductors. It does turn the equation into a differential/integral equation. But that's just a technicality. It's still correct.

Answer

Use sympy like this:

var('r1 r2 r3 r4 r5 v1 v2 v3 v4 i1 i2')                       # declare variables
eq1 = Eq( v1/r1 + v1/r2 + i1, v2/r1 + v3/r2 )                 # KCL node V1
eq2 = Eq( v2/r1 + v2/r3 + v2/r4, v1/r1 + 0/r3 + v3/r4 )       # KCL node V2
eq3 = Eq( v3/r2 + v3/r4 + v3/r5, i2 + v1/r2 + v2/r4 + 0/r5 )  # KCL node V3
ans = solve( [ eq1, eq2, eq3 ], [ v1, v2, v3 ] )              # Symbolic solution
for v in ans: v, ans[v].subs( { r1:1, r2:2, r3:3, r4:4, r5:5, i1:3, i2:7 } ).n()
(v1, 5.23529411764706)
(v2, 5.11764705882353)
(v3, 11.4705882352941)

And a convenient Spice run (using LTspice) to see what it delivers from your schematic:

enter image description here

Nice match and that's about all there is to it.

Best wishes.

jonk
  • 77,059
  • 6
  • 73
  • 185
  • Choosing the voltage on a reference node doesn't only simplify the analysis, it allows you to actually solve the equations. Trying to solve for all four voltages gives you an indefinite admittance matrix which is singular. It doesn't make sense to try to solve for absolute voltages for all four nodes. – Tesla23 Sep 28 '21 at 01:22
  • @Tesla23 Good point. I'll include a note about that. – jonk Sep 28 '21 at 01:25
  • @Tesla23 Done. And thanks! – jonk Sep 28 '21 at 01:32
  • I think the analysis would greatly benefit from a wye-delta transformation of R1/R3/R4 – Bart Sep 28 '21 at 09:24
  • @Bart The OP is looking to correctly apply KCL. So that was my focus. The use of \$\Delta\$-**Y** would be a distraction from that. I could also have used Norton to Thevevin conversion. And that also would have been a distraction. The OP was looking for how to properly set up the KCL nodal equations. That's where I went. – jonk Sep 28 '21 at 09:29
0

I think you should not have node v4 because it's the same as the reference node, thereafter you will get only 3 equations rather than 4 equations