Help with resistor network analysis - Page 1
Forum section: electronics / beginners

author: ifonlyeverything
author_rank: Regular Contributor
timestamp: December 15, 2022, 11:59:20 pm
content: I want to vary my power supply output, which I understand can be done with a DAC. Someone was nice enough to make an online calculator here.https://www.fischl.de/dcdccontrol/I have a 3.3V DAC, a power supply with a 2.5V feedback pin, and I want to vary output between 4V and 6V. I attempted a solution with KCL and KVL.i1 + i3 = i2vpsu - r1 * i1 - r2 * i2 = 0 (inner left loop, clockwise as arrow shows)vdac - r3 * i3 - r2 * i2 = 0 (inner right loop, counter-clockwise)vpsu - r1 * i1 + r3 * i3 + vdac = 0 (outer loop, clockwise)I know that the FEEDBACK node is 2.5V and I arbitrarily chose r2 to give 1mA. So we have,r2 * i2 = 2.5r2 = 2500The online calculator gives me R1 = 1984.85 Ohm, R3 = 3275.00 Ohm and this does agree to what I can see in LTspice. So this should be solvable. I tried plugging this into a computer algebra system for conditionsvpsu == 6 and vdac == 0as well asvpsu == 4 and vdac == 3.3but I don't get a result for the second solve command?Code:var('vpsu,vdac,r1,r2,r3,i1,i2,i3')eq1 = i1 + i3 == i2eq2 = vpsu - r1 * i1 - r2 * i2 == 0eq3 = vdac - r3 * i3 - r2 * i2 == 0eq4 = vpsu - r1 * i1 + r3 * i3 + vdac == 0eq5 = r2 * i2 == 2.5eq6 = r2 == 2500pretty_print(solve([eq1,eq2,eq3,eq4,eq5,eq6,vpsu==6,vdac==0],vpsu,vdac,r1,r2,r3,i1,i2,i3))pretty_print(solve([eq1,eq2,eq3,eq4,eq5,eq6,vpsu==4,vdac==3.3],vpsu,vdac,r1,r2,r3,i1,i2,i3))https://sagecell.sagemath.org/?z=eJydkMEKwjAMhu-C75DbNhvHmqy79UlEZOgOBdHZzYJvb-JUBEXBww_hz5c_bVIb8yz1wxnTrt1itBgJI2OwGAgDZ8V81p0seAgWDAQGLyWpSWLqJCwhWlgoIBVpRUpVCrFCkqwt1hZ_gOr3JPPEzTT_YJ2wL_NUOnWbyVXDVcL1sRvHy6aP4TDmw3Gfunwl30B5tYhFtciJGtTN3je3A3hfrfHLOYrin-z6ns0l_0i_Alo0bgM=&lang=sage&interacts=eJyLjgUAARUAuQ==

author: ledtester
author_rank: Super Contributor
timestamp: December 16, 2022, 04:29:25 am
content: I didn't take a good look at your equations, but I tried another approach and it seems to work.Using superposition you can quickly write down this equation:$$V_{\text{out}} \frac{R_2 || R_3}{R_1+R_2 || R_3} + V_{\text{dac}} \frac{ R_1 || R_3 }{R_2 + R_1 || R_3} = V_{\text{fb}}$$Note that the resistor ratio terms are just voltage divider expressions. In general, if you have a bunch of voltage sources connected via resistors there is a nice pattern for the voltage at the meeting point.So try this code:Code:var('r1,r2,r3')def par(a,b): return a*b/(a+b)def div(a,b): return b/(a+b)def equation(vdac, vout, vfb): return vout*div(r1, par(r2,r3)) + vdac*div(r2,par(r1,r3)) - vfbeq1 = equation(0, 6, 2.5)eq2 = equation(3.3, 4, 2.5)pretty_print(solve([eq1, eq2, r2-2500], [r1, r2, r3]))Running it I get this answer:

