Parameter sweep simulation

Hello,
A newbie to KiCAD here, looking great!
I have a circuit in which the output voltage is produced depending on a resistor value that changes according to a parameter.
I would need to sweep that parameter and observe the output voltage. That is, the only simulation type I need is sweeping that parameter.
Im attaching here the project. Every component has a simulation model. The resistor in question is TH1 and the parameter is called “Temperature” (could be a different name for the case).
Looking forward to your comments!

Cant upload the file being a new user, so Im sharing a link to it: project

Mod edit: Added the project here:
Project KiCAD.zip (19.7 KB)

I would start adding a pulse voltage source. Connect minus to ground and plus to a label (e.g. VT for temperature). Set it like PULSE(-20 70 0 1 1 1 5) to get a sweep. Set the value of the resistor to R=V(VT)**2*10 or any formula that calculates resistance from temperature.
But I’m using LTspice :slightly_smiling_face:

The name of this parameter has to be ‘temper’. Please see ngspice manual chapter 5.1.2. Then using the .dc simulation with varying temp is o.k.

May I suggest that you split up your circuit?

Firstly simulate only the resistor TH1, putting it into a resistive divider. Check if the model is o.k.

Then try simulating it with U2 only. Your power supply is between 5 V and GND. I don’t think it is a good idea then to reference the diff amplifier to GND as well, as you are exploiting the opamps common mode input range to its limits. Only when this part is up and running, add the other structures.

Thanks, Holger.
TH1’s model is tested on another spice-based simulator and should work fine. However, I dont find a way to make it happen in KiCAD - ngspice.
I have put TH1 into a resistor divider and tried to sweep ‘temper’ (by sweeping TEMP).
I get this:
Warning: there is no circuit loaded.
Command ‘remcirc’ is ignored.
Note: Compatibility modes selected: ps lt a
Circuit: KiCad schematic
Numparam warning: overwriting P,S or X line (linenum == 2).
Numparam warning: overwriting P,S or X line (linenum == 40).
Please check your input netlist.
Error: ngspice.dll cannot recover and awaits to be detached

The project for reference is here.

I have downloaded your project, and opened CourseProject (with only the TH1).
Then I have re-attached the model for the TH1, as mine is not located in H: something, but one folder above the project folder, as in your download.
Then the model runs out-of-the-box.

Please try re-attaching the model from file PT1000.CKT in the ‘Simulation model editor’ window:
Select the file in line File:, and then select the subcircuit in line Model:.

Hello and welcome balfonso,

This link to a Kicad FAQ explains the requirements for new users before links are able to be posted.

You need to open and look at another ten posts for two minutes to self-promote to Basic, after which you can upload. :slightly_smiling_face:

1 Like

Thanks Holger.
I have placed the project and the model on a path with no blanks and re-attached the model to TH1. I still don’t get a simulation out of it, not even OP. It’s asking me to check my input netlist.
I’ll keep trying.

Edit: I have tried now by replacing TH1 with a standard Resistor (so that I have a fixed voltage divider). I still get no simulation, even with this basic circuit in which no models are involved (apart from ideal resistors). There must be something in my setup… Im using Win 10.

Here is a follow-up.
It looks much better now. I was simulating a project schema, which, for some reason, made it fail.
Opening the schema from an Eeschema instance fixes the issue.
The simulation now is correct but stops at 50C due to lack of convergence.
From my previous tool, I know I can make it converge by modifying gmin. Is it possible to adapt this from KiCAD?
Attached is the schema for reference and a screenshot of the simulation result.
Project.zip (15.1 KB)

The general problem with this approach is that you modify the overall temperature. The opamps are not made for 200°C, so this might fail.

You might follow the suggestion by Robert, add a voltage source with ramp equivalent to the temperature. Then the model for TH1 has to be changed accordingly.

Thanks, Holger. True, the OpAmps will never reach those temperatures. It’s only a “theoretical” example.
By adding this line the simulation gets completed.

.options gmin=100n

My next point would be: we use 4 individual OpAmps in this simulation. There exists as well one single part that encapsulates all the 4 single OpAmps. Is there a way I can use it to instantiate the sim model of the single part?
As far as I know, I can assign one pin one time.

In KiCad Eeschema as GUI for ngspice, tutorial for setting up the simulation you will find a solution to this problem.

1 Like

I tried it, but for some reason, it wont take it:

Error: unknown subckt: xu1 probe_int_probe_int_/test_xu1_1_xu1_1 probe_int_probe_int_/test_xu1_2_xu1_2 probe_int_probe_int_+4v_xu1_3_xu1_3 probe_int_probe_int_vdda_xu1_4_xu1_4 probe_int_probe_int_net-_r3-+__xu1_5_xu1_5 probe_int_net-_r12--__xu1_6 probe_int_net-_r13--__xu1_7 probe_int_a_temp_xu1_8 probe_int_net-_r14--__xu1_9 probe_int_net-_c2-+__xu1_10 probe_int_0_xu1_11 probe_int_net-_r2-+__xu1_12 probe_int_net-_c2--__xu1_13 probe_int_net-_c2-+__xu1_14 mcp6401c
Error: there aren't any circuits loaded.

To my understanding the quad model is correct.
Project.zip (17.1 KB)

It works fine with 4 single OpAmps, not with the quad model, as mentioned.

Unfortunately not. Please see the line
.include MCP6401
which has to be
.include MCP6401.CKT

You also might exclude U2-U5 from simulation (see the tic box in the ‘Symbol Properties’ window) to avoid any irritation of the simulator.

1 Like