Digital adjustable resistor - Page 1
Forum section: electronics / beginners

author: eslavko
author_rank: Contributor
timestamp: September 26, 2022, 04:26:55 pm
content: Hello...Is it possible to make digital adjustable resistor based on attached schematics?I can't find proper resistor values to have for example 100 to 1600 ohm values in linear range....and resistors are of range tens of watts...

author: Kleinstein
author_rank: Super Contributor
timestamp: September 26, 2022, 04:31:28 pm
content: Switching with the MOSFETs only works well for 1 direction of the current and low voltge in the other direction.Finding the right values may be tricky, but with high power one could use parallel / sereis connections. This can also help reducing the BOM. Power resistors are often not very accurate anyway and may need some trimming / added parallel resistor for fine adjustment.

author: eslavko
author_rank: Contributor
timestamp: September 26, 2022, 04:40:54 pm
content: The 'resistor' will see DC voltage. I know that values for each resistor will be strange. The problem is that I fail to calculate R1...R4 values.

author: jwet
author_rank: Frequent Contributor
timestamp: September 26, 2022, 05:14:05 pm
content: You don't say but this but this looks a bit like an electronic load type circuit- unipolar. You can make a constant R type load from a current sink by using the input voltage to program the sink current to a standard op-amp FET type current sink. The higher the volts, the higher the current, just like an R. You adjust the fraction of the voltage that take to adjust the R. If this is just a one time need, most electronic load will do constant R mode. Also at your resistances this wouldn't be too bad. The confusing part is 10 watts across a 1600 ohm resistor is about 125 volts. The benefit is this is that you don't need a lot of high power R's (expensive) just a bank of FET's on a good heat sink.If I was making a more universal type "floating" resistor, I would consider using something like Photomos parts like the Panasonic AQY211EHAX. These can do an amp continuous, conduct in both directions, etc. The FET's are actually turned on by light from the LED's so you don't have to mess with biasing, etc. This would allow you to make network the resistors in a 100,200,400,800 series string. I would take 3 Photomos, the base 100 ohm would be unswitched minimum a Photomos across each of the upper 3. You might buy 200's and series and parallel them to get your values- cheaper by the dozen. Opto isolation is a nice side effect.Don't overlook plain old relays or latching relays if power is tight. They still have their place but at these resistance values, their best attribute- low low R is kind of wasted. Have fun. Also add a fuse to this rascal- if my calcs of the volts and amps are right, this could be dangerous during failures.

author: Kleinstein
author_rank: Super Contributor
timestamp: September 26, 2022, 05:22:20 pm
content: The get a large range and about equal steps it would be test to have resistors in 1,2,4,8,16,... ratio. The steps would be equal for 1/R.Depending on the intended use is may be also OK to have several equal resistors for the smallest value as this helps with the BOM.With mechanical realys one could even consider unsing the same high resistors in series or parallel depending on the needs. This works well with 3 resistors in series and 2 additional links to switch to a parallel configuration.

author: eslavko
author_rank: Contributor
timestamp: September 26, 2022, 05:47:27 pm
content: Opamp solution doesn't work well.The applied voltage is 0 to 30V but i's like PWM. Using single FET and opamp I can't got working result. FET/OPAMP works if I use DC or slowly changed DC. But with Square wave at 10kHz all thing rings to much.Resistors in ratio 1,2,4,8 doesn't works as results aren't linear...the results for 1,2,4,8 are:GATES Resistance0000 open1000 1.00100 2.01100 0.66666666666666660010 4.01010 0.80110 1.33333333333333331110 0.57142857142857140001 8.01001 0.88888888888888880101 1.61101 0.61538461538461540011 2.66666666666666651011 0.72727272727272730111 1.14285714285714281111 0.5333333333333333

author: eslavko
author_rank: Contributor
timestamp: September 26, 2022, 05:50:40 pm
content: Even 1/1, 1/2, 1/4, 1/8 doesn't work...Resistors 1.0, 0.5, 0.25, 0.125 gave me:0 0000 open1 1000 1.02 0100 0.53 1100 0.33333333333333334 0010 0.255 1010 0.26 0110 0.166666666666666667 1110 0.142857142857142858 0001 0.1259 1001 0.111111111111111110 0101 0.111 1101 0.0909090909090909112 0011 0.0833333333333333313 1011 0.0769230769230769314 0111 0.0714285714285714215 1111 0.06666666666666667

