Resistor Y junction calculations. - Page 1
Forum section: electronics / beginners

author: paulca
author_rank: Super Contributor
timestamp: March 14, 2023, 12:00:05 pm
content: Given the voltage divider:V+|R1|+|R2|GNDI know how to calculate VR1 and VR2. What I need is the following:V+|R1|+ -- R3 -- VDAC|R2|GNDVR2 will control a DC-DC converter IC which expects a feedback voltage of 800mV (776mV - 824mV).R1 was a potentiometer, but I struggled measuring it's resistance in circuit, so I removed it.R2 is 8k2.R1, R3 and VDAC I get to decide. The question is how.I have been working with this white paper:https://www.analog.com/en/technical-articles/digital-adjustment-of-dcdc-converter-output-voltage-in-portable-applications.htmlHowever when I run these calculations I couldn't get results I expected.My mathematics isn't 100%. I have an issue understanding when things mean multiply and when they don't. For example those equations have a form like "this = that( something something+something)". The only assumption I have to work with is that () usually mean multiple and if there is no operator again it usually means multiply.What I believe I need is the MCU reading it's ADC, deciding to raise or lower the feedback to induce the output voltage I want. A basic hunting/tracker algorithm will do, as long as it's fast enough for the buck IC.I considered direct injecting the feedback voltage, however it only has a 50mV range and direct injection sounds more risky. The circuit shown in the paper suggests a Y divider will allow the main voltage divider be set to a "default" resting value and allow the full scale swing of the DAC to influence the VR2 value by +-24mV accurately.I think I need a little push in the right direction.

author: paulca
author_rank: Super Contributor
timestamp: March 14, 2023, 06:16:05 pm
content: The penny dropped that the voltages are not where to start. The current through R2 is where to start. If you can determine the current you can determine the voltage across it.That still doesn't help with the resistor network as V+ and R1 will impact what R3 is trying to do to R2.This:https://e2e.ti.com/blogs_/b/powerhouse/posts/vary-the-output-voltage-in-an-inverting-buck-boost-topologygave me a different strategy. Using a transistor as a variable current source and inject that current into the divider.I still have confusion on how that works. Although I think it answers part of my confusion with:"The only downside to this method is that the control of the output voltage isunidirectionaland needs an extra component."Unidirectional. I can see if the transistor is amplifying Ictrl (Vctrl through Rctrl) * gain and sourcing that at the RTop, RBottom divider junction, it will allow current to bypass RBottom, reducing the current through RBot, reducing the voltage across it and thus lowering VRef output?Did I get that right? It can sink current out of the junction, rather than inject it into it. Hence it can only push the feedback voltage down, raising the output voltage of the converter.That's probably fine for the purposes. I can set the divider up such that a 0 VDAC gives me the minimum voltage I want from the converter and then modify the feedback to cause it to raise that voltage up to where I want it.If I maintain a constant positive voltage on Vctrl, l that translates to Ictrl through Rctrl, resulting in an amount of current, to be calculated, sourced via RTop, bypassing RBot, resulting in a VRBot becoming VRef for the feedback pin.I can't be far off. I have a horrible suspicion have things upside down somewhere though. I forever think of circuits "pushing" and have a hard time remembering a lot of them "pull" instead, if that makes sense, it's just not in my intuition yet.EDIT: I do have it upside down, their bjt is showing an arrow into the divider. I miss read it. I thought Vctrl was on the base. It's on the collector.I'll have another go later.

author: paulca
author_rank: Super Contributor
timestamp: March 14, 2023, 06:55:56 pm
content: The PNP transistor has it's base tied to ground. That means it's fully open and whatever current arrives on it's collector is going to come out it's emittor * it's gain for those conditions.Assuming that is right and assuming the values for the transistor gain and Rctrl are choosen well it should be as simple as adding current across R2 in my case or RBBT (RBottom) in their case.Given I have an 8k2 as R2 and a VRef of 800mV. I can pick an R1 (RTop) to give 800mV for an output of (2.5V), application specific. If the MCU is off, the injected current will be 0 and the PNP cannot back conduct as it's a diode, thus 800mV stays on the feedback if the VOut is 2.5V.Thing is, does increasing the current through R2 not raise the voltage across it... which would tell the convertor the voltage is too high. Upside down again. I have to start with the maximum VOut and work backwards, pulling it down by injecting current.That then impacts the corner case of boot up. When VDAC is 0 the VOut will be VMAX, which is probably not desirable. This is fine however as I can just move to a DC converter with an enable pin and MCU control it. Such that it's off at boot and only enabled after a valid value is set on the VDAC peripheral.

