Implementation of AD8611 Comperator

Hello,

I tried to implement a AD8611 and used original SPICE model from the AD site:
https://www.analog.com/media/en/simulation-models/spice-models/AD8611.cir

Unfortunately, I am getting the following error in a simple test implementation:
Error on line 0 :
s.xu_comp.s1 xu_comp.10 xu_comp.11 0 0 slatch1
Unable to find definition of model slatch1 - default assumed
Background thread stopped with timeout = 0
Reducing trtol to 1 for xspice ‘A’ devices

Can anyone tell me how to debug/narrow down the error in the subckt-code of the spice model?

Since I am not able to upload files to the forum, my test circuit can be downloaded from
https://www.sendspace.com/file/34wyx6

Patrick

You have to set PSPICE compatibility, as described in http://ngspice.sourceforge.net/ngspice-eeschema.html#setting.

Thank you for the advise. Indeed I did not setup the pspice option. However, somehow I am not able to get rid of the error message.

The instruction is not very detailed for setting up the pspice option. When talking about the “environmental variable” is the windows 10 system environment or the kicad environment meant? Neither one or the other one has a variable “USERPROFILE”. Anyhow, I tried both enviroments, added the variable and tried both file names. Can someone help me?

Patrick

Put a text file named .spiceinit into your user or home directory.
For Windows 10 the home directory is typically: C:\users’your name’. It may depend on your language settings, in German for example it is: C:\Benutzer’your name’. If you open the Windows command line window, it will typically immediately point to the USERPROFILE. You may the enter the set command. I will get something like (among many others):

USERNAME=holger
USERPROFILE=C:\Users\User
windir=C:\Windows

So my home directory is C:\Users\User.

I checked the environmental variable setting with the SET command from the command line. Everything looks as you described (in my case the username and the directory name of the user profile is the same):

USERNAME=patrick
USERPROFILE=C:\Users\patrick
windir=C:\Windows

I also tried, the two versions of the .spiceinit-file where the file ends at the line with the statement or with a new line.

However, the simulator still throws the same error. Is there a chance to check inside Eeschema if ngspice starts in the pspice behavior setting? So we could identify if this is truly the reason for the error?

.spiceinit is directly sourced by Ngspice shared lib.

You did not tell us which KiCAD and Ngspice versions you are using.

For Ngspice you may place

.op
.control
version
.endc

into an empty eeschema window and run the simulator.

Sorry, for not mentioning the versions. It is KiCad 5.1.5-3 with the ngspice version that came along with the KiCad version 5.1.5-3 installation.

When placing the code, I am getting the following feedback:
Circuit: KiCad schematic


** ngspice-31 : Circuit level simulation program
** The U. C. Berkeley CAD Group
** Copyright 1985-1994, Regents of the University of California.
** Please get your ngspice manual from http://ngspice.sourceforge.net/docs.html
** Please file your bug-reports at http://ngspice.sourceforge.net/bugrep.html
** Creation Date: Sat Nov 2 21:58:52 UTC 2019


Doing analysis at TEMP = 27.000000 and TNOM = 27.000000
Reference value : 0.00000e+00
No. of Data Rows : 1

Another hint: When you make a change to the ngspice settings, or when you get a non-recoverable error in ngspice, you need to shut down eeschema completely. It is not sufficient to just close and re-open the simulator window.

I will make a bug report (wish list) to change that in the future. I guess it is better that shared ngspice will be attached to eeschema only when opening the simulator window and be detached again when closing it. The overhead to do so would be negligible.

I already did so, but it did not help. Any further hint or something how I can check if the pspice Mode if activated? Why is the pspice mode not activated by default?

Unfortunately I cannot read your eeschema example. There seems to be a library named ngspice.lib missing. All your symbols refer to that library.

You might try
set ngbehavior=psa
This then will make the full netlist PSPICE compatible, not only the file read by .include.

ngspice is compatible to spice3. We then have compatibility switches for PSPICE, HSPICE and LTSPICE. The latter is not yet very sophisticated. PSPICE is for board level electronics, HSPICE for IC design, well and LTSPICE is on its own. PSPICE and HSPICE are mutually exclusive. The switch howver might be set to PSPICE by KiCAD, as this seems to be usefull to many board level designers. You might put this on the agenda by a ‘bug report’ at https://gitlab.com/kicad/code/kicad/issues?label_name[]=ngspice&scope=all&state=opened

Using the

set ngbehavior=ps

command did not help.

I used the ngspice.lib from here to implement the components in the circuit:


Is this something you would not recommend?

A bug report sounds a bit hard for a request. I will check if there is something like a wishlist.

I believe the issue is indeed with the set ngbehavior=ps command. Your project simulates fine on my system, and then when I remove the command I get the same exact error as you do.

Put this attached file into C:\Users\patrick\ and then re-launch Eeschema and try again:
spice.rc (46 Bytes) .

This is absolutely o.k… But when you publish a schematic using this library, you should mention that you have used it and where it came from (or add it to your files). Otherwise your publishing is not usable by others.

Now it is running. Thanks all of you for the help.

It seems that my Windows 10 has problems with the filename “.spiceinit” which I used in most of my tests and when I did the tests with the “sice.rc” filename, the userprofile path or something like this was not set. I can’t backtrack it.

Patrick