Coder Social home page Coder Social logo

pfalstad / circuitjs1 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sharpie7/circuitjs1

1.7K 64.0 286.0 3.69 MB

Electronic Circuit Simulator in the Browser

License: GNU General Public License v2.0

Java 72.85% HTML 2.88% PHP 0.05% JavaScript 23.59% Python 0.34% Shell 0.15% CSS 0.14%

circuitjs1's Introduction

CircuitJS1

Introduction

CircuitJS1 is an electronic circuit simulator that runs in the browser. It was originally written by Paul Falstad as a Java Applet. It was adapted by Iain Sharp to run in the browser using GWT.

For a hosted version of the application see:

Thanks to: Edward Calver for 15 new components and other improvements; Rodrigo Hausen for file import/export and many other UI improvements; J. Mike Rollins for the Zener diode code; Julius Schmidt for the spark gap code and some examples; Dustin Soodak for help with the user interface improvements; Jacob Calvert for the T Flip Flop; Ben Hayden for scope spectrum; Thomas Reitinger, Krystian Sławiński, Usevalad Khatkevich, Lucio Sciamanna, Mauro Hemerly Gazzani, J. Miguel Silva, and Franck Viard for translations; Andre Adrian for improved emitter coupled oscillator; Felthry for many examples; Colin Howell for code improvements. LZString (c) 2013 pieroxy.

Building the web application

The web application can be compiled and run locally using Eclipse, or in a cloud development container like Github Codespaces or gitpod.io. Both of these services provide a number of free usage hours every month. You can also use the cloud tools from ./dev.sh on your local Linux machine or in a local docker container.

Development using Eclipse

The tools you will need to build the project are:

  • Eclipse, Oxygen version.
  • GWT plugin for Eclipse.

Install "Eclipse for Java developers" from here. To add the GWT plugin for Eclipse follow the instructions here.

This repository is a project folder for your Eclipse project space. Once you have a local copy you can then build and run in development mode or build for deployment. Running in super development mode is done by clicking on the "run" icon on the toolbar and choosing http://127.0.0.1:8888/circuitjs.html from the "Development Mode" tab which appears. Building for deployment is done by selecting the project root node and using the GWT button on the Eclipse taskbar and choosing "GWT Compile Project...".

GWT will build its output in to the "war" directory. In the "war" directory the file "iframe.html" is loaded as an iFrame in to the spare space at the bottom of the right hand pannel. It can be used for branding etc.

Development using cloud containers

  1. Install Visual Studio Code and the appropriate remote extension: either Gitpod Extension or Codespaces Extension.
  2. Open your fork of the circuitjs1 repository in your chosen provider's dev container.
  3. This should open a new tab in your browser showing VS Code. Click in the green button in the bottom left corner, then select "Open in VS Code Desktop" in the popup menu that opened. Click "Allow" in all URL popups and authenticate using github if asked.

Once you have successfully connected your local VS Code to the remote workspace, you should be able to see the content of the remote container in your local VS Code. You can now continue with the setup:

  1. Open a shell inside the dev container by pressing Ctrl+Backtick or pressing F1 and typing "Create new Terminal".
  2. Make sure you are in the folder /workspaces/circuitjs1 inside the container (necessary only once per newly created container).
  3. Run ./dev.sh setup to install all development dependencies, including GWT and Java.
  4. Run ./dev.sh start to start the web server and the GWT code server. This will start two services: http://localhost:8000 and http://localhost:9876.
  5. Make sure both port and 8000 and 9876 are forwarded in the "Ports" tab (next to "Terminal").
  6. If you edit a Java file in VS Code and reload http://localhost:8000, it should recompile the file automatically. It will then load the compiled JavaScript and the corresponding source map from the code server running on http://localhost:9876. You should be able to see the your changes in the web application.

Note: When running the web application server inside a remote dev container, port forwarding is necessary in order to access the remote server from your own computer. This port forwarding is provided by Visual Studio Code running on your local computer.

Theoretically, it would be possible to use the browser-based VS Code interface. However, both Gitpod and Codespaces map forwarded ports to different domain names instead of different ports, which confuses the GWT code loader. It is possible to fix this by live-patching the serverUrl variable in circuitjs1.nocache.js using a custom HTTP server, but it also requires setting the port visibility to "Public" to avoid CORS errors due to redirects. Using a local installation of VS Code is much simpler.