author: paulca
author_rank: Super Contributor
timestamp: March 14, 2023, 07:42:38 pm
content: Some things are clearer after a schematic and a calculator session.I'm packing it for tonight.If you are still following along, thanks. I'm sure it's painful to watch, but feel free to step in an nudge me if I'm going in the wrong direction or upside down AGAIN? I hope not.

author: paulca
author_rank: Super Contributor
timestamp: March 14, 2023, 08:07:42 pm
content: Coming at it the other way....This is using to Vctrl (VDAC) in the equations withThe term:VCtrl - VBE / RFBTaka VDAC - VBE / R1Voltage Base Emitter?Base is 0V, emitter is VFeedback. Ohhhh...... VBE is the forward diode voltage of the PNP's NP. Thus to get anything VDAC > VBE or Vf for the NP portion of the transistor.But, it's R1, I was expecting R2. Although iR1 == iR2.This is the part I'm still failing at. Directionality. If the base is pulled to ground the VE is 0+Vforward BE. VE is set by R1, R2 for 800mV. Take that as a "dart throw" start point, VE=800mV (if VDAC is 0). Rather VE = VFeedback if VDAC =0. <--- EDIT I think I got lost here.Okay, closing off open ends, keep going...If VDAC was 3.3V and RCtrl was 0Ohm for now.Then. 3.3V - (call it 0.7V for Vforward) = 2.6VVBE / R12.6V / 35k = 74uANope. I think the problem is the assumption. iR1 = iR2 = iR1+R2. I believe this only aplies until the third leg joins the party. Which brings me right back to the start, although I feel a learnt a little and maybe unlearnt little.Just a nudge. Only a nudge! Go on!

author: paulca
author_rank: Super Contributor
timestamp: March 14, 2023, 08:28:00 pm
content: Current is equal at all points in a circuit.But... when you have more than one path that is no longer simple as you no longer have a single "circuit" the current has several options. Those will "ratio out"... There will be a linear relationship wrapped around V=IR. I'm trying to put my skill of reverse engineering logic to reverse extrapolate the significance of that.It has no option via R1. It's options are R2 or the PNP. That suggests why the calculation is biased by R1 and not R2 which is variable in the calculation.It's just there is more than one.In the original equations they use [] which with only vague understandings of their use in maths I have taken to meaning similar to code, but with an understanding it means "for a set of". It's use in this equation ... it's simultaneous equations for a given Vfeedback a given set of R values exist for a given set of Vout values.Seriously it's been a LONG time since I did simultaneous equations. Although if I can wrap my head around this a little tighter I believe I can write code that does the same thing by brute force.Please stop me if I'm heading in the wrong direction.Is this rambling through the problem helpful ...in the beginners forum? Does anyone else think this way?

author: fourfathom
author_rank: Super Contributor
timestamp: March 14, 2023, 08:37:28 pm
content: That transistor current-source is going to be temperature-sensitive, which may or may not be a problem for you. Going back to the resistive divider, here's one way to solve for the values.First, say the DAC output range is 0-3V. You want to have a feedback voltage range of 0.776 - 0.824V. That's a 0.048V range, so that's the first step, create a resistive divider that drops 3V down to 0.048V. See the schematic below, that's the top circuit.Next, shift the output voltage up to the desired level by replacing the ground with an offset voltage. This is still a simple voltage divider calculation. See the middle circuit.Next, create that offset voltage with a voltage divider, having the same "Thevenin equivalent" resistance as in the previous circuit. Here, it's 1 Ohm. In the bottom circuit I used 3.3V to feed the divider, but you can use whatever stable voltage you like.Finally, scale up all the resistor values to something practical, perhaps 1000X. You don't want to load down the DAC output or draw excessive current from your supply. You should allow for DAC output impedance, and regulator input impedance, but this is a good starting point.This will be only as precise as your resistors and voltages, but this is how you can calculate the values.

author: paulca
author_rank: Super Contributor
timestamp: March 14, 2023, 09:05:05 pm
content: Thank you! I am + 1 bottle of red. So will digest tomorrow.The bright LED in your diagram is that VOFFSET.The directionality problem. Anytime I was asking myself a question about current flow I kept answering "both directions". I could'nt resolve current in both directions as I kept thinking of the VBE related to ground.Both directions denotes a negative current. Sink verus source, or vice versa. Thinking about the Vctrl as a voltage source AND current source and thus uni-directional made me loose the plot. Correctly identifying the MCU cannot pull a negative voltage does not mean it cannotsink AND sourcecurrent via the Rctrl and PNP. So (insert peripheral config) I can use the MCU sink and source around an offset voltage. It was the need to bias things above 0V that made some sense.A lot of the other details of you post I did not understand or engage with

