Possible simulator bug?

Newbie alert - just learning to use the simulation feature, using a basic inverting op-amp circuit with a voltage gain of -1. This is the circuit:

The input voltage is set to 1V AC, 1kHz. Performing a transient analysis and getting this:

This looks wrong: it’s showing a voltage gain of -3, not -1. Is this a bug?

I’ve run the identical circuit in NI Multisim:

image

And this is what is produced:

That looks correct: inversion with no gain. Am I doing something wrong? Or is this a bug that I need to report?

Attached are the relevant files.

Simulation 2.net (6.1 KB) Simulation 2.pro (919 Bytes) Simulation 2.sch (7.0 KB) Simulation 2.cir (354 Bytes)

I had to reorder the pins, as shown here:

The value of R2 in your spice netlist is 30k. Update the netlist and rerun your simulation.

1 Like

@radix is correct, that’s the reason: image

Generally I would suggest not using the resistors in the PSPICE library. Just use the regular resistor in the library (device/R). If the refdes starts with R kicad/ngspice will automatically guess it’s a resistor and use the “Value” field as its resistance. Then you don’t have a separate Spice_Model field that needs to be kept in sync…

Edit: in this case I would just delete the contents of the Spice_Model field. If it’s empty I think Value will be used instead.

Also, not important in this particular case, but another relevant file is the spice model for the opamp (ti.lib).

2 Likes

radix and gkeeth: thank you, thank you!

I feel like a fool, but it’s a lesson I won’t forget! In particular, I’ll take on board your point that a separate Spice model field can get out of sync if you’re not careful.

Thanks again - what a great bunch of people in this forum. :slightly_smiling_face:

1 Like

don’t feel like a fool, it’s not obvious…

I just had a short peek at the library “Simulation_SPICE” and it does not have any resistor at al in my variant of the libraries.
(Although I do recall a resistor in there several years ago).
It’s a very small library with only 20 schematic symbols:

Just curious:
What KiCad version do you have?

Are the Spice libraries in this directory link from some external source?
image

KiCad’s own library names were in plural form in KiCad V4 and changed to singular in KiCad V5.

The current stable KiCad version is V5.1.9.
You can copy the full version info by copying it from: Eeschema / Help / About KiCad / [Copy Version Info and then paste it here.

It looks like:

Application: Eeschema
Version: 5.1.9-73d0e3b20d~88~ubuntu20.04.1, release build
Libraries:
    wxWidgets 3.0.4
    libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3
Platform: Linux 5.4.0-66-generic x86_64, 64 bit, Little endian, wxGTK
Build Info:
    wxWidgets: 3.0.4 (wchar_t,wx containers,compatible with 2.8) GTK+ 3.24
    Boost: 1.71.0
    OpenCASCADE Community Edition: 6.9.1
    Curl: 7.68.0
    Compiler: GCC 9.3.0 with C++ ABI 1013

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

@SteveT was using the resistor from the pspice library, not Simulation_Spice

Ah, now I see.
Sorry for the noise.

Just to confirm:

Application: Eeschema
Version: (5.1.8)-1, release build
Libraries:
wxWidgets 3.0.5
libcurl/7.71.0 OpenSSL/1.1.1g (Schannel) zlib/1.2.11 brotli/1.0.7 libidn2/2.3.0 libpsl/0.21.0 (+libidn2/2.3.0) libssh2/1.9.0 nghttp2/1.41.0
Platform: Windows 8 (build 9200), 64-bit edition, 64 bit, Little endian, wxMSW
Build Info:
wxWidgets: 3.0.5 (wchar_t,wx containers,compatible with 2.8)
Boost: 1.73.0
OpenCASCADE Community Edition: 6.9.1
Curl: 7.71.0
Compiler: GCC 10.2.0 with C++ ABI 1014

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