Deployment of the web application

  • "GWT Compile Project..." as explained above or run ./dev.sh compile. This will put the outputs in to the "war" directory in the Eclipse project folder. You then need to copy everything in the "war" directory, except the "WEB-INF" directory, on to your web server.
  • Customize the header of the file "circuitjs1.html" to include your tracking, favicon etc.
  • Customize the "iframe.html" file to include any branding you want in the right hand panel of the application
  • The optional file "shortrelay.php" is a server-side script to act as a relay to a URL shortening service to avoid cross-origin problems with a purely client solution. You may want to customize this for your site. If you don't want to use this feature edit the circuitjs1.java file before compiling.
  • If you wish to enable dropbox loading and saving a dropbox API app-key is needed. This should be edited in to the circuitjs.html file where needed. If this is not included the relevant features will be disabled.

The link for the full-page version of the application is now: http://<your host>/<your path>/circuitjs1.html (you can rename the "circuitjs1.html" file if you want too though you should also update "shortrelay.php" if you do).

Just for reference the files should look like this

-+ Directory containing the front page (eg "circuitjs")
  +- circuitjs.html - full page version of application
  +- iframe.html - see notes above
  +- shortrelay.php - see notes above
  ++ circuitjs1 (directory)
   +- various files built by GWT
   +- circuits (directory, containing example circuits)
   +- setuplist.txt (index in to example circuit directory)

Embedding

You can link to the full page version of the application using the link shown above.

If you want to embed the application in another page then use an iframe with the src being the full-page version.

You can add query parameters to link to change the applications startup behaviour. The following are supported:

.../circuitjs.html?cct=<string> // Load the circuit from the URL (like the # in the Java version)
.../circuitjs.html?ctz=<string> // Load the circuit from compressed data in the URL
.../circuitjs.html?startCircuit=<filename> // Loads the circuit named "filename" from the "Circuits" directory
.../circuitjs.html?startCircuitLink=<URL> // Loads the circuit from the specified URL. CURRENTLY THE URL MUST BE A DROPBOX SHARED FILE OR ANOTHER URL THAT SUPPORTS CORS ACCESS FROM THE CLIENT
.../circuitjs.html?euroResistors=true // Set to true to force "Euro" style resistors. If not specified the resistor style will be based on the user's browser's language preferences
.../circuitjs.html?IECGates=true // Set to true to force IEC logic gates. If not specified the gate style will be based on the user's browser's language preferences
.../circuitjs.html?usResistors=true // Set to true to force "US" style resistors. If not specified the resistor style will be based on the user's browser's language preferences
.../circuitjs.html?whiteBackground=<true|false>
.../circuitjs.html?conventionalCurrent=<true|false>
.../circuitjs.html?running=<true|false> // Start the app without the simulation running, default true
.../circuitjs.html?hideSidebar=<true|false> // Hide the sidebar, default false
.../circuitjs.html?hideMenu=<true|false> // Hide the menu, default false
.../circuitjs.html?editable=<true|false> // Allow circuit editing, default true
.../circuitjs.html?positiveColor=%2300ff00 // change positive voltage color (rrggbb)
.../circuitjs.html?negativeColor=%23ff0000 // change negative voltage color
.../circuitjs.html?selectColor=%2300ffff // change selection color
.../circuitjs.html?currentColor=%23ffff00 // change current color
.../circuitjs.html?mouseWheelEdit=<true|false> // allow changing of values by mouse wheel
.../circuitjs.html?mouseMode=<item> // set the initial mouse mode.  can also initially perform other UI actions, such as opening the 'about' menu, running 'importfromlocalfile', etc.
.../circuitjs.html?hideInfoBox=<true|false>

The simulator can also interface with your javascript code. See war/jsinterface.html for an example.

Building an Electron application

The Electron project allows web applications to be distributed as local executables for a variety of platforms. This repository contains the additional files needed to build circuitJS1 as an Electron application.

The general approach to building an Electron application for a particular platform is documented here. The following instructions apply this approach to circuit JS.

To build the Electron application:

  • Compile the application using GWT, as above.
  • Download and unpack a pre-built Electron binary directory version 9.3.2 for the target platform.
  • Copy the "app" directory from this repository to the location specified here in the Electron binary directory structure.
  • Copy the "war" directory, containing the compiled CircuitJS1 application, in to the "app" directory the Electron binary directory structure.
  • Run the "Electron" executable file. It should automatically load CircuitJS1.