author: fourfathom
author_rank: Super Contributor
timestamp: March 14, 2023, 11:35:04 pm
content: Here the schematic modified to I hope clarify things a bit. That "Thevenin equivalent" thing I mentioned is the fact that the two resistor voltage divider (R7 and R5) is electrically equivalent to a 1 Ohm resistor connected to 0.778V. The math involved here is just adding, subtracting, multiplying and dividing. You might want to use reciprocals when calculating R7 and R5 so that their parallel resistance is equal to 1 Ohm. Just make sure you understand how the circuit behaves before you get out your slide-rule.

author: paulca
author_rank: Super Contributor
timestamp: March 18, 2023, 04:44:49 pm
content: I had a go with Falstad and came up with a "working" circuit.Got carried away with a current limit amp and a really brutal attempt at a hardware overvoltage protection at 4.2VThe buck regulator is simulated or at least it's error amp as an ideal opamp.The current sense amp may or may not be a hardware opamp, but it's reference voltage will likely be another DAC input.I am fully aware that Falstad is an "over simlification" and this is in no way a finished circuit, just a toy by which I'm trying to understand a bit qualitatively if I'm struggling quantitatively.VDAC at 0V, produces the maximum target output voltage of about 4.3VHowever, the mickey mouse zenner circuit starts to conduct current into the current sense amp which feeds back cutting the charge voltage back.VDAC at 3.3V, produces the minimum charge target voltage of about 3V, which given the "simulated battery" starts at 3V it settles pretty quickly.VDAC at 1.65V charges to about 3.7V and then I step it to 0V and full charge over voltage protection. This highlights the zenner is a bit "vague".Honestly, I would ignore the zenner over voltage circuit, it's not important. Just a toy I was playing with.

author: paulca
author_rank: Super Contributor
timestamp: March 23, 2023, 02:31:21 pm
content: Quote from: fourfathom on March 14, 2023, 08:37:28 pmComing back to this. The first time I read it I got lost at "Thevenin equivalent".In my parallel attempts with falstad (as a ball park tool where I can change things and see the response without the ordeal of LTSpice). We did not take the same approach.One aspect is that the divider voltage, input voltage, output voltage and output load are all subject to change. I tend not to find easy problems it seems.The input VMAX (or VCC) is basically going to be "Solar panel Voc", possibly 19V. The output voltage and current will be controlled to produce a 3.0V to 4.2V charge curve for a Lithium cell. The micro-controller is 3.3V.In my circuit the resistors in question are the 32k, 68k and 8.2k with the later being fixed in my current case. I don't understand the maths, but I can play with the 32k and 68k and garner some insight into how the effect each other.I found the 68k seems to almost directly impact the amplitude of the VDAC's effect on the voltage. Lower values give the VDAC more control and vice versa. The 32k however would naturally be around 35k to get a 4.2V output with no VDAC and tends to have the effect of moving the centre point of where the DAC has influence.The difficult bit is, changing any one of them also impacts the others. Changing the 68k to give the DAC a wider amplitude or more influence, results also in a shift in the offset. Changing the 32k to change the offset changes the amplitude.Sometimes I would get it to balance and then test sanity by grounding the VDAC to simulate a MCU crash and results in 5 or 6V on the output because VDAC has far too much influence.I'm getting round to testing this in physical, by using 10 turn trim pots for the 68k and 32k, having pre-set/measured them at those approximate values.It takes me back to the very first article on this as to what the tuning will involve. For every component the tolerances mean it can have a max, min and typ value. I need to make sure that under all combinations of those min, max values that no "do not exceed" conditions exist. Such as the maxmimum lower end of the VDAC influence when all components are working against it, does not produce a voltage over 4.2V. Ideally without having to cap it with a voltage limiter circuit.For that part. I need to convert these resistor calculations into code so that I can understand them... and hopefully re-use them to calculate voltages and responses correctly in the code that will control the buck. Such that it can take a voltage sense value and extrapolate out the "real" voltage, determine the response and then convert that back into DAC volts, using the same calculated and measured component values.

