Author Topic: KVL and KCL Equations  (Read 2987 times)

0 Members and 1 Guest are viewing this topic.

Offline cjuriedTopic starter

  • Contributor
  • Posts: 31
  • Country: 00
    • Juried Engineering
KVL and KCL Equations
« on: October 28, 2019, 01:40:54 am »
Hello,

I have a basic circuit (I have attached a screenshot of the circuit) in which I am trying to enter both my KCL and KVL equations into my TI Nspire calculator using the "systems of equations" option. I keep getting a "False" for the answer. I am trying to solve for the three variables: is, ia, ib.

The equations are:

Equation#1 KCL at Top Node: -is+ia+ib=0
Equation#2 KVL @ Left Node: -200+is(4)+ia(20)=0
Equation#3 KVL @ Right Loop: ib(80)-ia(20)=0

Thank you for your help.
« Last Edit: October 28, 2019, 02:00:57 am by cjuried »
juriedengineering.com/
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6548
  • Country: fi
    • My home page and email address
Re: KVL and KCL Equations
« Reply #1 on: October 28, 2019, 02:51:09 am »
I don't know what goes wrong for you, but when I tell Maxima (free/open source, available for all OSes)
    solve([ ia + ib - is = 0, 4*is + 20*ia - 200 = 0, 80*ib - 20*ia = 0 ], [ia, ib, is]);
it tells me there is exactly one answer,
    [[ ia = 8, ib = 2, is = 10 ]]
Maple agrees, too.
 
The following users thanked this post: cjuried

Online rstofer

  • Super Contributor
  • ***
  • Posts: 9914
  • Country: us
Re: KVL and KCL Equations
« Reply #2 on: October 28, 2019, 03:11:39 pm »
I like working on these problem with Maxima so I'll embed the code here.  I highly recommend wxMaxima (the windowing version of Maxima).  Of course, I also recommend MATLAB


Code: [Select]
/* Kirchhoff's Current Law */

KCL1    : Is=(200-Vn)/4$
KCL2    : Ia=(Vn-0)/20$
KCL3    : Ib=(Vn-0)/80$
KCL4    : Is-Ia-Ib=0$

res     : solve([KCL1,KCL2,KCL3,KCL4])$ /* we could skip the 'res : ' part, replace the $   */
                                        /* with a ; and skip the pretty print stuff         */
                                        /* like this:                                       */
                                        /* solve([KCL1,KCL2,KCL3,KCL4]);                    */
                                        /* but I like pretty print                          */
results : float(res)$                   /* this stuff is the pretty print of sorted results */
lngth   : length(results[1])$
sorted  : sort(results[1])$
print("KCL")$
for i:1 thru lngth do
    print(sorted[i])$
print("")$

/* Kirchhoff's Voltage Law */

KVL1    : 200 - (Ia+Ib)*4 - Ia*20 = 0$
KVL2    : 200 - (Ia+Ib)*4 - Ib*80 = 0$
KVL3    : Is = Ia + Ib$                 /* KVL3 and KVL4 are not required for a solution    */
KVL4    : Vn = Ia*20$                   /* but they provide the other values for the circuit*/

res     : solve([KVL1,KVL2,KVL3,KVL4])$ /* pretty print stuff again                         */
results : float(res)$
lngth   : length(results[1])$
sorted  : sort(results[1])$
print("KVL")$
for i:1 thru lngth do
    print(sorted[i])$
Code: [Select]
KCL
Ia=8.0
Ib=2.0
Is=10.0
Vn=160.0

KVL
Ia=8.0
Ib=2.0
Is=10.0
Vn=160.0

[/font]

The upper code block is the actual wxMaxima code while the lower code block is the output.

You will notice that we disagree on the sign convention for KVL.  That's ok, it doesn't matter.  However, if I go through a device from (-) to (+), I treat that as a voltage gain.  If I go through a device from (+) to (-), I treat that as a loss.  In this circuit, all of the resistors are losses and the only gain is the battery because both of my loops are clockwise.  One through the inner loop on the left and the other around the outside.  That's MY sign convention and it isn't required as long as you are consistent.

