8

I just recently found this tutorial (and various other places mentioning a similar technique) when trying to evaluate how one of my circuits behaves when using real world components with real world tolerances.

However normally I design it with ideal values, play around with .step directive etc. so to just do that evaluation I would have to change all the value statements to use the mentioned functions, and when I am not happy, change them back and to play with values again and so on. This seems like an awful lot amount of work. I could probably write a script that does it on the .asc files for me, but I was wondering if there really is no other way.

For most components you have a "Tolerance[%]" field, so I was wondering if this can be used in some global way? Just like some components seem to react on the .step temp variable. Unfortunately in the documentation I find the temp mentioned, but not the tolerance (which results in SpiceLine tol=xxx in the .asc file, if that helps anyone).

So, is there an easy way to have LTSpice (randomly) vary component tolerances over multiple runs, without having to put formulas at each and every one? (I am mostly interested in resistors and capacitors today, if that helps to find a 90% solution)

Fizz
  • 14,355
  • 2
  • 43
  • 97
PlasmaHH
  • 6,498
  • 5
  • 38
  • 49
  • Of the freebie sims, only Intersil's Isim:PE can do Monte Carlo relatively painlessly, as far as I know. See [this](http://www.intersil.com/content/dam/Intersil/documents/an16/an1652.pdf) for docs. Probably the [free/demo version of SIMetrix/SIMPLIS](http://www.simetrix.co.uk/site/demo.php) can do it too (and it's a bit more up-to-date than the Intersil version) but I already had the former installed, and I didn't want to risk messing it with two versions installed. – Fizz Dec 07 '15 at 03:50

3 Answers3

1

Monte Carlo analysis and worst-case is usually the way this is done, exactly as the linked article describes. For Monte-Carlo you don't have to change your components by hand, just run the Monte Carlo sims and the simulator will automatically change the components based on your Tolerance field. You have to run enough cases to get a statistically significant result, and you can calculate how many runs you need for a given confidence. Worst-case requires a little more work and knowledge of how the circuit works, but the linked article explains that as well.

John D
  • 22,677
  • 1
  • 39
  • 56
  • " just run the Monte Carlo sims" exactly that is the question. How to do that in ltspice without having to change the components to formulas, like the linked article suggests. – PlasmaHH Nov 10 '14 at 22:37
  • For Monte Carlo, you just add the .mc directive. You can do that in the GUI by clicking on the little .op on the toolbar. The linked article shows this is done. Since you're not doing worst-case you don't need to worry about the functions. Just find the circuit diagram for the Monte-Carlo analysis in the linked article, add the directives shown in the schematic and you're good to go. – John D Nov 10 '14 at 22:58
  • Hm, looks like I am blind. I can't find any .mc directive, all I can find is *"rather than define a resistor's value as, say, 10K, we define it as "{mc(10K,0.05)}", "* – PlasmaHH Nov 10 '14 at 23:13
  • You're right, it's not the .mc directive it's the .step param directive. You still have to use the built in Monte-Carlo function for the components, but you don't have to define special functions as they do for the worst-case analysis. It's not that big a deal to add the built in mc function to the components. It may be more cumbersome to run MC than some other versions of SPICE, but for the price it's hard to complain. – John D Nov 10 '14 at 23:20
  • 1
    I wasn't aware that asking for if there is a nicer way is considered complaining; especially given there is a tolerance, which then doesn't seem to be used for anything. So in the end, I either have to completely change my workflow and put formulas instead of values everywhere (which probably also means running custom modifications of transistors etc.) right at the beginning, or have to write a script that translates my current .asc file into one that uses mc() everywhere instead... – PlasmaHH Nov 10 '14 at 23:32
  • I definitely see your point, and the "hard to complain" comment is really a figure of speech, I wasn't suggesting that you were really complaining by asking the question. Of course you could always go buy a simulator that supports traditional Monte Carlo methods instead of writing the script :) – John D Nov 10 '14 at 23:40
  • 1
    It just seems like such a trivial feature to add. Unless of course their codebase is a giant mess... – PlasmaHH Nov 10 '14 at 23:42
  • @PlasmaHH If you have valuable features to request you might want to pass them on to Mike E. who has parted ways with AD. As his profile says: "Best known as the author of LTspice, but has since written an all new and better simulator!" – Spehro Pefhany Mar 02 '21 at 04:09
  • @SpehroPefhany unless its a drop in replacement with all the same libraries and models its hard to switch over all the things already developed – PlasmaHH Mar 02 '21 at 09:35
1

I use the following for the value of components: Example for a resistor is {if(nom,R1,mc(R1,tolr))}. Then I define a parameter 'nom' such that if it is set to 1 then the resistor gets the nominal value (R1 parameter in this case, but could be a 'hard' value like '10k'), otherwise if it is 0 then it gets the Monte Carlo Value.

DEngland
  • 11
  • 1
0

This post is old... but as of March 2021 LTspice still does not support using the built in tolerance parameter on components. See page 102 of the recently published (Nov 2020) "Passive Circuit Analysis with LTspice®: An Interactive Approach". In reference to resistor tolerance fields it states: "This is accepted but, as we have already seen, not acted on. ... So tolerance and power rating really are there as reminders when specifying resistors for production."

The recently free Micro-Cap software may better support MC more intuitively.

Michael
  • 106
  • 1
  • 3
  • Yes, many tools may do some things better, but that was not quite the point of the question. I am probably not the only one who has quite a few things done already in ltpsice and wishes to work with that, and usually other programs are not even able to read the format, or don't have the parts being used. And unless I overlooked something in micro-cap you have to chose which graphs to draw before running a transient analysis, which can be extremely cumbersome and time consuming when debugging something. It seems to have a lot of other nice features for other applications though. – PlasmaHH Mar 02 '21 at 10:10
  • I hear you, I'm just as frustrated. I found your post after digging around and trying to find out how to use the 'tolerance' field in LTspice. It's frustrating that EE's get the short end of the stick with design software. Spice simulation and PCB EDA has always felt janky compared to mechanical 3D CAD or 2D art software. – Michael Mar 02 '21 at 15:16
  • my current pipeline is still ltspice but with a script added that runs it and changes the component values and then collects all the results... – PlasmaHH Mar 02 '21 at 15:42
  • All that in one script? Neat! Would you mind sharing it? – Michael Mar 02 '21 at 17:18
  • pretty specific to what I do, but I added a (mental) note to try making it open source and more general when possible. Might add it as an answer here then.... – PlasmaHH Mar 02 '21 at 20:24