Code Monkey home page Code Monkey logo

kicad-spice-library's Introduction

KiCad Spice Library

This organization and repo is born from the need of having an easy way to find Spice models. It is not made by KiCad or Spice themself but it is user powered

There are a total of 50.093 models

Modules

In this folder there are all the modules and libraries, I tried to organize them with a minimum of logic but better approaches then mine are really welcome

Supported.txt

This is the list of supported parts in a human readable way, useful if you wish to do a quick search

Scripts

check_supported.py

This script check if a given part is between the supported modules. If yes it says us from which file it cames so we can easily add to our Spice simulation. It also contain a simple but working wrong-spell checks. See the examples at the end of the README

In the future it could be easily turned into a command line interface script or maybe a KiCad plugin

extractModels.pl

This script extracts the models for the requested components from the libraries. You can redirect it to a file like 'localSpice.lib' in your KiCAD project to have a local copy to reference. This avoids several side effects (libraries that are too big, libraries with invalid characters, duplicate models). You can add the models you need to 'spiceModel.lst' so that you can automate the extraction in a script.

Run the script without parameters for help.

generate_supported.py

This script generate the list of supported modules, it should be run only when new files are added to the repo

NOTE: Right now I am extracting the .model and .subckt from *.lib and *.mod files, the .subckt from *.fam files and the models from EESchema-LIBRARY Version 2.x so maybe there are some hidden modules around

downloader.py

This script downloaded all the 1803 files from http://espice.ugr.es/espice/src/modelos_subckt/ and saved them. It is not needed anymore and is here only for reference

Supported.pickle

This file is a python serialized dictionary where every key is a model and the items are path to libraries where that model is defined. It is not made to be read by humans, use Supported.txt instead

License

I do not own any license for the files inside the Modules folder, if you find any of them that breaks a license open an issue or send a message and it would be removed as soon as possible. All library, modules and other are released with their own license. The GPL3 is related only to the files in the Scripts folder

Contribuite

Do a pull request, add a library, module, whatever in the category that suit better in Modules or improve the python scripts

I would like to accept in the organization other KiCad or Spice fans to keep this page going on, if you would like to partecipate open an issue

Resources

Examples

Here there are a few possible usage scenarios with check_supported.py:

  • Searching bc337
Write here the part you are looking for: bc337
bc337 found in /Models/Manufacturer\Infineon Technologies\infineon.lib, /Models/Transistor\BJT\BJTN.LIB, /Models/uncategorized\spice_complete\siemens.lib

Also other 10 similar part has been found:

bc337/sie found in /Models/uncategorized\spice_complete\siemens.lib
bc337ap found in /Models/Manufacturer\Zetex Semiconductors\ZMODELS.LIB, /Models/Transistor\BJT\BJTN.LIB, /Models/uncategorized\spice_complete\zetex.lib, /Models/uncategorized\spice_complete\zmodels.lib
bc337ap_zx found in /Models/uncategorized\spice_complete\zetex.lib
bc337c_in found in /Models/Manufacturer\Infineon Technologies\infineon.lib
bc337s found in /Models/uncategorized\spice_complete\S_AFBJT.LIB
qbc337-16/plp found in /Models/uncategorized\spice_complete\phil_bjt.lib
qbc337-25/plp found in /Models/uncategorized\spice_complete\phil_bjt.lib
qbc337-40/plp found in /Models/uncategorized\spice_complete\phil_bjt.lib
qbc337/plp found in /Models/uncategorized\spice_complete\phil_bjt.lib
qbc337a/plp found in /Models/uncategorized\spice_complete\phil_bjt.lib
  • Searching 2n2222
Write here the part you are looking for: 2n2222
2n2222 found in /Models/uncategorized\IdealDiode.lib

Also other 5 similar part has been found:

