Generic mosfets? [solved]

I may be missing something obvious, or my install is broken. I can get generic BJT models working fine with

.model qnpn npn
.model qpnp pnp

but when I try a generic mosfet, I get “could not find a valid modelname” error. According to ngspice-27 manual, chapter 11.2 MOSFET models (NMOS/PMOS) a minimal model is

Each model is invoked with a .model card. A minimal version is:
.model MOSN NMOS level=8 version=3.3.0

but can’t get that to work:



I built a 5rc2-ish KiCad from source, so maybe it is not setup right

Application: kicad
Version: (5.0.0-rc2-dev-266-gbad462a22), debug build
Libraries:
    wxWidgets 3.0.3
    libcurl/7.57.0 OpenSSL/1.0.2n (WinSSL) zlib/1.2.11 libidn2/2.0.4 libssh2/1.8.0 nghttp2/1.29.0
Platform: Windows 7 (build 7601, Service Pack 1), 64-bit edition, 64 bit, Little endian, wxMSW
Build Info:
    wxWidgets: 3.0.3 (wchar_t,wx containers,compatible with 2.8)
    Boost: 1.66.0
    Curl: 7.57.0
    Compiler: GCC 7.3.0 with C++ ABI 1011

Build settings:
    USE_WX_GRAPHICS_CONTEXT=OFF
    USE_WX_OVERLAY=OFF
    KICAD_SCRIPTING=ON
    KICAD_SCRIPTING_MODULES=ON
    KICAD_SCRIPTING_WXPYTHON=ON
    KICAD_SCRIPTING_ACTION_MENU=ON
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=OFF
    KICAD_SPICE=ON

Ha! The Law of Sod says I find the answer just after posting :wink:

The problem is not really the modelname ! ngspice is expecting 4 nodes for the mosfet, so it thinks pmos is the 4th node, and the model name is blank. Of course a blank name is not found…

The error message might be strictly correct, but completely confusing. Since modelname is mandatory parameter, a message “insufficient parameters supplied” would be better.

Answer: The latest KiCad pspice.lib has the mosfet symbols with the substrate pins. For own symbols, use a MOSFET symbol with 4 pins, in the order specified in Chapter 11.1 MOSFET devices

image

1 Like

With the right symbols, we get expected results. :smiley:

image

Complete project : inverter_mosfet.zip (1.6 KB)

1 Like

nice, was able to get mosfets working for first time on a project with your example; still haven’t figured out how to use all the types like vdmos, etc.

VDMOS requires at least ngspice-28. So better upgrade to ngspice-30. See http://ngspice.sourceforge.net/ngspice-eeschema.html for more info.

yes, installed ngspice 30 from http://ngspice.sourceforge.net/tutorials.html
and then kicad 5 which is said to have ng 30 built in. trying to figure how to check version of ng running…

used dpkg, says ngspice 26, i forgot to put the initfile in when i installed 30, will try, but not sure where to put it

Installing ngspice according to the tutorials.html does not help. Please have a look at the eeschem/ngspice tutorial cited above.

Installing KiCad under Windows will install ngspice as libngspice-0.dll into KiCad/bin. This is still version 27. You have to overwrite it by the procedure described in http://ngspice.sourceforge.net/ngspice-eeschema.html.

If you are using Linux, ask here again.