enter image description here

enter image description here

My netlist file is:


.param Va=1 Vb=0 Vc=0

Va a 0 {Va}
Vb b 0 {Vb}
Vc c 0 {Vc}

Ra a 2 {Ra}
Rb b 2 15k
Rc c 2 {Rc}

R1 1 0 20k
Rf 1 3 100k
RL 3 0 4.7k

X1 1 2 3 OPAMP

    .SUBCKT OPAMP 10 20 30
    Rin 10 20 1E15
    E1 30 0 20 10 1E10

.step param Ra 1k 35k 1k param Rc 1k 35k 1k
.save V(3)

I have solved it by doing 3-simulations setting:

  1. \$V_a=1 \quad V_b=0 \quad V_c=0 \quad \text{yields} \qquad V_o = 1 \\\$
  2. \$V_a=0 \quad V_b=1 \quad V_c=0 \quad \text{yields} \qquad V_o = 2 \\\$
  3. \$V_a=0 \quad V_b=0 \quad V_c=1 \quad \text{yields} \qquad V_o = 3 \\\$

and then search for the output using cursor.

The results are \$\: R_c=10k \quad \text{and} \quad R_a=30k \$.

enter image description here

  • \$\begingroup\$ You don't need LTspice, in particular, for this, the same way you don't even need any SPICE simulator, in general, other than to possibly verify the results. Which is what you actually need. This is how an XY problem is born. \$\endgroup\$ Oct 10 '20 at 19:41
  • \$\begingroup\$ @a concerned citizen I know that I do not need any, but I want to do it using LTspice. If ther is a way simpler than mine. \$\endgroup\$
    – Ali
    Oct 10 '20 at 19:54

I think you can check it with LTSpice but, to "solve it" I'd use Millman's theorem: - enter image description here

enter image description here

Above pictures from this website.

This gets you the voltage at the mixing point (the non-inverting input to the op-amp). To add gain is simply to use an op-amp very simply. So, choose your input resistor values to suit and add gain to bring the output inline with what you require.


Direct Solution Method

Just use KCL.

Let's call the (-) input to the opamp as \$V_\text{-}\$ and the (+) input to the opamp as \$V_\text{+}\$. If the opamp is ideal then \$V_\text{-}=V_\text{+}\$. From KCL for \$V_\text{+}\$: \$\frac{V_\text{+}}{R_\text{a}}+\frac{V_\text{+}}{R_\text{b}=15\:\text{k}\Omega}+\frac{V_\text{+}}{R_\text{c}}=\frac{V_\text{a}}{R_\text{a}}+\frac{V_\text{b}}{R_\text{b}=15\:\text{k}\Omega}+\frac{V_\text{c}}{R_\text{c}}\$. You can solve that for \$V_\text{+}\$. From KCL for \$V_\text{-}\$: \$\frac{V_\text{-}}{20\:\text{k}\Omega}+\frac{V_\text{-}}{100\:\text{k}\Omega}=\frac{V_\text{O}}{100\:\text{k}\Omega}\$. You can solve that for \$V_\text{-}\$. Now just set these two solutions equal to each other, as you already know that \$V_\text{-}=V_\text{+}\$. Solve that for \$V_\text{O}\$ and set that equal to \$V_\text{a}+2 V_\text{b}+3 V_\text{c}\$. You now have an equation that relates all the necessary parts.

As you already pointed out in your answer, you can now generate as many equations as you like by arbitrarily setting different combinations of values for \$V_\text{a}\$, \$V_\text{b}\$, and \$V_\text{c}\$ and solve those simultaneously.

Using sympy/sage I might write the following:

var('va vb vc ra rb rc vx vo')
for x in solve([eq.subs({va:1,vb:0,vc:0}),eq.subs({va:0,vb:0,vc:1})],[ra,rc])[0]:

None of the above tells you how better to solve this with LTspice as the solver. I think you already found your way, in this regard. Your answers were right. So I'm not sure you have a question there. Unless you are asking someone to tell you a better method than the one you already used.

LTspice-Only Solution

