Where is the built-in potentiometer model?

In the docs:
EESchema reference manual

there’s the statement:

" Built-in models: […] The following devices are available:

  • Resistors (including potentiometers) […]"

Where would I find the built-in potentiometer model?

Additional note:

You may notice that I’ve also posted a question about how to use example models from the ngspice documentation, in which I used the docs “potentiometer” example. I am pretty sure that is not what is meant by the Kicad docs mention of built-in models, as other “built-in models” appear in Kicad’s UI, while potentiometer does not seem to. Regardless, if someone does clue me in how to use examples from ngspice’s docs, that would also satisfy my quest for a potentiometer model :-).

Some time ago I have pushed a feature request to add a potentiometer (including model) to the Simulation_SPICE library (see Add potentiometer to Simulation_SPICE symbol library (#17812) · Issues · KiCad / KiCad Source Code / kicad · GitLab). You may give it a “thumbs up”.

OK, I have thumb-upped the feature request. I have also filed a bug for the documentation:

For those facing the same issue, a way to acquire a model for a potentiometer can be found on this thread:

Scroll on down to the sample potentiometer project by @holger , but be aware that the provided library file is broken, and needs to be fixed up according to my (gwideman) suggestion a could of posts later. (I think the syntax used by ngspice may have changed between holger’s post and now).

Also, you may want to scrutinize the mapping of pins to resistors, and ratio, if you would like ratio=0 to correspond to 0% rotation (fully CCW - Counter Clock Wise).

EDIT:
… but read on further comments below! This may or may not be “the final answer”.

The ngspice syntax has not changed.

However the interface of Eeschema to ngspice has changed a lot between version 6 and 8.

.SUBCKT my_pulse 1 2 PARAMS: V1=0V V2=10V TD=0us TR=0.1us TF=0.1us PW=9.9us PER=20us 
V_my_pulse 1 2 PULSE V1 V2 TD TR TF PW PER
 .ENDS

is accepted,

.SUBCKT my_pulse 1 2
.param V1=0V V2=10V TD=0us TR=0.1us TF=0.1us PW=9.9us PER=20us 
V_my_pulse 1 2 PULSE V1 V2 TD TR TF PW PER
 .ENDS

is no longer recognized by Eeschema (would be no problem with ngspice).

You might issue another regression bug report on this.

Just to comment here - the KiCad SPICE model editor GUI supports assigning/editing potentiometer models to symbols in the GUI (they are listed as a subtype of resistor models). I believe this uses the ngspice potentiometer code model under the hood. This is what the documentation is referring to.

This is separate from the issue linked above, which is requesting a symbol in the Simulation_SPICE symbol library with a potentiometer model pre assigned. But you can assign a potentiometer model to any symbol you want using the GUI even if there’s no symbol in the simulation library - that library is “just” for convenience and ease of discovery.

@holger in your issue you suggest creating an external model for a potentiometer in the spice file we ship with the simulation symbol library. Is there an advantage to doing that versus using a symbol parameter type model we use for most devices in the simulation symbol library? For most symbols in that library, we use the “built in” models when they are available. I think we’ve only put external models into that file if we can’t use a built in model.

In the @gkeeth’s response to doc issue 883, I learned that indeed you can select a built-in potentiometer model directly in Simulation Model Editor window, by choosing:

  • Device: Resistor
  • Type [of model]: Potentiometer

But that approach seems like it may have a bug, as follows.

  • This is holger’s potentiometer sample called “pot-only” from 2022.
  • RV1 uses holger’s pot-ng-model.lib that uses a subckt containing two resistors, which I revised to include the now-required parameter declarations. This works OK.
  • For RV2, I associated the “built in” model (Device: Resistor, Type: Potentiometer)

Note how the Kicad/ngspice OP analysis fails to show current flags for RV2. The ngspice netlist:

.title KiCad schematic
.include "G:/_DownloadForInstall/KiCad/ngspice_libs/pot-only/pot-ng-model_explicit_params.lib"
.model __RV2 potentiometer( r=1k position=0.7 )
.save all
.probe alli
.probe p(R2)
.probe p(XRV1)
.probe p(R1)
.probe p(R4)
.probe p(V1)
.probe p(R3)
.param val1 = 300
.param val2 = 0.75
.op
R2 /IN Net-_R2-Pad2_ 200
XRV1 Net-_R1-Pad2_ Net-_R4-Pad1_ GND RPOT value=200 ratio=0.5
R1 /IN Net-_R1-Pad2_ 200
R4 Net-_R4-Pad1_ GND 100k
V1 /IN GND DC 1 
ARV2 Net-_R2-Pad2_ Net-_R3-Pad1_ GND __RV2
R3 Net-_R3-Pad1_ GND 100k
.end

I’m not sure if current flags are supposed to appear for all components just by way of “.probe alli”, or does each component need a “.probe p()” entry, which is missing for RV2, which is renamed to “ARV2” in this netlist, I guess to invoke an “A” model from the built-ins?

Anyhow, to gkeeth’s question, it seems like the (or any) version of a potentiometer model that’s based on a subcircuit presently plays nicer with the current flags than does one based directly on a built-in A model?

I’m not sure about why there is no current probing - I would expect the current probes to be shown and it would seem to be a bug that they’re not (edit: or perhaps ngspice does not support directly probing current on code model terminals without a wrapper, I’m not sure). I don’t think the .probe p(...) lines have anything to do with the current measurement or lack thereof, as .probe p(...) is for measuring the power dissipation of a device.

As for the prefixes, yes, ngspice (and every other SPICE I’m aware of) uses the first character of the component name to determine the component type. R is resistor, C is capacitor, etc., as you would expect. X is subcircuit (note that your RV1 subcircuit potentiomenter becomes XRV1) and A is a code model, I believe. There are also different source types: V is voltage source, I is current source, B is behavioral source, G is voltage-controlled current source, etc. These are listed in the ngspice manual if you want to see more.

When it constructs the ngspice netlist, KiCad chooses component names for each component in the schematic based on the KiCad refdes and the ngspice component type. For some components (e.g. resistors) this means the ngspice component name is probably the same as the refdes, as resistor symbols usually use an R refdes prefix.

Note that I doubt “ngspice component name” is the technical term, but I don’t know what else to call the first token in an ngspice netlist component definition line (also not a technical term).

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