sharpie7 / circuitjs1 Goto Github PK
View Code? Open in Web Editor NEWElectronic Circuit Simulator in the Browser
License: GNU General Public License v2.0
Electronic Circuit Simulator in the Browser
License: GNU General Public License v2.0
First of all, the project is awesome and is probably the best free GUI circuit simulator out there. That said, there are a few editing modifications I feel should be added:
Im trying to write log to file on client side. Can it be done? like export the values of a circuit in a text file using client.
however,send logs on server side and write to file on server works.
I'd personally find it useful to have support for connectors. These would act like multiple switches that all toggle on and off at the same time. It could be a simple thick-ish line that crosses over the wires that when clicked on splits into two thinner parallel lines to show it is disconnected.
As a bonus it would be awesome if it was possible to simulate the connections being shorted together (as is the case with 3.5mm audio connectors) or wires disconnecting at slightly different times (as can happen with many of the long multi-pin connectors).
It would be nice to add voltage and current controlled sources components. Thanks!
It would be nice to have a comparator component, like the op-amp, but with open drain output that's either 0 or high-Z. Currently you have to make it with op-amp + voltage-controlled switch.
When create a circuit and failed ,it's necessary to know circuit wrong state. Especially tell user why fail to create right circuit.
Is the a method to do this ? Thx.
I had trouble getting this circuit working.
The problem ended up being the transistors being exactly identical, which is a very bizarre problem to have. Would it be hard to implement component value errors?
$ 1 0.000005 0.13386567243530942 50 5 50
R 176 128 176 80 0 0 40 5 0 0 0.5
r 176 128 176 192 0 3900
r 400 128 400 192 0 3900
w 176 128 400 128 0
w 176 192 208 192 0
w 400 192 368 192 0
r 208 192 256 192 0 47000
r 320 192 368 192 0 47000
w 256 192 320 224 0
w 320 192 256 224 0
w 176 192 176 208 0
w 400 192 400 208 0
t 368 224 400 224 0 1 -4.073909850738368 0.32816588861736995 101
t 208 224 176 224 0 1 -6.3375382159237965 -1.808826491257624 100
w 368 224 336 224 0
w 336 224 320 224 0
w 256 224 240 224 0
w 240 224 224 224 0
w 224 224 208 224 0
d 320 224 320 256 1 0.805904783
d 256 224 256 256 1 0.805904783
r 336 224 336 272 0 100000
r 224 224 224 272 0 100000
w 400 240 400 272 0
w 400 272 336 272 0
w 336 272 224 272 0
w 224 272 176 272 0
w 176 272 176 240 0
w 256 320 256 256 0
w 320 320 320 256 0
c 256 320 288 320 0 1e-9 2.605348736966969
c 320 320 288 320 0 1e-9 4.7562609050011115
w 288 320 288 352 0
w 288 352 112 352 0
R 112 352 112 320 0 2 2000 5 0 0 0.5
w 176 192 144 192 0
w 400 272 464 272 0
R 464 272 464 304 0 0 40 0 0 0 0.5
r 432 192 432 240 0 220000
r 144 192 144 240 0 220000
w 400 192 432 192 0
O 432 192 480 192 0
w 432 240 432 320 0
w 432 320 320 320 0
w 256 320 144 320 0
w 144 240 144 320 0
o 34 1 0 2091 5 0.00078125 0 -1 0
o 41 1 0 2090 5 0.00009765625 0 -1 0
I tried to generate high voltage pulses with the following circuit (and also tried with a resistor in the capacitors place)
$ 1 1e-9 0.10425469051899915 50 5 43
R 464 320 384 320 1 2 1000 2.5 2.5 0 0.5
f 464 320 512 320 16 1.5 0.02
g 512 336 512 400 0
l 416 240 512 240 2 0.01 0.009968548165247795
R 416 240 352 240 0 0 40 5 0 0 0.5
187 720 240 720 352 0 1000 1000000000 1000 0.001
g 720 352 720 400 0
w 512 240 576 240 0
w 576 240 720 240 0
c 512 240 512 304 2 0.000009999999999999999 3.846836422686465
o 5 64 0 2083 10 0.00009765625 0 -1 0
However, going down to 1n time step, it still fails to converge.
Two parallel wires seems to make it think there's a short circuit, despite a load in series with it.
Hello. It would be nice to have a dimensionless area that can be scaled.
When drawing a resistor the text is too close to a the component which makes the design unclear.
Hello,
can you please add following components?
TRIAC (it does not work very well when i simulate it using two SCRs). This can be very usefull.
Rail to rail OPAMP with power supply pins (currently the OPAMP in circuit does not allow to connect supply voltage). So it's output is not dependent on supply voltage of the rest of the circuit, which caused me problems in past. I mean like OPAMP giving constant 5V output in circuit powered by slowly discharging battery worked in simulation, but was off in real life, because it's output changed as supply voltage changed. Maybe it does not have to be "rail to rail" it should just have power supply pins and way to set how close the output can get to the supply voltage.
TL431 quite common component that integrates precision voltage reference, opamp, NPN transistor and diode. They are almost everywhere nowadays...
KB817 (=PC817) optocoupler is very common and cheap optocoupler. i really don't know how to simulate such component using substitutes made from other parts. especialy when it's not fully on or fully of. there's a piece of region, where it can be used for transmitting analog signals using opamps and feedback loop. that's something that simply cannot be substitued using relay, etc...
DPDT switch. Also quite usefull. Now i have to use single switch and relays.
Full bridge rectifier. While it may be quite easy to draw 4 diodes... Why not? We do this all the time again and again, so why not make life little easier?
LM317, LM337, 7805 - quite favourite linear regulators are something that i miss in simulator. They are also very popular. Maybe it can be just single 3-legged component with configurable polarity, voltage reference and voltage drop. defaulting to LM317.
I found this bug while using the app to build a circuit. After you move elements around a couple of times, the leads will stop connecting. In fact, you cannot connect them at all. Seems something must be wrong with the coordinate system when dragging the leads of any element.
I am not very familiar with your code but I will try to look into this myself.
I will also try to give step by step instruction to reproduce the bug, specifically using one of the built in circuits.
I have attached an image. The leads of the individual elements cannot be connected again unless you create a new elements. I'm thinking it has to do with going from screen size changes.
EDIT#1: I should mention that ones it starts happening I can only move the elements leads when the CTRL key is pressed.
When a circuit is loaded via the startCircuit parameter, potentiometer positions are not reinstated.
First off, I just want to say I am glad this project was picked up again. The changes already make it work much smoother (Component organization, especially the crosshairs so it isn't difficult to line up wires, being able to drag components from switch nodes), and I can't wait to see how much better it gets.
Anyways, onto some of my suggestions. I definitely like some of the ideas listed by Harvie (Triacs, Isolators, full bridge rectifier, etc), and thought I might as well suggest a few of my own. Don't know if anyone else thinks they are particularly useful or how difficult they might be to implement, but here they are:
Fuses: I'm actually surprised this was never added. Just a simple component that breaks when a certain current is reached, for testing of protection circuits.
Varistor: Isn't exactly reproducible by anything else, and would add a lot more functionality to circuits that wasn't possible.
Cable: Don't know if anyone else would find this remotely useful, but I thought it could be in some instances. While the wire is a short, a cable could simply be a wire over a significant distance. While a resistor could easily be used in this instance, I just thought this could be a simple way to test wiring, by simply changing values of conductivity, radius and diameter to get different resistances (or even just have a drop-down list of different gauges and wire materials).
Multi-point switches: Not sure how difficult this would be to implement let alone deciding node placement, especially since the program is based off a square grid. This would be rotary switches, or switches that have a single input, with a changeable amount of outputs (say, between 3 and possible 10).
Interactive probe: Works like the place-able scope probe. The idea is you would place down a lead for a probe, and then the cursor would display a voltage difference between the placed probe and the component/node the cursor is hovering over. Could be enabled like a mode, where simply clicking again would replace the reference point.
Oscilloscope Tweaks: Includes showing time intervals of the tick marks, allowing for vertical tick-marks that show the voltage/current/power intervals for each oscilloscope separately (currently they are automatic, and that can get annoying sometimes when the graph is close to zero and indistinguishable, or when a sudden spike can blow the graph up)
External Waveform Input: This would probably be extremely difficult and/or time consuming to implement, but I will go ahead and suggest it. This would allow a custom waveform to be imported somehow, either from a certain file type or a built-in waveform editor. This could allow testing of more complex filtering circuits.
Logic Table: Could work similar to the built-in oscilloscope. With a series of logic inputs and logic outputs, a user could be shown a logic table (assuming there is no time dependence, other than a clock, which could simply all be connected as 1 logic input). Not sure how it could be implemented, but thinking the user could select all the desired logic inputs/outputs, the program would run through every possible combination and display a table. -Right after writing this, I figured this might be pointless, as there is plenty of software and programs already out there for pure logic circuits that it wouldn't be worth adding. However, I'll leave it here in case it might still be implemented.
Motors: (May be impossible to estimate, and completely dependent on the exact part) Would allow the user to input an RPM and stall torque, and see the effect a given load would have on the circuit (And see an estimated relationship between the output torque/rpm). Can help for designing motor/actuator interfacing and power management, especially H-bridges and such.
Internal Resistance: Just a simple tweak that would add an optional internal resistance to a voltage source. Not at all necessary, but convenient.
Solar/Light Dependent Circuits: A setting to set the ambient light (in lumens, lux, or whatever else would work best) could be added to options. This would allow for the application of photoresistors/transistors, solar cells, and testing them in circuits. The light created by components could be ignored.
Symbol Tweaks: First off, I think an option to edit grounds and toggle between a chassis and earth ground symbol (for each one seperately) could be added for easier identification. Also, like the european resistor toggle, an option could be added to show the bulk arrow on the mosfets.
Hopefully this list proves helpful in some way. I already had some second-thoughts about some of the ideas I posted, but I'll leave them in anyways just in case.
On page www.falstad.com/circuit/e-multivib-a.html the circuit explanation appears to have an error. First it says that the Q1 collector current discharges C1, then in the next paragraph it says that the collector current charges C1, which I believe is correct.
Variable capacitors and inductors would be incredibly useful for prototyping resonant circuits including VFOs, tuning circuits and transmatches, particularly amongst the ham radio crowd
As shown in the demonstration video, and LED in a DC circuit with 0 ohm resistance will draw an extremely large current.
https://youtu.be/o4iGcNkldEY?t=10m42s
An inductor in a DC circuit with 0 ohm resistance, the current drawn will keep increasing - beyond what could realistically be supplied. The same is true if the resistance is less than one ohm.
Perhaps a simple solution is to add a max current attribute to power sources - it could even graphically signal its at maximum current.
Below is a test example that can switch 0/0.5/1 ohm and LED / inductor.
$ 1 0.0000049999999999999996 382.76258214399064 34 5 50
v 176 448 176 320 0 0 40 5 0 0 0.5
w 720 384 720 544 2
w 720 224 720 384 1
l 528 560 624 560 0 1 -8.481532894164689
r 272 240 368 240 0 0.5
S 176 224 272 224 0 1 false 0
w 400 240 432 224 0
w 400 208 432 224 0
w 368 208 272 208 0
w 368 208 400 208 0
w 368 240 400 240 0
w 624 240 656 240 0
w 624 208 656 208 0
w 624 208 528 208 0
w 656 208 688 224 0
w 656 240 688 224 0
S 432 224 528 224 0 0 false 0
r 528 240 624 240 0 0.5
w 688 224 720 224 0
162 368 560 272 560 1 2.1024259 1 0 0
w 240 560 272 560 0
w 240 528 272 528 0
w 368 528 272 528 0
w 208 544 240 560 0
w 208 544 240 528 0
S 464 544 368 544 0 1 false 0
S 720 544 624 544 0 0 false 0
w 464 544 496 528 0
w 464 544 496 560 0
w 624 528 528 528 0
w 496 528 528 528 0
w 496 560 528 560 0
w 176 256 176 224 2
w 176 544 176 512 2
w 176 544 208 544 0
w 176 320 176 256 1
w 176 448 176 512 1
On Firefox 50.0.2, the circuitjs version currently running at Paut Falstad’s fails load any circuit, giving only the error message TypeError: ERROR.captureStackTrace is not a function
in the web console. The menu bar and UI is shown, but the circuit canvas remains white. The error messages is logged many times a second, possibly at every simulator tick.
something.txt
, like something.circuitjs
. I was calling them something.falstad.txt
for a while, but a real file extension would probably be better.I can see why making a double click on components as a way to edit them is a good idea. The problem is you might click on switches more frequently.
It's driving me crazy when I'm tweaking things that if I click on a switch to fast it popups up the edit dialogue. It's even more likely to happen with a momentary button.
add export as shortened (maybe with a local database hash:full_link instead external service)
This would make collaborative editing/pasting easier.
So I'm taking this class called ECE 3400 at Georgia Tech with professor Jennifer Hasler, and her class is about making analog systems with subthreshold mosfets. That's right, the leakage current isn't just a nuisance, but an important low power analog circuit building tool. I want to create some subthreshold-compatible mosfet elements for this project, and I just want to announce it here. Hopefully I can get it integrated in the original website, because your sim really helped me learn the basics.
Let me know if this is out of scope with the project!
I can use pots to simulate variable resistors by tying the ends together, but it would be nice to have a simpler device for variable resistors.
While we're at it, how about things like LDRs, PTC/NTC thermistors? They could be linear approximation or perhaps have inputs for approximate curves. Maybe use B parameter? Some datasheets seem to provide it.
https://en.wikipedia.org/wiki/Thermistor#B_or_.CE.B2_parameter_equation
http://reprap.org/wiki/MeasuringThermistorBeta
Or just point entry to approximate a curve. Take 5 - 8 points like these. There might even be some kind of java library for fitting curves to a set of points.
http://www.bapihvac.com/wp-content/uploads/2010/11/Thermistor_100K.pdf
Thanks,
-Alan
http://www.falstad.com/circuit/circuitjs.html used to work without any issues but in the last month (max time the effect started) the site is now way more resource intensive and generally unusable because of lag.
I've noticed that when I build a simple square wave inverter, the applet hiccups profoundly whenever the voltage reverses direction, and will under some circumstances slow to several seconds per frame.
I've reproduced this on the JS and Java versions in both Firefox, Chromium, and local Java. Below is the circuit in linkified form. I don't know that much about discrete electronics, but I have a lot of fun messing around in this rad little applet.
See for example:
$ 1 0.000005 10.20027730826997 50 5 50
159 640 240 640 304 0 20 10000000000
159 640 304 640 368 0 20 10000000000
w 624 272 624 336 0
i 528 368 528 240 0 0.01
w 640 368 528 368 0
w 528 240 640 240 0
In reality, I have an LED with 0.3 mA going through it, and another with 1.4 mA, and they're plenty bright. I can't simulate this, though, because in the simulator, it looks like you need 10 mA to get full brightness, and it quickly dims to invisibility below this:
Is there some way to make the LED more realistic? I'm not sure if this is because the brightness vs current curve should be nonlinear or if it's just efficiency differences between different LEDs, but I'd like to be able to have the LED at full brightness when the real LED is at "full" brightness, rather than using inaccurately small resistors in the simulation to make it visible, that then don't behave like reality.
Hello,
First off I want to say that I love this circuit simulator. It has served me very well during my time as a student. Keep up the great work!
Second, I know it was originally possible to download a version of the Circuit Simulator that could be used "offline". Is that still possible? I often find myself in situations where I may or may not have a reliable internet connection and I would love to be able to use your wonderful program in those cases.
Thanks again!
Hi thanks so much for helping in the other iFrame issue here: #3.
I want to be able to add a button on to my html page which effectively goes to and takes the link from "File" -> "Export as Link" and saves it to memory. I load the circuit in an iFrame method (described in the issue above):
<iframe src="{{pathPrefix}}/static/circuitjs/circuitjs.html" style="position: fixed; height:87%; width:100%; margin-top:-2.5%; border: none"></iframe>
I can then load the circuit right back if you left the page, without having to manually go to File and import it back.
The difficult solution appears to be modify the original Java before it is compiled in Eclipse with GWT, I have no Java experience. Would you know of any way to do grab the URL through javascript or even HTML or have done before?
Mannan
Is possible make integration with apache tomcat? Example of integration with apache tomcat?
Hello,
I´m sorry to bother but I found the app to be way to slow with a lot of parts.
Going to drop here my designed so that you can see the lag, I don't dared add more parts and im still like 20%.
Thank you and happy new year !!!
Buck, Boost, & Buck-Boost topologies!
Hello,
can you please set "z" key to be shortcut for zener? this bugs me quite often :)
Hi first off thank you very much for making this port. It works great! Is it possible to resize the simulation shown in the browser i.e. make it not full-screen? I can't seem to do it by adjusting the width/height in the iframe. Would this be done Java side before compiling?
Sincerely,
Mannan
Instead of stacking the scope vertically, like is done now, be able to show two signals in the same graph in the scope, much like a real oscilloscope.
I appreciate the audio output. Unfortunately I have to wait a long time to get a human-listenable length of audio (but of course that is entirely understandable considering that a javascript simulation is going to be orders of magnitude slower than real life).
However, the most common case of making audio circuits is dealing with a repeating waveform, and that repeating waveform is what I would want to listen to in a loop. If the repeating waveform changes, then I would want to hear that change. Would only need to wait for one period of the waveform to simulate before updating the looped audio.
Detect repeating waveform should be fairly straightforward. There is already a feature to detect the frequency of a waveform, so clearly there is already logic in the code to detect a repeating waveform. In case it is not there, could always have the user manually set a trigger voltage on the oscilloscope, in which case the start of the waveform would be determined by when the waveform crosses from the trigger voltage (could be set for positive slope or for negative slope). Maybe a scope trigger voltage is a separate feature request, but I bring it up because determining the repeating waveform would be a prerequisite for looped audio output, then would simply be a matter of copying the repeating waveform into an audio buffer that is continuously set to the browser's audio out.
I'd be happy to help out.
It would be really nice to have a proper icon based toolbar on the left side of the screen that performed the action of the draw menu. It would reduce the number of clicks needed and also allows for the currently selected tool to be shown at a glance rather than buried in menus.
It would also be nice to have a UI element in the bottom of the right side menu that shows the settings of the currently selected component rather than having a modal UI for it. Then if you select the drawing tool of an element it could show the same UI and allow you to preset the settings of that component before actually placing it. It would also be nice if middle clicking an existing component changed the active tool to that component and copied its settings so that copying component values is much quicker and easier.
It would be fun to play with programmable circuits. I imagine a microcontroller that interprets javascript code on every simulation iteration. It could have some GPIO pins, AD/DA pins accessible with simple syntax to interface with the rest of the circuit.
The +/- sign for the volt meter / scope probe seems wrong when used together with ground reference.
Please see the attached diagram. At the positive terminal of the battery, I attached a volt meter. At the negative terminal, I attached it to ground. However, the volt meter reads -5v.
I created another measurement that connect both the leads of the voltage probe. That reads correctly 5v. I also added a led to show the direction of the conventional current flow is correct (i.e. the battery terminal is +5v)
If I right click on a labeled node and choose "view in scope" I would expect it to work like an "analog output", but it does not.
Also I would think that labeled nodes in the scope would show their name, maybe at the top/middle of the scope? Maybe configurable? Right click on scope, "show name", "name location".
Side note: This is my favorite sim.
@pfalstad Somewhere in the recent changes (I guess due to the "wire" optimization) the sim has started drawing node dots in places where they shouldn't be (example attached). There is a node there, but it wouldn't be marked with a dot in a circuit diagram. I think this worked correctly before.
I haven't gone hunting for the fix yet, but I guess it might ring a bell with you and you could go straight to it.
I think this is a bug. When T input is high and clock rises, the output should toggle to low, but it doesn't always do that. Sometimes it waits until the next rising edge to toggle.
$ 1 0.000005 10.200277308269968 50 5 50
R 256 400 224 400 1 2 100 2.5 2.5 0 0.5
w 256 400 256 272 0
w 256 272 336 272 0
L 272 240 224 240 0 0 true 5 0
M 432 240 464 240 0 2.5
193 336 240 384 240 4 0
w 336 304 272 240 0
152 432 160 336 160 0 2 0
w 336 160 336 240 0
w 432 144 432 80 0
w 432 80 272 80 0
w 272 240 272 80 0
w 432 176 432 240 0
o 3 64 0 551 5 0.00009765625 0 -1
o 0 64 0 551 5 0.00009765625 0 -1
o 4 64 0 550 5 0.00009765625 0 -1
Tested that this happens in the original Java version, too.
Hello,
i think that copypaste between two different windows would be nice feature :-)
Also it would be really usefull if importing schematic from file would allow me to import one schematic to another (like copypaste, but from file), so i can import reusable circuit blocks to bigger composite circuit.
Another step might be adding support for real blocks: Eg. i make full bridge rectifier, add "pin components" with labels to it's endpoints and save it to file. Then i "import as block" which would show whole rectifier as single component with 4 pins. With connection being dynamic, so i can modify the block without breaking the super circuits that are using such blocks.
It is super annoying when simulating a circuit and then having it fail and needing to start over from the beginning at a lower step size. Not to say that this process might need to be repeated multiple times, taking exponentially more time to find a functional step size.
How about instead of having a static step size we could have a dynamically changing one. For example, for every nth step, we save the circuit state and upon entering a convergence failed situation, reset to last known good state, lower step size and try again.
Now, I don't know what the situation actually is but given that we can already export the circuit at any state, it shouldn't be too hard to implement this?
That's obvious, actually, but the point is that there may be ways to work around that. The ability to load circuits from a file on the local server is great, but what if a user just wants to link their circuit to your site? You can earn the adsense revenue... what do I care? How about an embedding option to load a circuit from a URL? Or via some other means? Perhaps your server could accept and forward post data?
Before I get to the point of this, I want to say that this project is incredible! I am an instructor for a theory course, and this project has inspired me to create a handout using the capabilities of this excellent project.
The only issue I am having is adding a "text box" with a value of just a plus sign. I can create it, and it saves in the code for the circuit, but will not load when pasting the code into the app, and even disappears from the code when trying to copy it again.
My course teaches electron flow, so it's important when I create a current source that I label the direction of electron flow, since the conventional flow symbol for current points in the opposite direction.
Thanks for the outstanding efforts put into this app.
Just want to report overall stability and accuracy deterioration with the latest update(-s).
I'm getting GA and GV of dormant current for one and not even stopping and/or resetting fixes it.
Could you make a separate page for the old stable version?
I'm trying to simulate a high-power buck converter, but realized that the MOSFETs have a very high on-resistance (I measured it to about 200ohm). The inductors I don't know the resistance of. It would be nice it the resistance value is at least documented, and at best, possible to set.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.