Simulation of analog multiplexers with LTSpice - Page 1
Forum section: electronics / general

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 14, 2023, 08:53:02 pm
content: Trying to simulate analog multiplexers with LTSpice - the goal here is to multiplex several channels for low-current measurement. Hence, low-leakage is mandatory.(My goal is leakage current <= 1nA.)I tried simulating the ADG1208, which seems to fit the bill.Attached is the sim file. I get a horrible leakage current of 80nA. (In off state - MUX disabled entirely - there's about 80nA through R1.) In on state, the leakage is in the same order (adding to the current sources on the Sx side.) I tried other analog multiplexers from AD, they pretty much all exhibit leakage currents in simulation much higher than the rated max leakageAny idea of what could be wrong? Are LTSpice models just fucked up and not simulating leakage currents properly? Did I do something wrong here?Edit: I tried simulating this with ngspice, using the Spice model here:https://www.analog.com/en/products/adg1208.html#product-toolsI have better luck, the leakage currents look closer to what they should be. But the simulated 'on' resistance is 1000 times higher than what it should be. I guess this Spice model is not quite compatible with ngspice.Truly baffled by this LTSpice behavior. If anyone can try with the file I posted (.zip because apparently one can't post .asc files directly anymore.)

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 16, 2023, 12:12:00 am
content: Follow-up:- I was using LTSpice on Wine, I tried on Windows just in case - same result. (That's reassuring.)- LTSpice models look encrypted. Nothing we can analyze in them. Unless someone knows how to. Not that I'd even want to modify them, but at least be able to see what they actually do model and what they don't. Traditional Spice models are in clear text, with usually comments stating what is modeled and what isn't. With LTSpice, you just don't know. Unless someone can point me to a resource that details all LTSpice models, which I doubt exists given the sheer number of them. But who knows.- So I just suppose that the ADG1208 model, and actually a number of other multiplexers do not properly model the off state. It's a very rough modeling.- Speaking of which, I have also noticed that some of their low-input bias current opamps were not properly modeled as far as input bias current is concerned. The simulations look ok, until you get a close look at the input bias current.Certainly something to be wary of. But if anyone manages to get "better" results than what I did, please let me know. I may be missing something, some option.Regarding ngspice: I found out what the culprit was in AD's ADG1208 Spice model. It uses POLY() expressions in a way that ngspice doesn't support. Details:It contains 3 lines of this kind:Code:EOUTb25 6bPOLY(2) (22,14) (3b,14) 0 0 0 0 230/1000One of the coefficients of the poly, as can be seen is not directly a literal, but an expression '230/1000'. ngspice doesn't seem to support that. I changed all these in the model by the equivalent literal (here for instance: '0.23'). And the model behaves as expected. (Apparently ngspice just seems to ignore the '/1000' part, without issuing any error or warning.)If that can be useful to anyone - AD's Spice models often use POLY's with such expressions for coefficients, so if you run into that and want to use them with ngspice, you'll know what to do.Also, ngspice needs to run in PSpice compatibilty mode to handle these models. My .spiceinit config file contains the following:Code:set ngbehavior=ltpsa

author: Fgrir
author_rank: Regular Contributor
timestamp: July 18, 2023, 07:30:01 pm
content: Just guessing here, but what voltages are you getting at S1 and S2 where the current sources are attached? The current sources should put out whatever voltage it takes to force their current through the switch, and depending on how the model is built that might be affecting your current through R1.

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 18, 2023, 08:50:43 pm
content: Nope, that's not the problem. Could have been, but these are actually current sources set as "active loads", something that LTSpice offers for its current sources (while Spice does not, but you can emulate that somehow with a bit convoluted circuits.) Active loads in LTSpice model what you'd expect from real-life current sources, contrary to ideal current sources. So definitely not the problem here. The current through them in simulation is in the order of a few tens of pA when the switch is off. Replacing these active loads by just resistors yields exactly the same result.Actually, some more testing in LTSpice shows that the model just acts as though there was an internal resistance of about 62Meg between the D pin and ground.So with V3 = 5V, I get about 80nA through R1 when the MUX is disabled. With V3 = 1V, I get about 16nA. That's all there seems to be to it, unfortunately.

author: Kleinstein
author_rank: Super Contributor
timestamp: July 19, 2023, 08:41:21 am
content: The open pins to the MUX may be an issue, though with a correct model it should not be a problem.The leakage part of the CMOS switch chips is anyway tricky and scattering from unit to unit. The limit values in the datasheets are often just test limits, not actual component properties. The typical values may be use useful, but still scattering.Another problem that is known to be often not properly included in the models is the charge injection on switching. Here one also have to be careful with the definition: the charge injection in the data-sheets is usually the charge pulse on turn off. There is also some charge pulse on turn on, that can be quite different (often larger).

author: Fgrir
author_rank: Regular Contributor
timestamp: July 19, 2023, 07:27:51 pm
content: Quote from: SiliconWizard on July 18, 2023, 08:50:43 pmAhh, you are right. I'd never played with the active load setting before. As far as the ADG1208 model, I'd say you are almost right. It looks like the D pin leakage is actually about 125Meg to each supply rail since none of that leakage current actually comes out the GND pin. Probably they weren't too careful modeling the leakages of the diodes to the supply rails. Always fun finding the limitations of SPICE models.

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 19, 2023, 08:07:10 pm
content: Yes. And you're right, hadn't taken the time to even go that far, but the leakage current of the model doesn't actually come out of the GND pin, so yes most likely the internal protection diodes are not properly modeled and leak too much.But again, the Spice model doesn't have this issue and behaves much closer to what the actual chip should.The comments state:QuoteSo ngspice it is for now. (And I gave tips on how to use it with these models.)Unfortunately, unencrypted Spice models are now pretty rare and most vendors have stopped distributing these for newer parts. There still are some for the "older" parts.As I mentioned earlier, the big problem with LTSpice, however useful (and free) it is, is that their models are absolutely not documented, so we never know what exactly they do model.But what I can say is that many of their models do not model leakage and input bias currents correctly.As a side note, LTSpice's AD parts seem to have much worse models overall than LT parts, which is not surprising considering that the addition of AD models was a late addition and there was probably a number of errors and limitations along the way. The fact that the original Spice model of the ADG1208 behaves completely differently from the "native" LTSpice one shows that they didn't just use Spice models, they translated them to their native format.

author: thm_w
author_rank: Super Contributor
timestamp: July 19, 2023, 09:29:34 pm
content: Is it definitely encrypted and not just compressed as their schematic binary format is?https://stackoverflow.com/questions/58409079/how-to-decode-compressed-binary-raw-files-from-ltspice-with-python

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 20, 2023, 05:26:11 am
content: Quote from: thm_w on July 19, 2023, 09:29:34 pmLTSpice's schematics and symbols are in clear text. The linked discussion talks about the .RAW format (which is the output data of simulation).I don't think anyone has "reverse-engineered" the model format of LTSpice (.sub files). I have always assumed they were "encrypted", maybe they aren't, I don't know. But I opened a few with a hex editor just to have a look. I can't recognize any known format. There is just some header in text, but after that, I don't know what it is and don't feel like wasting a lot of time on that. But if someone else has, please chime in!The files start with '0x0D 0x0A <Binary File> 0x0D 0x0A 0x0D 0x0A 0x1A s~MS' and after that nothing decipherable in an obvious way.I bet that even if we could decode the format somehow, we might not be able to figure out a lot of what it does, as LTSpice uses a number of extensions to pure Spice and since these are largely undocumented, we would probably not understand much. But again, if anyone has any more info on that, could be interesting.