author: ejeffrey
author_rank: Super Contributor
timestamp: September 26, 2022, 08:18:08 pm
content: You aren't going to get get exactly linear resistances out of switched parallel resistors because their conductances add not their resistances.If you don't need tremendous resolution the easiest way is to use more stages than you need (say 6 or, then just select the closest values to what you need. The non-linearity is always going to be extreme near the highest resistances, so let's say you want resistances from the range 0..1. Use R values of 4, 2, 1, 0.5, 0.25, .125] and you will get a lot of values in the range of 1/16..1. There will also be resistance values up to 4, but they will be widely spaced and less useful.

author: EPAIII
author_rank: Super Contributor
timestamp: September 27, 2022, 05:33:37 am
content: If you want to use a 1, 2, 4, 8 sequence of resistors, you are going to have to arrange them in series. Then each resistor can be shorted by a relay in parallel. Drive the relays with transistors, FETs, or even logic chips.

author: strawberry
author_rank: Super Contributor
timestamp: September 27, 2022, 06:26:04 am
content: LM324

author: eslavko
author_rank: Contributor
timestamp: September 27, 2022, 06:36:11 am
content: Quote from: EPAIII on September 27, 2022, 05:33:37 amI'm allready know that combination 1,2,4,8 doesn't work. But I just wonder if there is any other combination that will give similar results

author: eslavko
author_rank: Contributor
timestamp: September 27, 2022, 06:40:29 am
content: Quote from: strawberry on September 27, 2022, 06:26:04 amThis works as DC load. But It sucks when applied voltage is square wave. (When input voltage at FET is 0V the opamp and FET is saturated, and on fast rising ramp (0.5us/20V) the whole thing just oscillate few ms. I did try this approach and try to avoid saturations but without success.

author: CountChocula
author_rank: Unknown
timestamp: September 27, 2022, 12:02:03 pm
content: Quote from: eslavko on September 27, 2022, 06:36:11 amThat combination should work if you place it in series and bypass each resistor with a switch that shorts across its terminals. In theory, it gives you linear resolution of 1/(2^n), where n is the number of resistors you have in series. In practice, you have to deal with non-linearity caused by resistor tolerances. This is basically how an e-pot works, except those are usually laser-trimmed to match the resistors to a certain precision—and even those can typically only achieve 10% tolerance.One thing you can do to avoid dealing with weird resistor values is to use anR-2R ladder, which only requires two values (really, only one, since you can double it up to obtain the 2R arm of the ladder) and, again, gives you theoretically linear resolution. If you want to control it with MOSFETs, though, I think you're going to have to deal with a lot of losses in the circuit, because the transistors aren't perfect switches; depending on the performance characteristics of your circuit, you may be better off using relays. I sketched up asimplistic examplefor you—as you can see, even the simulator shows less-than-perfect performance (assuming I wired my circuit correctly, of course).HTH!—CC

author: Terry Bites
author_rank: Super Contributor
timestamp: September 27, 2022, 01:50:08 pm
content: You can use a ladder network. Its easy to work out the binary sequence and values you need.MOSFET ringing at switch on can be reduced by limiting the gate voltage rise time.A series gate resistor, say 10 Ohms will help.Its like pwm or is it pwm?Where does the opamp come into it?Please post a circuit diagram.

author: eslavko
author_rank: Contributor
timestamp: September 27, 2022, 03:39:05 pm
content: Quote from: Terry Bites on September 27, 2022, 01:50:08 pmI tried similar as strawberry posted.It's not PWM. Source give two informations one is frequency and other is ratio. Voltage is irelevant and can be any from 5V up to about 30V - Must be 50V safe. The 'load' must change resistance betwen low portition of signal and should mimic pure resistor close as possible.

author: eslavko
author_rank: Contributor
timestamp: September 27, 2022, 03:46:26 pm
content: To be more specific I have working circuit as I posted. It have 11 bits (I posted with 4 just for clarity). But in current circuit I have only one FET active at time. So I have 11 useable values (matching my requirements), now I got idea to do testing device with same hardware but instead using only one bit at time to use as binary number. So the FETs must be grounded, and actually I can't change design, but can change values (piggybacking resistor is allowed) and can change firmware.So I just wonder if there is any way to get more linear response. If I use 1/1, 1/2, 1/4, 1/8 seems pretty logharitmic curve and not line.

author: eslavko
author_rank: Contributor
timestamp: September 27, 2022, 03:48:57 pm
content: Quote from: CountChocula on September 27, 2022, 12:02:03 pmI don't need DAC, but variable resistor. So that circuit and R2R variant probably can't work

author: Terry Bites
author_rank: Super Contributor
timestamp: September 27, 2022, 05:18:50 pm
content: www.edn.com/scalable-current-load-offers-constant-resistance-mode/All is revealed! Make sure you manage the heat and layout properly.It it really ringing or do you have a poor grounding set up at the scope probe? See our friend DaveIt might alsosuckbecause you didn't take enough care contructing it. A bad grounding and decoupling scheme will make ringing far more likely.It may also ring horribly becasue the pulse souce supplying it has its own stability and/ or output drive issues. Again very likely, it will have a finite ouput impedance and who knows what strays. Unless you have perfect cables, limitless power and speed it will affect performance.You'll have to check that.How fast a rise time do you need?How much overshoot/ undershoot are you aiming for?

author: ejeffrey
author_rank: Super Contributor
timestamp: September 27, 2022, 05:57:29 pm
content: Quote from: eslavko on September 27, 2022, 03:46:26 pmAs I posted above: it's impossible to get a linear resistance range by adding fixed resistors in parallel.The way to get close is to A) use more stages that you might otherwise think, and B) use a restricted region of the total range.If you use binary weighted resistors as has been suggested you get something which is linear in conductances. It is not logarithmic, it is 1/x. So plot 1/x, and then you will see that if you pick a restricted region it can be approximately linear. Scale your resistor values so that your desired range fits there, then use enough stages that you can adjust for imperfections by varying the code.Otherwise you will need to put the resistors in series and use floating switches.

author: MrAl
author_rank: Super Contributor
timestamp: September 28, 2022, 03:51:32 am
content: Hello,If you use resistors 4,3,2,1.1 you get the following total resistances. The hex code is the code that it takes to get that value. The values have been sorted so you can see the increments and they are not equal. The increments are shown on the far right. Note hex code 00 produces an open circuit because all switches are off, but you could add a permanent parallel resistor to get some lower value and not affect the other values too much unless it is a low value.0.501901, 0F,0.573913, 07, 0.0720120.602740, 0B, 0.0288270.670051, 0D, 0.0673110.709677, 03, 0.0396270.804878, 05, 0.0952010.862745, 09, 0.0578670.923077, 0E, 0.0603321.100000, 01, 0.1769231.200000, 06, 0.1000001.333333, 0A, 0.1333331.714286, 0C, 0.3809522.000000, 02, 0.2857143.000000, 04, 1.0000004.000000, 08, 1.000000inf, 00, infA better idea i think is to bite the bullet and use a 1 of 16 decoder and 16 'switches' and 16 hand selected resistances that range from 1 to 16 or really whatever you want. You could also have a second set of 16 resistors and switch them out or in with another switch. This would involve both N channel MOSFETs and P channel MOSFETs.An even better way i think is to create a digital resistance decade box.This would involve two 1 of 10 decoders, around 20 switches, and around 20 resistors. One set could go from say 0 to 9 Ohms in steps of 1 Ohm each and the second set from 10 to 90 Ohms in steps of 10 Ohms each (and one switch has to create 0 Ohms for that bunch too). That way you can get resistances from 0 to 99 ohms in steps of 1 Ohm each with an 8 bit binary word. You may have to make some adjustments in the resistor values for the 'on' state resistance of the transistors, but if you only have to go say 0 to 90 Ohms in steps of 10 Ohms and then 100 to 900 Ohms in steps of 100 Ohms then the transistor on state resistance may not matter as much. Again this would involve both N and P channel devices and perhaps some carefully planned drive circuits.I could see something like this making a nice load box for testing power supplies and the like.Another perhaps even more interesting idea would be to combine a current source with some known resistances. Since you can make a zero Ohm active current shunt this way, i would think you could create an 'any' Ohm shunt (which is just a resistor) this way too. It would take a decent voltage or current controlled current source and some control circuitry which may only require an op amp or two. If the resistances will only be used in a DC circuit this would be possible, but an AC version would have to be faster to response to fluctuations in the signal.The main idea here is to make a larger resistor look lower or a lower resistor look higher in value by feeding the circuit a current from an external current source under the control of a measurement circuit.

author: eslavko
author_rank: Contributor
timestamp: September 28, 2022, 06:15:58 am
content: Quote from: Terry Bites on September 27, 2022, 05:18:50 pmI have that design for my battery bank capacity tester. Works perfect for that but misearably failed as load resistor for 'PWM' tester.When you have load connected and Opamp inputs are the same (current matched Vref) all works perfect. Even frequency response is good. But now let's go to the worst case scenario. Assume the load is disconnected. voltage at R2 is 0V and inverting input is at 0V. But noninverting input is at some voltage and the output of opamp is saturated at high voltage and fet is saturated too. Now when you connect load the inrush current will be much higher as opamp must go out of saturation and this take time in range of a few microseconds up to milisecond (depend on quality of opamp).

author: Kleinstein
author_rank: Super Contributor
timestamp: September 28, 2022, 10:47:52 am
content: With enough resolution one can just the parallel configuration to get relatively close to the values you want. It just adds a little math and more channels (with relatively large resistors and thus low power).

author: eslavko
author_rank: Contributor
timestamp: September 28, 2022, 11:27:19 am
content: Quote from: Kleinstein on September 28, 2022, 10:47:52 amThat is... I just wonder if there are some better selection available? with 1/1, 1/2, 1/4 .... values and 11 bits I have, the lower 2/3 of scale have good resolution but in upper 1/3 the range is to coarse.

author: Kleinstein
author_rank: Super Contributor
timestamp: September 28, 2022, 12:27:43 pm
content: Other resistor stepping should not get significant better, as there would than be uneven holes in the 1/R scale and thus more problems. Ohne could just change the range, so that 2/3 of the resistance would be the new full scale. So there would be a few point above the normally used range.

author: Terry Bites
author_rank: Super Contributor
timestamp: September 28, 2022, 01:27:19 pm
content: You'll find the maths much easier if you work in conductances. Use G instead of R. See explanation at:www.khanacademy.org/science/electrical-engineering/ee-circuit-analysis-topic/ee-resistor-circuits/a/ee-parallel-conductanceDecide on a range of conductances Gs and increments of G needed. All that 1/(1/R1-1/R2....) stuff will drive you mad. G1+G2... will save you time and headaches. Gselect= 1/RselectEasy, but as noted there is no linear arangement of resistor branches that can be paralleled.So my suggestion is that you buy a box of 10R resistors and build a matrix and swich it with good old relays. No ringing there.

author: Nominal Animal
author_rank: Super Contributor
timestamp: September 28, 2022, 02:00:41 pm
content: You cannot control the overall resistances in the parallel arrangement (where each MOSFET or relay is in series with each resistor) as well as in the series arrangement (where each MOSFET or relay is in parallel with each resistor).Consider the case where you have three resistors, A, B, C, and therefore eight different states:0 = Open Open Open: Disconnected1 = Closed Open Open: Total resistance is A2 = Open Closed Open: Total resistance is B4 = Open Open Closed: Total resistance is C3 = Closed Closed Open: Total resistance is A//B = 1/(1/A + 1/B) = AB/(A+B)5 = Closed Open Closed: Total resistance is A//C = 1/(1/A + 1/C) = AC/(A+C)6 = Open Closed Closed: Total resistance is B//C = 1/(1/B + 1/C) = BC/(B+C)7 = Closed Closed Closed: Total resistance is A//B//C = 1/(1/A + 1/B + 1/C) = ABC/(AB + AC + BC)In particular, if A = B = C = 1, the seven finite resistances are 1, 1, 1, 1/2, 1/2, and 1/3; yielding three unique ones: 1.000, 0.500, and 0.333.If A=1, B=2, C=4, the seven finite resistances are 1, 2, 4, 2/3, 4/5, 4/3, 4/7; yielding 0.571, 0.667, 0.800, 1.000, 1.333, 2.000, 4.000.If A=1, B=2, C=3, we get 0.545, 0.667, 0.750, 1.000, 1.200, 2.000, 3.000.Simply put, your resolution at the low end will always be better than at the high end, because of how parallel resistances behave.In particular, if your N resistances are R/2n= 2-nR, n=0..N-1, then you can obtain resistances R/k, k=1..2N-1.Compare to the series configuration with N resistances 2nR, n=0..N-1, which yields resistances Rk, k=1..2N-1.The serial configuration is superior, because with N resistors R, 2R, 4R, ..., 2N-1R, you can produce any resistance between 0 and 2NR - R, inclusive, at a resolution of R. Furthermore, these can be built from resistors all having the same value, putting several in series-parallel configuration (although it is easier if you have two to four different values).For example, let's say you want 256 steps, or eight shortable (via MOSFET or relay) resistance steps, from 0 to 255R, inclusive, using 4-8 resistors of 8R or 16R each:R: eight 8R resistors in parallel2R: four 8R resistors in parallel4R: four 16R resistors in parallel8R: two pairs of two 8R series resistors in parallel16R: two pairs of two 16R series resistors in parallel32R: four 8R resistors in series64R: four 16R resistors in series128R: eight 16R resistors in seriesfor a total of 20 individual 8R resistors and 20 individual 16R resistors. With 4 4R, 12 8R, 12 16R, and 4 32R resistors, each would consist of exactly four resistors.With R=12.5Ω –– linear 12.5Ω steps up to 3187.5Ω ––, you'd need 32 resistors: 4×50Ω, 12×100Ω, 12×200Ω, 4×400Ω. If you have resistors with the same resistance from different batches, and a precise resistance measurement, you can hand-tune the resistances to get very good resolution.(Note that with 11 steps, 100%/211= 100%/2048 ≃ 0.05%, so you'd need the highest resistor set to be exact to within 0.025%, to keep the midway step (the 50% glitch where you switch from 10 lowest to only the highest) within 0.25R and 0.75R. With 8 steps, 100%/2⁸=100%/256≃0.39%, so the highest step overall resistance should be within 0.2% or so. Because series resistors are easier to select, it can make a lot of sense to use twice the number of resistors for the largest resistance.)When switching resistances, I would recommend always opening the short (enabling resistors) before adding new shorts (shorting resistors), doing the switch in two steps. This means that switching from cocccccc to occccccc you actually do cocccccc → oocccccc → occccccc, with enough delay in between to stabilise the switching transistors or relays. This way, you always 'glitch' toward higher resistance. If you have a glitch that temporarily has very low resistance (for example, cocccccc → cccccccc → occccccc, you have anear zero-ohm short, cccccc, for a short while), the resistance could be so low it damages your voltage/current source.

author: eslavko
author_rank: Contributor
timestamp: September 28, 2022, 06:00:23 pm
content: Ok I find that whatever I do with parallel connection will have more dense values at low end and coarse at high end. With series I can get linear response.But FET switching at parallel connection is easy as all gates are referenced to ground. In series connection the gate drive will go complex as fets aren't ground biased. In parallel connection I can use any fet with RdsOn in miliohm range, in series I can imagine only optocoupler with fet and this one have RDSon in ohms.Did I miss something?

author: Zero999
author_rank: Super Contributor
timestamp: September 28, 2022, 07:24:02 pm
content: Put the resistors in series. If the MOSFETs can be driven from 30V, use high value gate resistors and zener diodes to protect the gates.

author: Nominal Animal
author_rank: Super Contributor
timestamp: September 28, 2022, 07:46:40 pm
content: Consider using P-channel MOSFETs with source tied to gate with say a 100k resistor, each across a resistor (or set of resistors), with the body diode in the blocking direction. Use a Darlington transistor to pull each gate to ground, for example ULN2003 or ULQ2003 (seven in an 16-pin package).Their gate-source voltage, Vgs, then limits the maximum voltage across the entire resistor pack. The gate threshold voltage, Vgs(th), limits the minimum voltage across the entire resistor pack. If the voltage across the resistor pack is too low, pulling the gates to ground will not turn them on. This means that at low voltages, the resistor pack resistance will always be too high.If you want the resistor pack to operate down to zero volts, or with negative voltages, I would use relays instead: one relay across each resistor (set), shorting it out, normally open (SPST-NO, aka 1 form A); say Omron G5Q-1A4-DC5 ones (with 5V coil voltage), rated at max. 5A 30VDC (30V maximum DC voltage) or 3A 250VAC (277VAC maximum AC voltage), available at Mouser for under 1.5€ apiece in lots of ten. At 5V, each relay draws about 40mA continuous when energized. Since the relay coils are isolated from the load voltages, you can run the relays off an USB wall wart or even a power bank. It can be dropped to 16mA after 100ms, but that requires a somewhat smarter relay drive circuit (than just an IC and a diode per relay to handle the inductive spikes); a pair of NPN transistors per relay with some current-limiting resistors, for example.

author: Zero999
author_rank: Super Contributor
timestamp: September 28, 2022, 09:05:13 pm
content: P-MOSFETs will only work at higher voltages. N-channel MOSFETs should work over 0V to 30V, providing there's always 30V available for gate drive.You're right, relays are the only way to do this with negative voltage. These can be made solid state with N-MOSFETs connected back-to-back with photovoltaic gate driver opto-couplers.

author: Warpspeed
author_rank: Contributor
timestamp: September 28, 2022, 09:14:17 pm
content: You can do it with binary weighted resistors as suggested above ^^Or you could build an R-2R resistor ladder network of as many bits as you want that only requires two different resistor values.https://en.wikipedia.org/wiki/Resistor_ladderThese R-2R ladders can be bought ready made having precision resistors which really saves a lot of board space, and give excellent accuracy.Check out the Bourns 4100R series.https://octopart.com/datasheet/4116r-2-220-bourns-1428321?utm_source=bing&utm_medium=cpc&utm_campaign=b_cpc_intl_search_dsa_english_en_usd_datasheets&utm_term=datasheet&utm_content=Intl%20Datasheet%20DSAOr you could build up something yourself, using high powered resistors for just the first few stages, for use as a stepped resistive test load.It would be easy to do with 100R and 200R resistors, as these are standard easy to get values.Either N or P channel mosfets would work, and all the mosfet sources are commoned which simplifies driving, especially for higher voltages, or where there are a large numbers of bits.For very high power loads, the first stage might have to carry many amps and require a high powered mosfet and resistor.The tenth stage might only have to carry a few milliamps so the parts there can be quite small.All the resistor values would be the same for each stage of course, maybe 100R and 200R, or whatever values you need.

author: MrAl
author_rank: Super Contributor
timestamp: September 28, 2022, 10:59:53 pm
content: Hi,Another idea is to go with the 8 4 2 1 series connection and just use a separate carefully designed bias circuit to drive the four transistors (that short each series resistor). With proper bias it may work except in maybe the very very light current load applications because the gate current is very small once the transistor switches, although you may see transients as they switch in and out.At this point i am not sure if you want a real resistor network or you just need to adjust a load current for testing some device or devices. If you just want to provide a set load current the design task is much much simpler using a control circuit similar to what has been shown in this thread already. It's not too hard to adjust a load current it's harder to adjust actual resistor values. What is more is that an adjustable load current device can be adjusted for any 'equivalent' resistance not just in steps. SO if you just need a variable load current then now is the time to point that out ... or not that.

author: MrAl
author_rank: Super Contributor
timestamp: September 29, 2022, 01:43:53 am
content: Quote from: MrAl on September 28, 2022, 10:59:53 pmI forgot to mention you can use optocoupler drivers to turn the mosfets on and off, along with some thought about the mosfet drive voltages. This might not be too hard to set up. For extreme use you may also need independent voltage supplies one for each mostfet. That can be had with a multi winding transformer and rectifier/filter circuits.

author: eslavko
author_rank: Contributor
timestamp: September 29, 2022, 05:48:06 am
content: The device is battery powered so releays is out of scope. The power source is 4x AA cell, and dimensions are already defined. At least for prototype I must do that on existing PCB (parallel resistors) and there are two sets of resistors. One set is of 11 resistors and other is for 13 resistors. So I need 24 driver circuits in real.

author: eslavko
author_rank: Contributor
timestamp: September 29, 2022, 05:52:54 am
content: I need to check if this circuit from post #13 improve performance.Many times R2R ladder is suggested but AFAIK the R2R ladder need to drive leg to 0V or Reference. I don't know what result is if it's driven to 0V or left float. Can someone simulate this?

author: MrAl
author_rank: Super Contributor
timestamp: September 29, 2022, 09:10:49 am
content: Quote from: eslavko on September 29, 2022, 05:48:06 amIf you can find dual action relays you only power them when they switch.

author: MrAl
author_rank: Super Contributor
timestamp: September 29, 2022, 09:12:20 am
content: Quote from: eslavko on September 29, 2022, 05:52:54 amYes the 'legs' are driven to either +vcc or ground never just open.That's not a 1R2R ladder but even if it was you still have to drive the bottom of each leg to either +vcc or ground (P type and N type mosfets) but never just open.It's usually used to act as a stepping voltage divider with equal steps.

author: ledtester
author_rank: Super Contributor
timestamp: September 29, 2022, 04:56:51 pm
content: Quote from: eslavko on September 29, 2022, 05:52:54 amI've cobbled together this R-ladder calculator web app which allows you to play around with different resistance values:https://pc88mxer.gitlab.io/public-pages/ladder.htmlThe "Control Word" represents which switches are closed.Setting the top values to 0 will place all of the vertical resistors in parallel with each other.You should enter the same number of values for both the top and vertical resistors, but if you don't the missing values will be set to 0.Let me know if you have any questions or spot any issues.The app probably displays best on a desktop.

author: Warpspeed
author_rank: Contributor
timestamp: September 29, 2022, 11:24:40 pm
content: By far the easiest way to use an R-2R resistor network, is to operate in direct voltage switching mode.To do this, the 2R resistors that extend out from the R-2R network are driven direct from CMOS output logic gates.These switch from either ground to supply with fairly low impedance in either logic state.The output voltage then switches in even steps between ground and the supply voltage to the CMOS driver.The circuit below would ramp up the voltage in 16 even steps with each incoming clock pulse, then overflow back to zero.For best accuracy the resistors need to be made reasonably higher than the output impedance of the CMOS driver, say typically 1k to 100k.The output op amp can then increase the output voltage span, and provide a lower output impedance if required.

author: Warpspeed
author_rank: Contributor
timestamp: September 29, 2022, 11:35:18 pm
content: The above circuit is basically correct, but looking at again it after I posted it, there are some devils in the detail.The driver chip could certainly be a ripple counter connected up as shown, but definitely not TTL.It absolutelyMustbe CMOS chip to ensure full rail to rail switching.A 74HC93 would work, but not a 74LS93.The output op amp is also drawn as a summing amplifier, and would produce an inverted negative going output ramp, although the output terminals are labeled plus and minus, which suggests a positive going output ramp. Which it ain't.

author: Warpspeed
author_rank: Contributor
timestamp: September 29, 2022, 11:38:47 pm
content: double post.

author: eslavko
author_rank: Contributor
timestamp: September 30, 2022, 06:37:59 am
content: Quote from: ledtester on September 29, 2022, 04:56:51 pmlink doesn't work (404)

author: eslavko
author_rank: Contributor
timestamp: September 30, 2022, 06:55:19 am
content: Thanks all for contribution.This thread goes in little wrong direction. As I allready write I need variable resistor and not variable voltage. The device is battery powered handheld and there are 24 legs.With design as is and resistors in 1/1, 1/2, 1/4 ... ratio I get desired values in low end without problem as there steps are superfine. But in higher values the steps are to coarse. I do the simulation and found that I need at least 15 legs (16 better) for each of two chain.The real question was 'Is there any better resistor aragement than 1/1, 1/2, 1/4 ...And seems that answer is NO.So if anyone can arrange resistors to have finer steps at high range this is the answer for me. They don't need to be linear as I can use translation table in MCU.

author: MrAl
author_rank: Super Contributor
timestamp: September 30, 2022, 10:36:23 am
content: Quote from: eslavko on September 30, 2022, 06:55:19 amYes as i said the 1R2R ladder is usually used to generate voltage steps or if into a zero ohm grounded current sense then a current, so i cant see that being any use here.

author: Nominal Animal
author_rank: Super Contributor
timestamp: September 30, 2022, 01:20:57 pm
content: The "optimum" resistor set is linear, down to about half the largest one.As a practical example, with 100Ω, 75Ω, 50Ω you can get 23.1Ω, 30.0Ω, 33.3Ω, 42.9Ω, 50Ω, 75Ω, and 100Ω.You can combine 1.0, 0.9, 0.8, 0.7, 0.6, 0.5 into 0.118, 0.134, 0.136, 0.139, 0.142, 0.147, 0.155, 0.158, 0.161, 0.164, 0.166, 0.169, 0.173, 0.173, 0.176, 0.181, 0.183, 0.187, 0.187, 0.192, 0.196, 0.199, 0.203, 0.209, 0.209, 0.214, 0.214, 0.220, 0.226, 0.229, 0.230, 0.235, 0.238, 0.243, 0.244, 0.248, 0.255, 0.264, 0.265, 0.272, 0.273, 0.283, 0.292, 0.298, 0.308, 0.321, 0.323, 0.333, 0.343, 0.360, 0.373, 0.375, 0.394, 0.412, 0.424, 0.444, 0.474, plus you then have the 0.500, 0.600, 0.700, 0.800, 0.900, 1.000 on their own.This is because parallel resistor arrays simplymathematically cannotprovide many combinations in the upper half:ForNresistors in parallel, the total resistance cannot exceed max(R)/N, where max(R) is the largest resistor in the parallel array ofNresistors. Thus, the distribution in the upper half is the set of individual resistances (within the upper half).GivenNsuch resistors, with largest 1 and smallest 0.5, the minimum resistance possible is 1/(2×(N-1)×sum(1/(N+k-1), k=0..N-1)).ForN=2, 1/3≃0.333; forN=3, 3/13≃0.231; forN=4, 10/57≃0.175; forN=5, 105/743≃0.141; forN=6, 252/2131≃0.118; forN=7, 2310/22727≃0.102; forN=8, 25740/288851≃0.0891; forN=9, 9009/113567≃0.0793; forN=10, 136136/1904613≃0.0715; forN=11, 11639628/178964263≃0.0650 ≃ 1/15. Since the minimum forN=24 is 204773655626139600/6837434095326667939≃0.0299489 ≃ 1/33, the tradeoff with this approach is the minimum stays relatively high (about 1/Nc, with 1≤c≤1.2555 forN≥4), even with many resistors.In my opinion, if you want a linear distribution of total resistances, parallel configurations just won't work: the upper half of the total resistance range is always covered by individual resistors, no matter what you do! It is a square peg in a round hole; the wrong tool for the job.

author: Siwastaja
author_rank: Super Contributor
timestamp: September 30, 2022, 01:48:38 pm
content: Also consider photo-MOSFETs. They can accept bidirectional (like two opposite back-to-back MOSFETs, removing the conduction of body diodes) voltages over them while off, so behave like ideal switches. Thanks to isolation, control voltage doesn't need to be in any relation to the switched voltage: if you can turn a LED on with arduino/whatever you are using, you can control photo-MOSFET.They are just quite expensive and on-resistance might be too much and/or maximum blocking voltage too low for your application, but do check them out. It will be the easiest way to the 2^n series configuration.

author: Zero999
author_rank: Super Contributor
timestamp: September 30, 2022, 05:46:36 pm
content: The R2R network is no good for this. The person who mentioned it was mistaken.Use the circuit I posted above with photo-voltaic output opto-couplers driving the MOSFETs.Here's a link to a part which has two channels, so you only need two of them to give a 4-bit input.https://rocelec.widen.net/view/pdf/tp3wmnljhw/IRSDS10626-1.pdfhttps://www.digikey.co.uk/en/products/detail/rochester-electronics-llc/PVI5013RPBF/12608484

author: eslavko
author_rank: Contributor
timestamp: September 30, 2022, 06:59:32 pm
content: Quote from: Nominal Animal on September 30, 2022, 01:20:57 pmI'm confused.You say that I need linear gap in resistance? 25+25=50, 50+25=75, 75+25=100, 100+25=125.....just take some base and does multiply value.Strange as I get better result with values like 100, 200, 400, 800I need to re check my simulation

author: Zero999
author_rank: Super Contributor
timestamp: September 30, 2022, 07:31:54 pm
content: Quote from: eslavko on September 30, 2022, 06:59:32 pmPresumably he's talking about parallel?You're right. You need resistors with doubling values, to get a linear variable resistance with series connected resistors.

author: Nominal Animal
author_rank: Super Contributor
timestamp: September 30, 2022, 09:53:53 pm
content: Quote from: eslavko on September 30, 2022, 06:59:32 pmThe "optimum" resistor set for the parallel configuration is linear, i.e. 1/1, 9/10, 4/5, 7/10, 3/5, 1/2. It was an answer to your question in #42, showing that 'yes, there is an arrangement that gives larger linear range than powers of two', or fully linear upper half. Rest of the post (tries to) explain why this is so, the drawbacks, and why the parallel configuration is simply unsuited for this. (Simply put, even the "optimum" resistor set is horribly crappy, if one desires linear steps.)For the series configuration, with power of two resistances (multiplied by a common constant), the combinations give an exactly linear set. It's perfect.Thus, the optimum resistor set for the series configuration has each switchable resistor value be twice the value of the next smaller one, giving a linear distribution, with step size the size of the smallest switchable resistor.If the smallest resistance isR, and there areNswitchable resistors, the total resistance of the combinations isk×Rfork=0..2N-1.If you have some target resistancer, calculatek=(int)(r/R+0.5). (The add half before truncating to int is all about rounding, so that 4.4 rounds to 4, but 4.6 rounds to 5 and not 4. With pure integers,k=(r+R/2)/Ryields basically the same results.)If you sort the resistors, so that the smallest resistance corresponds to the least significant bit (bit 0), and the largest resistance to the most significant bit (bitN-1), then the binary representation ofkmatches the resistor configuration, set bit indicating resistor in use, and clear bit resistor is not used (is shorted).If you additionally haveR(same as the smallest switchable resistance) always in series, then the total resistance of the combinations isk×Rfork=1..2N. Still,k=(int)(r/R+0.5), but now(k-1)in binary represents the resistor states.In other words, if you do use power of two series, i.e. each resistor twice the value of the smaller one, you do not need any kind of a table at all in your microcontroller. If you want, I can show you the very simple code needed for this, including the logic that ensures you enable resistors (remove shorts) before you disable them (enable shorts), so that the switching "glitches" always via a temporarily higher resistance, and never via temporarily lower resistance.

author: eslavko
author_rank: Contributor
timestamp: October 01, 2022, 08:03:14 am
content: Got it.If I linear space resistor in betwen R nad R/2 I got best response. If I go betwen R and R/3 the response is worse but I can get wider range. Will try to find compromise.

author: Terry Bites
author_rank: Super Contributor
timestamp: October 03, 2022, 12:23:14 pm
content: I decided to model an electronic resistor out of curiosity. Then I stumbled upon thishttps://www.edn.com/electronic-rheostat-provides-decades-of-load-resistance/Nice and easy. You'd have to rescale R1 and R2 to suit your purposes. As the man says, if you run it of a battery, it floats. Note the stabilty components.

author: Zero999
author_rank: Super Contributor
timestamp: October 03, 2022, 08:02:06 pm
content: Quote from: Terry Bites on October 03, 2022, 12:23:14 pmThe whole point is it's supposed to be digitally controlled. Using a digital potentiometer would make it easy to control with a microcontroller, via an opto-isolator. It needs to be suitable for a 9V supply. I found the MCP45HV51-104E/ST on Mouser.https://www.mouser.co.uk/datasheet/2/268/20005304A-347268.pdfThe MAX480 is not recommended for new designs. I wonder if the OP07 could be used instead? An LED could be used to lift the local 0V up by 2V, so a single supply op-amp isn't needed. The frequency compensation might need to be adjusted, as the OP07 is much faster. The downside is it will use more current, so perhaps an isolated DC:DC converter could be used, rather than a battery.Here's the circuit with the values changed to give 75R to 2k, which is more than enough. I went for a slightly wider range, because the digital potentiometer has a tolerance of 20%, so it might have a much lower value of 80k. The circuit would need to be calibrated, if such a wide tolerance is unacceptable.

author: ledtester
author_rank: Super Contributor
timestamp: October 03, 2022, 08:46:22 pm
content: Quote from: Zero999 on October 03, 2022, 08:02:06 pmThe resulting resistance is given by R_eff = (1+R1/R2)*R_shunt where R1 is the upper leg of the non-inverting input voltage divider.A digital pot could be used for R1 to give linear spacing between resistances.Alternatively, it seems that you could use the original parallel control idea for R2 since such a configuration gives linear spacing between conductances, i.e. R_eff = (1+R1*G2)*R_shunt.

author: MrAl
author_rank: Super Contributor
timestamp: October 04, 2022, 12:06:19 am
content: Quote from: Nominal Animal on September 30, 2022, 01:20:57 pmYes i had to agree that parallel resistors is not a very good way to do that.I think the way to look at it is that sometimes there is simply no dual to some circuit so transforming from series to parallel is not actually possible. Some circuits that are a little more complicated do have duals, but some simply do not. That's life. The next best thing is to try to come up with something that is usable but not perfect, or go with a more elaborate design.If i was to build something like this i think i would go with the dual action relay idea because that allows a lot of flexibility and nearly perfect linearity.The down side to all of this is that there are always gong to be limitations i probably could not live with unless it was being designed for a PARTICULAR application. In other words, it would be difficult to design a resistor bank that went from 0.1 Ohms to 100k Ohms, so you are stuck with choosing a range.Back when i worked in the industry, none of this would work because the power dissipation of the 'resistors' would simply be too high. We're talking up to 10kWatts, 3 phase, and it's very hard to design a resistor bank for something like that. The only way is to use banks of resistive load cones that can handle up to 500 to 1000 watts each, and a bunch of screw in lamp bases. With that you can screw in the 'resistors' you need and simply dont screw in those you dont need. A benefit is it also works with AC.For DC, i favor the control circuit and transistor(s) method. That is where you adjust the current not the resistance. You can get a wide variation in current levels and it's fully adjustable. i used this idea back in the 1990's with a simple setup where a single potentiometer would be used to adjust the base current to an NPN power transistor. You can get a wide variation in current with that simple setup. Might need a driver transistor also, and of course depending on power levels you probably need a heat sink of the appropriate size, and possibly a parallel transistor arrangement to handle larger power levels.

author: eslavko
author_rank: Contributor
timestamp: October 04, 2022, 06:36:24 am
content: Quote from: Zero999 on October 03, 2022, 08:02:06 pmThat circuit seems to near avoid trouble from post #20, as input amplifier isn't saturated but has only 'opamp dif err' when load is not connected. But the circuit itself doesn't solve the primary deal. As I start that thread the tester was intended for some use but in time arised that it can be used for one more task. Its just software change and span. The required span is from 50 Ohm up to 3kOhm with max 15 ohm step (mimic 0.5% resistor) , up to 4k5 with max step of 30 O (mimic 1% resistor).On boot time device have self callibration procedure (connecting known voltage to input and measure current from 24bit ADC) to avoid drifts.

author: eslavko
author_rank: Contributor
timestamp: October 04, 2022, 06:48:58 am
content: ... just wonder how to add PWM/PDM signal to mimic R1/R2 in circuit from #55. For example to set value of 2k Digipot to get lowest resistance required, and to set 100k potentiometer with resistor to get max resistance required, and parallel with that resistor to have PWM/PDM controlled switch. If switch works in few MHz range just the small capacitor at + input of opamp can filter fignal.I allready do similar but I was feeding PWM through RC filter directly to + input of opamp, and failed as + input can have some high voltage and - input can have 0 V if there are no load, thus saturate opamp. With getting IN+ voltage as reference for PWM I think this situation can be avoided. Need to make some tests.

author: Zero999
author_rank: Super Contributor
timestamp: October 04, 2022, 10:37:53 pm
content: Quote from: eslavko on October 04, 2022, 06:36:24 amI've just realised the circuit I posted would require the digital potentiometer to be powered off +IN.I thought you wanted 100R to 1k6. Now you say 50 to 3000 with 15 Ohm steps or up to 4500 with 30 Ohm steps. Which is it?All you need is a string of resistors, bypassed with switches, whether they be mechanical relays, or solid state.You just need more bits.A chain of: 15, 30, 60, 120, 240, 480, 960, 1920 would give 0 to 4607 Ohms, in 15 Ohm steps. You could add another resistor in series, which isn't switched out, to give a minimum resistance.

author: jwet
author_rank: Frequent Contributor
timestamp: October 05, 2022, 02:41:54 pm
content: The OP-07 is a nice op-amp but is no good on single supply. Its common mode is a volt off its V- terminal (max 2v). Setting up a a pseudo ground gets kind of messy in DC type circuits. An LM-358 would probably work fine. A few mV of offset wouldn't be a big deal here.

author: Zero999
author_rank: Super Contributor
timestamp: October 05, 2022, 06:19:58 pm
content: Quote from: jwet on October 05, 2022, 02:41:54 pmThe LED forms a pseudo ground and should work quite well in this application.QuoteThe problem with the LM358 is the offset voltage is a bit higher and would affect the accuracy, especially at lower voltages.

author: EPAIII
author_rank: Super Contributor
timestamp: October 06, 2022, 09:25:42 am
content: To answer your ORIGINAL question, EXACTLY as it was asked,NO! You can not use any sequence of four resistor values in the PARALLEL circuit you show to produce a LINEAR sequence of overall resistance values. It is MATHEMATICALLY IMPOSSIBLE.This is because resistance values, in parallel do not directly add together. It is their reciprocals that do add together and reciprocals produce an entirely different type of mathematical sequence than that produced by the numbers themselves. And, of course, after adding the reciprocals, you must take the reciprocal of the sum.If the numbers graph as a straight line, then the reciprocals graph as a curved line and if the reciprocals graph as a straight line, then the numbers graph as a curved line. OK, it is not really that simple. But you can take my word for it or look at the following attempt.Since resistors in parallel will always result in a combined value that is less than either (any) of the individual resistors, we need to start with the highest value desired. You said 1600 Ohms. Now, what value is needed, in parallel with 1600 Ohms to get 1500 Ohms? I get 24K Ohms. So that is one value we will need. Next, what value is needed, again in parallel with 1600 Ohms to get 1400 Ohms? I get 11.2K Ohms. Notice it is not the nice, neat 12K Ohms which would be half of 24K Ohms. Here are two tables that attempt to show a the list of individual, parallel resistors that are needed to get the linear sequence you want:You can see that neither of them works. The first table starts with a 1600 Ohm resistor and then shows the values for individual resistors that need to be in parallel with that 1600 Ohms to bring the combination to the values at steps of 100 Ohms. These are in the second column. The resulting sequence is not very regular and I see no way to combine any of the values there into any kind of groups. You simply need all 16 different values. I added a third column in an attempt to find a common difference. This is one simple trick to find a pattern in a sequence of numbers. But it too yields nothing. I even tried a second column of differences (not shown) but they too were still quite irregular.The second chart tries to combine the parallel resistances in an additive manner. So the 1500 total value would use one resistor in parallel with the 1600 Ohm one. And the 1400 total would need two. The 1300 would use all three down to that point, etc. This produced a slightly better sequence and the differences show a sequence in 200 Ohm jumps. But even that does not allow us to construct a circuit.In short, there just is NO WAY to do what you want with parallel resistors, no matter what the values are unless you are willing to use a total number of resistors equal to the number of total values you want. The math just does not allow it.This is why I, along with others, suggested a SERIES circuit instead of a parallel one. As we have said, four resistors in series along with relays or other means of shorting them individually, WILL give you sixteen values, spaced at equal intervals. I suggested relays because FETs at different DC bias points (along that series string of resistors) will need a complicated set of driving circuits.Quote from: eslavko on September 27, 2022, 06:40:29 am

author: Terry Bites
author_rank: Super Contributor
timestamp: October 06, 2022, 01:40:07 pm
content: Notes the Gm stage hast be fast. That s not easy in the tradional V to I source, the opamp can't drive the MOSFET porperly.Its a bit easier using a Darlington insted of a MOSFET.Driver stages just make compensation even more problematic.You can control β with a multiplying DAC. Take care that the DAC doesn't see the high voltage. You can pot down twice if needs be.Make a or buy a servo controled pot.So much less pain.https://www.eevblog.com/forum/chat/digitally-controlled-potentiometer-i-got-this!/https://onlinecontrols.com/dc-motorized-potentiometers/

author: Nominal Animal
author_rank: Super Contributor
timestamp: October 06, 2022, 03:43:01 pm
content: Quote from: Terry Bites on October 06, 2022, 01:40:07 pmA dual one, where one side was used to measure some reference voltage (AVcc works fine, as this is just a ratiometric measurement) by using the side as a voltage divider, might be particularly useful. Instead of keeping track of the resistance in memory, one could use the potentiometer state itself, its measured resistance, as the value.Of course, that assumes the two tracks have the same resistance.If you find a non-servo pot, you can use an ubiquitous small 28BYJ-48 stepper with a ULN2003A driver, and a pair of plastic gears to drive the pot. Trivial to drive from a microcontroller, and ubiquitous in the Arduino world. These have internal gearing, so that a full turn is typically 2048 steps, but it does vary. You can also use a timing belt, or even a short length of silicone, rubber, or PVA tubing as a direct inline coupler. 3D printed PLA gears and pulleys work fine for this kind of low loads, but you can find lots of suitable ones at eBay, Banggood, et.al., and also by maker-oriented companies.The real problem I see, is that potentiometers usually cannot dissipate much heat; and high-power rheostats tend to be expensive –– 25W 5kOhm Ohmite RHS5K0E costs 80€ at Mouser –– and at least Mouser has them in single-gang only. The dual-gang 5kOhm ones I found at Mouser topped at 1 W. (Which means the current over the potentiometer should not exceed 15mA when the resistance is 4500 Ohms; or 47mA at 450 Ohms; or 149mA at 45 Ohms.)As a comparison, you can get ten Omron G5RL-K1A-E-DC5 latching relays for under 45€ (total for ten), giving you 1024 steps. (Say, 5 Ohm steps from 5 Ohm to 5120 Ohm). These relays can handle up to 16A 25VDC, and only need 5V 120mA for 10ms (0.0216 mAh) to switch. They latch, meaning they draw no current except when switching. You can use for example three ULN2003A Darlington arrays to drive ten of these relays (but I'd also add ten diode pairs to snub the voltage spikes). If you don't have 20 GPIO pins in your MCU, you can use for example three 74HCT595A serial-to-parallel chips, and five GPIO pins instead. For 5 Ohm steps up to 5120 Ohm, the needed resistances are 5, 10, 20, 40, 80, 160, 320, 640, 1280, and 2560 Ohms. For say max. 8A current, the resistances need to be able to dissipate 12.8W, 6.4W, 3.2W, 1.6W, 0.8W, 0.4W, 0.2W, 0.1W, 0.05W, and 0.025W, respectively. Single resistors suffice for the two highest ones (if you find precise enough ones!), but the rest I would build out of parallel arrays, with plenty of room in between for cooling.

author: Zero999
author_rank: Super Contributor
timestamp: October 06, 2022, 04:52:55 pm
content: A servo controlled potentiometer will need a considerable level of calibration. The tolerance is typically 20%, or poorer and matching is poor for dual ganged units.An array of resistors, bypassed with switches is by far the best option, in terms of close tolerance, cost and simplicity.

author: eslavko
author_rank: Contributor
timestamp: October 07, 2022, 05:48:45 am
content: Quote from: EPAIII on October 06, 2022, 09:25:42 amThanks for that!During that post I realised that linear response is impossible.But I can live with nonlinear response if the steps on high range are not to coarse.In the start of topic I had a range from 100 to 1600 Ohms with steps to mimic 0.5% resistor.But I see another use for device if I widen range to be from 50 to 4500 Ohm.The step from 50 Ohm to 3k Ohm should be under 15 Ohm (mimic 0.5% scale), and from 3k to 4k5 with max 30 Ohm step (mimic 1% resistor).So how many bits I need to accomplish that?I need someone who know math better than me.And as reply to other's. Device is handheld, battery powered. At lowest range the dissipation is around 20W. So there are no place for relays, servo rheostats. Dynamic nature of signal prevent to use opamps driving current sources...

author: ledtester
author_rank: Super Contributor
timestamp: October 07, 2022, 06:43:33 am
content: Quote from: Zero999 on October 04, 2022, 10:37:53 pm1920+960+480+240+120+60+30+15 only gets you to 3825 so you'll need an additional switchable resistor to get to 4500.This makes sense since 4500/15 = 300 and log base 2 of 300 is > 8 so you should need at least 9 resistors.Quote from: eslavko on October 07, 2022, 05:48:45 amTo span from 50 to 3K in increments of 15R you need at least 8 bits (log base 2 of 3000/15).Using Zero999's scheme plus a 3840R resistor (total of 9 resistors) you can span 15R to 7.6K in increments of 15R which covers both of your use cases.Quote from: ledtester on October 03, 2022, 08:46:22 pmI think it is worth investigating the schematic in Reply #52 but where R2 is a set of switchable parallel resistors and the top leg of the divider is fixed. For instance, consider the following selection:R_shunt = 35Rfor the "2k digital pot + 100k variable" use a fixed 13.7K resistor (call this R1)for R2, use a switchable parallel combination of 9 resistors with values 32K, 16K, 8K, 4K, 2K, 1K, 500R , 250R and 125R.The effective resistance is given by (1+R1/R2)*R_shunt. This gives a minimum resistance of (1+13.7/32)*35 = 50R and an increment of (13.7/32)*35 = 15R.

author: eslavko
author_rank: Contributor
timestamp: October 07, 2022, 08:39:26 am
content: Quote from: ledtester on October 07, 2022, 06:43:33 amSeems nice. All switches are ground based so no gate drive problems. Need to check if OPAMP saturation and transitions are solved. If there are no IN+ voltage the inverting and noninverting inputs are at 0V. I think this worth to be tested. And impact of R4/C1 on transitions.

author: Nominal Animal
author_rank: Super Contributor
timestamp: October 07, 2022, 02:54:09 pm
content: The formula for calculating how many binary switching elements you need is$$N = \log_2 \left \lceil \frac{\max - \min}{\text{step}} \right\rceil$$where \$\lceil x \rceil\$ is rounding up to next whole integer, and \$\log_2\$ is base-2 logarithm; you can use \$\log_2 x = (\log x) / (\log 2)\$ (regardless of the base of the logarithms on the right side, as long as you use the same one for both).Or, in another terms, \$\log_2\lceil x \rceil\$ means you find the smallest power of two that is at least \$x\$, i.e. the smallest \$k\$ for which \$x \le 2^k\$, and use the exponent \$k\$.When you have \$N\$ switching elements in series, there are \$2^N\$ combinations. The base one, \$\text{step}\$, is then$$\text{step} = \frac{\max - \min}{2^N - 1}$$If you round it up, you'll push \$\max\$ higher; round it down, and you reduce \$\max\$:$$\max = \min + (2^N - 1)\text{step}$$(The term \$2^N-1\$ comes from the fact that the largest \$N\$-bit value is \$2^N-1\$. There are a total of \$2^N\$ values, yes, but the smallest one is zero.)Quote from: eslavko on October 07, 2022, 05:48:45 am\$\frac{3000 - 50}{15} \le 197\$, and the closest power of two not smaller than that is \$256 = 2^8\$, so you need 8 steps for that. You'll also need a non-switchable 50 Ohm resistor in series with the switchable ones.Quote from: eslavko on October 07, 2022, 05:48:45 amBecause the steps are formed by the smaller resistors, you save nothing by combining two separate linear scales into one resistor pack. Here, you'd need \$33\$ steps, and even if we round it down to \$32 = 2^5\$, you'll still add five new resistors.If you instead extend the range to 4k5, \$\frac{4500-50}{15} \le 297\$, the closest power of two not smaller than that is \$512 = 2^9\$. Only one added resistor, in other words.Quote from: eslavko on October 07, 2022, 05:48:45 amOnly nine, and you get a full 50 to 4k5 range with constant-sized steps, assuming exact resistor values.You even have options. For example, if your smallest resistor is 10 Ohms, and you start at 10 Ohms (i.e. have an unswitchable 10 Ohms always in series), the range will be from 10 Ohm to 5120 Ohm (0 to 5110 Ohm if you do not have a fixed 10 Ohm resistor), with a step of 10 Ohms, because$$\max = \min + 10 \times (2^9 - 1) = \min + 10 \times 511 = \min + 5110$$Edited: In practice, if each switchable resistor is precise to within \$v/N\$ (in Ohms, i.e. absolute precision, not relative precision like is usually used), your resistor pack will be precise to within \$v\$ Ohms. There are other ways to ensure precision, but I think this is the most useful (I could be wrong, though).In any case, I personally would get – borrow, hire – a precise resistance meter when building the resistor packs.

author: Terry Bites
author_rank: Super Contributor
timestamp: October 07, 2022, 05:00:26 pm
content: Something that could easily be automated?

author: Nominal Animal
author_rank: Super Contributor
timestamp: October 07, 2022, 06:49:37 pm
content: Quote from: Terry Bites on October 07, 2022, 05:00:26 pmI could create a self-contained tool page that requires no server nor internet access, only a browser; works fine if you save the page locally on your computer and open it from there. Similar to myFinite Impulse Response spectrum analysis page. What would be useful there?Most of the work in these is trying to devise an user interface that works well in a browser. For example, the above one only requires you to paste some coefficients in the top (center-right) bar –– say, 1 0 1 ––, and press Enter.Maximum power dissipation per resistor is easy to calculate if the overall current drawn through the series system is specified.Linearity and relative and absolute error calculation is possible, if one specifies a minimum and a maximum resistance for each element. Since the page is standalone, one could even let each value be calculatable via JS eval(): even though that opens cross-site scripting vulnerabilities (since it allows the execution of arbitrary javascript in the context of that page), in this particular case, it would be fully acceptable.So, I'm thinking of at least two separate tools: one to find out the number of resistors needed and their power dissipation when maximum current through the series system is specified, and the other to show how the selection of particular resistors affects the overall precision and monotonicity.Or did you mean something completely different?

author: Zero999
author_rank: Super Contributor
timestamp: October 07, 2022, 08:10:04 pm
content: Quote from: ledtester on October 07, 2022, 06:43:33 amYou're right. 9-bits are required, for 15R increments and > 4k5.

author: eslavko
author_rank: Contributor
timestamp: October 08, 2022, 10:23:25 am
content: I say 0.5% up to 3k and 1% up to 4k5.Can someone calculate how many bits I need if I use pure parallel aproach? I know that in upper range steps will be coarser and this is reason why I say 1% from 3k to 4k5.All serial circuits are out of question as driving fet needs serious gate circuit (float voltage up to 30V) or at least to use P fet, zener, resistor and another pulldown transistor (of course -V generator is necessary in that case ). relays are just to bulky to be usable(it's easyer to add few bits and keep parallel resistors than redesign all thing to have serial resistor.)

author: eslavko
author_rank: Contributor
timestamp: October 08, 2022, 10:32:33 am
content: Quote from: Nominal Animal on October 07, 2022, 06:49:37 pmActually I still prefer parallel resistors (inperfect response) but no gate driver hassle.

author: Zero999
author_rank: Super Contributor
timestamp: October 08, 2022, 06:02:32 pm
content: Quote from: eslavko on October 08, 2022, 10:23:25 amThere are some very small relays:https://www.te.com/commerce/DocumentDelivery/DDEController?Action=srchrtrv&DocNm=1-1773734-7_IM_Relay_I_Type&DocType=DS&DocLang=EnglishOr go solid state.https://toshiba.semicon-storage.com/info/TLP241A_datasheet_en_20200217.pdf?did=14237&prodName=TLP241AAnother option is opto-couplers which can be used to drive high-side MOSFETs.https://www.infineon.com/dgdl/pvi5013r.pdf?fileId=5546d462533600a401535683d8d12940https://toshiba.semicon-storage.com/info/TLP3905_datasheet_en_20200929.pdf?did=15185&prodName=TLP3905

author: ledtester
author_rank: Super Contributor
timestamp: October 08, 2022, 06:30:33 pm
content: Speaking of small relays, have a look at this digital resistance substitution box:https://www.kickstarter.com/projects/eastwoodtech/qr10-pocket-high-accuracy-programmable-resistance-box?ref=discovery&term=QR10Also discussed in this forum thread:https://www.eevblog.com/forum/crowd-funded-projects/high-accuracy-programmable-cute-resistance-substitution-box/They use small relays:

author: BrianHG
author_rank: Super Contributor
timestamp: October 08, 2022, 06:33:27 pm
content: One note, if you want a digital attenuation, you should not be using fixed resistors with matched R2R values. It is a waste as proper logarithmic constant impedance versions can be done with the right resistors and wiring. Also, a proper 6 bit logarithmic attenuation, IE: set to a true 1.5db per lsb step, would offer the equivilant to a 16bit linear digital resistor.Spread sheets/calculators exist for these resistor values.Ignore this post if you just need a linear programmable resistor instead of a programmable attenuation.

author: Nominal Animal
author_rank: Super Contributor
timestamp: October 09, 2022, 12:39:13 am
content: Here's an idea for the series configuration, using n-MOSFETs. I don't know if this works, but perhaps the experienced members here could tell. I did simulate it, and it seems to work.Let's say the series resistor set is between Vin and Vout, with Vin > Vout.You use an n-channel power MOSFET with low Rds(on) to short out each resistor. Each will have a high-value resistor (say, 1M) between gate and source, so by default they are non-conducting. (The idea is that we just need to pump some current into the gate to short out each resistor.)Microcontroller GND is at Vin, and Vcc at Vin+4V. On each GPIO output, you have the gate of a P-channel MOSFET (like DMP610DL that can withstand (Vout-Vin)-4V drain-source and gate-source voltages, with low enough gate threshold voltage so it can be switched at -4V; the currents are tiny). Their sources are connected to Vcc, and drains are connected (via current-limiting resistors) to the gates of the n-channel MOSFETs.When the GPIO is high or tri-state/floating, the p-MOSFET gate and source are at the same potential, so it does not conduct. Then, the n-MOSFET gate also has its gate and source at the same potential, so it does not conduct either, and the resistor is enabled (not shorted).When the GPIO is low, the p-MOSFET has Vgs=-4V, so it conducts. This lifts the n-MOSFET gate to at least 4V higher than its source (more, if the voltage has dropped in the preceding resistors).

author: eslavko
author_rank: Contributor
timestamp: October 09, 2022, 06:05:39 am
content: Relay are still to bulky and all optocouplers suggested are to slow! Switching time in 5ms! I need to change resistance inside 100us window when PWM/PDM signal is in low state.And to be more clear.We have around 10 devices and I want just to upgrade them. The populated PCB cost around $150. The device as is have 11 bits in one leg and 13 bits in other leg (can simulate two resistors). But in present state have only one bit on each leg ON. So one leg can have 11 values, and other one 13 values.If I manage to make parallel resistor to cover required range the update is just firmware change and resistors change on PCB. To make both legs with 12 bits I need to cut one trace and make one bridge. Using serial resistors, relays optocouplers it's near impossible to use existing PCB.So is it possible to get required range from 12 bits?

author: Zero999
author_rank: Super Contributor
timestamp: October 09, 2022, 06:02:54 pm
content: Quote from: eslavko on October 09, 2022, 06:05:39 amThose relays are not bulky. They're tiny compared to the size of resistors required to dissipated the required power.You should have stated the speed in first place. It's possible to get faster isolated gate drivers, but it's going to be very difficult to make something that fast, because the resistors form a RC time constants with the parasitic capacitances of the MOSFETs.

author: Nominal Animal
author_rank: Super Contributor
timestamp: October 09, 2022, 07:19:36 pm
content: Quote from: eslavko on October 09, 2022, 06:05:39 amThe math says, when using selectable resistors in parallel, "all resistances in the upper half of your resistance range must be provided by individual resistors".If the maximum resistance is 3000 Ohms, and you use 12 resistors linearly/evenly distributed between 1500 and 3000, your resolution at the upper end is 1500/(12-1) ≃ 136 Ohms. The minimum resistance is then 179 Ohms, with 190 to 642 Ohms covered with better than 1 Ohm resolution.If the maximum resistance is 4500 Ohms, and you use 10 resistors linearly/evenly distributed between 2250 and 4500, your resolution at the upper end is 2250/(10-1) = 250 Ohms. The minimum resistance is then 322 Ohms, with the dense coverage from 346 Ohms to 1000 Ohms or so.To cover the bottom end of your range, you'd need additional resistors, which just increases the step size at the upper half of the range.In real life, we do not usually need a linear distribution of resistors, but an 1/N distribution (because for example I=U/R). To see what kind of set of parallel resistances you can make, I suggest you start with the highest resistance you need, then the next highest, and so on. The following simple Python program will tell you all the possible parallel combinations, in sorted order:Code:#!/usr/bin/python3# -*- coding: utf-8 -*-# SPDX-License-Identifier: CC0-1.0if __name__ == '__main__':from sys import stdout, stderr, argvif len(argv) < 3:stderr.write('\n')stderr.write('Usage: %s [ -h | --help ]\n' % argv)stderr.write(' %s RESISTANCES...\n' % argv)stderr.write('\n')exit(0)R = [ float(argv) for k in range(1, len(argv)) ]N = len(R)R.sort()value = []for k in range(1, 2**N):invsum = 0.0for n in range(0, N):if (k & (2**n)) > 0:invsum += 1.0 / Rvalue.append(1.0/invsum)value.sort()stdout.write('Resistors:')for n in range(0, N):stdout.write(' %.6f' % R)stdout.write('\nPossible parallel resistances:\n')for k in range(0, 2**N - 1):stdout.write("%.9f\n" % value)Runningpython3 parallel.py 4500 4200 3950 3750 3600tells you that they can be combined to the following parallel combinations:Code:794.959030140965.526606786980.554406289995.2606635071008.8172696871020.2533721451253.7471345441277.8904665311300.3265839321304.3478260871319.3892158421327.7310924371347.6118271421354.8387096771375.5458515281401.5770205581836.7346938781883.4437086091923.7012987011938.4615384621981.1320754722000.0000000002035.5828220862045.4545454552103.5502958582172.4137931033600.0000000003750.0000000003950.0000000004200.0000000004500.000000000Notice the huge gap between 2172 and 3600? That is because as the math says, "all resistances in the upper half of your resistance range must be provided by individual resistors". Since I didn't have any between 2250 and 3600, there's a huge gap in there.

author: eslavko
author_rank: Contributor
timestamp: October 10, 2022, 08:30:03 am
content: Quote from: Nominal Animal on October 09, 2022, 07:19:36 pmI already do near same python script using plot to show result.When I playing with numbers I got interesting results.Based on your writing the best I can get is with linear distribution betwen 1 and 0.5.I do it like that:Code:res=[]stp=1500/12for i in range(12):res.append(stp*i+1500)The result is 8% difference from 174.968535 to 2875.000000, with 12 bitsWith binary weightrd resistors (each one is double the size of previous) like:Code:res=for i in range(11):res.append(res[-1]*2)I got 0.93% difference from 75.018315 to 2982.524272, with 12 bits.If I didn't make some mistake then seems that binary values will be better.(I did mistake in 1st version of my script and based of bad result that thread is started at all)

author: Nominal Animal
author_rank: Super Contributor
timestamp: October 10, 2022, 09:44:46 pm
content: Like I said, the distribution of resistances in the upper half of your resistance range is the key, when the selectable resistances are in parallel.If you want a 1/N distribution of resistances, then power of two sequence is likely optimal (each resistance double the previous one).If you want a linear distribution of resistances, then linear sequence is optimal.In my own circuits –– I'm a hobbyist who interfaces all kinds of sensor and display circuits to microcontrollers and single board computers –– I tend to need either precision resistors under 100 Ω (and current shunt resistors under 1 Ω), or larger resistors picked from one of theE series of preferred numbers. So even a bumblefuck hobbyist like myself has quite different needs for resistors.You seem to be undecided on what kind of distribution of resistances your switchable box needs; only that 50 Ω to 3000 Ω or maybe 4500 Ω would be useful.Yet, it is exactly the resistance distribution you desire, especially in the upper half of the resistance range (so 1500 Ω to 3000 Ω, or 2250 Ω to 4500 Ω), that is the determining factor here.Logarithmic resistance ranges are a bit more complicated than either 1/N or linear, as discussed above. Considering the 50 Ω to 4500 Ω range:For example, in the E6 series, the desired resistances would be 47, 68, 100, 150, 220, 330, 470, 680, 1000, 1500, 2200, 3300, 4700.From the E6, only the three highest ones (2200, 3300, 4700) are needed for the upper half of the resistance range.In the E12 series, the desired resistances would be 47, 56, 68, 82, 100, 120, 150, 180, 220, 270, 330, 390, 470, 560, 680, 820, 1000, 1200, 1500, 1800, 2200, 2700, 3300, 3900, 4700.Only the four or five highest ones (, 2700, 3300, 3900, 4700) are needed for the upper half of the resistance range –– without 2200, the closest value is 2131.4=2200-3.12%.In the E24 series, the resistances would be 47, 51, 56, 62, 68, 75, 82, 91, 100, 110, 120, 130, 150, 160, 180, 200, 220, 240, 270, 300, 330, 360, 390, 430, 470, 510, 560, 620, 680, 750, 820, 910, 1000, 1100, 1200, 1300, 1500, 1600, 1800, 2000, 2200, 2400, 2700, 3000, 3300, 3600, 3900, 4300, 4700.Only the eight or nine highest ones (, 2400, 2700, 3000, 3300, 3600, 3900, 4300, 4700) are needed for the upper half of the resistance range. Again, without 2200, the closest values the higher ones combine to are 2200+2.1% and 2200-3.12%.I am not aware of any formula that directly generates the lower range resistances that (along with the fixed upper range resistors) yields the desired values, but a brute-force search ought to find good candidates that can be analysed to minimise relative error in the resistances.

author: eslavko
author_rank: Contributor
timestamp: October 11, 2022, 08:21:13 am
content: Quote from: Nominal Animal on October 10, 2022, 09:44:46 pmAs I write it's not adjustable resistor box but testing/callibrating device. Until now some parameters are adjusted automatically and other manual, and I wish to make all adjustment automated. For that I need specific resistor ranges (and there can be some gaps present). Now with working "python calculator" I can see results quick and can do some changes in resistor sets to get desired results using like brute force approach. At least in this thread I learned that in high range whatever I do the step will be coarser.Thanks for support and all ideas.