« Last Edit: October 28, 2019, 05:13:25 pm by rstofer »
 

Offline cjuriedTopic starter

  • Contributor
  • Posts: 31
  • Country: 00
    • Juried Engineering
Re: KVL and KCL Equations
« Reply #3 on: October 29, 2019, 02:01:46 am »
Thanks for your answers. I changed my syntax and things came to life. I have attached a screenshot of the slight modifications in which TI Nspire calculators seem to be accustom to. 
« Last Edit: October 29, 2019, 02:10:38 am by cjuried »
juriedengineering.com/
 

Offline Tom45

  • Frequent Contributor
  • **
  • Posts: 556
  • Country: us
Re: KVL and KCL Equations
« Reply #4 on: October 29, 2019, 04:09:25 am »
And for us fossils from the slide rule era:



Didn't even need to use a slide rule for this one.
« Last Edit: October 29, 2019, 04:11:29 am by Tom45 »
 

Online rstofer

  • Super Contributor
  • ***
  • Posts: 9914
  • Country: us
Re: KVL and KCL Equations
« Reply #5 on: October 29, 2019, 05:45:08 am »
Or, 80 in parallel with 20 => 16 Ohms
16 in series with 4 => 20 Ohms
200V / 20 Ohms => 10 Amps for Is
10 Amps through 4 Ohms => 40V drop
200V - 40V => 160V output
160V / 20 Ohms => 8 Amps (Ia)
160V / 80 Ohms => 2 Amps (Ib)

Of course, the real solution has to use the proper technique.  All this approach does is verify what has been verified several times above.  Still, the problem is simple enough to do these shortcuts in just a moment or two.  Just a check...

In my view, the take-away is that there is a standardized approach to these equations using something like wxMaxima.  Install the software, rip the code and save it away for a day when you get a really difficult circuit.  Perhaps in AC theory when there will be inductors and capacitors and you would have to use complex numbers and deal with magnitude and phase.

I like Nominal Animal's solution better than mine because it is short, sweet, and right to the point.  Very clean!  OTOH, I like my solution because it scales well and, with comments, it is more like telling a story.  One of the goals of Maxima is to create documents with text, equations and graphs suitable for publication.  I have no particular interest in the text or publication features but it sure does a nice job with equations and graphs.

 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6548
  • Country: fi
    • My home page and email address
Re: KVL and KCL Equations
« Reply #6 on: October 29, 2019, 06:07:28 am »
Oh yeah, mine was only the straightforward math part, I didn't even look at the circuit itself; I kept it as simple as possible, and just wanted to show that the given equations do have a single real solution.

When I work on a problem, I create a directory for it, and put the "story" part in a README.txt file.

