A simulator for experimenting with circuits.

Run circuit sandbox
Run Circuit Sandbox in English, or with a smaller screen for mobile.
Ejecutar Circuit sandbox en español.
运行 Circuit Sandbox 简体中文版 (simplified Chinese).
Circuit Sandbox を日本語で実行する (Japanese)

Want to help translate Circuit Sandbox into other languages? It’s easy!


YOU DON’T NEED TO READ THE REST OF THIS UNLESS YOU GET STUCK. You will do fine.


Contents


Playing in the sandbox

To create a circuit, drag components from the part bin on the right onto the schematic.

Run circuit sandbox

Sample output: Click on TRAN to perform a transient analysis, a plot of voltage vs. time.

Transient analysis screenshot

Getting started

Drag components from the parts bin onto the main screen.

Add wires by dragging between components connection points (small circles).

Tap on the Rotate icon or type “r” on the keyboard to rotate a component.

Tap on the Delete icon or type BACKSPACE to delete a component.

Double-tap on a component to change its properties, like resistance value.

Add a ground symbol (triangle shape at the top of the part bin).

Add node labels (the short straight line underneath the ground symbol).

Add voltage or current probes to the nodes you want to plot.

Select DC, AC, or TRAN from the menu to simulate the circuit.

How to build the circuit shown above

To create the $\text{RC}$ circuit shown above, follow these steps starting from a blank schematic (open this link in a new tab).

  • Add components (a voltage source, resistor, and capacitor). Click on a component in the parts bin on the right, then click on the schematic. Or, you can mouse down on a component in the bin and drag it to the schematic.
  • Select the resistor by clicking on it. It will turn green. While it is selected, hit the “r” key on the keyboard to make it rotate to horizontal. You can also click on the R⤵ icon. Rotate several times to see what happens.
  • Position components on the page by dragging them around.
  • Add wires by dragging between the connection points on the components. If you make a mistake, hit the backspace/delete key on your keyboard to delete whatever is selected, or click on the $\large \times$ icon.
  • Specify a ground node by dragging the ground symbol from the parts bin (the triangle with a stick) and connect it to the bottom of the voltage source.
  • Adjust the component properties. Double-click on the voltage source and change its type to “step”. Give it a name if you want. In the same way, change the resistor value to $1$k, and the capacitor value to $1$u. The k and u suffixes are short for $10^{+3}$ and $10^{-6}$.
  • Add a voltage probe to the top node of the capacitor. (The thing in the parts bin that looks like a voltmeter probe.) This is the voltage we will plot.
  • Select an analysis to perform. For this example, let’s do a transient analysis. Click TRAN in the menu. Set the stop time to $10$m. The m stands for $10^{-3}$ so we will simulate for $10$ milliseconds.
  • Click OK. The simulation is performed and a plot should appear.

Here is the completed $\underline{\text{RC}}$ circuit.

Help

Add a component: Tap on a part in the parts bin, then tap on the schematic.

Add a wire: Touch on a connection (open circle) to start a wire. Drag. Release.

Select: Drag a rectangle to select components. Shift-click to include another component (desktop only).

Move: Touch and drag to a new location.

Delete: Tap to select, then tap the icon or hit BACKSPACE on the keyboard.

Rotate/Reflect: Tap to select, then tap on the Rotate icon or type the letter “r” to rotate 90. Repeat for more rotations and reflections (8 total).

Properties: Double-tap on a component to change its properties like resistance or voltage.

Numbers may be entered using engineering notation,

T    10^12          m   10^-3 
G    10^9           u   10^-6 
M    10^6           n   10^-9 
k    10^3           p   10^-12
                    f   10^-15 

example: $1000$ can be entered as $1\text k$

Labeling and annotation

You can give a node a name by attaching the label part—the short straight line under the ground symbol. Double-click on the label and enter a node name.

You can add unattached text annotation to the circuit with the same label part. Place a node label anywhere on the schematic. It does not have to be connected to anything.

On-screen controls

Scroll/pan Scroll/Pan
Zoom Zoom in, out, fit
Rotate Rotate
Delete Delete

Help: List the Help information shown above.

