Creating a working symbol from a .suckt containing random() function

Dear all, someone can help me to solve this issue? Is there a trick? Thx

The symbol generated from the “.subckt” containing the “random()” function is the one attached: MC_V_DEV.qsym (779 Bytes)
It is originated from the behavioral voltage source B2 in the middle.
B2 circuit works perfectly (after Vnom & Vtol initializations) while the circuit on the right does not.
This is the message error from sim that include the generated symbol:

You can troubleshoot your symbol in schematic window, View > Netlist.
With that, you can see a + in calling X1, which mean you forgot to comment 4th attribute in symbol. As you changed + text into light blue, it is a bit difficult to tell by just looking at the symbol. Anyway, comment this attribute and this symbol will work. Functional version is attached.
MC_V_DEV.qsym (780 Bytes)

Just curious, it seems your schematic with completely different color scheme, how you can do that?


If in case, you need to rotate symbol, using text string in symbol can be a mess. (Ctrl-R your symbol in schematic and you will know what I mean)
The method to prevent that, is to build your symbol with drawing instead of text attribute with comment. Here is an example for your reference.
MC_V_DEV_RemoveText.qsym (1.0 KB)


@ KSKelvin thanks a lot for your support … It was simpler than expected, fortunately! :blush:
Here is the result of a basic library to perform Montecarlo analysis with QSPICE, taking into account also LOT models implementation. I hope that this will help the community… MCA_BASICs1.qsch (10.0 KB)

(I will update the symbols with ”drawn” texts in next days for sure :wink:)
It remains just a warning generated by the LOT models. It’s this one:

Sincerely I don’t know if it can be cured.
More important is the point that it seems not possible to measure (and plot) the currents at “.subckt” terminals. Have you an idea of how to do it?

Regarding the colors, I discovered it by chance one of the first times I’ve run the program.
After opening the drawings, proceed as follows:
Edit => Color Preferences => “CAD Colors” window will open with Background selected as default. So, you can choose preferred color for it from palette (or through RGB numbers).

If you left open the “Cad Colors”, and click on a different item in the electrical drawings, the selected item changes … and so you can color each part as you prefer.

1 Like

The warning actually give you hint, problem somewhere in random() function.
Again, View in Netlist, you can easily see where the problem is. X2, X5, X6 symbol implemented a formula with random(run). Remove “run” and will free from warning.

Thanks for explaining how to change color for schematic items. I thought color preferences is only for background. I wondered why people can change schematic items color many months. :rofl:
I will document that in my entry guideline.

@ KSKelvin I know it, but doing so you’re going to lose the only “magic” behind the implementation I’ve proposed. In fact, the function “random()” with “run” parameter as argument unequivocally distinguishes the LOT model from the DEV model. Please, try to run my sims more time to check it.
“Random(x)” produces numbers from 0 to 1 according to the integer value of x”. It does not seem to produce random numbers but more a sort of LUT (Look Up Table). I’ve tried to simulate it associating a ramp to its argument. Please see below for fun.

Independently of “seedclock” option, time duration and simulation run, voltage levels generated at v(out2) are always the same in value and in number (11 values for an input voltage level from 0 to 10 volts). It does not seem a real random generator… what do you think?
This mapping tool can be used to force always the same value at each simulation run of a MCA and, so, help linking more sources together. Finally, the small issue about the warning remains.

An alternative solution could be forcing the same seed to a “random()” function called in each LOT models (i.e. a couple of resistors or voltage sources etc…). But I don’t think this option is currently implemented in QSPICE. @ Engelhardt: Is it planned?

Just for dissemination, a practical example in which LOT models are essential for a reliable analysis in extreme conditions is the case of a comparator element with hysteresis for which is requested to evaluate the EOL variations of both the thresholds (i.e. under/over voltage protections).

Download Device Reference Guideline from my Github, search random(x)
There are 3 pages to explain random(x), .option seed and .option seedclock.

Qspice/Guideline at main · KSKelvin-Github/Qspice