Circuit Editor

Circuit Editor is a Mac OS X application for editing and simulating electronic circuits.

It is designed to be used as a teaching tool for students new to electronic circuits. Unlike more powerful packages like SPICE, Circuit Editor is interactive and it simulates circuits in real time. Currently, it has support for resistors, capacitors, batteries, and toggle switches.

Steven La, whose website is at http://www.stevenla.com/, created some of the graphics for me.

Downloads

You can get Circuit Editor by clicking the link below. It only runs on Mac OS X. The package includes a pre-built version of Circuit Editor, instructions, and a number of example files.

Download Circuit Editor

Screenshots

Details

I originally made Circuit Editor in the winter and spring of 2009. I wanted to learn more about electronic circuits, but I was having trouble learning by reading a textbook. So I decided to write my own circuit simulator. I learned some by writing the code, and more by playing with the simulator once it worked.

This online applet is a free electronic circuit simulator that has many more features than mine. If I had known it existed, I probably wouldn't have written mine.

Technical details

Some people have wondered how circuit simulators work. Here is an explanation of how mine works.

Disclaimer: I am not an expert on this.

The first step is to express the circuit as a system of equations. If you just use resistors and voltage/current sources, you get a system of linear equations. If you include capacitors and inductors, you get linear differential equations. If you include semiconductor components, you have to handle nonlinear equations too.

Systems of linear equations can be solved using Gauss-Jordan elimination. Systems of linear differential equations can be solved analytically by finding the eigenvalues of the matrix, or just by approximating step-wise. I believe there is also a way to simulate the type of system that is produced by a circuit by using complex numbers, but I don't actually know, because I never finished that book on electronic circuits.

I'm not sure what the best way of solving systems of nonlinear equations is. I ended up using a technique that involves finding zeroes for the individual equations, finding the intersection of the linear approximations, and then iterating until the answer is good enough. I'm not sure if this technique has a name.

Source code

Circuit Editor's source consists of about 8,600 lines of Python and C code arranged into five sub-projects:

It may be impossible to build Circuit Editor from source with recent versions of py2app. As of 2010-04-14, I am unable to rebuild Circuit Editor from source on my machine running Mac OS X 10.6.3 with py2app 0.4.3 and Python 2.6.5. I don't have the time to track down this issue, which I suspect may be a problem with py2app or MacPorts.