I have the following circuit, in which i need to calculate max and min voltages possible (considering resistor tolerance). Does running a monte carlo simulation consider the absolute max and min values of voltage output that can be obtained at every point in the circuit, or is it purely based on number of iterations in the step command? Basically, if I do only two rounds of simulation, I must get the absolute max and min voltages at every point in the circuit. Is this method the right one for my needs? If not, please provide a step-by-step solution for my case.
-
\$\begingroup\$ Check the link in electronics.stackexchange.com/questions/137934/… \$\endgroup\$– HuismanCommented Jul 25, 2019 at 7:18
-
1\$\begingroup\$ It's a random process so doesn't definitely cover any particular case. \$\endgroup\$– ChuCommented Jul 25, 2019 at 7:41
-
\$\begingroup\$ I need only min and Max values of voltages at all points in the circuit. How can i do that? Or is this itself close enough? \$\endgroup\$– Nick RogersCommented Jul 25, 2019 at 7:46
3 Answers
A brute force solution can be implemented using the following number system.
This described method will cover the minimum and maximum result.
For example, using a decimal number system, you can specify the tolerance by 10 values.
The number of digits is the number of components you want to vary.
ABCD
0000 all components have their minimum value
0001
0002
....
0009 components A,B and C have their minimum value and component D its maximum value
....
9999 all components have their maximum value
Now, using the LSpice directive .step param run 0 9999 1
you can use the run
parameter to define the value of each component.
Using floor() you can select the component, e.g. component C is selected by floor(run/10)-floor(run/100)*10
.
(Note that the divisors are powers of 10, because a decimal number system is used. For other number systems, corresponding divisors must be used).
In the decimal number system, we have 10 tolerance values. Spreading them evenly, the digit has to be subtracted and then divided by (10-1)/2. So, digit value "0" gives -1, digit value "9" gives +1.
With these notes, if the value for component B is e.g. 680Ω 1% the LTspice resistor value becomes R={ 680 * (1 + 0.01*( floor(run/10)- floor(run/100)*10 -4.5)/4.5 )}
Below is a comparative result. I didn't have the diode, so I left it out. The first waveform is the total result, the second waveform zoomed in at the maximum values, the third waveform zoomed in at the minimum values, the last waveform is showing the values of the resistors.
-
\$\begingroup\$ thank you, but this doesn't seem to give a large enough band between min and max voltages like monte-carlo does. Now i don't know which one to believe. What i mean is, using monte-carlo the min volatge i get is lesser than than the min voltage this gives and the max voltage is more than what your method is giving. \$\endgroup\$ Commented Jul 25, 2019 at 8:56
-
\$\begingroup\$ @NickRogers I noticed a mistake in the floor() part of the equations, see update. The last part misses a multiplication: e.g. the *10 in
floor(run/100)-floor(run/1000)*10
. \$\endgroup\$– HuismanCommented Jul 25, 2019 at 9:08 -
\$\begingroup\$ @NickRogers I made another mistake... The first part of R should be: ```R={ 680 * (1+ 0.01*( floor... ) } \$\endgroup\$– HuismanCommented Jul 25, 2019 at 9:24
-
\$\begingroup\$ @NickRogers Sorry for informing about the last (important) typo, it should have been
.step param run 0 9999 1
of course. \$\endgroup\$– HuismanCommented Jul 25, 2019 at 9:46
Let's take a simple voltage divider AND you are only interested in resistor tolerances, not supply tolerances (assume psu is ideal)
It is trivial to calculate the nominal, minimum and maximum
max: \$10\cdot \frac{10k*1.01}{(10k*1.01) + (10k*0.99)}\$ = 5.05V
nom: \$10\cdot \frac{10k}{10k + 10k}\$ = 5V
min:\$10\cdot \frac{10k*0.99}{(10k*1.01) + (10k*0.99)}\$ = 4.95V
Can a Monte-Carlo output this value? Probably, a very very VERY small probably occurrence. Why?
A Monte-Carlo simulation will generate a random value within stated bounds (normal distributed, 1%, mean value). Statistically speaking it could generate, but this is a one in a billion type occurrence. To then pick the absolute max and hte absolute minimum, in the same run? I would rather bet on a national lottery.
The absolute max/min output "worst of the worst" is a best suited for pen & paper, excel, mathCAD, Jupyter etc ... and is extremely valuable in determining whether a design will operate over all possible tolerances (very useful for stress calculations). Real world type behaviour? the probabilistic approach relies on these types of sweeps.
In practice both are useful as you can take credit since 6\$\sigma\$ covers 99.999997% and thus anything outside of this is 3.4 errors per million
So in short.. Will a Monte-Carlo run provide the extreme outputs? probably. If you want to know the extreme outputs then most tool can be set for extreme value calculation, but you need to guide them to determine which combination will provide the maximum/minimum
The Monte Carlo analysis assumes a normal distribution of the component tolerance. The more runs you make, the more accurate your result will be. You will not get the minimum and maximum voltage for your circuit with two runs.
The solution for your problem is well described in "LTspice: Worst-Case Circuit Analysis with Minimal Simulations Runs".
Where, the number of runs is determined by \$2^N +1 \$, where N equals the number of indexed components, to cover all the max and min combinations of the device plus the nominal.
-
\$\begingroup\$ N equals the number of indexed components \$\endgroup\$– Daniel KCommented Jul 25, 2019 at 9:11
-
\$\begingroup\$ What's that, please tell me how to find it for my example circuit \$\endgroup\$ Commented Jul 25, 2019 at 9:12
-
1\$\begingroup\$ N is the number of components which influence your output voltage by component tolerance. In your case it is 4! Please read the article I have linked to, it's all explained with an example. \$\endgroup\$– Daniel KCommented Jul 25, 2019 at 9:15