That is because I don't want to have to open wxMaxima to see it; I'm very, very lazy.  (And "paranoid", I don't like being beholden to any single application; I much prefer copy-pasting the code, than using Maxima/Maple workbooks for long-term storage.)

Even my scripts and example programs show "usage" (summary of the "story") when run without parameters, or with -h or --help. That way I only need to run the likeliest executable in the problem/solution directory, to see what it is about.  I have a few hundred of these, and if they're on the same machine (I recently archived most of them), I can find a specific one based on a vague memory in seconds.

The story, the context and background for the math, is invaluable in the long term.  It takes only a few minutes to write down the context with the solution method.  Even if you never end up needing the solution again, writing it up in a concise way (but descriptively enough so you'll re-understand it even after a long interval), also helps most people to better understand the problem at hand.  It is not rare to realize the answer when one constructs an efficient way to ask the question.

When I have a complete solution on a math problem, I usually write it up in LibreOffice Writer, and save both that and a PDF "print" version (that I'll consult when necessary).  I really should move to LaTeX, though.
« Last Edit: October 29, 2019, 06:10:35 am by Nominal Animal »
 

Online rstofer

  • Super Contributor
  • ***
  • Posts: 9914
  • Country: us
Re: KVL and KCL Equations
« Reply #7 on: October 29, 2019, 02:54:53 pm »
You spend a lot more time on this kind of thing than I do.  I'll comment the code and that's about it.  OTOH, these are just brain exercises for an old man who is long retired.

I like Tom45's solution as well.  I remember solving these problems in exactly that way back in the very early '70s.  3x3 was ok, 4x4 was doable, 10x10 for the Statics class was not as much fun even though the matrix was quite sparse.  Sloppy handwriting probably came up about here...
« Last Edit: October 29, 2019, 03:01:45 pm by rstofer »
 

Offline Tom45

  • Frequent Contributor
  • **
  • Posts: 556
  • Country: us
Re: KVL and KCL Equations
« Reply #8 on: October 29, 2019, 04:32:45 pm »
This is obviously an artificial class problem.  To build it you would need a 200 volt, 10 amp supply (2KW), a 4 ohm 400 Watt resistor, 20 ohm 1280 watt resistor (!), and an 80 ohm 320 watt resistor.

So what is the point of the exercise? First it seems to be testing knowledge and application of Kirchoff's laws. As a class problem,  that might be all that is needed.

However, cranking through the equations is needed in real life. So in engineering classes that step would usually be tested too.

The solution I gave reflects what I would have had to do in the 60's. Others here used a specialized calculator, or some math software packages.

So I wonder what would be general practice in a modern circuits class. And also, what would be general practice in the industry, assuming you had to solve a problem like this. Would anyone even think of starting with Kirchoff's laws, or just build it up in Spice or equivalent and click the button?
 

Online rstofer

  • Super Contributor
  • ***
  • Posts: 9914
  • Country: us
Re: KVL and KCL Equations
« Reply #9 on: October 29, 2019, 05:00:07 pm »
So I wonder what would be general practice in a modern circuits class. And also, what would be general practice in the industry, assuming you had to solve a problem like this. Would anyone even think of starting with Kirchoff's laws, or just build it up in Spice or equivalent and click the button?

My guess is there would be a hybrid solution.  Do it by hand, back it up with MATLAB.  Print the MATLAB output to .pdf and submit the homework electronically.  Actually, this isn't a guess.  This is the process used at the local university and there is a required MATLAB course at the beginning of the engineering curriculum.

In the specialized area of electronics engineering, LTspice might be an option.  I can't imagine anyone doing complex filters by hand.  Even way back in the early '70s, I had access to the IBM Electronic Circuit Analysis Program (ECAP) and an IBM1130 computer.  Filter calculations weren't nearly as dreadful and, if I did solve the problem by hand, I had a reference solution.  ECAP would produce punched card output but it didn't know about the plotter.  I wrote a bit of FORTRAN to solve that problem.  My Bode' Plots look pretty good on log-log paper.

Remember that awful Differential Equations course?  "Assume the solution if of the form ..." was popular at the time.  My grandson's DE course revolves around the ODE45 solver in MATLAB.  They're missing out on all of the fun!  Actually, some of the homework is done by hand but, as that is too hard to grade, the vast majority of it is interactive.

In industry, I doubt that anyone is doing hand calculations.  There's just too much risk of slipping a digit.  It was pretty common with slide rules and I don't suspect things have changed.  Besides, almost every solution needs a graph and more points is better than less.

That MATLAB is a required course is pretty telling.  Still, a bit of hand-waving is useful in the learning process.  How variations in components will affect the solution.  Wait!  ECAP would do that!  You could iterate over component variations.  Clear back in the very early '70s.

I would expect today's EE student to have to create the mesh and node equations.  How they solved them might vary.  I doubt anybody is doing row elimination when they can just plop the equations in a solver (calculator, wxMaxima, MATLAB/Octave).  Maybe they see a problem or two solved this way but I doubt that it is common practice.
« Last Edit: October 29, 2019, 05:03:54 pm by rstofer »
 

Offline RoGeorge

  • Super Contributor
  • ***
  • Posts: 6480
  • Country: ro
Re: KVL and KCL Equations
« Reply #10 on: October 29, 2019, 05:25:37 pm »
The circuit and the values are obviously made for mental calculations.

No need for KVL, programs or computers:  There are 2 resistors in parallel, then connected with a 3rd one in series.

R|| = 20 || 80 = 20*80/(20+80) = 1600/100 = 16  \$\Omega\$
R total = 16 + 4 = 20  \$\Omega\$
I source = 200/20 = 10 A

Ia is 4 times bigger than Ib, and together are 10 A, so

Ia = 8A
Ib = 2A
Vo = 2*80 = 160V

Offline GerryR

  • Frequent Contributor
  • **
  • Posts: 256
  • Country: us
Re: KVL and KCL Equations
« Reply #11 on: October 29, 2019, 05:58:23 pm »
Yeah, back in my fossil days, they would say that the solution(s) were "intuitively obvious," and then after two or three pages of calculations later, maybe it was somewhat obvious. ::)  In this case, I agree with RoGeorge that the values were made for quick mental calculations and to give the student some training in recognizing different component combinations to simplify analysis.
Still learning; good judgment comes from experience, which comes from bad judgment!!
 

Online rstofer

  • Super Contributor
  • ***
  • Posts: 9914
  • Country: us
Re: KVL and KCL Equations
« Reply #12 on: October 29, 2019, 06:59:15 pm »
I agree, the point is building the equations.  There are at least 3 ways of writing the mesh equations (and I don't think there are more) and just 1 way to write the node equation.  In school, we seemed to focus on KVL but in many cases KCL is easier and may involve fewer equations.

The numbers were neat but the magnitudes were gross.  We simply don't work in Amps and Ohms, it's more likely mA and kOhms.  Volts aren't in hundreds, they're down around 5 or 3.3.  It doesn't matter, it's the process of writing the equations that matters.

I can hardly wait for the AC circuits!

"Intuitively obvious to the most casual observer!"
« Last Edit: October 29, 2019, 07:01:41 pm by rstofer »
 

Offline Tom45

  • Frequent Contributor
  • **
  • Posts: 556
  • Country: us
Re: KVL and KCL Equations
« Reply #13 on: October 30, 2019, 06:35:31 pm »
My college years far predates Matlab or equivalent. So I've never had any experience with what seems to be a common tool now.

However ECAP is very familiar to me. In 1966 I ported ECAP from IBM 1620 FORTRAN II to CDC 3300 FORTRAN IV. Source was 4 boxes of punched cards. Once ported, I wrote an introductory user manual for it. Needless to say, I remember nothing about the details of using it. But I do remember many of the general features such as sensitivity analysis. 4 boxes of punched cards was somewhat less than 8000 lines of source code. Amazing what ECAP could do in what today would be a tiny program.

I later ported MIMIC, an analog computer emulation that ran on digital computers. I don't remember the source computer, but the target was again the CDC 3300. The last job of that trilogy was to port CIRCUS, a more advanced program that ran on an IBM 7094. It used quite a bit of 7094 assembly language which made the task a lot harder. I never finished it as I was reassigned to something else. I doubt anyone else ever attempted to finish it either.
 

Online rstofer

  • Super Contributor
  • ***
  • Posts: 9914
  • Country: us
Re: KVL and KCL Equations
« Reply #14 on: October 30, 2019, 07:14:14 pm »
I'm a little behind you, I started college (again) in 1969.  I was playing with the IBM1130 by 1970 and I well remember carrying a box of cards from my office to the computer lab about 1/4 mile away.  Did it all the time.  Came in on weekends to work on homework.  I spent so much time there the manager was beginning to think he should just hire me.

I also had the source to ECAP and I think I still do.  It's been a couple of years but I think I have it running on my FPGA version of the 1130.  I also have CSMP, the Continuous Systems Modelling Program.

I also had some restricted access to the CDC 6400 but the cost per minute was so high I didn't use it much.

The IBM1130 was my first computer and is still my favorite.  It was amazing what you could do 8k words of core when you go clever with overlays.

I graduated in '73 and did grad school in '75-'76, right at the very beginning of the microcomputer era.  It's been an amazing ride!
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14925
  • Country: fr
Re: KVL and KCL Equations
« Reply #15 on: November 05, 2019, 09:33:01 pm »
KVL is for the birds anyway.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf