Circuit Simulator

This electronic circuit simulator is highly interactive giving the feeling of playing with real components. It's very helpful for experimentation and visualization. Best of all, thanks to the power of HTML5, no plug-ins are required! The original implementation, in Java, belongs to Paul Falstad who kindly gave his permission for me to build this port.

Click here to open the simulator in a full window.

How to use this

When the simulator starts up you will see an animated schematic of a simple LRC circuit. The green colour indicates positive voltage. The grey colour indicates ground. A red colour indicates negative voltage. The moving yellow dots indicate current.

To turn a switch on or off, just click on it. If you move the mouse over any component of the circuit, you will see a short description of that component and its current state in the lower right corner of the window. To modify a component, move the mouse over it, click the right mouse button (or control-click if you have a Mac) and select "Edit". You can also access the edit function by double-clicking on a component.

There are three graphs at the bottom of the window; these act like oscilloscopes, each one showing the voltage and current across a particular component. Voltage is shown in green, and current is shown in yellow. The current may not be visible if the voltage graph is on top of it. The peak value of the voltage in the scope window is also shown. Move the mouse over one of the scope views, and the component it is graphing will be highlighted. To modify or remove a scope, click the right mouse button over it and choose "remove" from the menu. There are also many other scope options in this context menu. To view a component in the scope, click the right mouse button over the component and select "View in Scope".

The "Circuits" menu contains a lot of sample circuits for you to try.

Some circuits, eg Basics->Potentiometer, contain potentiometers or variable voltage sources. These can be adjusted using sliders that are added to the right hand tool bar, or by positioning the mouse pointer over the component and using the scroll wheel.

Here's a video to help you get started.

Drawing and editing circuit

You can get a blank circuit by choosing "Blank Circuit" from the "Circuits" menu. You will need to add at least one voltage source to start the simulator.

To add components or a wire choose one of the "Add...." options from the "Draw" menu. Note that common components have keyboard short-cuts to select their add mode. When in add mode the cursor changes to a "+". Click and drag the mouse to add a component.

Components may be moved and resized in the selection mode. When in selection mode the cursor changes to an arrow. Choose "Select/Drag Sel" from the "Draw" menu or press "space", or press "escape" to go in to selection mode. Hovering over a component will highlight it and show information about that component in the info area. Clicking and dragging on a component will move the component. If you click and drag on the square handles or hold down the ctrl key this will resize the component and move the terminals.

Wires only connect at their ends and not in the middle therefore you have to draw each segment of a wire separately. If the simulator spots unconnected points it thinks you intended to connect it will highlight these with a red circle.

Many components have adjustments that can be made using the edit function explained above. For resistors, capacitors and inductors you can conveniently set the value from the E12 range by rolling the mouse wheel when hovering over the component

The File menu allows you to import or export circuit description files. See notes below on browser compatibility.

The Reset button resets the circuit to a reasonable state. The Run/Stop button allows you to pause the simulation. The Simulation Speed slider allows you to adjust the speed of the simulation. If the simulation isn't time-dependent (that is, if there are no capacitors, inductors, or time-dependent voltage sources), then this won't have any effect. The Current Speed slider lets you adjust the speed of the dots, in case the currents are so weak (or strong) that the dots are moving too slowly (or too quickly).

This video demonstrates some of the above points.

Here are some errors you might encounter:

  • Voltage source loop with no resistance! - this means one of the voltage sources in your circuit is shorted. Make sure there is some resistance across every voltage source.
  • Capacitor loop with no resistance! - it's not allowed to have any current loops containing capacitors but no resistance. For example, capacitors connected in parallel are not allowed; you must put a resistor in series with them. Shorted capacitors are allowed.
  • Singular matrix! - this means that your circuit is inconsistent (two different voltage sources connected to each other), or that the voltage at some point is undefined. It might mean that some component's terminals are unconnected; for example, if you create an op-amp but haven't connected anything to it yet, you will get this error.
  • Convergence failed! - this means the simulator can't figure out what the state of the circuit should be. Just click Reset and hopefully that should fix it. Your circuit might be too complicated, but this happens sometimes even with the examples.
  • Transmission line delay too large! - the transmission line delay is too large compared to the timestep of the simulator, so too much memory would be required. Make the delay smaller.
  • Need to ground transmission line! - the bottom two wires of a transmission line must always be grounded in this simulator.

Browser and computer requirements

This simulator makes extensive use of HTML5 features and definitely needs a modern browser. It also performs a lot of calculations in JavaScript and the speed of this varies a lot between browsers. Currently Chrome seems to have the best performance and feature support for this application. Internet Explorer also runs the JavaScript well but sadly lacks compatibility with all the file menu options.

The simulator benefits a lot from having a reasonably fast computer. My Core i5 laptop from 2012 runs most circuits OK so it doesn't need to be the latest and greatest hardware but you'll probably find performance disappointing on older machines.

The capability to load and save files to the local disk requires HTML5 features that are not supported in all browsers. If the application detects the features required are not supported then some of the file options will be unavailable. Currently Chrome and Firefox support all the needed features.

Dropbox integration doesn't fully work on Firefox due to a bug in the browser. On Firefox you can only load shared links and not use the Dropbox browser or saver.

The simulator will run on tablets and even phones if they have a suitable browser and should work OK with touch interfaces.

What's New

Thanks to hard work by several people the simulator continues to be developed. Here are some recent features

  • Integration with Dropbox and URL-shortening to enhance collaboration modes
  • Touch interfaces are supported
  • Scopes can show an FFT spectrum (uncalibrated currently)
  • New input and output modules (eg "Test Points")
  • Ability to show RMS voltage and other parameters on Test Points and probes
  • Several user interface improvements and bug fixes
  • Choice of Euro or US resistor style is based on browser language preference

Simulation != Real Life

Physics simulations are not real life, and don't assume that simulation and reality are identical! In common with most simulations this one idealizes many components. Wires and component leads have no resistance. Voltage sources are ideal - they will try and supply infinite current if you let them. Capacitors and inductors are 100% efficient. One consequence of these simplifications is that the simulator doesn't converge on a result for circuits that have no defined behaviour - for example an ideal voltage source short-circuited by an ideal wire. When using the simulator you must account for places where real electronics differs from the ideal.

High Frequency Circuits

This simulator simulates the circuit using a series of short time steps. In each step the changes to the voltages and currents in the circuit are calculated based on the component models and the current circuit state. For this process to work the time steps used need to be significantly shorter than the duration of any event of interest in the circuit. Or, if you prefer, the time steps need to be significantly shorter than the period of the highest frequency signal of interest.

By default the simulator uses a 5µs step size. This is OK for audio frequency signals but not for radio frequency signals or fast digital signals. The step size can be changed from the "Other Options..." dialog on the options menu. For comparison, the transmission line example in the application uses a 5ps step size.

The step size shouldn't be confused with the "Simulation Speed" controlled by the slider in the right hand panel. The step size controls how long (in simulated time) each step is. The "Simulation Speed" slider controls how often (in real time) the computer calculates a step.

For developers

This application was developed, with permission, from the Java circuit simulator by Paul Falstad. I always found this a great tool to help visualize circuits and loved the interactive nature compared to normal SPICE implementations. However, I never really liked Java in the browser and with recent security problems and consequent changes in security policy by browser vendors it seemed to me that there would be a lot of benefit in having a version that didn't require plug-ins.

To create this version I modified the original Java to run in the Google Web Toolkit (GWT). Most of the user interface was rewritten but the technical parts of the simulation are almost untouched. The total work on this project took just over a month.

Thanks to the kind permission of Paul Falstad the source project for this version of the application is now available on GitHub under a GPLv2 license.

https://github.com/sharpie7/circuitjs1

License Suitability for Purpose

The simulator is provided with no support or warranty. Absolutely no guarantee is provided of suitability for any purpose.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

For details of licensing see http://www.gnu.org/licenses/.