Known limitations of the Electron application:

  • "Create short URL" on "Export as URL" doesn't work as it relies on server support.

Thanks to @Immortalin for the initial work in applying Electron to CircuitJS1.

License

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.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

circuitjs1's People

Contributors

adrians avatar azambon avatar bartsimp avatar colinhowell avatar dependabot[bot] avatar ericfont avatar ferrybig avatar fritzw avatar gnbl avatar irichter avatar issalig avatar johndoe31415 avatar jopdorp avatar kamarado avatar liuxilu avatar mervill avatar nulldg avatar pfalstad avatar programmerjake avatar seva77 avatar sharpie7 avatar tangdou1 avatar vitorsgoncalves avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

circuitjs1's Issues

Annoying unintentional drag of the drawn box or line

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.

feature: analog multiplexer

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!)

555 timer with non-ground negative supply

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.
Screenshot

(please ignore the long "off" time in the upper scope trace at the beginning. I was messing around with the time step setting).

Here's the link to that sample circuit: https://www.falstad.com/circuit/circuitjs.html?ctz=CQAgjCAMB0l3EwwEx2QdnQZkgDmQGwCcR6IArJBRVeQKYC0YYAUGAeSACxe4ip8uBLvzwgC3aCWklK8BCwDG3diCxYJXVVzhRwjMmGjZIwyFlyR0RJDzIwFAJxUT2VLROQ69XdPBYA7hTont7kRMj83pCBFBFRtPFuULHhkcnkYOkEVDFBmdm0WeAhKfnFyR7gOSnOVV7uqjgiVEhwsTx8DS4JZdy8apAiVc19I0M96hJ5kxr9fFN95DxqBHzLw7ozG9y6VTq5sTaRByDouJuHQcerfDenM+cii7hNc48XgyJPau+xrxJRj9RjMAb0ft0Ys4Id5gRNWv4grhLNUqD9kqCUclka1SjMiDVsViaviat0Ca0SUcVuSydEWNDPskYbluH52spgXMfg99AwyFxoFlwuYQgQwBpkEROA5IKx2JwwQIQLgsJFldMWBp1qUMJEcl10JFDtqQEQaUazbrLYcAEo9SqqLJ8VlhPS5aDkFj29E1dHIF0+VnBz3enqnfZq927aMer0+z6nHlR11UBgy92hgD2gxVQaI63E0Ba-FzWBYOawEEDWSl7ikMlk8gQUFgLaokSrahYQA

CCVS `abs(dadt)` doesn't work

$ 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

The relay component switches to the intermediate state immediately giving incorrect results for some circuits.

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.

Abnormal BJT current source behaviour with oscillating transformer in circuit

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:

1
2
3
fail_src.txt

Greetings,
Sebastian.

Simulation wrong for reverse diode?

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

circuit1
circuit2
circuit3

op amp freaking out in differentiator

image

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

Relay contacts should indicate whether they are NC or NO

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.

Scope Vertical Scale

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

Zooming and panning doesn't work on mobile

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.

Screenrecorder-2023-05-15-11-35-10-826.mp4

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.

Screenrecorder-2023-05-15-13-17-39-783.mp4

Tested on both Chrome & Firefox
Android 12
Xiaomi Redmi Note 9 Pro

Non-inverting op amp phase incorrect

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

Labeled Nodes

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

https://www.falstad.com/circuit/circuitjs.html?ctz=CQAgzCAMB0l3BWEBGGAmOaDsWyQBxoBsAnCViAhEgpJQKYC0yyAUAO7iQAsIRveXsjT4orACZchI8EVHISaEEvH0AZgEMArgBsALhKnKERWfMXKQqzboOS03OgqWCUMleu37DDpxddoJpbWXgacAUGuYAhKkBxmKBbcyKbOYhgUrvxGKSC8AJYAdgA6AA6sGUbRLjx5cHkgRYwVkBTJqUnc5kq8APZaBpVY3NKiOKkyvADyAKoAKvFEDihYpibyq2KcRFhKyCN8uyjC6a18BCumRBdoYD0gAOIAcgAii0f7vDt711vn8idvsdYi0KOtLpQwKlNrwAJJPNCgyhyFAHKipA5wp5sbYXFhKa7yGRxNTI+QHQmogR7aBIGCQRFTEDDXgkUzjEBsqBiUlEO4QoHITb85C0qCwRHbD4nFnA5RIylBSnLXgANQAwuqFR8LEC0CrHq9WAAnf7Is347moeCsUldOhgKGUDDgJ0isX0xFDA6WjmWvoDVhAA

