Software for modeling circuits and verifying constraints? - Page 1
Forum section: electronics / beginners

author: gsgx
author_rank: Contributor
timestamp: July 19, 2023, 05:41:36 pm
content: I don't think any SPICE software does what I'm looking for, but please correct me if I'm wrong.As a beginner with electronics, I'm quickly finding that even simple circuits have so many parameters that can be tweaked and so many design considerations to be mindful of that it can be overwhelming. Consider this basic common emitter amplifier circuit:I would like to experiment with different values of the resistors in the voltage divider biasing network, the input/output filtering capacitors, the collector and emitter resistors, the emitter bypass capacitor, and the source and load impedances. But I'd like to verify certain properties about the circuit and ensure no constraints are violated. For example, I may want to verify that the input cutoff frequency is less than 20Hz, that the quiescent current is below 2mA, that the transistor will not become saturated for the expected values of the input, that the input and output impedances of the amplifier are within some range, and more. And I want to verify these properties under different temperatures/values of Beta. I could "just wing it", and I have done that and it works some of the time, but when it doesn't work it can be very time consuming and potentially expensive. It's also not as satisfying to just wing it, at least for me.Is this possible with SPICE software, or is there alternative modeling software I can use to verify that my constraints will all be met? I've used SPICE to make basic graphs of voltage and current, but I don't know how to verify the rest of this without a bunch of manual work in addition to the SPICE simulation.I am considering writing a simple Python script to compute certain values I'm computing manually (i.e. input/output impedance, cutoff frequency, etc), but I feel like there must already exist something to solve this problem. Is there any free and opensource software I could use for this? And for engineers who work in the industry (I'm only a hobbyist), I'm curious how this is approached in the industry, as real world circuits will be much more complicated than my simple example and I can't imagine all of these constraints being validated manually or just by looking at SPICE graphs.

author: Benta
author_rank: Super Contributor
timestamp: July 19, 2023, 06:22:54 pm
content: KiCAD comes to mind. I use it myself for this kind of thing.Draw the schematic, import the simulation models and run ngspice from within KiCAD.

author: Solder_Junkie
author_rank: Frequent Contributor
timestamp: July 19, 2023, 07:27:44 pm
content: An easy to use spice program, that appears to be aimed at the education market, is Tina. There is a free version called Tina-Ti which is provided by Texas Instruments.https://www.ti.com/tool/TINA-TIhttps://www.tina.com/Probably the most popular spice program is LTSpice, provided free by Linear Technology (now Analog Devices).https://www.analog.com/en/design-center/design-tools-and-calculators/ltspice-simulator.htmlNot surprisingly, Tina-Ti and LTSpice, contain models of their respective components. LTSpice is supported in a forum by Analog Devices, who even help hobby users.I use both Tina and LTSpice. They are very accurate and save a lot of time and are really the best way to design or “tweak” circuit parameters.SJ

author: eugene
author_rank: Frequent Contributor
timestamp: July 19, 2023, 07:29:00 pm
content: I'm certain that can be modeled withLTspice. It comes with many NPN models, but you can model any NPN transistor with three parameters. It's worth learning, but it would probably be faster to just breadboard the circuit.

author: gsgx
author_rank: Contributor
timestamp: July 19, 2023, 07:44:46 pm
content: Thanks for the responses. Do any of you know if these SPICE applications can do the equivalent of "assertions", like a design rule checker that reports if any of the computed values doesn't match an expected value? Part of my problem with SPICE right now is that I don't always want to look at the graph to verify everything looks right.

author: Solder_Junkie
author_rank: Frequent Contributor
timestamp: July 19, 2023, 08:18:37 pm
content: Quote from: gsgx on July 19, 2023, 07:44:46 pmIf you look at the Tina web page, there is a chart showing features for each version. I don’t know what features the free Ti version has, or the comparison with LTSpice features.Either is more than enough to model basic circuits right up to some very sophisticated circuitry.SJ

author: Benta
author_rank: Super Contributor
timestamp: July 19, 2023, 09:49:42 pm
content: Quote from: gsgx on July 19, 2023, 07:44:46 pmSounds more like you're looking for a production-line go/no-go checker.If you don't like looking at graphs when designing, well...

author: tychob
author_rank: Contributor
timestamp: July 19, 2023, 10:27:00 pm
content: It sounds like what hes looking for is more like a unit testing system. So take the example amplifier, Use the graphs to come up with a set of parameters that has sufficient linearity. Encode those assertions. Then look at Power supply ripple and the impact make any tweaks, and encode those assertions, then take a look at quiescent current and see if that can be improved. Then see if you can reduce the BOM. On a single amplifier thats already starting to get overwhelming to look at all the graphs for all those issues at once. Now consider a more complex mixing or synthesis circuit. Is there not any tool that can automatically tell you if the relevant part of the graphs has changed without having to dig through 20 graphs for every parameter tweak?

author: gsgx
author_rank: Contributor
timestamp: July 19, 2023, 10:33:30 pm
content: Quote from: tychob on July 19, 2023, 10:27:00 pmYea, it's exactly this. I look at the graphs while designing, but then I tweak something somewhere else and it be great to know immediately if I "broke" something elsewhere. Of course I could just test it on a breadboard, but this would increase development time, and probably even discourage me from pursuing some designs as they'd be a lot of effort to get right (as a hobbyist I make a lot of mistakes). I'm a software dev, so I'm spoiled by stuff like unit tests, linters, fuzzing, static analysis, etc. to spot out mistakes quickly. But by the responses so far it seems like there may not exist a solution currently for this (although I still need to dig into Tina-TI).

author: gsgx
author_rank: Contributor
timestamp: July 19, 2023, 10:45:05 pm
content: I could probably get PySpice to work for my use case, but it doesn't seem like it's maintained at the moment:https://github.com/PySpice-org/PySpiceMATLAB SimuLink might be the kind of thing I'm looking for:https://www.mathworks.com/solutions/model-based-design.htmlIt has all of the modeling/graphing capabilities of SPICE (although I would guess there's many more SPICE models available online), and as it's in MATLAB you can probably do normal programming things like assertions and tests. I may try out the trial just to get a sense of what it can do, but it's not really a long term option for me as I'm looking for something free and open source.

author: eugene
author_rank: Frequent Contributor
timestamp: July 20, 2023, 05:26:46 pm
content: You might want to ask for a price quote before you spend too much time looking at Matlab with Simulink. ConsiderSciLabwith Xcos if you think that sort of tool is what you really want, but don't want to spend Matlab money. Theelectrical paletteincludes all the building blocks you need including a simple NPN transistor model. I don't know how good that model is, but it might serve you well enough.

author: gsgx
author_rank: Contributor
timestamp: July 20, 2023, 05:54:38 pm
content: Thanks! SciLab with Xcos does seem like it might be what I need, I'll try it out.