loading

The picture is the result of a a couple of resistance calculations and some plotting with it.

The second picture is of an incredibly powerful calculator, for its day, but not a resistance calculator.  It is called the Difference Engine. You can read about it at:  http://en.wikipedia.org/wiki/Difference_engine  The calculator here for resistance  is Python based ( a variant called SageMath ) and is made of software not hardware.
 

The Internet is full of calculators for resistance, particularly for series and parallel circuits, or for equations to solve for total resistance in circuits given different resistor values. But this one is better.   I will show you how to use this incredibly powerful resistance calculator, it does all of the above and more including:

  • Impedance of Capacitors
  • Impedance of Inductors
  • Modeling of Potentiometers and Voltage Dividers
  • Current through Circuits
  • Phase Shift in Circuits
  • Making Custom Values
  • Circuits with Resistors, Capacitors and Inductors
  • Resonate circuits

First Picture Calculated with the Resistance calculator, second picture is from:  http://commons.wikimedia.org/wiki/File:Difference_engine.JPG

Step 1: Tools and Materials

The calculator is written in a version of Python, but you do not need Python to run it, the whole computer environment is available for free on the web.  What you will need is:
  • A computer with an internet connection. Can be PC, Mac, or Linux
  • Some files containing the calculator and some examples of calculations. They are attached to this insturctable.

The image for this step is from:  http://xkcd.com/353/

Step 2: Electrical Theory

I will not go into the basic electrical theory here but just use the results.  Wikipedia has a good discussion of the  basic theory:


Lets first deal with just resistance ( no capacitance, C, or Inductance, L ).  If you have a single resistor with resistance r1 there are two ways you can connect another resistor, r2, either in series or parallel .  If you do either one some basic formulas allow you compute the effective resistance of the pair, this is the resistance  you would have if you replaced the pair with a single resistor.  LRC carries out the calcuation.    

Now that the value of LRC is equivalent to one resistor you can repeat the addition of a new resistor.  

The methods we have in LRC to do this are called  add_serises_r() and add_parallel_r().

What if it is not a resistor but a capacitor?  First if we assume a sine wave for the voltage ( which we almost always do ) the resistance depends on the frequency.  Second we use complex numbers to represent the resistance ( and if we are careful call it the impedance ).  Once we have the complex impedance we can use the same formulas as for resistors.  Again this is what LRC does.

In the "real world" physical values are not complex so to interpret the results we often use only the real part or the absolute value, LRC also does this as appropriate.  The whole theory is pretty cool, consider learning if if you are not already familiar with it.

The picture is from wikipedia, Maxwell's equations, the basic equations of electromagnetism.

Step 3: The Two Basic Circuits: Series and Parallel

These 2 circuits are not the most interesting, but they are a good place to start.
 

