pfalstad / circuitjs1 Goto Github PK
View Code? Open in Web Editor NEWThis project forked from sharpie7/circuitjs1
Electronic Circuit Simulator in the Browser
License: GNU General Public License v2.0
This project forked from sharpie7/circuitjs1
Electronic Circuit Simulator in the Browser
License: GNU General Public License v2.0
what is the difference between the labelled nodes in the following link?
look at the nodes labelled out on the right hand side, all the the nodes have a slightly different font size and manipulating and placing them behave differently and fail to snap properly to the grid.
this usually happens if you copy and paste circuits from the circuit menu at the top or from within your Subcircuits examples on the top menu, the labelled nodes appear to be different from the labelled nodes in the right click and labelled node option
is it possible to add the seconds to the auto generated save as filename?
if you have multiple tabs open and you save all your work consecutively one file after another at the same time, all the files that fall within the same current minuet get given the same filename like
circuit-20240421-2358.circuitjs.txt
if the filename was
circuit-20240421-235800.circuitjs.txt
this would not happen
side note, is there any need for "circuit" at the start and "circuitjs" at the end, this only generates over length filenames with little benefit i can see, one or the other would be nice, like
circuitjs-20240421-235800.txt
20240421-235800.circuitjs.txt
probably the first as that would group all the circuit files alphabetically together
I changed a few of the color options (of voltage, current, etc.) and there is no obvious way to reset the colors to their defaults. It didn't reset after refreshing and the only way to get the colors' values was to find them on another device.
Because the pins of subcircuits are made of named nodes, they are all he same if you have multiple instances.
They behave like they are connected parallel.
Terminals of a subcircuit must be independent of other instances. They should be build of an element say "pin" which behaves like a normal unnamed node.
Observed behavior:
When inserting / resizing a tristate buffer, it is possible to give it a size that places the middle control terminal halfway between grid points, making it impossible to connect the middle terminal. If the buffer is sized using the default grid size, and then "small grid" is enabled, the middle pin of buffer becomes accessible. However, with "small grid" enabled, it is then possible to resize the buffer such that the middle pin becomes inaccessible even with the smaller grid size.
Expected behavior:
The resize routine for the tristate buffer only allows sizes that place all pins at accessible locations for the user's currently-selected grid size. This could be achieved by snapping the width of the buffer to every other grid point instead of every grid point.
Examples:
Do you think it would be difficult to implement interruptions?
For example at pin RISING, FALLING or LOW.
Thanks
Do you plan to provide a Mac version for Apple Silicon (ARM) ?
The app currently runs under Rosetta.
Thanks in advance !
Right. As we all know, there's no such thing as free energy. Conservation of energy is a harsh mistress.
Which is why this simple circuit, which contains no power source but generates infinite voltage, seems like it has to be a bug.
In case the link breaks, this is literally just an LM324 "Op Amp (real)" with its supply voltage pins connected together:
I was trying to simulate this circuit (source), which relies on the current path through the IC to drain the caps when no voltage source is connected. Since that required a model for the inverter that includes simulation of the supply voltage, I was using the LM324 "Op Amp (real)". Suffice to say, the "phantom" voltage source in the LM324 model interfered with my simulation attempt.
I want to customize the color of the wire. If there is no current passing, it is gray. If there is current passing, I want to customize the display color. How can I achieve this? Thank you!
I work with MCUs like the ESP32, STM32 and NXP series. I mostly work in MicroPython as it is easier to prototype because of it compiling at runtime. One of the things that I have not come across is a simulator that is geared in a more advanced manner. I have found ones that use Blockly which is geared more for the newbie.
I work with LVGL graphics library quite a bit and they have put together a means of compiling their software with MicroPython and because MicroPython has the ability to be compiled into a javascript they have put together a pretty decent simulator but it is missing the ability to add functional circuits.
You can check out the simulator they have here.
I know your circuit simulator can be programmatically altered using websockets and I am interested in knowing more about the functionality.
This is what I am thinking. The user would be able to select an MCU they want to develop for from a list. This would then launch MicroPython with the proper modules loaded into it. On startup it would make a websocket connection to the circuit simulator and pass information to it about the MCU. The user would be able to run MicroPython code that would be the same as if they had the code loaded onto an actual MCU but instead it would be talking to the circuit simulator to get or set GPIO states.
Is that something that is possible?
can you add div button in circuit1js.html here
for undo (always show)
Standard differentiator circuit, just different values than the example. Scope is of the op amp output. When I toggle the logic input, I expect a sharp pulse in the opposite direction from the op amp and then silence. Instead it freaks out.
Interesting to note that when I bring up the example (5k resistor, 2µ cap) and change the triangle wave to square wave, it does not freak out like this. When I change it to 1k and pulse wave, it freaks out when it's 5V and ok when it's 0V
Hello,
the currently available Multiplexer is digital-only: the output is the "High Logic Voltage" if the selected input pin's value is True.
It would be nice to have an analog option, that would basically transfer the selected input pin's voltage/current to the output.
Maybe something like this in MultiplexerElm.java
, though I'm not sure how the internals of CircuitJS work:
class MultiplexerElm extends ChipElm {
final int FLAG_INVERTED_OUTPUT = 1<<1;
final int FLAG_STROBE = 1<<2;
final int FLAG_ANALOG = 1<<3;
...
int getSelectedValue() {
int selectedValue=0;
for (int i = 0; i != selectBitCount; i++)
if (pins[outputCount+i].value)
selectedValue |= 1<<i;
return selectedValue
}
void execute() {
int selectedValue = getSelectedValue();
if (hasFlag(FLAG_ANALOG)) {
double current = pins[selectedValue].current;
if (strobe != -1 && pins[strobe].value)
current = 0;
pins[outputPin].current = current;
} else {
boolean val = pins[selectedValue].value;
if (strobe != -1 && pins[strobe].value)
val = false;
pins[outputPin].value = val;
if (hasFlag(FLAG_INVERTED_OUTPUT))
pins[outputPin+1].value = !val;
}
}
I hope this makes sense!
(And congrats for this excellent software!)
I'm unable to zoom or pan with two fingers on mobile, I'm able to zoom and pan on the side panel or if I open any menu like long press to open the add menu, but not on the circuit itself.
Also I've noticed that I lose the ability to edit the circuit once I start zooming or panning, when I reload the page I'm able to edit, when I start to zoom, the screen shrinks and I lose the ability to edit.
Tested on both Chrome & Firefox
Android 12
Xiaomi Redmi Note 9 Pro
Hi, i noticed a strange behaviour:
there seems to be some "interconnection" between coil and contacts of a relay ....
can be reproduced with simple circuit attached.
relay issue.txt
Hi, i an new here and don’t know exactly how to raise a requests
I think the formula for acceleration in rotational motion is
speed += sim.timeStep * (torque- b * speed)/J ;
that should be in ThreePhaseMotorElm.java in line 192
Thanks
I have an audio circuit that I want to run but I do not need to see the UI updating, so I would like to have the simulation run as fast as possible without losing any accuracy in the audio. Otherwise I have to wait a long time to get 1-2 seconds of audio samples.
with the mouse it would be ctrl + left click for dragging pops up the context menu that is normally under right click. Because the context menu is over the point you want to drag, it does not work or very inconvenient with many try and error.
I thing you should add a set, reset button for many bits latch.
I've been using this simulator since way back when it was still Java. Nice to see it still going strong. One thing that surprises me is that in the examples, no one has submitted any examples for three-phase. I would like to rectify this. I don't know if I should be submitting it here or to Iain, but I'll post it here for now and if I hear otherwise, I'll also submit it to him. For now, you seem to be the one updating more frequently. It isn't letting me attach the text file, so I'll post it here directly. This one is a really basic wye-wye, which I like because the source doesn't require any extra resistors for the simulator to not break. If you're interested, it would not be hard for me to build other examples with deltas, wyes, xfmrs, etc. My only complaint is that I cannot do neat things like additive vector plots to show neat stuff like rotating magnetic fields.
$ 1 0.0000049999999999999996 4.43302224444953 45 169 50 5e-11
v 80 208 80 144 0 1 60 169.705627485 0 0 0.5
v 80 208 32 256 0 1 60 169.705627485 0 2.0943951023931953 0.5
v 80 208 128 256 0 1 60 169.705627485 0 4.1887902047863905 0.5
r 384 208 384 144 0 1000
w 80 144 384 144 0
r 384 208 336 256 0 1000
r 384 208 432 256 0 1000
w 128 256 336 256 0
w 32 256 32 288 0
w 32 288 432 288 0
w 432 288 432 256 0
w 80 208 192 208 0
w 384 208 288 208 0
s 192 208 288 208 0 0 false
x 111 133 158 136 4 12 Phase\sA
x 31 304 79 307 4 12 Phase\sC
x 138 250 185 253 4 12 Phase\sB
x 220 224 308 227 4 12 Neutral-Return
x -34 349 512 352 4 24 3\sPhase\sWye-to-Wye\sBalanced\sResistive\sLoad
o 1 64 0 4098 320 0.2 0 6 1 3 0 0 0 3 2 0 2 3
o 5 64 3 4102 320 0.2 1 7 5 0 5 3 3 0 3 3 6 0 6 3
please can you disable the Mouse Wheel adjusting Resistor and Capacitor Values? it is extremely annoying when you try to zoom in and out and the scroll wheel to zoom in and out randomly adjusts circuit values ruining your work if the mouse happens to be in range of a component
Over the time using the app I have created a number of subcircuits by selecting "Save Across Sessions". Problem is that the list is now relatively long in the Draw->Subcircuits menu, and I would want to remove some of them that I do not longer use or have misspelled names. How can I accomplish this? Thanks
I am working on some electrical engineering homework regarding switched capacitor circuits. The lectures show simulations using pspice or Cadence, tools only available at the university and that are not easily accessible.
The homework asks us to implement an inverting 1st order low-pass filter replacing the resistors by switched capacitors. I did just that on CircuitJS.
Project link: Falstad CircuitJS | 1st order 10KHz inverting low-pass filter using non-inverting parasitic-insensitive switched capacitors
Analyzing switch capacitors can be done using discrete-time analysis or using the flow-graph (block diagram) method.
By using discrete-time analysis, which is the preferred in order to learn how are charges redistributed between the different capacitors in the circuit.
This method is not always intuitive, to solve this, I've used circuitJS to better understand the physics of the circuit, but the main point which is observing the charge of elements in the circuit is not available yet.
For this reason, I request to be added in the "scope properties" a plot for "show charge". It would essentially be the integral of current over time.
I set out to analog multiplexer 74HC4052 as I need it myself, and to address issue #76 by the way. In the datasheet, 74HC4052 recognizes HIGH for logic (aka VIH) depending on the VCC:
Is there a way to make logic gates inside subcircuits use specific voltage level?
For now it seems like I need to make multiple versions depending on (ideal) VCC I want to target. While it's trivial to me to edit the TXT file (replacing 5\n
to 3.3V\n
) , it's a bit annoying.
In the following example OUT1 of the Comparator displayed to a graph has a blip in time with the Oscillator switchover
is this something i do not understand or some kind of bug.
other than the connection via VCC from NOT EAVEN the same voltage source as VCC2, i do not understand how the Oscillator can affect the Comparator output
When I have a diagonal line on my circuit it gets dragged whenever I click and drag in the rectangular zone around it (the rectangle whose diagonal is the drawn line). I expect to drag the line only when I click and drag the line itself (just like a wire). Not when I misclicked some component from any side of the line.
Same issue with the drawn box. I expect to drag it only when I click and drag its border, not when I misclick some component inside the box.
Hello,
Week ago or so I've discovered weird behaviour of transistors while playing with circuit known also as joule thief. I wanted to experiment a bit with it and added simple current source made from two PNP transistors and three four resistors. While joule thief part is not oscillating, current source works as expected, otherwise it just starts giving abnormal high current pulses even, if I disconnect it from joule thief part and switch back to resistor. I though problem was with web browser (JS engine?), but this happens on MS Edge and Firefox.
I know this simulator is not best to do such things, but it's still very useful and I like to play with it a lot.
I'm attaching screenshots and source sketch file for reproduction:
Greetings,
Sebastian.
I was testing a circuit built from many relays and diodes. The simulator uncovered an unexpected failure case where the back emf from the coil of one relay activated another. I was (and still am) impressed at the simultor finding that behaviour, but have realised that the behaviour would very likely not occur with real relays: the transients from the switch off are only momentary, too short a period to cause any significant movement of the switch. It would be useful to be able to specify delays for both parts of the switching action.
For a long time, issues were supposed to be put on the other repository, should people be redirected here instead?
I cannot find any setting anywhere to change Scope Vertical Scale divisions from 8 to 10,
Im sure there is a logical reason why 8 divisions is useful to someone but dividing any base 10 number like 1 volt into peace's would be much more useful to me as whole numbers or single decimal placed numbers in this instance,
like 0.1v 0.2v 0.3v NOT 0.125v 0.25v 0.375v
Hello,
I was under the impression that the "Reset" button should reset the circuit to the state when the page was loaded.
With that said, the "delayed buffer" example cannot be reset by using the "Reset" button.
One has to reload the page to see the delay between input and output signal.
This is the link to the example: http://www.falstad.com/circuit/e-delayrc.html
Hello,
I stumbled across an issue with the 555 timer. It appears that if the "gnd" pin is connected to a voltage other than 0V, the component misbehaves.
Take a look at the attached screenshot: two oscillators with the exact same components and configuration and both supplied with 5V, except that one uses a positive supply (+5V / 0V) while the other uses a negative supply (0V / -5V). One would expect both circuits to behave the same, except that the voltage levels are shifted. Instead the one with negative voltages does weird things.
(please ignore the long "off" time in the upper scope trace at the beginning. I was messing around with the time step setting).
Hello, I'm attaching the text that illustrates a non-inverting op amp circuit with a phase shift of 180* degrees on the first scope plot, and a correct in-phase non-inverting op amp circuit on the second scope plot. It seems that the op amp model with the negative terminal on top consistently causes this issue. Thanks for your consideration.
Platform is Chrome 108.0.5359.125, Windows 10.
$ 1 0.000005 30.13683688681966 50 5 50 5e-11
w 528 128 528 192 0
w 432 128 432 176 0
g 432 64 432 32 0 0
r 432 128 432 64 0 10000
r 432 128 528 128 0 10000
a 432 192 528 192 8 15 -15 1000000 3.1432826843313153 3.1433455499850016 100000
w 432 208 368 208 0
v 368 208 368 272 0 1 40 5 0 0 0.5
g 368 272 368 288 0 0
g 848 256 848 272 0 0
w 848 48 848 112 0
w 752 48 848 48 0
r 848 256 848 192 0 10000
r 848 192 992 192 0 10000
w 992 128 992 192 0
a 848 128 992 128 9 15 -15 1000000 -3.143282684331315 -3.1433455499850016 100000
w 848 144 848 192 0
g 752 128 752 160 0 0
v 752 128 752 48 0 1 40 5 0 0 0.5
o 7 64 0 20482 10 0.1 0 4 7 3 0 0 0 3 Bugged
o 11 64 0 20482 10 0.1 1 4 11 3 14 0 14 3 Correct
is it possible to improve the "Outputs and Lables / Box" so be useful for enclosing parts of a circuit
if you put a box around your circuit, it is then not possible to drag select any of the components within the box as it drag selects the box instead.
example attached, please try and select both of the capacitors in the link below and move then without moving the box
selection of the box itself should only happen if the mouse is actual on the frame border itself NOT anywhere within the frame.
Whenever I scope something with a waveform faster than ~30KHz it often stops displaying the frequency as text.
Other times it will display frequencies ABOVE ~35KHz.
Adding audio sources with 48KHz sample rates triggers the option to increase horizontal scale resolution, which is sometimes helpful, but I'm not sure if the value propagates to existing scopes.
options>other options> Auto-Adjust Timestep / Minimum time step size (s)
Doesnt seem to help, and I'm not sure if its setting always propagates either.
I'm an electronics noob who is trying to see what I remember, so I tend to work around the intermittent frequency display, and havent done any empirical testing on the problem, so maybe its just me, but it feels like an intermittent bug.
Hi. I am teaching electricity to my high school students.
I tried connecting 3 circuits to a 5V DC voltage source (attached as images).
The first has a resistor, an red LED and a 1N4004 diode in series (forward biased). Voltage drops look fine.
The second is the same but the LED is reversed. Voltage drops look fine still.
The third is the same as the first one, but this time the diode is reversed. This time, there is only 4.488 volts across the reversed diode, not 5 volts as I would expect (like we get in circuit 2).
Am I missing something, or is the simulation wrong?
Thanks,
Steve
$ 1 0.000005 54.00526672067058 47 5 50 5e-11
c 176 64 224 64 2 0.000009999999999999999 1.0794454695837479 5
214 224 32 320 32 0 2 abs(dadt)
p 320 32 320 64 1 0 0
l 176 32 224 32 0 1 -0.014894344722485907 0
w 176 32 176 64 0
403 384 16 512 80 0 2_64_0_4098_5_0.1_-1_1
I'm using CircuitJS a lot in lectures I'm giving. One issue that was raised to me is that for people with color deficient vision, colors might not be clearly discernible. While I can (and do) use a setting of positiveColor and negativeColor, the neutralColor is fixed at gray, which is not an ideal choice there.
CircuitElm already supports the neutralColor
, but the interface is not exposed yet. I propose exposing it via the query parameters just like the other colors (positive, negative, select, current) so that it becomes easier to generate a variant that is well-readable for people with color deficient vision.
I could give that a shot once the semester is over and I have a bit of free time. Seems easy enough. Would you be interested to include this when I file a PR?
When my circuit has a potentiometer with some non-central wiper position set its position is slightly off the set value on every save-open cycle.
How to reproduce:
Every save-open makes the wipers of the potentiometers a little off.
It would be very nice to have (mechanically) latching relays, e.g. for relay-based registers that don't draw power to hold a value and are therefore non-volatile (unlike electrically latching relays).
I use circuit.js in iframes on my reveal.js slides (https://virtlab.fakultaet-technik.de/Vorlesungen/Digital2.html). Fast slide changes with the cursor keys result in the message "Can't load circuit list!". Please add a query parameter to suppress these messages.
As the title says. If you have a contact linked to a relay that's far away, its not obvious at a glance whether it's NC or NO without opening the properties dialog, which makes circuits harder to understand. Maybe draw a bar over the linked relay name to indicate an NC contact? There's lots of symbols in use for relay contacts, but that seems like the easiest way to do it.
I'm trying to implement a few features that I hope you would find useful. However, the current indentation style with tabs vs. spaces appears rather random (see attached screenshot from CirSim.java). It looks okay when setting the Tab width to 8 and indenting by 4 spaces, but sadly that is not possible in VSCode right now (microsoft/vscode#5394), in contrast to e.g. vim. :-(
@pfalstad: Do you prefer any specific indentation style for new contributions? I understand that unifying all the old code would mess up the git history, so that is out of scope. In the absence of any guidelines I would use spaces-only for new code because editors can't mess that up and using tabs consistently leads to messes.
If I put a capacitor between positive and negative of a DC voltage source, I cannot start the simulation. It keeps complaining that there's a capacitor loop without a resistor. But decoupling caps don't need a series resistor, as far as I know. Granted, I'm not an electrical engineer, but every example I can find on the web always has them directly between + and - (which makes sense to me).
Example circuit (I use a simple resistor as a load, but imagine it's something that requires a stable voltage, like a µC):
$ 1 0.000005 10.20027730826997 50 5 43 5e-11
v -352 96 -352 -64 0 0 40 5 0 0 0.5
w -352 -64 -288 -64 0
w -352 96 -288 96 0
c -288 -64 -288 96 0 0.00001 0 0.001
w -288 -64 -224 -64 0
w -288 96 -224 96 0
r -224 -64 -224 96 0 1000
I apologise if my lack of electronic knowledge is the issue here, but seems to me that this circuit should work. I actually built it on a breadboard, and the universe didn't collapse. ;)
In latest master branch,after build get below outputs
Uncaught Error: java.lang.StringIndexOutOfBoundsException: Index: 0, Size: 0
at V5e_g$.BC_g$ [as createError_0_g$] (Throwable.java:116:1)
at V5e_g$.MC_g$ [as initializeBackingError_0_g$] (Throwable.java:108:1)
at V5e_g$.uC_g$ (Throwable.java:68:1)
at V5e_g$.aD_g$ (Exception.java:29:1)
at V5e_g$.iD_g$ (RuntimeException.java:29:1)
at V5e_g$.VRe_g$ (IndexOutOfBoundsException.java:29:1)
at new V5e_g$ (StringIndexOutOfBoundsException.java:30:1)
at ysg_g$ (InternalPreconditions.java:487:1)
at Lsg_g$ (InternalPreconditions.java:475:1)
at d0e_g$ (String.java:359:1)
at L1e_g$ (String.java:358:1)
at g2d_g$.w4d_g$ [as processSetupList_0_g$] (CirSim.java:3788:1)
at fDg_g$.hDg_g$ [as onResponseReceived_0_g$] (CirSim.java:3756:1)
at umc_g$.xmc_g$ [as fireOnResponseReceived_0_g$] (Request.java:227:1)
at jnc_g$.knc_g$ [as onReadyStateChange_0_g$] (RequestBuilder.java:412:1)
at XMLHttpRequest.<anonymous> (XMLHttpRequest.java:329:1)
at uL_g$ (Impl.java:299:1)
at xL_g$ (Impl.java:358:1)
at XMLHttpRequest.<anonymous> (Impl.java:78:1)
The problem occurs on
line
is empty String.if (line.isEmpty() || line.charAt(0) == '#')
, it's gone.
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.