There is a way to get LTspice to solve your circuit. And, in general, you can use the method to solve any number of unknown variables. It's not so easy, though. And as I already mentioned, the schematic you must use won't look a lot like your original schematic. It's equivalent. But as you'll soon see that's not a lot of help.

Let's start with your schematic:


simulate this circuit – Schematic created using CircuitLab

I won't waste any time doing the KCL solutions. You already know the obvious: \$V_{+}=\frac{V_a+2 V_b+3 V_c}{6}\$. You also know that the resulting KCL is:


But solving the above is exactly the same thing as solving two cases of this:


...where the conductances are used instead of the resistances.

This has a certain symmetry to it. If, instead of conductances, we treat the conductances as voltages and the voltages as conductances, then we just might have ourselves a circuit that LTspice can resolve for us.

Let's agree on one thing, right now. You have two unknown variables. As I mentioned before, LTspice solves node voltages and various currents. It's easier if you just assign one unknown variable to a node. In this case, that means you need two nodes where a solution is required. And as I'm now dragging you through this process, you can already see where I'm headed.

To get your two equations to help solve the two unknowns, I will take the two cases where:

$$\begin{align*} V_a=1\:\text{V}&& V_b&=0\:\text{V}&& V_c=0\:\text{V}\tag{1}\\\\ V_a=0\:\text{V}&& V_b&=0\:\text{V}&& V_c=1\:\text{V}\tag{2} \end{align*}$$

This makes easy work, applying (1) and (2) above to (0) to get:

$$\begin{align*} 1\,G_a-\frac16\,G_a&=\frac16\,G_b+\frac16\,G_c\\\\ 1\,G_c-\frac12\,G_c&=\frac12\,G_a+\frac12\,G_b \end{align*}$$

From the above, the following schematic just falls out:


simulate this circuit

Placed into LTspice, here is the result:

enter image description here

As \$G_a\$ and \$G_c\$ are conductances, to get the resistance just invert them. And there you find \$R_a=\frac1{G_a=3.33333\times 10^{-5}}=30\:\text{k}\Omega\$ and \$R_c=\frac1{G_c=1.00000\times 10^{-4}}=10\:\text{k}\Omega\$.

And no, it doesn't look like your pretty schematic. But you wanted a simultaneous solution for two unknowns. And you wanted LTspice to do that job, instead of a solver whose job it is to do exactly that. So you pay a price. You have to couch it into a form where LTspice will construct the necessary simultaneous solution. But you can do it.

So, you can have a nice schematic and be limited by the available steps and sweeps it allows, which limit your variable space. Or you can have a less-nice looking schematic that can handle any number of unknown variables for you, but won't look pretty.

You just can't have it both ways. This is one of those areas where you can have a cake if you don't eat it, or you can eat your cake and not have it anymore, but you cannot both eat your cake and still have it, after.

P. S.

You can simplify the above schematic into:


simulate this circuit

I just didn't want to do that, as I wanted the schematic to expose a little more of the equation development. But feel free to simplify.

Well, I answered your actual question after you finally clarified it. It may not be the answer you hoped it might be. But it is an answer using only LTspice as the solver. And it works.

  • \$\begingroup\$ yes this is what I am looking for a simpler method than mine if it exists. \$\endgroup\$
    – Ali
    Oct 10 '20 at 19:57
  • \$\begingroup\$ @Ali But only using LTspice to achieve it, yes? You aren't looking for any approach except one using LTspice? Correct? You just want an easier way using this existing "solver?" \$\endgroup\$
    – jonk
    Oct 10 '20 at 20:00
  • \$\begingroup\$ yes only LTspice. I do not want any intermediate step just using LTspice from A-Z. \$\endgroup\$
    – Ali
    Oct 10 '20 at 20:03
  • 1
    \$\begingroup\$ @aconcernedcitizen I know. I mentioned that option, in fact. I just wanted to nail down the OP's coffin lid. \$\endgroup\$
    – jonk
    Oct 11 '20 at 9:09
  • 1
    \$\begingroup\$ @jonk Damn, I'm blind. I'm sorry for the noise, I'll delete that comment. \$\endgroup\$ Oct 11 '20 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.