author: ledtester
author_rank: Super Contributor
timestamp: December 16, 2022, 06:44:04 am
content: I think I found your problem:QuoteThe outer loop is just the difference of the two inner loops. This will always be the case with KVL -- the sum of all of the smaller loops will be the equation for the largest loop. Hence you only need to include the equations for the smallest loops.In this case the outer loop equation should be the left loop minus the the right loop and it should read:vpsu - r1 * i1 + r3 * i3-vdac = 0 (outer loop, clockwise)but you've got + vdac.Since this third equation is a combination of the first two you don't need to use it.Update: This also explains why you can solve the equations for Vdac = 0 but not Vdac = 3.3. Because of the sign error Vdac is forced to be 0, so attempting to set it to any other value results in no solutions.

author: MrAl
author_rank: Super Contributor
timestamp: December 16, 2022, 07:12:14 am
content: Quote from: ifonlyeverything on December 15, 2022, 11:59:20 pmHello,How do you get an output voltage of 4v to 6v with those connections?Here is the solution as the circuit stands right now:Vfb=R2*(PSU*R3+DAC*R1)/(R2*R3+R1*R3+R1*R2)However, if you eliminate R2 entirely you get solution:Vfb=(PSU*R3+DAC*R1)/(R3+R1)In theory you can eliminate R2 unless of course it is already part of the system, such as a load of some type.The resistor values will come out different with R2 removed from the circuit.Perhaps you can mention how you get 4 to 6 volts out of that circuit though when the DAC only goes from 0 to 3.3 volts.

author: golden_labels
author_rank: Super Contributor
timestamp: December 16, 2022, 09:06:28 am
content: MrAl:That is a modification to an existing DC/DC converter board. They come with a feedback divider already on the PCB and I believe R2 is a part of that divider. The idea is, I presume, to nudge the output of that divider.ifonlyeverything:Just skimming over your calculations, there is one thing that should ring alarm bells in your head. You have 2 unknowns, but 6 equations!As for the solution, you have those currents:I1= (VPSU- 2.5 ) · G1I2= 0.001 I3= (VDAC- 2.5 ) · G3In case you did not encounter the notation yet, G = 1/R (electrical conductance). This just saves us from having 1/R everywhere in equations — there is no conceptual or numerical difference.From KCL:I1- I2+ I3= 0… equals:(VPSU- 2.5 ) · G1- 0.001  + (VDAC- 2.5 ) · G3= 0You have two constraints:I. VDAC= 3.3 , VPSU= 4 II. VDAC= 0 , VPSU= 6 That gives us a system of two equations:(4  - 2.5 ) · G1- 0.001  + (3.3  - 2.5 ) · G3= 0(6  - 2.5 ) · G1- 0.001  + (0  - 2.5 ) · G3= 0From that you calculate G1and G3, which are inverses of resistances you want.Since this is just two-dimensional space, the system can be solved visually. See the attachment. The solution is around (G1= 0.5 mS, G3= 0.3 mS). That corresponds to resistances of about 2000 Ω and 3333 Ω.Since you have used a linear solver yourself, let’s use linear algebra approach as the second one. The entire problem is written as: A·x = b:Code:⎡ 4 - 2.5 3.3 - 2.5 ⎤ ⎡ G₁ ⎤ ⎡ 0.001 ⎤⎣ 6 - 2.5 0 - 2.5 ⎦ · ⎣ G₃ ⎦ = ⎣ 0.001 ⎦Code:⎡ 1.5 0.8 ⎤ ⎡ G₁ ⎤ ⎡ 0.001 ⎤⎣ 3.5 -2.5 ⎦ · ⎣ G₃ ⎦ = ⎣ 0.001 ⎦The solution is, x = A-1·b, equals (see Wolfram Alpha):Code:⎡ 0.000503817 ⎤⎣ 0.000305344 ⎦Which, this is not a coincidence, is a point — just like with the graphical method. The corresponding resistances are: 1985 Ω and 3275 Ω.Finally, the high school approach, step by step:⎧ (4  - 2.5 ) · G1- 0.001  + (3.3  - 2.5 ) · G3= 0⎩ (6  - 2.5 ) · G1- 0.001  + (0  - 2.5 ) · G3= 0⎧ (1.5 ) · G1- 0.001  + (0.8 ) · G3= 0⎩ (3.5 ) · G1- 0.001  + (- 2.5 ) · G3= 0⎧ (1.5 ) · G1- 0.001  + (0.8 ) · G3= 0⎩ (3.5 ) · G1- 0.001  + (- 2.5 ) · G3= 0Substracting:(1.5  - 3.5 ) · G1- (0.001  - 0.001 ) + (0.8  - (-2.5 )) · G3= 0-2  · G1+ 3.3  · G3= 0Calculating G1:G1= (-3.3  · G3) / -2  = 1.65 · G3Substituting G1:1.5  · G1- 0.001  + 0.8  · G3= 01.5  · (1.65 · G3) - 0.001  + 0.8  · G3= 02.475  · G3- 0.001  + 0.8  · G3= 0(2.475  + 0.8 ) · G3- 0.001  = 0G3= 0.001  / 3.275 Plugging G3:1.5  · G1- 0.001  + 0.8  · G3= 01.5  · G1- 0.001  + (0.8  · 0.001  / 3.275 ) = 01.5  · G1- 0.001  + (0.0008  / 3.275) = 01.5  · G1+ (-0.002475  / 3.275) = 0G1= 0.002475  / 4.9125 … which gives us the resistances of R1= 4.9125 / 0.002475 ≈ 1985 Ω, and R3= 3.275 / 0.001 = 3275 Ω.

