Need help: INA193 in ngspice-30 - Page 1
Forum section: electronics / projects

author: thinkfat
author_rank: Unknown
timestamp: August 30, 2019, 11:15:57 pm
content: Hi,I'm trying to simulate an INA193 in ngspice-30. I got the pspice model from the TI website and tried to convert it to ngspice.ngspice doesn't have TEMP so I added a .PARAM TEMP=27 at places where it was needed.I also replaced VSWITCH with ASWITCH according to the ngspice user manual.ngspice then complained about this construct:VCCVS4_in 42 2I found some posting on the TI E2E forum suggesting to add a '0' as the third parameter, which I did.Lastly, the resistor model in ngspice is called "R" not "RES", I changed that, too.Unfortunately, still no luck. The output is always 0V.I've attached the modified INA193.LIB and a simple test netlist for ngspice.Maybe someone more experienced can help me out?

author: SiliconWizard
author_rank: Super Contributor
timestamp: August 31, 2019, 01:18:03 am
content: I took a look. First, your test circuit doesn't look right. Apparently you're loading the output of the INA193 with a 1 ohm resistor? It's not going to like that much.Then, the load supply (couldn't see it?) and load current source (seems weirdly connected), that doesn't look right. I see it's generated from KiCad, dunno if it's a problem with KiCad or with your schematic. You could maybe post a picture of it.That said, I fixed the test circuit, and still get 0V exactly at the output. Can't figure out what's wrong with the model, but it clearly is borked. It's not 100% Spice compatible. We can see it's been designed for Tina, and frankly I have already run into TI models (especially the more recent ones) that I couldn't figure out how to use in ngspice or LTSpice... I did the same as you tried to fix them, and had no luck.

author: thinkfat
author_rank: Unknown
timestamp: August 31, 2019, 07:06:49 am
content: Thanks for having a look. Yes, I noticed that the current source is upside down and also about the 1 ohm resistor, corrected netlist is attached. I also attached a screenshot of the circuit. It's really the most basic thing I could come up with.

author: thinkfat
author_rank: Unknown
timestamp: August 31, 2019, 11:35:27 am
content: Small progress: I found out that ngspice has a "limit" function that is incompatible with pspice' "LIMIT"replacing that with a compatible "ps_limit" gives me a constant 4mV out

author: T3sl4co1l
author_rank: Super Contributor
timestamp: August 31, 2019, 12:33:24 pm
content: On a broader note; what are you trying to learn from the model? Are you simulating the behavior of a larger circuit and only need this for its normal functionality (a high-CMRR amp of nominal gain and bandwidth)? Or are you testing the part itself, for function under somewhat unusual conditions and would like to evaluate the model under these conditions?Tim

author: thinkfat
author_rank: Unknown
timestamp: August 31, 2019, 01:21:35 pm
content: Quote from: T3sl4co1l on August 31, 2019, 12:33:24 pmI'm trying to come up with a current limiting for my power supply, I did have a something with a difference amplifier and a comparator made from a dual opamp, but it has terrible CMRR and temperature drift. I'm trying to get the whole power supply simulated before I actually build it.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: August 31, 2019, 02:16:01 pm
content: Low side sensing not practical..?To play with limiting and compensation of the '723, it should at least be okay to use a fixed gain amplifier (which can be a couple dependent sources and an RC or two to set frequency response and phase). I don't foresee any nasty problems within the range you'll be using it. But yeah it's always nice to have at least a little verification from a more fleshed out model.Tim

author: thinkfat
author_rank: Unknown
timestamp: September 01, 2019, 07:23:52 am
content: I'm not so worried about static behaviour, that I'd not need to simulate the circuit for, but I had some pretty weird effects when simulating load changes, the whole circuit got into oscillation.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: September 01, 2019, 08:42:25 am
content: Yeah, keywords there being the RC to set frequency response. This should be derivable from the datasheet. As for pathological edge cases, who knows, they probably didn't put those in their own model either.I don't much like the switches or nonlinear dependent functions in the model, but I'd have to poke at it for some time to see if there's anything funny with it in my environment, and I don't know about ngspice specifically...Tim

author: thinkfat
author_rank: Unknown
timestamp: September 01, 2019, 09:18:03 pm
content: After some more tinkering, I have the model working in ngspice now. See the attached file.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: September 01, 2019, 09:30:39 pm
content: Huh, what is "temper"?Tim

author: thinkfat
author_rank: Unknown
timestamp: September 01, 2019, 09:46:58 pm
content: Quote from: T3sl4co1l on September 01, 2019, 09:30:39 pmApparently the equivalent of pspice' TEMP.Gesendet von meinem Nokia 6.1 mit Tapatalk

author: mikerj
author_rank: Super Contributor
timestamp: September 01, 2019, 10:09:28 pm
content: Quote from: T3sl4co1l on September 01, 2019, 09:30:39 pmIt's what trying to convert spice models gives you.

author: SiliconWizard
author_rank: Super Contributor
timestamp: September 01, 2019, 10:13:34 pm
content: Nice job. The model is the 20V/V version apparently.Note that this has a large non-linearity for low Vsense values. Thus the datasheet states all params for Vsense >= 20mV...