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?

  • \$\begingroup\$ 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. \$\endgroup\$ – SupAl Jul 4 '17 at 11:27
  • \$\begingroup\$ 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. \$\endgroup\$ – Transistor Jul 4 '17 at 12:50
  • \$\begingroup\$ (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. \$\endgroup\$ – SupAl Jul 5 '17 at 13:47
  • \$\begingroup\$ (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? \$\endgroup\$ – SupAl Jul 5 '17 at 13:47
  • \$\begingroup\$ I should add, that what i meant by LSB in my first comment is \$R_{LSB}\$ \$\endgroup\$ – SupAl Jul 5 '17 at 13:51

Does anybody have an idea of how this could be implemented, without looping through all the possible values?

It's called successive approximation and is used quite effectively in determining the digital value of an analogue signal. So, with 4 resistors you would make 4 decisions in order to decide which of the 15 values above zero was most appropriate: -

enter image description here

To make this work like an ADC, feed the unknown resistor with a constant current and do the same for the controllable resistance. Then feed both signals to a comparator that "makes the decision".

Alternatively, buy a cheap ADC and throw away your transistor and resistor network in favour of a much more stable R-2R network and inbuilt algorithm.

| improve this answer | |
  • \$\begingroup\$ This is a nice solution. Actually i wanted to implement it in a uController, but this idea translates well. Thanks! Btw, the reason for not using a DAC is that the transistors/resistors are chosen to be able to handle quite large powers, which is not something ADCs are capable of, to the best of my knowledge. \$\endgroup\$ – SupAl Jul 4 '17 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.