LTspice Examples & Design #2

Thread Starter

tkosan

Joined Dec 17, 2019
25
Mod: Link to Starter Thread
https://forum.allaboutcircuits.com/threads/ltspice-examples.169795/post-1512411


Looks like this was not an original idea. Top four Google hits for LTspice Libraries on Github
<snip>
I think the original idea you mentioned was "browsing and searching" capability. If we had a database that contained LTspice circuits, searches like the following could be done on it:
  • All circuits that contain resistors and capacitors but no inductors.
  • All circuits that contain at least 5 capacitors.
  • All circuits that contain at least one voltage divider.
  • All circuits that contain a half-wave rectifier and at least one voltage divider.
  • etc.

A repository hosting service like GitHub is used to maintain the circuit file source code. However, software would need to be written that reads these files into a database and more software would need to be written that performs the searching.

Are you aware of any searchable database like this for circuits?
 
Last edited by a moderator:

MrAl

Joined Jun 17, 2014
11,393
I think the original idea you mentioned was "browsing and searching" capability. If we had a database that contained LTspice circuits, searches like the following could be done on it:
  • All circuits that contain resistors and capacitors but no inductors.
  • All circuits that contain at least 5 capacitors.
  • All circuits that contain at least one voltage divider.
  • All circuits that contain a half-wave rectifier and at least one voltage divider.
  • etc.

A repository hosting service like GitHub is used to maintain the circuit file source code. However, software would need to be written that reads these files into a database and more software would need to be written that performs the searching.

