I am trying to to simulate a ferroelectric capacitor using simple schmitt triggers subcircuits :


simulate this circuit – Schematic created using CircuitLab

I would like to pass {R1} as a function of each subcircuit instance names (or from a table with each desired values). The goal is to do something like this :


that will effectively increase the R1 value for each new component created.

As I need a few hundred subcircuit in parralel with different {R1} values manual editing is not optimal.


The aim of this project is to reproduce the electrical measurement of a ferroelectric material similar to what can be seen here: enter image description here

This can be achieved by a large sum of ideal schmitt triggers with capacitors in series.

  • \$\begingroup\$ Welcome to SE.EE - what software are you using? \$\endgroup\$
    – awjlogan
    Aug 14, 2018 at 11:13
  • \$\begingroup\$ 1) Using a (model of) TL081 complicates things, consider using a voltage controlled voltage source instead as that behaves more like an ideal opamp and will simulate faster as it is simpler than a full TL081 model 2) consider a completely different approach to modelling the capacitor, LT Spice has controlled sources and you can enter a formula to define Vout(Vin). 3) You might want to explain in more detail what behavior of the capacitor you want to model, then more helpful suggestions can be given. \$\endgroup\$ Aug 14, 2018 at 11:19
  • \$\begingroup\$ I'd remove the capacitor and schmitt-trigger tags because they don't appear relevant to your question (or vice versa). \$\endgroup\$
    – Andy aka
    Aug 14, 2018 at 11:19
  • \$\begingroup\$ -I did not notice the Op amp model, i use an ideal model for the actual circuit. -The software is LTspice XVII -Tags removed \$\endgroup\$
    – Alex
    Aug 14, 2018 at 11:38
  • \$\begingroup\$ Would it also work to just run one model with different r values? Then you can use the stepping functionality \$\endgroup\$
    – PlasmaHH
    Aug 14, 2018 at 16:25

1 Answer 1


I hope I didn't get this wrong. When you create your subcircuit, write the value as {R1}, and in the symbol attributes, add R1=.... This way, when you place your symbol, you can change the value however you want (tables included). If you don't work with symbols (directly with SPICE directives as .subckt), then add a line in your subcitcuit defining the parameter: .param R1=.... Remember, though, that this needs to be done for all the subcircuits you place. For example:

.subckt Bla 1 2
.param R1=... ; this line is optional, but it can serve as a fallback value
R1 1 2 {R1}
.ends Bla

In the first placed symbol, you can add R1=3, in the 2nd R1=5, etc.

If you want external control through other .param statements, directly from your schematic, then you can use R1={R1_1} for the 1st symbol, R1={R1_2} for the 2nd, and so on (or whichever code you wish), and in the schematic you'll have something like .param R1_1=... R1_2=..., or you can make a function to encompass all the values, something like this:

.func res(x) {table(x, 1, 1k, 2, exp(-2), 3, sqrt(3), ...)}  ; or some other function:
.func res(x) {cosh(x)}

Then, you can write: R1={res(1)} for the 1st symbol, R1={res(2)} for the 2nd, etc, and depending on the definition in the .func, each resistor will have a value assigned. This function is used in the top schematic.

One way to cheat would be to use a spreadsheet, making use of =""&<expression>&"". Here's an example:

="C"&$A1&"b "&$A1&" 0 {"&$A1&"/w} Rpar={Rpar}"

while the A column has sequential numbers. This will generate these lines:

C1b 1 0 {1/w} Rpar={Rpar}
C2b 2 0 {2/w} Rpar={Rpar}
C3b 3 0 {3/w} Rpar={Rpar}
C4b 4 0 {4/w} Rpar={Rpar}

The values for the capacitance can be calculated using your favourite mathematical expression (I used a simple sequential numbering). For constant values, a simple {Rpar} was used.

This means you will no longer place symbols, manually, but add a SPICE directive (S key) and insert these lines. Any subsequent additions/subtractions from the list means a simple generating lines and a copy-paste, or deletion of lines.

The way the above works is to define the generic SPICE element as:

<Designator> <pin1> <pin2> ... <pinN> <Name> <Attributes>

For the case above, it's a capacitor, so it has the designated letter C, followed by the numbered instance in the schematic, two pins, its value (known to be in pF), and optional attributes such as parasitics (Rser used, but also Rpar, Lser, etc) and temperature coefficient (not used). It does not have a name since it's a primitive element, the designator automatically says that it's a capacitor. The LTspice manual has more about these in LTspice > Circuit Elements.

Subcircuits have their special designator, X, and the number of pins is as many as the subcircuit is made with. The name here is mandatory, as it is used to know what the subcircuit is called. The attributes are optional and are usually the parameters.

Looking at the example in the LTspice's manual, the subcircuit is defined as a resistive divider, so it has three pins. It is connected between nodes in, out, and 0 (which is recognized as ground), the name is divider, and optional attributes are its two parameters: top and bot.

Using SPICE directives to write elements can be a convenient way for an iterative process, for example (such as this case), but it can prove a bit cumbersome in case of probing voltages from within the schematic's GUI. A solution is to simply draw bits of nets and label them accordingly, ready for probing.

  • \$\begingroup\$ If i understood correctly, this is already what i did. The problem is that every new component will have to be edited manually. The goal is to do something like this R1=100k*(instance#) that will effectively increase the R1 value for each new component created. \$\endgroup\$
    – Alex
    Aug 16, 2018 at 7:37
  • \$\begingroup\$ @Alex I'm afraid that's not possible, but I'll update the answer with an attempt at cheating. \$\endgroup\$ Aug 16, 2018 at 7:45
  • \$\begingroup\$ I see how this would be helpfull, however i'm not familiar with spreadsheets in Ltspice. how do you create/import them ? \$\endgroup\$
    – Alex
    Aug 16, 2018 at 9:08
  • \$\begingroup\$ @Alex I was talking about a generic software that supports spreadsheets, like Excel, or Open/LibreOffice, etc. LTspice does not support them. You create the desired spreadsheet, make your entries there, then copy-paste into LTspice. For example, try what I said. Make the A column with 1, 2, 3... (type 1, then click-drag the corner of the cell, downwards). Then, at B1, copy-paste my example. Repeat the click-drag with tthe B1 cell, downwards, see what you get. \$\endgroup\$ Aug 16, 2018 at 19:24
  • \$\begingroup\$ @a concern citizen , I tried your exemple and finally understood that your text is actually simulating electrical component. Effectively this is a good cheat to my situation. To fully close this question i think i need a last explanation on this text alternatie to the drawn component. How does this work is it Component_name node1 node2 param1 param 2 ? How does it work when using home made component ? \$\endgroup\$
    – Alex
    Aug 17, 2018 at 8:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.