Expose interface of neutralColor

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?

Submitting new circuits

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

Apple Silicon (ARM) version ?

Do you plan to provide a Mac version for Apple Silicon (ARM) ?

The app currently runs under Rosetta.

Thanks in advance !

CirciutJS 2.8.1js run simulation not smooth in some circuits.

Hi, I'm not sure if it's a bug or not. But when I simulate the "True RMS Converter" circuit. It not smooth, when compared to the old version(2.7.6js). Is there anything that needs to be set for the new version?

the left picture below is version 2.7.6js and the right picture is version 2.8.1js

CirchitJS

I want to customize the color of the wire.

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!

Feature- Latching Relays

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).

latch buttons

I thing you should add a set, reset button for many bits latch.

interrupts on avr8js

Do you think it would be difficult to implement interruptions?
For example at pin RISING, FALLING or LOW.
Thanks

BUG: Potentiometer wiper position change on file open (or on file save?)

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:

  1. Create a blank circuit
  2. Place potentiometer there
  3. Make its total resistance, say, 10k
  4. Set its wiper to, say, 7.6k/2.4k
  5. Save the circuit to a file
  6. Open the file
  7. See the wiper position of the potentiometer is 7.5k/2.5k
  8. Save again
  9. Open again
  10. See the wiper position of the potentiometer now is 7.4k/2.6k
  11. And so on...

Every save-open makes the wipers of the potentiometers a little off.

Ignoring timestep and running simulations without UI updates

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.

I've discovered free energy!

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:
image


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.

error in threephasemotorElm.java

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

Mouse Scroll Wheel Resistors and Capacitors Values

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

'show frequency' is intermittent

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.

2024-04-25--18-01-35_betlogbeast_20240425175405betlogbeastfalstadcomcircuitcircuitjshtmlGoogleChromepngGeeqie

Tristate buffers can be sized such that it is impossible to connect their middle terminal

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:

Default grid size

image

Small grid size

image

Analog switch: Lack of input voltage settings in the Edit Component dialog

Edit Component dialog for [Active Building Blocks] analog switch component looks like this:
image

While it allows setting on/off resistance, it doesn't allow setting input low/high voltage levels. Both input voltages are hardcoded to 2.5V, while real components have different levels.
Examples:

  • ADG719 / ADG419 / ADG721/ADG722/ADG723:
    image

  • BU4S66:
    image

"Outputs and Lables / Box" Selection

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.

https://www.falstad.com/circuit/circuitjs.html?ctz=CQAgjCAMB0l3BWcMBMcUHYMGZIA4UA2ATmIxAUgpABZsKBTAWjDACgAjEJww2kbIRoCwfSJxCEwxWmXB4ZovFDYBjEChTC0yzdowooUWPAhUYcdupR5d+DbY0GjF0y5PsgA

Decoupling capacitor causes error message: "Capacitor loop with no resistance!"

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. ;)

Feature Request: Plot charge in scope (useful for switched capacitors) - example provided

Background

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

Issue

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.

Feature request

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.

Code Style: Indentation settings?

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.

image

File SaveAs

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

Uncaught Error: java.lang.StringIndexOutOfBoundsException

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


whenline is empty String.
I'm not good at debugging in GWT, and I don't know why it would be empty, but after I turn it to

if (line.isEmpty() || line.charAt(0) == '#')

, it's gone.

couple of questions to see if this is possible.

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.

https://sim.lvgl.io/v9.0/micropython/ports/javascript/index.html?script_startup=https://raw.githubusercontent.com/lvgl/lvgl/0d9ab4ee0e591aad1970e3c9164fd7c544ecce70/examples/header.py&script=https://raw.githubusercontent.com/lvgl/lvgl/0d9ab4ee0e591aad1970e3c9164fd7c544ecce70/examples/widgets/slider/lv_example_slider_2.py&script_direct=0d22c3378d4bb43ac657c93bd01f17d21ac6bde1

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?

Subcircuit terminals shared between all Instances.

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.

How can I make logic gates inside subcircuits use specific voltage level?

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:

image

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.

image

Default colors

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.

How to remove sub circuits from the Draw->Subcircuits menu

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

Comparotor OUT Spike

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

image

