- How to model an opamp? (the implications on simulation)
- From netlist to code: strategies to implement schematics modelling, the results
- Analog modelling: A prototype generic modeller in Python
- Analog modelling: The Moog ladder filter emulation in Python
- SD1 vs TS9
- Triode circuit
- Should I invert my matrix or not?
- Comparing preamps
It’s a question I always asked myself. Models in SPICE are usually for full models, or you can use a gain voltage gain as well. What are the implications of selecting one model over another for a real time model? Let’s go for the more complex model to the simplest ones.
The implications on the simulation are not just about precision against the real electronic circuit. It’s also about the simulation speed. The simplest the model, the faster you expect it to be. It may not account for all imperfections, but you may not hear the differences.
There will be still implications on the simulation through the matrix condition number. The higher the number the more unstable the simulation.
A simple simulation
To understand the implications of the matrix condition number, let’s start with a simple model with two voltage dividers. This show how to derive the condition number from the model and what it means.
Let’s start with a simple double voltage divider circuit.
From there, we get the following system of equations:
We can simplify this further into:
I put all the variable parts on the left side and the input on the right side. From this, we have the parameter matrix . We get from there a condition number lower than 3, which is very well behaved.
Modeling an opamp
Let’s now look at a simple opamp circuit:
We don’t really care about the values of the resistors, as the circuit basically follows the input voltage. The question is how well?
A not-so-simple model
Let’s start form a model of the opamp that has a resistor between and and the output is a voltage source set at . The non-linear function models everything that happens outside the small-signal range.
The equation system is now:
We can check the eigenvalues around 0, with , and a gain and we get . Here, we have a condition number that is quite different around 2000, which is very different from the condition number we had earlier.
If we assume that the opamp is saturated, then we get a condition number of “only” 50. Still higher than the first circuit, but it’s a manageable number.
Using a fixed voltage gain
Let’s remove the distortion part as well as the opamp resistor (setting it to infinite). Our matrix doesn’t change that much, and the eigenvalues as such are basically the same at . This means that the the input resistor basically has no impact no the result and this approximation is sound.
The same can be said for the distortion. If we keep to the part of the where the linear approximation is correct, then the system is exactly the same.
The actual perfect opamp
The question I always asked myself is that SPICE provides all the above models, but there is no model for the perfect opamp. And it’s a model we use always when we identify that an opamp is in linear mode. When writing equations, you do it with the perfect linear model.
This model is simply . There is nothing more. The circuit will do what is required to fulfill the equation. But this changes the top eigenvalues tremendously: $latex [0.02, -0.090499, 0.110499] which gives a condition number of 4.5, so just above the simple passive double voltage divider. It’s more stable and it also involves less computations.
The more complex models are interesting and they fulfill a purpose, but the amount of distortion you get from it needs to be measured: there is no point in using this model if you don’t get anything out of it. Additional complexity cost time, as a consequence, using any model must respond to a reason and must have a tangible effect on the end result. If the perfect linear model is enough for you, don’t let SPICE tell you to use a more complex one!