# How to solve this problem in the simplest way via LTspice?

My netlist file is:

5.24(a)

.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
.ENDS

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


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 \$$.

• 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. Oct 10 '20 at 19:41
• @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.
– 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: -

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')
vp=solve(Eq(vx/ra+vx/rb+vx/rc,va/ra+vb/rb+vc/rc),vx)[0]
vm=solve(Eq(vx/20e3+vx/100e3,vo/100e3),vx)[0]
eq=Eq(solve(Eq(vp,vm),vo)[0],va+2*vb+3*vc)
for x in solve([eq.subs({va:1,vb:0,vc:0}),eq.subs({va:0,vb:0,vc:1})],[ra,rc])[0]:
x.subs({rb:15e3})
30000.0000000000
10000.0000000000


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.

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:

$$\frac{V_a}{R_a}+\frac{V_b}{R_b}+\frac{V_c}{R_c}=\frac{V_{+}}{R_a}+\frac{V_{+}}{R_b}+\frac{V_{+}}{R_c}$$

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

$$V_a\,G_a+V_b\,G_b+V_c\,G_c=V_{+}\,G_a+V_{+}\,G_b+V_{+}\,G_c\tag{0}$$

...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:

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.

• yes this is what I am looking for a simpler method than mine if it exists.
– Ali
Oct 10 '20 at 19:57
• @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?"
– jonk
Oct 10 '20 at 20:00
• yes only LTspice. I do not want any intermediate step just using LTspice from A-Z.
– Ali
Oct 10 '20 at 20:03
• @aconcernedcitizen I know. I mentioned that option, in fact. I just wanted to nail down the OP's coffin lid.
– jonk
Oct 11 '20 at 9:09
• @jonk Damn, I'm blind. I'm sorry for the noise, I'll delete that comment. Oct 11 '20 at 9:12