https://www.falstad.com/circuit/circuitjs.html?ctz=CQAgzCAMB0l3BWEAWaA2ATARjWMmsEAOATg2RJDWRAHYQFIGBTAWiywCgB3EduIn2RN+kQYMg8+JNCOHSsGIUwycAbnywDl02TqZN5GaEgNQTnDJHqsSinayJE5hkACUAogDEMCKaPFNbVolSV5bPRCFJSjVDQC6JQimKJokLXgGKGyYPysbOxikpxSlGgAFAHUAWU4AcyCxEEF+cmacy2to9sdndpoAcQA5ABFOgvt2fD4SzWmaADUAYSX1RpasaeS5tByUJlMci3DCnozAsPWHc5mJfxkRTd3bSaeQVQAnIQ3IGlZkFryJgZOCcL4yII0CH-MwgyQAFxmZn+EmyWHMCBIYGQCAwtCwtBIRLQRAwlBgaEUVkgmKwyAw2JpIAyIAAJswAGYAQwArgAbeGcRGKVEQ2FCaBgSBoIlEijOQkkJCsMDoEjIRXCIgIWhoTHpOBszm8gX+AHM3YQnBQcbfHZ29h6RYrM0-KHPLQ0ST5O1YMh27C7QajW3sIhevhWVHO1Y+gm7FRNVyeLxaUOnN69YHzEAAZQAkkMPGsEpmHszpq5GO8TDXDrl7noy-Y3qpwjcoqXK-4RQ5zTD3lJ4zpoUYh7q0RhUW3NFPso4zKoAJa+rbmv2hcxwLg+l7FFqzXoodzeNPxG5H7ZHsxAtUQMwNk56S+nI8zhKXi9vS4o+2--g0FwAAeuiaNqKAeqSx5tEsAD2AC2AAOXIfLB8KwR8roWnaTiDuE5q4b+36cAAzmBEbsHOD4gNyfIkcwnAgawxBKGAlD-MgQZlO8NAAPIkQAxkufJ8ly6EfAAOiR75asyyB-Pggh0l6rpKfJQhgEoG42vhmnMv6KrhvpSjvggTYGQgLb+u+lK7MpfBmcC-o-mg1DvGZfCuYBeg-op7nPF5-k6Xwfn2SqJJBQiDnTDgci4bFaKeegvhEISIpEFgTjYpGsCpSQhKYFKpAUAggGGuy3L8oKu4AoIUbfHV8jBmM+HxROKJ1U0XBfB1ICjvF6nAvAoa1X1zyjW5MZgtFlrPAgMWDcy8Del0zHTNC827JNIDLKs4SbXJfwHQlkgCQ1h3KGpEYwMtkBwrdD2sdApCQHY820FKGAkvZN13ZwZ2sLZF1rXZi2-fA90PctJnQMpbEAvSmkYMj96wH94SBWFmM+aGgXQoF227dNgNufjbk-Utw27kD+PWoTLo9TTAXWhTIL+EDw6A9a9U7qtQP1VzuzkK4wxjIiJPeSIHM+cyGIkDSJJ2NiMoFaE6CcSQ4abHikC+OQEAshVJqCvhnZ9P8nbruz1oLp5NtW+LxB-LTzxirLuTy2ZpCbBqODIHg5jUDKWuabQuu0BHSnlcaVVCg5vygRbSRu+igPJcQaVTlOcBSsqxhiISqtfVoX1adHlWmtT9stEDjrHqLI2W4CnbWs1-12x6z5e5oMvg9uUMDzDcPqlrIcyKj27t8xVg93ILe92jEMD1DSSqi9b1gCEMgyvL9C-Vw+0JxEDkRY6Bj+E7ie4o8OOm0kCVJ5o9guTbD+1xwoTE7Xwsd5ozmU5IHq3dWA-2YqfbSQ1hpAJniA+Q09Hj-zhMTDUSRQEoL-puNmGMbagOAT-H819IxwPQbA8+d8MFCHnmQhyMDtLwNnsFMBGwLLgNvr-dgBl344yrs8UB39Ug7RdPtU+uCYH4MYg5KCIC9RCE4pGTA0E+KCWEqJcSUkD4OmIRsBMUhRxMGhNaFa9BOZGCaAOPiABVAAKrzGwvYBxnx0JYqxqhYJ9XoNGV6lBTCL1erqMyvg0ScDAIIMASBUx7BgHYnasEBRcjqAxIAA

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.