2n2222a found in /Models/uncategorized\spice_complete\zetex.lib, /Models/uncategorized\spice_complete\zmodels.lib
2n2222a_zx found in /Models/uncategorized\spice_complete\zetex.lib
2n2222c found in /Models/uncategorized\spice_complete\ad.lib
q2n2222 found in /Models/uncategorized\spice_complete\cadlab.lib
q2n2222a found in /Models/Manufacturer\TRT-Electronics\2n2222a.lib, /Models/Manufacturer\Zetex Semiconductors\ZMODELS.LIB, /Models/uncategorized\spice_complete\cadlab.lib

NOTE: there are different models of these IC produced by different manufacturers, so we can pick the model more similar to our use case

  • If we don't know/remember perfectly the IC we are looking for
Write here the part you are looking for: 2n2
2n2 not found, maybe you meant one of these: 2n2102_on, 2n2222, 2n2222a, 2n2222a_zx, 2n2222c, mtd2n20, mtp12n20, mw32n20e, q2n2219, q2n2219a, q2n2222, q2n2222a, q2n2905, q2n2905a, q2n2907, q2n2907a, tn0102n2, tn0602n2, tp0102n2, tp0602n2
  • Searching less common part like the 2sa1940
Write here the part you are looking for: 2sa1940
2sa1940 not found, maybe you meant one of these: q2sa1940

Would you like to do another search? q2sa1940
q2sa1940 found in /Models/uncategorized\spice_complete\other_models\BJT_PNP\TOSH_PWR.LIB

Just for reference this is the output that I got from generate_supported.py the first time I run this project, now after better filtering the models are much more

5 txt found
375 lib found
290 mod found
699 spi found
71 fam found
356 cir found
9 other kind found

There are 8004 models

kicad-spice-library's People

Contributors

aster94 avatar bringert avatar erhannis avatar jdtimmerman avatar riesi avatar serveln avatar stoneddiscord avatar turnoffnod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kicad-spice-library's Issues

Here I wrote tl074.lib which will go nicely with your tl074.mod

.SUBCKT TL074c 1out 1in- 1in+ vcc+ 2in+ 2in- 2out 3out 3in- 3in+ vcc- 4in+ 4in- 4out
.include TL074.301
XU1A 1in+ 1in- vcc+ vcc- 1out TL074
XU1B 2in+ 2in- vcc+ vcc- 2out TL074
XU1C 3in+ 3in- vcc+ vcc- 3out TL074
XU1D 4in+ 4in- vcc+ vcc- 4out TL074
.ends

Because I see you only provide the opamp but not the whole chip

extractModels is broken?

