First, thanks for KiCad!
I recently migrated from KiCad 5 to KiCad 7. I have a circuit that simulated in KiCad 5 but there seems to be issues on repetitive simulation in KiCad 7. The circuit is a non-inverting opamp circuit. I have a potentiometer in the feedback loop to control gain. The value of the feedback pot is controlled by a .lib entry. The .lib model uses a simple voltage divider (two resistors and three pins). I have three .lib models for the potentiometer: low gain, medium gain and high gain. To vary the gain I load one of the three spice models and simulate. Everything worked in 5.x.
Here is the issue in KiCad 7.
Load the low gain model in the scchematic
Start the simulator
Simulate
Results are OK meaning low gain output
Load the high gain model in the schematic
Simulate
Results are OK meaning high gain output
Load the low gain model in the schematic
Simulate
Results FAIL. The output appears to be stuck in high gain mode.
I checked the schematic component and the correct .lib model is loaded in the schematic. The output stays stuck on the SECOND simulation result and does not change to the third (low gain in this case) simulation result.
If I exit the simulator and restart the simulator I get the correct low gain result. But after another high gain simulation run (steps 5-7 above) the output get stuck again.
It appears the simulator is not using the new model after two simulation runs.
Again, thanks for KiCad.
Regards,
Peter
I can’t help much with ngSpice related stuff, but others can help better if you include full KiCad version info (From Help / About / Copy Version info) and paste it into your post.
Also, zipping up and uploading your project helps a lot
KiCad version 7.0.9.
I “load” the simulation model in schematic editor. I double click on the component (the potentiometer) and click on the “simulation model” button. I then I use the “spice model form file” dialog.
Gotcha, just wanted to be certain I’m on the same page,
I’ve found that it’s important to save the schematic (after a model change) before starting the simulation again.
Thanks for the reply.
I tried saving the schematic after each model .lib change. The problem still exists : no update in the simulation window. If I close the simulator and restart the simulator, the correct results appear.
I tried t simulate other designs I am migrating from 5.X to 7.X .with the same incorrect type of results.
In moving from 5.X t 7.X I did reinitialize (use the spice dialog to load a lib file) for the opamps, transistor, switches and diodes. I did not reinitialize passives R’s and C’s. I tried to change the value of a resistor and got some error messages. I will reinitialize (load spice models for the R’s and C’s) the passives to see if this helps…Right now it looks like I am stuck.
Hmm. Never ran into this one. The simulator dialog screen in 7.x schematic sucks big time and will often lead you astray, but still…
Post the project and libs if it’s not too secret.
I will post a smaller circuit that illustrates the problem. Here is some additional information.
Here is my potentiometer model for mid gain. The pot is 1 Meg, Pins 2 and 3 are shorted together on the schematic. So the resistance between pins 1 and 2 is the resistance in the op-amp feedback loop.
Here is the high gain model
*Pot subcircuit
.subckt pot100 1 2 3
R1 1 2 900k
R2 2 3 100k
.ENDS
Here is the low gain model.
*Pot subcircuit
.subckt pot100 1 2 3
R1 1 2 50k
R2 2 3 950k
.ENDS
To repeat the earlier information. The circuit simulates correctly the first time.
Load a new model into the pot on the schematic and the circuits works the second time (or so it seems)
Any attempt to load a third model for the pot results in the simulator window not changing. I have to exit the simulator and restart the simulator to get the correct output level from the third model load.
Here is a method that seems to work OK. It involves manually editing the model (change the values of R1 and R2 on the first model loaded into the pot). No new model was loaded into the pot. I can manually change the values, save the lib file and re-simulate correctly any number of times.
I have no understanding of the underlying code but my guess is that the new values from the third and subsequent model reads are ignored. If I look on the “Alternate Pin Assignments” tab the correct code seems to be correctly loaded but it is not used for the simulation.
Also, asking twice for your KiCad version info and getting ignored, does not invite to give any further. response. The full KiCad version has much more info, such as the OS you use the included version of ngSpice and a lot of other stuff.
Sorry for the delay. I needed to reduce the circuit and attempt to better understand the issue.
My OS is Win 10. Kicad version 7.0.9.
I compiled a report on the issue. I hope it makes things clear. The report is a .doc file called pot report. pot report.zip (497.4 KB)
The schematic and lib files are here. PotTest.7z (13.5 KB)
First, let me say that I am grateful for the Kicad tools and development team. If any of my statements or responses appeared critical or negligent I apologize. As I stated the reason for the delay was to simplify the circuit, isolate the failure and write a report about my findings.
Also, I was not advocating for a bug report and program change but I would like a policy clarification. I wanted to ask the local knowledge base if this was expected behavior. If the policy is that model path and file name updates can only reliably occur at simulator invocation, well OK. The GUI seems to imply that model updates can happen at any time. Further windows like the Properties window deliver inconsistent information. From the obsessive engineering perspective this isn’t a great look.
If anyone is interested, my products are guitar stomp boxes. Assuming the effect has five control potentiometers (Gain, Treble, Mid, Bass, and Output), I would like achieve some measurable analog test coverage for maybe 15 test cases. Each potentiometer will be tested with a low, medium and high setting. So a test case may be:
Gain Medium
Treble Low
Mid High
Bass High
Output Low.
So what I wanted to do was to construct libraries of each potentiometer in three settings, load them in the schematic and then simulate. I would run each test case in a separate simulator plot window. A complete run of the 15 test cases would require 15 plot windows from the same simulator invocation. Then I can visually review the results across all 15 test cases. This testing method is close to some of the real world testing I perform on the actual product.
To answer the question of why I do not want to close the simulator each time. Yes I can do that and get the comparative results for the different potentiometer settings. To compare the results I would have to save the plot windows or the data. Later I could compile the plot windows or the data into a document to compare the results. This is why do not want to exit the simulator. In the past I saved a lot of intermediate simulation results for further review and never really reviewed the any of it. Generally a waste of time for intermediate simulations. I can note points of interest in my engineering notebook, modify the circuit based on those observations and rerun the 15 simulation test cases.
So, summing up. If Kicad/ngspice rereads the lib files from the same directory (the LIB directory in this case) and rereads the same lib file (P1.lib in this case) for each plot window simulation, I can construct a simulation strategy based on this program architecture. I just want to know if this is an accurate understanding.
Verify that the parameters of the potentiometer model (low gain, medium gain, high gain) are being updated correctly each time you change the model in the schematic. Ensure that the model selection is reflected in the schematic and that the parameters are correctly set for each case. Make sure that the references to the potentiometer models in your schematic are correct and that they are pointing to the right model files. Check the simulation settings and options in KiCad 7. Ensure that there are no caching issues or settings that might cause the simulator to retain previous simulation results. Reset the simulation settings if needed. KiCad may generate simulation data files during the simulation. Check if there are any temporary files or cached data that might be causing the simulator to reuse old results. You could try clearing any temporary simulation files before running a new simulation.