grid icon Grid: Toggle the background grid on and off.

Open netlist: Open a saved netlist.

Shared link: Displays a link you can copy for sharing your circuit. The link is uriencoded, also known as percent encoded. This lets you use these text characters , / ? : @ & = + $ # in signal and component names. The decoded link is echoed to your browser’s javascript console.

Save netlist: Save the current netlist. See System information below for where the circuit gets saved on different platforms.

Cut/Copy/Paste: The usual edit functions.

Mac shortcuts: ⌘-X, ⌘-C, ⌘-V
PC shortcuts: ctl-X, ctl-C, ctl-V

Delete: Delete the selected components.

Simulations

DC: Find the DC voltages and currents, also called the operating point.

AC: Sweep the AC frequency, plot voltage or current vs. frequency.

TRAN: Transient response. Find the time response, plot voltage or current vs. time.

Download: Saves the TRAN or AC data as a .csv file (comma-separated variables) called data.csv in your Downloads folder. This type of file can be opened in Excel or MatLab.

Device models

The simulator has simple models for semiconductor devices and an operational amplifier, with just a few adjustable parameters. For more sophisticated simulations, check out the other circuit simulator resources mentioned below.

The default diode saturation current is $\text I_\text s = 1.0\times 10^{-14} \text A$. The diode’s area parameter scales up the saturation current to $a \times \text I_\text s$.

System information

The circuit sandbox works best on a desktop or laptop computer where you have plenty of viewing area. You can also use it on a tablet. (It works on smart phone, too, but the experience is a bit awkward because the screen is so small.) It should work seamlessly in most modern browsers under Windows, Mac, and Linux. If you experience problems, please let me know.

Your circuit is never transferred to the Spinning Numbers web server.

Desktop/laptop

A quick way to save your circuit is to click on the link icon. It displays a big URL you can copy and paste wherever you want. Paste it into a browser to recreate the circuit.

The save icon saves the circuit to the Download folder on your computer in JSON format (JavaScript Object Notation). The file is named ckt.txt.

The open icon loads a circuit from your computer’s file system.

If you want to keep your work be sure to save your circuit before leaving the web page.

Touch devices

If you have a touch device (tablet or smart phone),

  • One finger selects a component or drags a selection rectangle
  • Two fingers pan the schematic window

Tablet

On a tablet you can save one circuit file. When you save a circuit, it is tucked into a memory area inside your browser. When you open the saved circuit, the circuit file is retrieved from browser memory. If you want to keep your work, be sure to save before leaving the web page.

Mobile devices

The simulator works on a smart phone, but the display is a bit small for drawing schematics. You can save and load one circuit file, the same as for a tablet.

Configure

Circuit Sandbox accepts a few extra parameters to customize the parts bin and analysis choices. You can do this with either the URL or the html <input> statement. Here is an example of a URL with a limited parts bin and analysis choices,

https://spinningnumbers.org/circuit-sandbox/index.html?parts=g,v,r,s&analyses=dc,tran

A URL parameter list starts with a ? question mark. Each parameter is separated by an & ampersand character. Notice there are no quote marks.

You can also provide an initial schematic. Draw up a circuit and grab the URL with the link. The circuit JSON is captured in the value parameter. Append the part and analysis options like this with ampersands,

https://spinningnumbers.org/circuit-sandbox/index.html?value=[["g",[104,112,0],{"_json_":0},["0"]],["r",[128,64,0],{"r":"1","_json_":1},["1","0"]],["v",[80,64,0],{"value":"dc(1)","_json_":2},["1","0"]],["w",[80,64,128,64]],["w",[80,112,104,112]],["w",[128,112,104,112]],["view",0.5,36.5,4,"50",null,null,null,"100","0.01","1000"]]&parts=g,v,r,s&analyses=dc,tran

You can do the same thing if you call Circuit Sandbox from an html <input> statement—this time with quotes,

<input type="hidden" class="schematic" height="400" width="600" parts="g,v,r,s" analyses="dc,tran" value=[["g",[104,112,0],{"_json_":0},["0"]],["r",[128,64,0],{"r":"1","_json_":1},["1","0"]],["v",[80,64,0],{"value":"dc(1)","_json_":2},["1","0"]],["w",[80,64,128,64]],["w",[80,112,104,112]],["w",[128,112,104,112]],["view",25.5,44,4,null,null,null,null,"100","0.01","1000"]]>

Your choices for analyses are dc, ac, and tran.

Here are your part choices,

   var parts_map = {
    'g': [Ground],
    'L': [Label],
    'v': [VSource],
    'i': [ISource],
    'r': [Resistor],
    'c': [Capacitor],
    'l': [Inductor],
    'o': [OpAmp],
    'd': [Diode],
    'n': [NFet],
    'p': [PFet],
    's': [Probe],
    'a': [Ammeter]
   };

Translation

If you would like to help translate the Circuit Sandbox into other languages, that would be great! If you are fluent in English and another language, especially the technical terms used in the simulator, I could really use your help. Contact me by email and I will provide a table of 170 terms and phrases for you to translate.

So far, Circuit Sandbox is available in,

  • English, en-US.js
  • Spanish, es.js (courtesy of Khan Academy volunteer translators)
  • Simplified Chinese, zh-cn.js (courtesy of GitHub user Zhu Hao)
  • Japanese, ja.js (courtesy of my friend Leslie Shiozaki, a professional translator)

The circuit sandbox was created at MIT

The Circuit Sandbox simulator was created at MIT by Professor Chris Terman in 2011, and was used by the very first massively-open-online class (MOOC), MIT 6.002x. MIT transferred Circuit Sandbox to EdX in 2012. I made further improvements to the simulator interface while at Khan Academy in 2016 and since then.

Circuit Sandbox is not a version of SPICE. It is its own interpretation of a circuit simulator. It includes schematic capture and a circuit simulation engine. The simulator is 100% Javascript and does not require installation. All you do is click on the link and the simulator opens, ready to run.

Other circuit simulators

The granddaddy of all circuit simulation programs is SPICE (Simulation Program with Integrated Circuit Emphasis). This program was created at the University of California, Berkeley in the 1970’s. It was originally written in FORTRAN and has always been in the public domain. SPICE is one of the jewels of human creativity.

The input to SPICE is a plain-text circuit description (a SPICE netlist). SPICE is the workhorse of the electronics industry because it supports sophisticated models for semiconductor devices (diodes and many types of transistors).

Many people have wrapped front-end interfaces around SPICE to allow designers to draw a schematic and automatically create SPICE netlists. The text netlist is submitted to SPICE for simulation. The results come back and you can plot them. Many of these packages can be found by searching the web for “circuit simulator.”

An excellent version of SPICE is available from Linear Technology, a semiconductor manufacturing company in Milpitas, California. The program is LTSpice (from linear.com) or LTSpice (from analog.com). LTSpice runs on Windows, Macintosh, and Linux machines with Windows emulation. It is free to download and use.

Note: Linear Technologies was purchased by Analog Devices in 2017. The web sites have been merged together.

Another simulator is JADE. This is also a creation of Chris Terman at MIT. It’s a follow-on to Circuit Sandbox with improved features for digital design and logic simulation. Here’s an intro video.

Licensing

© 2017-18 Willy McAllister, © 2016 Khan Academy, Inc., © 2012 EdX, © 2011 MIT EECS

This work is licensed under the Creative Commons (CC BY-NC-SA 4.0) Attribution-NonCommercial-ShareAlike 4.0 International.

Khan Academy makes its software available under the MIT License.

The MIT circuit simulator is part of the EdX Platform, licensed under the GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007. More information at EdX licensing.

Libraries

The Circuit Sandbox simulator uses two open-source libraries,

Download.js is licensed under the Creative Commons Attribution 4.0 International License, attributed to “dandavis”. No changes were made. Download.js allows to circuit files to be downloaded to the client computer.

Hammer.js is available under the MIT License. No changes were made. Hammer.js provides touch functionality, in particular, the double-tap function.

This version of the simulator includes additions by Willy McAllister, including,

  • Save/Load netlist
  • Sharable link
  • Touch sensitivity
  • Internationalization