Simulating with op-amps; ideal works; real models a problem

Using KiCAD 8.0, using ngspice to work with an op-amp circuit. The simulation works with an ideal op-amp model, but when I try a real model file from a manufacturer (TI) I get the “timestep too small” error message:

Without “Use initial conditions” checked:

doAnalyses: TRAN:  Timestep too small; initial timepoint: trouble with xu1.xin11:dvnf-instance d.xu1.xin11.d1
run simulation(s) aborted

With “Use initial conditions” checked:

doAnalyses: TRAN:  Timestep too small; time = 1e-19, timestep = 1.25e-20: trouble with xu1.xin11:dvnf-instance d.xu1.xin11.d1
run simulation(s) aborted

I have tried TI’s model for a TLV9151, and for an OPA2991.

Netlist:

.title KiCad schematic
.include "...opa991/opa2991.lib"
.save all
.probe alli
.probe p(V1)
.probe p(R1)
.probe p(R3)
.probe p(XU1)
.probe p(R4)
.probe p(R2)
.probe p(V2)
.probe p(R6)
.probe p(V3)
.probe p(R5)
.tran 10n 100.05m 99.95m 20u
V1 Net-_R1-Pad1_ 0 PULSE( 0 5 1u 500n 500n 49.5u 100u ) 
R1 Net-_R1-Pad1_ Net-_U1--_ 10k
R3 Net-_U1-+_ 0 10k
XU1 Net-_U1-+_ Net-_U1--_ VA+ VA- Net-_R4-Pad2_ OPA2991
R4 Net-_U1--_ Net-_R4-Pad2_ 20k
R2 VA+ Net-_U1-+_ 20k
V2 Net-_R5-Pad2_ 0 DC 5 
R6 Net-_R6-Pad1_ VA- 100m
V3 0 Net-_R6-Pad1_ DC 5 
R5 VA+ Net-_R5-Pad2_ 100m
.end

Is there something I’m doing wrong? I have tried with and without setting initial conditions; neither method works.

Check the pinouts of your TI models compared to the built-in model.
Correct accordingly.

Here’s what’s in the TI models:

1=IN+ 2=IN- 3=VCC 4=VEE 5=OUT

Here’s what’s in the netlist:

XU1 Net-_U1-+_ Net-_U1--_ VA+ VA- Net-_R4-Pad2_ OPA2991

This looks right to my eye.

Please check your circuit.
What is the output supposed to be with your configuration?
What about setting IN+ of the OpAmp to zero?

.subckt pointlessrant
The circuit is more of a test of whether spice will work for me this time. Historically, spice has been a complete failure for me. I spend a lot of time attempting to simulate a circuit, then give up and either bread-board it or just layout a design. So far this experience is the same as all others. As I mentioned, this circuit works perfectly with an idealized op-amp, but not with any actual model file from a manufacturer. I uploaded both the complete schematic and the spice netlist to make it easier to diagnose the problem(s).
.ends pointlessrant

What am I trying to do? The circuit simply takes a 0-5V square wave, and amplifies it to -5-+5V, so a 10V swing. The square wave is produced by the pulse definition, also in the uploaded schematic and netlist:

PULSE(0 5 1u 500n 500n 49.5u 100u)

So, V1=0, V2=5V, 1uS delay, 500nS rise time, 500nS fall time, 49.5uS high time, 100uS period. This makes a 50% DC 10KHz square wave with 0.5uS rise and fall times.

The amplifier model is for a TI OPA2991, which has a slew rate of 21V/uS; 10V/0.5uS=20V/uS, so the pulse waveform should comfortably fall within the capability of the amplifier to double the input signal. Again, it works with a simple op-amp model, but not with any real-world spice file I have tried.

The op-amp model it actually works with:

.SUBCKT IDEALAMP 1 2 3 4 5
RIN     1       2       10MEG
EGAIN   6 4     1 2     100K
RP1     6       7       1K
CP1     7       4       1.5915UF
EBUFFER 8 4     7 4     1
ROUT    8       5       10
.ENDS

Not sure what issue you are seeing, but the model works for me. I roughly replicated your schematic.
TI_opamp.zip (11.7 KB)

First of all, thank you. I downloaded your design and loaded it; I get the same simulation error:

doAnalyses: TRAN:  Timestep too small; initial timepoint: trouble with xu1.xin11:dvnf-instance d.xu1.xin11.d1
run simulation(s) aborted

So, why would it work for you and not me? The version of KiCAD I’m working with:

Application: KiCad Schematic Editor x64 on x64

Version: 8.0.1-rc1, release build

Libraries:
	wxWidgets 3.2.4
	FreeType 2.12.1
	HarfBuzz 8.3.0
	FontConfig 2.14.2
	libcurl/8.5.0-DEV Schannel zlib/1.3

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

Build Info:
	Date: Mar  4 2024 02:39:35
	wxWidgets: 3.2.4 (wchar_t,wx containers)
	Boost: 1.83.0
	OCC: 7.7.1
	Curl: 8.5.0-DEV
	ngspice: 42
	Compiler: Visual C++ 1936 without C++ ABI

Build settings:

Is yours newer?!? older?

Huh, weird. Did you check compatibilty mode for pspice/ltspice? The TI model is a pspice model. I am running a slightly newer version of kicad and ngspice. Maybe some issue got fixed?

Application: KiCad x64 on x64

Version: 8.0.8, release build

Libraries:
	wxWidgets 3.2.6
	FreeType 2.13.3
	HarfBuzz 10.0.1
	FontConfig 2.15.0
	libcurl/8.10.1-DEV Schannel zlib/1.3.1

Platform: Windows 11 (build 26100), 64-bit edition, 64 bit, Little endian, wxMSW
OpenGL: ATI Technologies Inc., AMD Radeon(TM) Pro Graphics, 4.6.14802 Compatibility Profile Context FireGL 21.40.64.20 30.0.14064.20002

Build Info:
	Date: Jan 11 2025 18:59:49
	wxWidgets: 3.2.6 (wchar_t,wx containers)
	Boost: 1.86.0
	OCC: 7.8.1
	Curl: 8.10.1-DEV
	ngspice: 44
	Compiler: Visual C++ 1942 without C++ ABI

Build settings:

This is what the output looks like for me:

Each last number change in version number means several dozen bugs fixed.
Where from comes the idea to use version that has probably a few hundred bugs more compared to currently available version?

Agreed. Update to 8.0.8, which should also bring your ngspice to 43 or 44.

I do have the pspice/ltspice box ticked, so that’s not it. The version of ngspice you have is newer, so maybe something’s changed there.

I just tried the latest version, 8.0.8. Yours works, mine works, a lot more of my circuit works; feels like… progress!

Thank you, thank you, thank you Lucas.

1 Like