Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subcircuits with 2-terminal voltage sources don't work #943

Open
arashhabibi opened this issue May 23, 2024 · 3 comments
Open

subcircuits with 2-terminal voltage sources don't work #943

arashhabibi opened this issue May 23, 2024 · 3 comments

Comments

@arashhabibi
Copy link

Good evening,
I am a computer science teacher and I would like to use your great applet for next year's electronic course at the Strasbourg University in France. I am trying to make subcircuits, and I don't understand whether I should include a ground inside the subcircuit or if I should have a ground pin that the subcircuit user connects to the ground outside the subcircuit.
Example 1 : this circuit :

https://www.falstad.com/circuit/circuitjs.html?ctz=CQAgjCAMB0l3BWcMBMcUHYMGZIA4UA2ATmIxAUgoqoQFMBaMMAKADMQAWbFEXTioSr8+vMNCQxIKFgCdBVMBkIKQKPHijJ4LAO6qetIXzwDIe1es2EUAq1BZpy3XiJdqEKgQDUAlgDtHSHIbOw0QUI8vEG8AewBXABcWADcuYhVsU3SVJRUqKk5aLQKJC04MkwFPYWzzfQrc5VU8hwbKrIF3TocnLh4q-tdsaIBxABMWIA

has no ground. When I try to make a subcircuit out of it, the "File/Create subcircuit" does not complain. But it is impossible to include this subcircuit in another circuit. But if I remove the Gnd label and replace it with a real ground inside the subcircuit, then the it can be included inside other circuits without any problem.

Example 2 : this other circuit :

https://www.falstad.com/circuit/circuitjs.html?ctz=CQAgjCAMB0l3BWcMBMcUHYMGZIA4UA2ATmIxATwosgoFMBaMMAKADNkUAWELsQ5Hip8B2FOGhIYkFOxB5CPEfLi9+IMRKmxZAJ0FVs2AWHxUUCAbVNwW+vKqMCHtC1eS2A7iteWDINygWbzxiUWMQUnFlSGDI4nEneTC1KzjQgWUFJXVY-SiNCNMhQvcbO2Tw50cI6y8QHAFAlwC-WO8C5VNuVKCQmuraLlV2-yTi4RG4idLwFHUk0YQuHkDG1rSOPE0uB3lFXj3NMEkoaFkQg6yrg9iOAoQwcW6eR8Tn09RpmRyTH94UqMZlxjmYQIQMOJRi0QeIWhCoXJtuJLLRshRCLRjp9znIHglOK8CdjtHoGhE1hFsAgoR47g1IDxCD11syeCSzhdyQI3tzwfg+vslCl0cseED-jSqC8KBg0pdXnKheDIYKZZjpf8EYLWcM+drRqzVfDVdDVNr0Qb0gdterTd8erawVbvGLeOa9cNaKNFLQ2QymT1DVSaXzdt64utw3zedDNKj+VQE6N8eINRQCT6BQgCenk3E85jE4cI9509G3dG49E9lG9imCbzfRQnoLm17wXrYwWu63m-7YmhyG7AiOBTwAGoAYynLCHFBWJYXSh2IAAwgAbADWc8gw8XHbd1OiIAnAEsAHa78hPBZFeZNEqTgD2AFcAC6RiLat1W+e-1Vfx6HgAHEABMWCAA

has no ground either, but unlike the first circuit, I have no problem making a subcircuit and including it in other circuits.

I think I am missing something. Which is the correct workflow in falstad ?

  • if grounds are not necessary in subcircuit, could you tell me what is wrong with the first circuit ?
  • if grounds are necessary in subcircuits, how can you make a subcircuit with only other subcircuits (no place to connect a ground) ?

Any help/explanations would be welcome

Yours

AH

@pfalstad
Copy link
Collaborator

There's a bug in the simulator that causes the first circuit to not work. It's throwing an exception, which is handled and ignored, so that's why nothing happens.

The problem is the 2-terminal voltage source. It doesn't work in subcircuits because of a bug.

You can work around the issue by doing the following:

  1. create a ground node like so: https://www.falstad.com/circuit/circuitjs.html?ctz=CQAgjCAMB0l3BWcMBMcUHYMGZIA4UA2ATmIxAUgoqoQFMBaMMAKADMQAWbFEXTioSr8+vMNCQxIKFgCdBVMBkIKQKPHijJ4LAO6qetIXzwDIe1es2EUAq1BZpy3XiJdqEKgQDUAlgDtHSHIbOw0QUI8vEG8AewBXABcWADcuYhVsU3SVJRUqKk5aLQKJC04MkwFPYWzzfQrc5VU8hwbKrIF3TocnLh4q-tdsaIBxABMWAHM1DF5bKkx5uZKWIA

  2. select everything except the ground

  3. create subcircuit

@arashhabibi
Copy link
Author

Thank you very much for your rapid and efficient reply. Everything works now.
So I must remember : all circuits yielding a subcircuit must contain a ground, even if, when making the subcircuit, we choose not to include the ground in the subcircuit.
I also must remember to use 1-terminal voltage sources in subcircuits.
All the best, and thank you for your great app !
AH

@pfalstad
Copy link
Collaborator

reopening this so I remember to fix the bug

@pfalstad pfalstad reopened this May 24, 2024
@pfalstad pfalstad changed the title bug-ground in subcircuit subcircuits with 2-terminal voltage sources don't work May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants