Spice Resistor Sweep

Hi!

I’m new to Kicad and schematics design in general and I’m still trying to learn how everything works, but I’ve already dealt with Orcad solutions before, I use Orcad at university’s courses so that I can simulate the circuits I’m studying in PSpice I’m able to achieve what I want. But… I think We would be better using FOSS projects like Kicad and ngspice than using proprietary software. Also it means that I have to dual boot or keep a windows virtual machine since I use Linux as my daily driver (currently doing it for other software :frowning: but it would be nice if I can eliminate one more!).

I’m trying to design a circuit for analog signal conditioning (I hope that’s correctly said in english) of a sensor, resistive sensor. Linearization of the signal, amplification, elimination of common mode voltage, etc, into an ADC and play with it under a digital environment.

NOW TO THE ACTUAL PROBLEM:

Since I’m working with a variable resistor (the sensor) I want to plot the variation of the output voltage relative to the resistor variation (with a constant input voltage).

Lets just image, for example that we have just a simple 5V DC voltage source with an RL load and I want to make that resistor get values from 10ohm to 1mega and probe the output voltage.

Using the simulator in Eeschema I’m able to plot the voltage as time progresses, and using the tune tool, change the resistor values, get voltage minimums, maximums and values in between, but not the actual curve or line of the variation.

I’ve tried the ngspice manual, but found no luck there, haven’t found any parameter to give a range of values for passive components.

I know how to easily do it in PSpice, and I know Kicad integrated simulation isn’t a solid feature yet, but I don’t assume this is the problem… I’m just missing something or making a huge mess.

Hope someone can give a hand
Best regards

1 Like

The .dc command allows to sweep a voltage, a resistance or the temperature (see ngspice manual chapt. 15.3.2). The KiCad-ngspice interface has adopted only the voltage sweep so far. Even if you do tools->simulator->settings->custom and add a suitable .dc… line, you can simulate, but you cannot plot because the res-sweep vector of input values is not stored.

An exotic idea may help: Create a symbol with two outputs (the resistor) and one input (for controlling the resistance by a voltage) for your sensor.

Then tie a subcircuit for a voltage controlled resistor (see example for such subcircuit below) to your symbol, add a voltage source for generating the control voltage and then run a .dc voltage sweep.

.title Voltage controlled resistor
V1 in 0 10
R2 out 0 10
* either constant R1 or variable X1
*R1 out in 10
X1 out in contr vres
V2 contr 0 1

* either resistance sweep or voltage sweep for X1
*.dc R1 1 10 1
.dc V2 1 10 1

* voltage controlled resistor subcircuit
* the voltage at node c has to be > 0
.subckt vres r1 r2 c
BRes r1 r2 I = v(r1, r2) / v(c)
.ends

.end

You may run this file off-line in ngspice and plot out to compare voltage and resistance sweep.

And you should place an entry to the whish-list (the KiCad bug tracker) to ask the devs for enhancing the .dc command (to add res and temp sweep).

1 Like

Thanks for you help!
I’ll experiment with your idea.
(I’m sorry for the late reply, but I’ve been overflowing with other projects)

There is a bug (wishlist) entry at https://bugs.launchpad.net/kicad/+bug/1821460. You may give it a “me too”.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.