Sim behaving unexpectedly, seems to be related to Hierarchical labels

Hi,

I’m using KiCad 8.0.4.
I’ve created a simulation (attached below) that originally worked with this release of KiCad (it is an amplifier), but, now it doesn’t.
It’s weird, I’m fairly sure all I added was hierarchical labels.
When I now run a transient simulation (e.g. 1u steps, 0.01 seconds run time), the output is fairly flat at some arbitrary voltage.
However, if I delete any hierarchical label, and rerun the simulation, then the output changes to a different arbitrary voltage (it’s still not correct).
Does this look like a bug?
I can’t actually seem to get back to the original functioning simulation.

junktest.kicad_sch (111.5 KB)
Here is a file where I’ve deleted the hierarchical labels:
junktest2.kicad_sch (100.3 KB)
The simulated output is different, but is still not correct.
Here’s the original functioning file:
opa_1633_amp.kicad_sch (105.8 KB)
It looks fairly similar, and yet it works, the output is successfully an amplified version of the input, whereas the previous two files don’t work like this at all.

Apologies if I’m doing something very basic wrong. I just can’t see it, but it is late here.

I can’t run the simulation because the model of the opamp is missing.

Where do those hierarchical labels connect to? At the moment KiCad does not have a method yet to simulate only a single sheet. The simulator always simulates all sheets of the project.

What does ERC say about your schematic?
Does the simulator give any error messages? If any, what are the error messages?

1 Like

Ah, apologies, I didn’t realize that model would be missing. I have attached the symbol file (which should contain that model hopefully).
opa1633.kicad_sym (4.5 KB)
This is the model file inside:
OPA1633.lib (14.6 KB)
The hierarchical labels do not connect to anything, because I’m opening the individual kicad_sch file outside of a project, by just opening in the KiCad Schematic Editor (this is an attempt to only simulate some individual sheets of a larger project).

Anyway, this is embarrassing.
I see this:


There’s a couple of those, and I can’t see how they got introduced (they are not in the original file).
Please ignore this thread, I’ll go away and fix the errors and see if it works, and report back.
Sorry for the time-waste : (

I suspect I’ve somehow corrupted things. Even if I delete the wires and try to redo them (video below), I still see the error. The grid is still at 1.27 (I don’t change that on a schematic).
Anyway, I’ll keep investigating, to see if I can get to the bottom of it.

EDIT:
A bit more progress. If I run the ERC inside the project, the connections are fine. But if I save just the .kicad_sch file as (say) junktest3.kicad_sch and open it outside of the project (i.e. using the KiCad Schematic Editor), then run the ERC, then the “Wires not connected to anything” error occurs. Bit weird. I guess what I’m doing isn’t very normal, since ordinarily a project would be opened.

I’ve been tinkering a bit, and it seems to work now:

I think the important part was that the pin mapping between the schematic symbol and the spice symbol was missing, or got damaged somehow. I changed it to:

2024-09-07_opa_1633_amp.zip (22.7 KB)

I also added some hierarchical labels, and it did not make any difference, it still worked.

Hi Paul,
Thanks so much for trying it out.
I think there is a bug of some sort, but I can’t get to the bottom of it.
Here’s what I’m doing: If I open the attached project, it contains hierarchical sheets, and if I click into the sheet called diff_amp_gain_stages, and then run the ERC, there are no “Wires not connected to anything” errors (there are other problems, mainly “pin not connected” errors since it’s still a circuit-in-progress). However, if I close the project, and then make a copy of the diff_amp_gain_stages.kicad_sch file (so as not to corrupt the original), and then right-click on the copied file (I’m using Windows) and select Open WithKicad Schematic Editor 8.0, then the file opens (i.e. not opening the entire project, just that sheet), and then if I run the ERC, I see the “wires not connected to anything” error appear.
meas_amp_4.zip (341.3 KB)
Just in case it’s needed, there’s another custom symbol being used in the project, on a different sheet:
opa211.kicad_sym (4.1 KB)
SPICE file for it:
OPAx211.LIB (18.0 KB)
Many thanks for all your help.

You’ve got over 70 ERC violations, and I have no interest in to puzzling out where the problem is, apart from that, it is also better for you if you learn to fix your own problems. Start with a small part of the whole thing, and make that work. Also run ERC and fix all ERC violations. Then slowly make your system bigger, and run ERC regularly, and each time fix the problems. Take some time to figure out what each of the different ERC messages mean and what is the best way for you to fix them.

1 Like

Hi,
I understand that; that’s why I didn’t really want to share the entire project, because I wanted the focus to be on the single sheet that has five errors (and the point of the post is that I can’t solve those two errors related to “wires not connected to anything”. The other errors are related to “input power pins not connected to output power pins” because it’s a sheet that will be (eventually, after simulating) become part of the larger project.

I always get to zero violations, but my entire project is still a work-in-progress to try to figure out how best simulate individual sheets (and if I were not doing that, then there would be no issue at all). That’s why there are no connections between sheets in the root level (causing most of the issues), since it was indeed incremental, I achieved success on one sheet, but then adding the second child sheet (so that I can make connections between the two sheets, on the root sheet, to make the connections that have to be absent until the second child sheet is drawn). The first child sheet in question, simulated perfectly (as was demonstrated in another thread, and as you’ve also found, although for some reason your copy of it needed the model pin connections mapping again). But somehow, something has been corrupted to the point that I’m seeing those errors, only when the sheet is opened in isolation (i.e. nothing to do with the 70 ERC’s in the project, since the project isn’t open).
I’ll carry on trying to figure it out of course, and carry on documenting it; I certainly don’t expect anyone to feel obligated to help, but at the same time I didn’t want to go silent and not provide any update.

Just an update (in case anyone ever comes across something similar, although it’s very unlikely unless they’re trying to do the same thing as me, i.e. ultimately to simulate individual sheets outside of a project) I’ve made connections on the root schematic, and on the second child schematic, just to demonstrate the issue.
meas_amp_4.zip (348.2 KB)

Here’s the errors/warnings (there are zero):


Next, I close the project, and then copy the diff_amp_gain_stages.kicad_sch file to (say) test.kicad_sch and then right-click on that and select Open With->KiCad Schematic Editor 8.0

Now when I run ERC, I see this (and of course this won’t now simulate correctly, because of these errors):

I can’t see where I’m going wrong, but perhaps this is simply an unsupported scenario, to open up the schematic outside of a project.
Since it’s reproduceable on my system, I’ll go ahead and raise a bug report, and let it be closed if it’s really not supported.

What is this:
image

Are you really using KiCad V8.0.0? The first version of any KiCad main version number always has quite a lot of small bugs. Hundreds of bugs have been fixed.

At first I thought I agreed with your bug, then realized KiCad V8.0.5 has been released (you MUST install and test against the latest stable KiCad version, or your report will be closed immediately by the bot) and I installed and tested with KiCad V8.0.5, and it just tells me where the error is.

In KiCad the RefDes annotation is saved somewhere in the project, but not in the schematic sheet (or maybe it can be saved there too). There is a bit of trickery going on here to make it possible to use multiple instances of a hierarchical sheet in a project. When you open your schematic outside of the project, the annotation gets broken and KiCad gets confused.

ERC does not work properly without a fully annotated schematic. This is a bug in itself, because KiCad should use the internal UUID’s for things like this, but an unofficial answer I once got about this is that it won’t get fixed (soon) because changing annotation is too likely to create (or trigger / expose?) other bugs.

I’m using 8.0.4, which was the latest version until yesterday.

It may be a different bug, that the Windows right-click menu shortcut name isn’t updated when a new dot-release is installed on top of an older release (I don’t uninstall the previous release, and KiCad doesn’t complain that a previous release exists when it overwrites it).

I believe with earlier versions of KiCad 7.0 and 6.0, the shortcut name was correctly updated, since I still have those releases installed.

I’ve installed version 8.0.5 today (and the Windows right-click shortcut still states 8.0.0), and now I get the different result that you mention:

I’ll update the bug report with the latest screenshot, to indicate that the behavior has changed between 8.0.4 and 8.0.5.

It’s a bit disappointing, since it would have been quite a neat solution to the problem of maintaining a single project with multiple separated simulations for smaller portions of the project, without needing to disable portions of circuitry from simulation each time, and without needing to have separate projects just for simulations, since those would get out of sync with the main project. That would have been a good differentiator compared to separately running LTspice etc. I appreciate that whole sheet disabling of simulation will alleviate the issue partially (but still not as good as just being able to select an individual sheet to simulate; I’ll mention that in the bug report as a possible preferred alternative).

Anyway, if it doesn’t work, and isn’t going to get fixed, then at least it’s documented in the bug report, in case anyone else hits it.

If you have a bug report, then put a link to it from here, and also put a link on gitlab back to this thread, so other people can find more background information.

At the moment I am not sure if the removal of annotation when opening your schematic in standalone mode is a bug or intended behavior.

I’ve just now opened up a second issue, as a feature request for a way to simulate just a single sheet at a time (without having to exclude all other circuitry each time):

The original issue link is:

The discussion here is also related to this discussion:

I have a solution of sorts!

I can’t take credit; the idea came from a comment from jancumps in a discussion, who suggested investigating using a script.

Since there’s no Scripting Console for schematics as far as I can tell, instead I created a normal Python program, that can be placed in the project folder, and run. It is called sim_select.py

When run, it will list all the schematic sheets in the project, and prompt the user to select the sheet that is desired to be simulated. The program will search-and-replace the exclude_from_sim attribute value appropriately, in all the schematic files.

After that, the user can open the schematic editor in the project (no need to close and repoen the project; simply leave the project open and just close the schematic while running sim_select.py), and then when the simulation is run, it will only simulate that single sheet.

I’ve tested this on my project, which has a root sheet which I never wish to simulate, and two child sheets which I wish to simulate independently, and it worked for me. I have not tested further, so there may still be bugs.

The program also makes a backup of all sheets before it modifies them, so at least one can revert back if there’s something majorly wrong.

Screenshot of program execution below; this is on Windows, but I also tested on Linux.