# Parallel resistor algorithm

I have build a circuit that functions as a variable load. It consists of 4 resistors in parallel - let's call them R1,R2,R3,R4 - each with an activation switch (implemeted with a transistor). R1 has the lowest value, the other resistors have value: Rn = R1*2n-1. I'm currently trying to find an algorithm that calculates the nearest resistance that is above a desired value, Rdes. Does anybody have an idea of how this could be implemented, without looping through all the possible values?

• Okay, i found an even better, very simple, solution. Just take the LSB (highest R value = $R_4 = R_1\cdot{}2^3$) and divide the desired resistance, $R_{des}$ and use the floor function: $floor(\frac{LSB}{R_{des}}$) and you have the desired bit pattern that should be switched on. – SupAl Jul 4 '17 at 11:27
• Can you explain a bit further? (1) If the resistors are in parallel you'll get an inverse decay curve. If they're in series you will get a linear rising resistance with your binary pattern. Are you sure you want parallel? (2) The floor() function can't return any values less than 1 so that rules out any combination involving the '1' resistor. – Transistor Jul 4 '17 at 12:50
• (1) part of the reason for choosing parallel, is to be able to handle a larger load. Each (power) resistor takes part of the current (in series they'd all have to take the full current). Furthermore, in my case, linearity is not so important. – SupAl Jul 5 '17 at 13:47
• (2) you should note that with the solution suggested in my comment, the resistance will always guarantee a resistance $\geq$ the desired resistance. Also, note that what floor function returns in this case is the bit pattern of the activated resistor values. So if i want the highest resistance, i.e., the value of the LSB, i would plug in $R_{des}=R_{LSB}$ and get $floor(\frac{R_{LSB}}{R_{LSB}})=1$, that is, in the case of 4 resistors, the value of $R_4$. Does that it make sense? – SupAl Jul 5 '17 at 13:47
• I should add, that what i meant by LSB in my first comment is $R_{LSB}$ – SupAl Jul 5 '17 at 13:51 