Are you aware of any searchable database like this for circuits?
That's interesting i started my own mini library of circuits and their analysis.
I started naming the files like this:
RLC-01.txt (if the circuit contained one R, one C and one L)
RRLC-01.txt (if the circuit had two R's and one C and one L)
RCRCRC-01.txt (if hte circuit had three R's and three C's like a filter).

However now i just usually label them the way they work such as:
LC_Filter-01.txt
RC_filter-01.txt
TwoTransistorAmplfier-01.txt
For a second version of a circuit like another RC filter circuit it would just increment the number:
RC_Filter-02.txt
RC_Filter-03.txt
etc.

It is interesting to have the full theoretical analysis along with simulation results that is why i did it this way, that way i can match the text file (analysis) with the sim file like:
RC_Filter-01.txt and RC_Filter-01.cir (or RC_Filter-01.asc for LT Spice).

Seems to work out and i have been doing it that way for a number of years now.

For some circuits i would be willing to contribute some theoretical analysis notes along with someone else contributing some simulation results and schematic.
 

Thread Starter

tkosan

Joined Dec 17, 2019
25
That's interesting i started my own mini library of circuits and their analysis.
I started naming the files like this:
RLC-01.txt (if the circuit contained one R, one C and one L)
RRLC-01.txt (if the circuit had two R's and one C and one L)
RCRCRC-01.txt (if hte circuit had three R's and three C's like a filter).

However now i just usually label them the way they work such as:
LC_Filter-01.txt
RC_filter-01.txt
TwoTransistorAmplfier-01.txt
For a second version of a circuit like another RC filter circuit it would just increment the number:
RC_Filter-02.txt
RC_Filter-03.txt
etc.
<snip>
This is a clever system and a step in the right direction! A step beyond this would be to create a circuit search engine that "looks" at a circuit's files and automatically determines if it contains an RC filter, a two transistor amplifier, etc.

In order to provide an idea of what a circuit search engine might look like in some ways I have an electronics formula search engine that I can make available by later this weekend for people to play with. If anyone is interested in playing with this electronics formula search engine let me know and I will put it on a server somewhere.
 

Papabravo

Joined Feb 24, 2006
21,159
Here is what I've got:

LTspiceExamples.png

I just keep adding folders with a leading index number corresponding to numbered divider tabs in a 3-ring notebook in case I decide to save any hard copies.
 

Papabravo

Joined Feb 24, 2006
21,159
Sure -- Here is the one for PWM Switch Models

Directory_13.png

The .asy files are symbols, and the .asc files are schematics. There are both stand alone flat schematics, and there are hierarchical schematics.
 

MrAl

Joined Jun 17, 2014
11,393
This is a clever system and a step in the right direction! A step beyond this would be to create a circuit search engine that "looks" at a circuit's files and automatically determines if it contains an RC filter, a two transistor amplifier, etc.

In order to provide an idea of what a circuit search engine might look like in some ways I have an electronics formula search engine that I can make available by later this weekend for people to play with. If anyone is interested in playing with this electronics formula search engine let me know and I will put it on a server somewhere.
Hello again,

Well i actually gave something like that some thought but determined that it may be too hard to do something that could look at a schematic itself and determine what components were in that circuit. The reason i came to that conclusion was because the symbols for various components are just too varied to be able to detect with a program. For example, many people use a spring looking thing for an inductor but others just use a rectangular box and still other schematics show just a lettering like "L1" or "L2" with no symbol at all just two lines going to that text that represent the wires. So i dont see a component recognition program being a possibility unless someone knows of one that has been done already or something.

I had created a Windows programming IDE some many years back that would recognize Windows components like buttons, windows, text boxes, etc., and it was not difficult, but the assumption was that everything would be in the shape of a rectangle.
If we had that constraint it would be easy, but unfortunately we dont.
Also, it would have to be able to recognize text like "R1", "R23", "C84", etc., and anyone that works with text recognition software knows that it is never perfect but always needs plenty of error correction by the human.

I would not rule anything out completely though so if anyone has any ideas in this direction i will be happy to consider and come up with a program if seems possible.

I already made schematic capture software but it assumes a certain format for the component graphical appearance. To use that, the user would have to manually convert each component into a form that is suitable for the program.
For example, if there was a resistor like R12 it would have to be typed in as something like:
+---R12---+

and so for larger circuits that would mean a lot of work on behalf of the user.

But still if anyone has any ideas i certainly would like to hear. Anything that prevents the user from having to draw the circuit all over again in a certain format that is.
If that is not the case, then i already have something that will do that but again it requires a redraw of the circuit.
 

Thread Starter

tkosan

Joined Dec 17, 2019
25
Between the fairly detailed folder-based categorization system that @Papabravo provided and the circuit example categories from the CircuitJS software, I think we have a good start on creating a general circuit categorization system. Does anyone else have a circuit categorization system they made that they would be willing to share?
 

Thread Starter

tkosan

Joined Dec 17, 2019
25
Well i actually gave something like that some thought but determined that it may be too hard to do something that could look at a schematic itself and determine what components were in that circuit. <snip>
I think current machine learning AI techniques would be capable of looking at images of electrical schematics and converting them into a data structure. However, it would take a large amount of work to train this software.

What I have in mind for now is to write software that parses existing .asc (and similar) files into a database. This database could then be searched to find circuits that have the desired circuit characteristics.
 

Papabravo

Joined Feb 24, 2006
21,159
I think current machine learning AI techniques would be capable of looking at images of electrical schematics and converting them into a data structure. However, it would take a large amount of work to train this software.

What I have in mind for now is to write software that parses existing .asc (and similar) files into a database. This database could then be searched to find circuits that have the desired circuit characteristics.
Something along the lines of the regular expression analyzer in Notepad++ that is used to do Syntax Highlighting
 

Papabravo

Joined Feb 24, 2006
21,159
I took a snapshot of my LTspice "...\examples" and "...\lib" folders, and the .7z file is 70 MB. If anybody wants it to experiment with or whatever just let me know.
 

Thread Starter

tkosan

Joined Dec 17, 2019
25
Something along the lines of the regular expression analyzer in Notepad++ that is used to do Syntax Highlighting
Regular expressions may indeed be helpful for parsing the files. However, the CircuitJS file reader just scans through each line and identifies the fields it contains. What I have in mind is to modify the CircuitJS file reading code to enable it to read LTSpice .asc files.
 

MrAl

Joined Jun 17, 2014
11,393
I think current machine learning AI techniques would be capable of looking at images of electrical schematics and converting them into a data structure. However, it would take a large amount of work to train this software.

What I have in mind for now is to write software that parses existing .asc (and similar) files into a database. This database could then be searched to find circuits that have the desired circuit characteristics.
Hi,

Oh ok that sounds very doable. I'll check one of the files right now.
LATER...
Ok it appears that the simplest way would be to use "View/SPICE netlist
and that seems to provide the entire netlist which can then be copied and pasted into a program similar to a inventory program.

Here is a small circuit sample:

* C:\Programs\LTC\LTspiceIV\MyStuff\TransistorModelTest-01.asc
Q1 N002 N003 N004 0 2N4401
V1 N003 0 0.7 Rser=0
V2 N001 N003 -0.579 Rser=0
R1 N001 N002 0.001
R2 N004 0 0.001
.model NPN NPN
.model PNP PNP
.lib C:\Programs\LTC\LTspiceIV\lib\cmp\standard.bjt
.op
.backanno
.end
 

Thread Starter

tkosan

Joined Dec 17, 2019
25
Hi,

Oh ok that sounds very doable. I'll check one of the files right now.
LATER...
Ok it appears that the simplest way would be to use "View/SPICE netlist
and that seems to provide the entire netlist which can then be copied and pasted into a program similar to a inventory program.

Here is a small circuit sample: <snip>
I had not thought about parsing the netlist file, but that could be done. I suppose one downside of using the netlist to obtain the circuit's structure is the physical location of the components would not be present. The video below shows the beginnings of automatic circuit layout capabilities that I am adding to the circuit simulator I am working on which may eventually help with this.

I think I would be able to parse the data that is in .asc and .asy files to read circuits into memory complete with the positions of their components.

 

jpanhalt

Joined Jan 18, 2008
11,087
I have wondered ever since doing anything as an adult in electronics why there was no cataloging of circuits by how components are connected (e.g., netlist).

Some of my background is in chemistry. If you share similar background, you know that chemistry indexes start with an empirical formula (e.g., components) then narrow the search by how they are connected. That process has existed in some form since 1778! Here's a list of some but not all of the notable indices:

Crell's --1778
Beilstein's Handebook 1779 - 1959
Annales de Chimie -- 1798
Chemical Absracts (JACS/Ohio State University) -- 1907 - present

I am anxious to see how a netlist search will work with designs that are similar in function versus identical in structure. If it relies on identity, then small differences in components and connections will lead to misses. One suggestion taken from AoE's organization is to classify components by number of pins and/or active or passive.
 

atferrari

Joined Jan 6, 2004
4,764
I have wondered ever since doing anything as an adult in electronics why there was no cataloging of circuits by how components are connected (e.g., netlist).

Some of my background is in chemistry. If you share similar background, you know that chemistry indexes start with an empirical formula (e.g., components) then narrow the search by how they are connected. That process has existed in some form since 1778! Here's a list of some but not all of the notable indices:

Crell's --1778
Beilstein's Handebook 1779 - 1959
Annales de Chimie -- 1798
Chemical Absracts (JACS/Ohio State University) -- 1907 - present

I am anxious to see how a netlist search will work with designs that are similar in function versus identical in structure. If it relies on identity, then small differences in components and connections will lead to misses. One suggestion taken from AoE's organization is to classify components by number of pins and/or active or passive.
I cannot imagine a search based on data arranged like that if I only am looking for a 3-pole band pass filter in the 3-20 KHz range or an op amp based triangle generator.

For my purpose the clasificación described would be an absurd.

Why not simply by the brief description of the function the simulated circuit acomplishes?
 
Last edited:

jpanhalt

Joined Jan 18, 2008
11,087
Chemistry did sort of lead the way. Physics, medicine, biology, and law have caught up. The key is for people to recognize a need.

Sticking to LTSpice, I can easily imagine an index based on parts used by both part number and function (e.g., op-amp), over all function (e.g., active filter), and how to do something (e.g, sweep a resistance).

Lacking is an index that allows a searcher to simply describe something. Search on "skin blister (or bubbles) on bottom of foot," and there are lots of relevant hits. There is no way in electronics to search on something by simply describing it, like "NPN transistor with foreword biased diode to base." Sure, Google will almost always return something, but most of it is not relevant to that question.
 

Thread Starter

tkosan

Joined Dec 17, 2019
25
I have wondered ever since doing anything as an adult in electronics why there was no cataloging of circuits by how components are connected (e.g., netlist).

Some of my background is in chemistry. If you share similar background, you know that chemistry indexes start with an empirical formula (e.g., components) then narrow the search by how they are connected. That process has existed in some form since 1778! Here's a list of some but not all of the notable indices:

Crell's --1778
Beilstein's Handebook 1779 - 1959
Annales de Chimie -- 1798
Chemical Absracts (JACS/Ohio State University) -- 1907 - present

I am anxious to see how a netlist search will work with designs that are similar in function versus identical in structure. If it relies on identity, then small differences in components and connections will lead to misses. One suggestion taken from AoE's organization is to classify components by number of pins and/or active or passive.
Since netlists are a kind of graph, I have been researching techniques for finding patterns in graphs. The research quickly uncovered that searching for patterns in graphs of chemical structures is a standard technique in chemistry. Since you point out the similarity between searching for patterns in circuits and searching for patterns in chemical structures, I am going to look more closely at how the searching of chemical structures is done.

As for searching by similarity in function instead of by identical structure, my thought is to implement identical structure search first then start thinking about how it can be expanded towards searching by similarity in function.
 

Thread Starter

tkosan

Joined Dec 17, 2019
25
Why not simply [search] by the brief description of the function the simulated circuit acomplishes?
If we had a large database that contained the circuits of complete products (such as radios, DVD players, etc.) creating natural language descriptions of the functions these complex circuits contain may take more effort than creating software that identifies these functions automatically.
 
Top