author: rstofer
author_rank: Super Contributor
timestamp: March 23, 2023, 04:38:05 pm
content: I don't know if it helps you or not but when I get to chasing my tail for this kind of thing, I will usually turn to wxMaxima (free) and just write out the equations.Consider the typical problem of a voltage source on the left connected to a node VA through a resistor, a voltage source on the right connected to node VA through another resistor and a load resistor between node VA and ground. See the ASCII art - note to self, never do this again!I agree, this is a very simple example of Kirchhoff's Current Law and nodal analysis. Circuits get much larger but it's a handy little reference project in that all of the syntax is correct and it actually prints the results - sorted.Code:[font=courier]/*Simple T Resistor Problem - Find VA and all branch currentsVoltages in Volts, Resistors in OhmsR1 VA R2.--/\/\/\---.---/\/\/\--.| 5 Ohm | 10 Ohm || / || R3 \ 5 Ohm || / || \ || | || | |V1 ( ) 5V | V2( ) 10V| | || | |-------------------------*/ratprint : false$fpprintprec : 4$eq1 : I1 = (V1-VA)/R1;eq2 : I2 = (V2-VA)/R2;eq3 : I3 = (VA/R3);eq4 : 0 = I1+I2-I3;eq5 : V1 = 5;eq6 : V2 = 10;eq7 : R1 = 5;eq8 : R2 = 10;eq9 : R3 = 5;res : solve([eq1,eq2,eq3,eq4,eq5,eq6,eq7,eq8,eq9])$results : float(res)$lngth : length(results)$sorted : sort(results)$print("")$print("Sorted Output")$print("")$for i:1 thru lngth doprint(sorted)$Save code to <filename>.wxmx, ignore the font and code tags.I decided to embed the code rather than add a .txt documentThe final output will be:Sorted OutputI1=0.2I2=0.6I3=0.8R1=5.0R2=10.0R3=5.0V1=5.0V2=10.0VA=4.0There are other 'solvers' like MATLAB and Octave (free) and they will work just as well but the syntax will be somewhat different. I use all 3 from time to time. I picked wxMaxima for this demo simply because I already had a working example of a larger project using AC and complex numbers. It was easy to copy the syntax for this problem.Mathematica and Wolfram are also great packages but I don't tend to use them.

author: paulca
author_rank: Super Contributor
timestamp: March 23, 2023, 04:58:48 pm
content: I get a permission denied on the link.The maths is where I fail. I don't even understand the syntax most times.Putting it into some C code I could probably understand it pretty quickly. I very likely deal with fairly complex mathematically equations in code, I just don't see them as that.Was trying to formulate a way for a compressor gain to return towards 0 on release. That's just output = output + delta/rate in a feedback loop. But I believe that is possibly a derivative or integral. When someone explains those to me I understand them. If someone asks me about them 10 minutes later I have no idea.My brain has an impedance to maths which scales exponentially as you get beyond about "high school" level.However. I can look at 100+ lines of code that contains many complex expressions, iterations and selections and make optimisations or refactoring which span, reorder and rearrange it. I can't however explain that process in terms that, say a linear algebra expert would understand. I have seen computer code described in that mathematical language, that and information theory syntax and many others and no... I don't get it. As with any such skill, if you don't need it, if you don't use it, then you don't get it. In my day job I have not had to define any process much more formally than the code itself would define. In the rare occurrence the equations come from the customer in mathematical form, I seek expert help.

author: rstofer
author_rank: Super Contributor
timestamp: March 23, 2023, 05:30:34 pm
content: Quote from: paulca on March 23, 2023, 04:58:48 pmI embedded the code and deleted the link.

author: rstofer
author_rank: Super Contributor
timestamp: March 23, 2023, 05:45:50 pm
content: I don't know about LTspice but the IBM Electronics Circuit Analysis Program (ECAP) I was using back in '70-'71 had a process for 'Sensitivity Analysis' where you could specify tolerances and the program would iterate solutions for altered values. I haven't used it in 50 years so my memory is a little vague.In my simple code above, all I would have to do is change the value of some parameter and solve. I could probably set the code up to do the change in a loop. Or nested loops...

author: rstofer
author_rank: Super Contributor
timestamp: March 23, 2023, 06:29:18 pm
content: Quote from: rstofer on March 23, 2023, 05:45:50 pmActually, I do know that LTspice can deal with tolerances:https://www.analog.com/en/technical-articles/ltspice-worst-case-circuit-analysis-with-minimal-simulations-runs.htmlThis is an app you really need to make friends with.