$ python3 ./Scripts/extractModels.pl
  File "/home/user/Dev/KiCad-Spice-Library/./Scripts/extractModels.pl", line 62
    $modelName=~s/([$"])/\\$1/g;
                     ^
SyntaxError: unterminated string literal (detected at line 62)

naming convention

So regarding your statement "In this folder there are all the modules and libraries, I tried to organize them with a minimum of logic but better approaches then mine are really welcome"

Right now, you probably took models and libraries from a lot of different sources and put them together in this repo.
That is a good first step but to me everything feels a bit unorganized /hard to use.
(already better than Kicad by default though since that has only basic models)

I would like to give the following suggestion:

  • create a naming convention and keep this consistent for all libraries
  • strongly look at the naming conventions for the KiCad Libraries (KLC)
  • example1: no spaces in files or folders
  • example2: top level directories as main "libraries" like diode-zener, transistor-FET, etc.
    level below that should contain lib files, not to much nesting of folders.
    (a diode-zener-ST.lib would belong under "diode-zener" obviously)
  • make (a) converter script(s) to convert from other formats to the ngspice/Kicad format.
    (LTSpice format is also fine since that is widely used and compatible)
  • On https://forum.kicad.info/t/where-do-i-find-models-for-ngspice/29485 I read something about encrypted models so maybe we need to allow for LTSpice models as well?
  • since models are shown in Kicad in the order they are defined, keep these lib's in alphabetical order.
    (and/or make a script to enforce this on pull requests)

Maybe a nice topic to have some brainstorm on...

A bit confused by file extensions

For example some .lib are Spice files and some Kicad files. Thus, I added naively some Spice files as a Kicad library...

I suggest adding few lines on the README, cleanup the file extensions and move Kicad file in a separate directory.

file is not a valid symbol or symbol library file in ....

Application: KiCad x64 on x64

Version: 7.0.1, release build

Libraries:
wxWidgets 3.2.2
FreeType 2.12.1
HarfBuzz 5.0.1
FontConfig 2.14.1
libcurl/7.83.1-DEV Schannel zlib/1.2.13

Platform: Windows 11 (build 22621), 64-bit edition, 64 bit, Little endian, wxMSW

Build Info:
Date: Mar 11 2023 03:41:46
wxWidgets: 3.2.2 (wchar_t,wx containers)
Boost: 1.80.0
OCC: 7.6.2
Curl: 7.83.1-DEV
ngspice: 39
Compiler: Visual C++ 1934 without C++ ABI

Build settings:
KICAD_SPICE=ON

74HC299
Screenshot_1

references to non-existing files in some library files.

in some files, for example "Models/Digital 20Logic/74HC.LIB" there are references to non-existing files like:

.model ls_shift4 d_state(state_file=shift4.txt
.model ls_count16 d_state(state_file=count16.txt reset_delay=26n)

anyone knows where I could find those files?

LM358 negative power consumption, need better model

The LM358/NS subcircuit model in this repository (Models/Operational%20Amplifier/Lm358.mod) sometimes exhibits negative power consumption and may actually end up seemingly powering connected circuits as an artifact of this bug. IN particular, this happens when the power supply is 5V (+/- 2.5V) or less (as allowed by the data sheet).

This can be shown by putting the model in a basic opamp example circuit and running a simulation with low power supply (I happened to do my tests in the popular LTSpice freeware instead of whatever is installed with KiCad, but others should be able to check that this also happens with the KiCad bundled spice).

The alternative subcircuit model published by SGS Thompson (ST) has a very similar bug, generating even more fictional power.

The alternative model file published by NS/Ti as "snom268b" is even messier, not even being a single subcircuit .

It would be good if the repository maintainers would add a warning in the top comments of the LM358 model file, and leave this bug open as something that others can solve by uploading a better LM358 model.

files/dir. to copy into Kicad

Sorry if too nooby or naive but really need clarification
Whatever files/dir. to copy and into where in the Kicad default paths in order the Tool->Simulator works seamlessly

Remove ENDS from some libraries

Simulation under KiCAD fails like this:

Error: Mismatch of .subckt ... .ends statements!
This will cause subsequent errors.
Error: ngspice.dll cannot recover and awaits to be detached

The reason is something like this (.ENDS without .SUBCKT):

*
*BLABLA MODEL
*
.MODEL BLABLA NMOS (LEVEL=3   RS=0.36            NSUB=1.0E15
+DELTA=0.1      KAPPA=0.0506    TPG=1              CGDO=6.343E-10
+RD=0.43        VTO=1.600       VMAX=1.0E7         ETA=0.0223089
+NFS=6.6E10     TOX=1.0E-7      LD=1.698E-9        UO=862.425
+XJ=6.4666E-7   THETA=1.0E-5    CGSO=9.09E-9       L=2.5E-6
+W=5.0E-3)
.ENDS

Changing to
The reason is something like this (.ENDS without .SUBCKT):

*
*BLABLA MODEL
*
.MODEL BLABLA NMOS (LEVEL=3   RS=0.36            NSUB=1.0E15
+DELTA=0.1      KAPPA=0.0506    TPG=1              CGDO=6.343E-10
+RD=0.43        VTO=1.600       VMAX=1.0E7         ETA=0.0223089
+NFS=6.6E10     TOX=1.0E-7      LD=1.698E-9        UO=862.425
+XJ=6.4666E-7   THETA=1.0E-5    CGSO=9.09E-9       L=2.5E-6
+W=5.0E-3)
* .ENDS

Fixes the issue.

Number of VDMOS exceeded

Trying to start a simulation using the Transistor/FET/MOS.lib library results in a crash (even after fixing the first line by changing '#' into '*')

In order to determine the cause, I decided to try to load the library using ngspice.
The behaviour is more or less the same.

File "test.cir":

.title KiCad schematic
.include "..\KiCad-Spice-Library\Models\Transistor\FET\MOS.lib"

Testing file "test.cir":

c:\Spice64\bin\ngspice_con.exe test.cir

I performed a "manual binary search" by deleting lines until the library load worked and up to the moment where the load failed.

I then got the following message in the ngspice console (not the KiCAD version):

Warning: Syntax check for VDMOS instances is limited to 256 .model cards

Circuit: KiCad schematic

This is coherent with the fact that I had to truncate the MOS.lib file to 263 lines.

I suggest to split the file into smaller parts.

More generally, all libraries could be checked by trying to load them using ngspice and verify that the ngspice execution does not exit prematurely.

Case insensitive search

It would be nice to have the following lookup working, independent of case:

$ ./Scripts/check_supported.py 2N3906
Searching for 2N3906
2N3906 not found!
$ ./Scripts/check_supported.py 2n3906
Searching for 2n3906
2n3906 found in
- Transistor/BJT/BJT.lib

trying to open DIODE2.lib: "Could not find model '1N4007'

In Kicad7 I am trying to add a diode model (bat54a) to my symbol.
When opening DIODE2.lib I get the error:
Could not find model '1N4007'to copy for "A Kind Of" model 'D1N4007'
The lib won't open.

Moving 1N4007 before D1N4007 helped for me.

Python script error

Thanks for this project, I think it could be better.
I got an error like:

[Ken@kenpc Scripts]$ python check_supported.py
Write 'exit' when you want to stop
Write here the part you are looking for: 555
555 not found, maybe you meant one of these: 555_pwr, atod_555, atod_555_nx, bb555/sie, bb555_in, bcr555/sie, bcr555_in, cd4555b, din555, do555, do555_nx, dtoa_555, fmmt555, fmmt555_zx, fxt555, fxt555_zx, io_555, irf7555_ir, j555, lm555, pmbt5550, pmbt5551, pmst5550, pmst5551, q2n5550, q2n5551, s0555r, tlc555_ti, ts555h, ts555h_st, ts555l, ts555l_st, ts555m, ts555m_st, ua555, ztx555, ztx555_zx
Would you like to do another search? lm555
Traceback (most recent call last):
File "check_supported.py", line 68, in
search(to_search)
File "check_supported.py", line 38, in search
print_match(module)
File "check_supported.py", line 16, in print_match
path = ', '.join(p[p.index(folder_name)+len(folder_name):] for p in supported[part])
File "check_supported.py", line 16, in
path = ', '.join(p[p.index(folder_name)+len(folder_name):] for p in supported[part])
ValueError: substring not found

OS: manjaro xfce 64bit

[Ken@kenpc Scripts]$ python -V
Python 3.7.3

check_supported script not working due to absolute paths

Hi,

I stumbled upon this project in search for a specific model. I tried using the check_supported script, but it did not work for me

~/git/KiCad-Spice-Library/Scripts $ python check_supported.py 
Write 'exit' when you want to stop
Write here the part you are looking for: lnd150
Traceback (most recent call last):
  File "/home/joost/git/KiCad-Spice-Library/Scripts/check_supported.py", line 68, in <module>
    search(to_search)
  File "/home/joost/git/KiCad-Spice-Library/Scripts/check_supported.py", line 38, in search
    print_match(module)
  File "/home/joost/git/KiCad-Spice-Library/Scripts/check_supported.py", line 16, in print_match
    path = ', '.join(p[p.index(folder_name)+len(folder_name):] for p in supported[part])
  File "/home/joost/git/KiCad-Spice-Library/Scripts/check_supported.py", line 16, in <genexpr>
    path = ', '.join(p[p.index(folder_name)+len(folder_name):] for p in supported[part])
ValueError: substring not found

I looked in to this and found out this was due to some path differences. Instead of just finding the part I need I procrastinated and tried to clean-up a bit of these scripts. I'll publish a pull request with my work

Extract requested models to cope with "Maximum" and "Duplicates"

In #16 I explained that the MOS.lib library has too many models, which prevents simulation (actually: KiCAD crashes).

I also had a conflict with the 2N7000 model because it appears in Supertex.lib that I loaded fror the VP2106 MOSFET as well as in MOS.lib .
However, one is a "NMOS" model and the otehr one is a "VDMOS" model - each model requiring a different number of nodes (the first model has bulk, the second one doesn't).

So I decided to create a library local to the project (spice.lib) where I added a copy of the model.
The benefits are:

  • The issue with the limit on the number of VDMOS models is avoided;
  • The issue with duplicates is avoided (we know which model is used);
  • All the models are included with the project (no need to refer to an external library).

So there would be some use for a script that would extract selected models from the libraries to extract them into a single project spice library file.

Anyway, extracting the model manually is fine for me as well: I do not make that many analogue simulations... .

Zener Diode pins are reversed

The Zener diode pins are reversed in the simulation, the breakdown effect is seen when the diode is wired in the direction of flow and no breakdown is seen when wired backwards.
DiodeReversed
DiodeForward

Añadir librerias

Hola, soy nuevo en kicad, podrian explicarme como añadir la libreria de elementos spice en kicad version 5.1.9
Muchas gracias por su trabajo

Generate plugin for in-escheema search of models

It would be nice to be able to search the models inside Escheema and assign them directly onto the corresponding symbol. Right now it doesn't seems to be feasible without trying to contribute directly to the Kicad project. I read that in a future release, Escheema, will have the capability to run python-scripts or more complex plugins, probably we need to wait in order to develop such a feature.

NE555 timer model not working

I wanted to use the NE555 model from this repo but it doesn't seem to be working:

$ ./extractModels.pl 'NE555#/uncategorized/Bordodynovs Electronics Lib/sub/NE555.sub'
*
* NE555 - Extracted from '/uncategorized/Bordodynovs Electronics Lib/sub/NE555.sub'
*
.subckt NE555 1 2 3 4 5 6 7 8
A1 N001 2 1 1 1 1 N003 1 SCHMITT Vt=0 Vh=1m
R1 N001 1 5K
R2 5 N001 5K
R3 8 5 5K
S1 1 7 N007 1 D
A2 N011 N003 1 1 1 1 N008 1 SRFLOP Trise=100n tripdt=10n
A3 6 5 1 1 1 1 N012 1 SCHMITT Vt=0 Vh=1m
S2 8 3 N009 1 O
S3 3 1 1 N009 O
A6 1 N006 1 N008 1 1 N007 1 OR Ref=.5 Vlow=-1 Trise=100n
R7 8 1 4K
R9 2 1 1G
R10 6 1 1G
A4 1 N008 1 N006 1 N009 1 1 OR ref=.5 Vlow=-1 Trise=100n
A5 4 1 1 1 1 N006 1 1 SCHMITT Vt=.7 Vh=1m
D1 4 1 DR
A7 1 N006 1 N012 1 1 N011 1 OR
D2 8 4 400uA
.model DR D(Ron=150K Roff=1T Vfwd=1.6)
.model O SW(Ron=6 Roff=1Meg Vt=0 Vh=-.8)
.model D SW(Ron=6 Roff=.75G Vt=.5 Vh=-.4)
.model 400uA D(Ron=1K Ilimit=400u epsilon=.5)
.ends NE555

When I try to simulate it (astable mode), I get the following error:

Note: Compatibility modes selected: ps lt a
warning, can't find model 'or' from line
a7 1 n006 1 n012 1 1 n011 1 or
warning, can't find model 'c' from line
c2 net-_u1-thr_ gnd c
Circuit: KiCad schematic
Error on line:
a.xu1.a1 xu1.n001 net-_u1-thr_ 0 0 0 0 xu1.n003 0 xu1.schmitt xu1.vt 0 xu1.vh 1m
MIF-ERROR - unable to find definition of model 1m

Here's my schematic:
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.