author: ifonlyeverything
author_rank: Regular Contributor
timestamp: December 16, 2022, 12:01:14 pm
content: Thank you all for such detailed responses!Will have to read them over in detail tonight, when I have some free time.

author: golden_labels
author_rank: Super Contributor
timestamp: December 16, 2022, 03:18:59 pm
content: Just remember those are answers to your question about a model. Explanations regarding mathematics applied to ideal elements. To see that in action you will have to build and test an actual circuit. They don’t sell 1985 Ω and 3275 Ω, 0% tolerance resistors. The closest resistors in E24 series (5%) are 2 kΩ and 3.3 kΩ, which makes the calculations off by a few percent even before taking other issues into account.The goal is to understand how to use maths and what the equations mean. Not to use them in place of a soldering iron.

author: MrAl
author_rank: Super Contributor
timestamp: December 16, 2022, 03:33:04 pm
content: Quote from: golden_labels on December 16, 2022, 03:18:59 pmHi,Not sure what values you are after, but what works sometimes is to parallel two resistors to get the final value.For example, if the resistor is 1010 Ohms and you need closer to 1000 Ohms, if you parallel it with a 100k resistor then the value comes out to 999.9 Ohms, in theory of course as the final value still has to be checked.Beats using a pot :-)

author: Terry Bites
author_rank: Super Contributor
timestamp: December 16, 2022, 06:47:06 pm
content: The solution requires the application of the superposition theorem. Your circuit is the classic illustration of its use.You don't need a deep dive into the matrix. Dont take the red pill or the blue pill.www.electricalclassroom.com/superposition-theorem/

author: ifonlyeverything
author_rank: Regular Contributor
timestamp: December 17, 2022, 04:03:06 pm
content: Quote from: ledtester on December 16, 2022, 04:29:25 amI've never learned the superposition principle until now (not an EE.) Am I misunderstanding something or does this give the incorrect answer? I tried plugging R1=1515, R2=2500, R3=1908 into LTspice and it's not yielding 2.5V at the feedback node?

author: ledtester
author_rank: Super Contributor
timestamp: December 17, 2022, 04:17:45 pm
content: Quote from: ifonlyeverything on December 17, 2022, 04:03:06 pmPlease post your .asc file - you can just upload it as an attachment.Here is the calculation from thehttps://www.fischl.de/dcdccontrol/app:

author: ifonlyeverything
author_rank: Regular Contributor
timestamp: December 17, 2022, 04:32:12 pm
content: Quote from: ledtester on December 17, 2022, 04:17:45 pmIt works fine, my mistake! I switched R2/R3 notation (relative to the fischl.de website) while you didn't.