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?
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: -
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.