To use the calculator you type into an “notebook”. This is a bit like a word processor where you can type what you want. The difference is that rather than paragraphs it is divided into “cells”. When you are finished with a cell you can “execute” it and its output appears just below the cell. Below that you can have another cell. A cell can be modified and then executed again perhaps with slightly different content. The notebook can be saved as a file.
 
 
This may seem a bit cumbersome but is really useful as you always have a record of what you have done, and can copy and paste from old work or sample work. You can also add comments to document your work. I will show you the contents of a cell with lots of comments ( so the explanation is inside the cell ) and then show you the cell output. Note that when you do your calculations you need not be nearly so verbose. ( Lines that begin with “#” are just comments for you and do nothing in the calculator. I will actually write some of this instructable using the comments in the code, please read them. Only 4 of the lines actually do the calculation, the rest are explanation. )

 

Here goes



 -------------------- begin code --------------------
# For the first calculation we will get the total resistance for a resistor 
# of 1 K ohms in series with one of 10 K ohms
# ( and yes I know if you know much electronics you can do this in your head )
print "First Calculation - Add 1K resistor to 10K resistor in series:"
print 

# Step 1
# make a resistor which is the calculator,  LRC stands for Inductance, Resistance, 
# Capacitance, and is # used because the calculator can do all of them.
# I will use the long name “aResistor” to remind you what it stands for, 
# but you could use just “r”
# This next line creates a "aResistor" of no value ( technically with a value of None )

# Step 1
aResistor = LRC()
print "ignore the print out about frequency, this is only used in more advanced calculations" 

# Step 2
# we now add a new resistance to our "resistor"

aResistor.add_series_r( 1000 )  # add a 1 k ohm resistor
# this will cause a output that tells what we did

# Step 3
# now add the second resistance, in series with the first

aResistor.add_series_r( 10000 ) # 10000 = 10K

# this again will cause a output that tells what we did


# Step 4
# get the final value for the resistance ( note that z is a general symbol for resistance )

print
print "Final value of combined resistance = ", aResistor.get_z( )

# shows the current value for the resistance, just the sum of resistances 

# final comment suppresses default print at end of cell

-------------------- begin output --------------------

First Calculation - Add 1K resistor to 10K resistor in series:

LRC() using internal frequency lrc_freq in Hz
ignore the print out about frequency, this is only used in more advanced
calculations
LRC.add_series_r() 1000
LRC.add_series_r() 10000

Final value of combined resistance =  11000
-------------------- end output -------------------- 

We can do the same sort of thing for 2 resistors in parallel we will use 1K and 10K again, here goes:





-------------------- start code --------------------------------
print "Second Calculation - Add 1K resistor to 10K resistor in parallel:"
print

# -----
# make a "aResistor" which is the calculator

aResistor = LRC()

# -----
# we now add a resistance to our "resistor"

aResistor.add_parallel_r( 1000 )

# this will cause a output that tells what we did, and the current 
# value for the impedance = resistance

# -----
# now add the second resistance, in parallel with the first

aResistor.add_parallel_r( 10000 )

# this again will cause a output that tells what we did, and the 

# -----

print
print "Final value of combined resistance = ", aResistor.get_nz( ) 
#  nz in function above pushes full numeric evaluation to a decimal value

# thi comment suppress end of cell default print

-------------------- start output --------------------------------

Second Calculation - Add 1K resistor to 10K resistor in parallel:

LRC() using internal frequency lrc_freq in Hz
LRC.add_parallel_r() 1000
LRC.add_parallel_r() 10000

Final value of combined resistance =  909.090909090909
-------------------- end output --------------------------------
A couple of notes on what is going on here.

  • This is object oriented programming. Statements like lrc = LRC() is how Python makes an object.
  • The first resistor added to the object is not really in series or parallel, it does not matter if you add in parallel or series, the resistance before adding is  "None".
  • Each time you add a resistance the object finds the equivalent resistance of its old value combined with the value you add. It ( you ) can keep on adding resistors for as long as you want, certainly not limited to 2 resistors.

 

Step 4: A More Complicated Circuit

Lets put 3 1.5 K resistors in parallel, then 2 more in series with it.

Here is the quick description of the calculation:

  • Make a LRC calculator
  • Using the calculator Add (in parallel ) a 1.5 k resistor, repeat 2 more times.
  • Add ( in series ) another resistor, repeat
  • Done

here is the code and response.

 

 

-------------------- start code --------------------------------

# A More Complicated Circuit 
# I will give the schematic in ascii characters -- not part of the calculation,
# just to help you understand 
# lots of print statements, not necessary, just to help explain what is going on 
#
print "Third Calculation - example of series and parallel resistor combination:"
print 
print "Calculate resistance from x to x"
print
print "    |-----------1.5K-------------|"
print "    |                            |"
print "x---|-----------1.5K-----==------|------1.5k------- 1.5K------x"
print "    |                            |" 
print "    |-----------1.5K-------------|"
print

# make the resistor calculator 
print "Begin..."
aResistor    = LRC(  )
print

print "Do the parallel resistors..."

print
print "    |-----------1.5K-------------|"
print "    |                            |"
print "x---|-----------1.5K-----==------|--"
print "    |                            |" 
print "    |-----------1.5K-------------|"
print

aResistor.add_parallel_r( 1.5e3 )   # 1.5e3 is scientific notation, a shorter way of writing 1500
aResistor.add_parallel_r( 1.5e3 )
aResistor.add_parallel_r( 1.5e3 )

print "and now the two series reisistors "
print
print "      |----------1.5k----------1.5K------|"
print
print

aResistor.add_series_r( 1.5e3 )
aResistor.add_series_r( 1.5e3 )

print  
# done but a final step using n()
print "Final value of combined resistance = ", aResistor.get_nz(  )  

# suppress end of cell default print


-------------------- end code, start output -------------------- 

Third Calculation - example of series and parallel resistor combination:

Calculate resistance from x to x

    |-----------1.5K-------------|
    |                            |
x---|-----------1.5K-----==------|------1.5k------- 1.5K------x
    |                            |
    |-----------1.5K-------------|

Begin...
LRC() using internal frequency lrc_freq in Hz

Do the parallel resistors...

    |-----------1.5K-------------|
    |                            |
x---|-----------1.5K-----==------|--
    |                            |
    |-----------1.5K-------------|

LRC.add_parallel_r() 1500.00000000000
LRC.add_parallel_r() 1500.00000000000
LRC.add_parallel_r() 1500.00000000000
and now the two series reisistors 

      |----------1.5k----------1.5K------|


LRC.add_series_r() 1500.00000000000
LRC.add_series_r() 1500.00000000000

Final value of combined resistance =  3500.00000000000
  
-------------------- end output -------------------------------- 

More on What is Going On

The calculator is running in a Python environment called Sage, so the lines you are typing are actually part of an interactive program. You can run this over the web by logging into a free web server at: http://www.sagenb.org/ You will need to register.

Since you are running in Python, all the rules of Python apply; a few to note here to keep you out of trouble:

  • Indentation matters, do not indent until you understand what it means.
  • Capitalization matters, aResistor is not the same as aresistor.
  • # starts a one line comment, may be used after some comment or non-comment code on the same line
  • there are some tricks for getting built in help read the Sage Notbook documentaion, the application is also well documented on the web.

Python is one of the best current languages, well worth learing.

Step 5: An Advanced Application

In this application we will show how the calculator can work with algebra as well as numbers, this can be used to find the standard equations for series and parallel circuits or even more complex formulas.  The code and output will be the only explanation here, use online resources if you need more info.


----------------- start code -----------------
print "Repeat and extend symbolic calculation -- solve for r sub 1"
print "Again without much explanation get the formula for 2 resistors in parallel"
print 

# when we do things symbolically we need to define our symbols

var("r1")    # symbol for resistor 1
var("r2")    # symbol for resistor 2
var("r3")    # symbol for resistor 3 the combination

lrc    = LRC()

lrc.add_parallel_r( r1 )
lrc.add_parallel_r( r2 )


print
print "so the two in parllel are: ",  lrc.get_z()
print 

print "Now do some algebra and turn the calculation into an equation for r3"
print "then solves for r1 in terms of r3 and r2"

# I am not explaining this, but it is just SageMath, look in web references

equation = ( r3 == lrc.get_z() )
print equation 

print
print "solving..."
solution = equation.solve( r1 )
print( solution )  # show( solution ) gives nicer output, try it 
----------------- start output -----------------
Repeat and extend symbolic calculation -- solve for r sub 1
Again without much explanation get the formula for 2 resistors in
parallel

LRC() using internal frequency lrc_freq in Hz
LRC.add_parallel_r() r1
LRC.add_parallel_r() r2

so the two in parllel are:  1/(1/r1 + 1/r2)

Now do some algebra and turn the calculation into an equation for r3
then solves for r1 in terms of r3 and r2
r3 == (1/(1/r1 + 1/r2))

solving...
[
r1 == r2*r3/(r2 - r3)
]
----------------- end output -----------------

 

Step 6: Setting Yourself Up With the Calculator

Download the file from this instructable ( called  “LRC Instructable Files.zip”, but the insturctable system may rename it  ).  It is a zip file with several different worksheets in it.  You do not have to unzip it, Sage will do that for you.

 
Go to  http://www.sagenb.org/    use" Select an OpenID provider"   for a site where you have an account, to log into the notebook.  You will be taken to your new account on the notebook server. 
 

Select <Upload> , and browse to select the file you have saved  “LRC Instructable Files.zip” press up "upload".


You will see the  worksheet  files in the notebok.  Click on one to run it, explore the sage environment and the LRC calculator.


Each worksheet is a separate environment but you can run several at once,  To make a new worksheet for LRC calculations either copy one then save it under a new name, then you are free to change it.  Or make a new blank worksheet and copy the LRC cell from one of the existing worksheets and execute it in the new worksheet.


I have included PDF versions of the worksheets, these cannot calculate, so I would urge you to try the real thing using the Sage Notebook.

Step 7: Going Farther

There is much more you can do with this calculator, this instructable is just the real basics. Some of the attached files are effectively instructables on these other features.  If you do not want to go to the trouble of running SageMath you can see the input and output of the files in the attached pdf's.  Without much explanation you can:

  • Use for AC circuits, just use setOmega() to set the angular frequency of the AC you want to use, do this right after the defining line ( aR = LRC() ).  Then you can use inductors and capacitors as well as resistors.  The values of impedance will then be complex ( see:  http://en.wikipedia.org/wiki/Electrical_impedance )
  • You may or may not want to read the cell that defines the LRC object.
  • Sage is a symbolic system you can solve equations, find maxima and minimua.... do some research on Sage using Google and the search term “Sagemath”
  • Read the code to get an idea as to the function calls and what they do.
  • I have  provided more example notebooks with lots of comments, install them in your Sage account and investigate how they work.
  • You can put a Sage Notebook on your own computer.
  • Sagemath Cloud is a new, free, beta, version of Sage.

I may extend this object to do more in the future.  What would you like to see it do?  Comment below or email me.
 
<p>Re your first step: </p><p>&quot;You have no hairs. Why?&quot; </p><p>&quot;I pulled them all out when trying to install a new lib for Python3 while I has running some of my stuff under 2.7 and others under 2.6. But the 3.0 resisted to accept the 2.6 parts, the 2.7 would not accept 2.6 and 2.6 would not accept any other version. Trying to remove one version resulted in a mess which refused to run anything at all, except sometimes 'Hello World'. &quot;</p><p>Just kidding. But with a grain of salt (aka my own experience).</p><p>Very nice i'ble. When I did my studies in electrical engineering I made a program using two-port networks. This is quite neat since you can model (almost?) any electrical part as a two-port network. Of course also resistors. But you can extend it easily with capacitors, inductors, transistors, whatever. Since this is more than 30 years ago (I guess I used Pascal those days) I don't have any source left over.</p>
<p>Yes upgrading to 3.0 is said to be hard, I am sticken to 2.7 for a bit.</p>
<p>Obligatory XKCD Ohm reference.<br><a href="https://xkcd.com/643/" rel="nofollow">https://xkcd.com/643/</a></p>
<p>XKCD is great, your comment made me search it for a few more references to resistance. I came up with these: <br><br>http://xkcd.com/356/<br>http://xkcd.com/227/<br>http://xkcd.com/730/</p>
<p>This is WONDERFUL! I would like to feature this project, but need you to adjust your main image to something more-related to your project. The difference engine is awesome, though :D</p><p>Let me know if you update your intro image by replying to this comment, and I can feature your project on the homepage.</p><p>Thanks!</p><p>Audrey</p><p>Community Manager for Instructables.com</p>
<p>Let me know how you like the new one.</p>

About This Instructable

21,170views

103favorites

License:

Bio: For now see me at: http://www.opencircuits.com/User:Russ_hensel
More by russ_hensel:Tic Tak Power Supply Difficult Dis-assembly: Taking Things Apart for Repair A Bit Better Bit Holder 
Add instructable to: