# Changing parameter values from a value list file in SPICE

In my circuit, there is a current generator. This generator generates vaules dependent on a parameter, we called N. But I want to use parameter as a variable. If values change linear, I will use .step function. But my values are gaussian distributed and 10k different value. Thus .step function does not suitable for me.

My question is, could I change N parameter value from an out .txt file continuously as .step function ?

Now, I'm using LTSpice. Tell me if any useful SPICE application you know. I know PWL() function changes current generator values with a file. But there is a mathmetical formula in I2() and N parameter using in that.

• Are you looking to apply random variables that distribute in a specified Gaussian distribution? If so, that's relatively easy to generate using the $\operatorname{gauss}\left(\sigma\right)$ function. You don't have to use a file. But it may still treat this as a continuous function of sorts. So I'm not sure here. If you actually need the specific order and values of your own Gaussian distributed values, I'm also not sure how. The 'wavefile=' parameter might be useful, but I doubt it in this case. Perhaps you can use a series of runs of LTSpice from the command line?
– jonk
Jan 13 '18 at 16:35
• thanks for participation jonk. I do not know gauss function that LTSpice had. For basic maybe just help for me. Unfortunately my values generated by an other script. I collect the value list prepared. Jan 13 '18 at 16:46
• I will looking some more for 'wavefile=' Jan 13 '18 at 16:46
• Also look at this link from Linear: linear.com/solutions/7852
– jonk
Jan 13 '18 at 16:51
• I think the OP wants his values to vary during the simulation, similar to a PWL source, but with a formula. In this case I can only think of a behavioural (current) source, bi, or bi2. See the manual for how to use it: LTspice > Circuit Elements > B. Arbitrary behavioural .... Jan 14 '18 at 6:35

Re-reading this now I think I understand what OP wants: to use a custom sequence of numbers that can be used in a .step command. If this is the case, I'll try to answer.

Normally, for a non-linear sequence of numbers that is not logarithmic, the keyword list is used. Unfortunately, it doesn't allow evaluations, i.e. the values must be numeric, {cos(1)} or {2*5} will fail. So about the only solution would be to generate the numbers externally, in a plain text file, as a single line, or as a concatenated line (with +  in front of each new line), and add:

.step param x list <sequence_of_numbers>


at the beginning. This file can then be added to the schematic with the .inc (or .include) command. Don't forget that LTspice XVII sorts the numbers in ascending order prior to simulation start. You may, or may not like it, but that's how it is now. The only way to circumvent this is to use LTspice IV.

To test this, the text file's contents looks like this:

.step param x list 7.254322142991044e-12 2.974321522582202e-10
+ 5.94864415973779e-9 7.733237831307738e-8 7.346575989515156e-7
+ 5.436466237528063e-6 3.261879742903331e-5 1.630939871486926e-4
+ 6.931494453849666e-4   0.02292014166076882 0.05730035415192529
+ 0.1278238669542985 0.2556477339086 0.4601659210354829 0.7477696216826623
+ 1.099661208356858 1.466214944475812 1.774891774891774 1.952380952380952


and the schematic gives this after a .op:

The numbers are some would-be Gaussian bell shape. The output looks like a straight line, but using the View > Mark Data Points shows that the distribution is nonlinear. Using .tran will show different DC levels, as expected.

You have a few options here, this does sound like an X-Y problem however.

First off, .step functions are for running different simulations.

If you desire to run a transient simulation with your own custom values for a source or load, you can use PWL or Wave files for input to sources in LT spice. (or you can just use the built in PWL option, which would be tedious to enter in thousands of values).

In the first circuit, V1 has a wavefile input which will set net Res to V1. For interests sake I included setting a resistor to the value of the wave file, which will make the R2 resistor variable to whatever the wave file is.

V3 has a PWL file input.

I1 has a PWL flie input.

Remember that PWL can be tricky on setting points, you can't have two points in the same time and PWL simply draws a line between points.

This is the only way for importing values into a lt spice file.

You can also use b-sources (either current or voltage) with math functions that control the input of the source.

The most useful functions if your trying to create a noise source would be white, random, and rand which allow you to create sources with Gaussian properties in the time domain and .trans simulation.