Design a Voltage Divider

for MAX666 programmable voltage regulator

Zhe Hu
huzhe@iit.edu
November 2005

A simple voltage divider can be composed of two resistors in series. In the example above, the "6 V" measured by the VoltMeter can be calculated as 12 ×(R2/(R1 + 
              R2)) . It's not true that you can get whatever fraction of the battery voltage simply by varying the value of these two resistors. Firstly it's because resistors in real world comes in a bunch of "preferred" values, i.e. you can't find a fixed resistor, say, 11.21  kΩ , not to mention that the resistors in your electronic cabinet gives you even less choices. Secondly it has something to do with what "load" you hook up to the "6V" output. Since the "load" will diverge some of the current, it will lower the voltage, which can also be calculated by Thevenin equivalent circuit.

To address the "fixed" resistor issue, we can certainly use a potentiometer (or "pot" for short). But there are still some preferred "design rules" to use the pot for the voltage divider.

This notebook defines some Mathematica functions that are useful for designing a voltage divider in the MAX666 voltage regulator circuit.

Pick a Standard Resistor

Due to the error tolerance in manufacturing real world resistors, the values of resistor come only in the geometric sequence, defined as (http://en.wikipedia.org/wiki/Preferred_values)

g[b_] := (10^(Range[0, b - 1]/b)) // N

So the standard (IEC 60063) {E6, E12, E24, E48, E96, E192} series resistors have values of (10^k)× {g[6],  g[12],  g[24],  g[48],  
          g[96],  g[192]}. To calculate resistor values from 10 to 100 decade,

10  g[6] // Round

which is actually a little bit different from the E6 standard. So it's a good idea to see what's the real value of resistors in your cabinet and correct the table. The real E6 standard gives the following resistor values:

E6 = {10,  15,  22,  33,  47,  68};

As in my cabinet , I have a collection of E24 (5% tolerance) resistors. The calculated values are

10  g[24] // Round

which differ somewhat from the real ones.

E24 = {10, 11, 12, 13, 15, 16, 18, 20, 22, 24, 27, 30, 33, 36, 39, 43, 
        47, 51, 56, 62, 68, 75, 82, 91}

You may want to define your own list of resistor values depending on the ones in your cabinet. To pick a resistor from this list that has the closest value to the resistor value you want, here is the Mathematica function

closest[x_, y_List] := 
        Extract[y, Position[Abs[x - y], Min[Abs[x - y]]]] // 
          First;

This next function assumes that you also have resistors the value (10^k)of the ones in your list.

findclosest[x_, y_List] := 
      Module[{tempx = 10^Floor[Log[10, x]], tempy = 10^Floor[Log[10, y]]}, 
        tempx closest[x/tempx, y/tempy]]

So if you need a resistor, say 16.6 kΩ, the function returns a 16 kΩ resistor, which is still an E24 standard resistor.

findclosest[16.6*^3, E24]

If you are lucky to have a collection of E96 (more expensive) standard resistors, it could be a closer match.

findclosest[16.6*^3, E96]

Design a Voltage Divider Using the Potentiometer

To design a voltage divider that gives nearly any fraction of the input voltage, one can use a potentiometer. There are some design rules, which I observe, while designing a voltage divider. 
Thumb of Rule 1. It is better to put two fixed value resistor in series with it;
Thumb of Rule 2. It is better to set the potentiometer (wiper) at 50% for the desired voltage output.

To code these rules into equations:

Rupper == R1 + Rv1;    
Rdown == 
      R2 + Rv2;
Rpot == Rv1 + Rv2;
(Rdown/(Rupper + Rdown)) == 
        (Vout/Vin);
Rv1 == Rv2;    
Rv2 == 
      k*R2;

The equation (Subscript[Rv, 1]) == (Subscript[Rv, 2]) constrains that the wiper of the pot is in the middle. And the last equation incorporates a k-value, which obviously is the ratio of the varying resistor to the fixed value resistor.

Now we come to the main part, i.e., to design the voltage divider for MAX666 programmable voltage regulator. You can easily find MAX666's datasheet from http://www.maxim-ic.com/

There are obviously  two voltage dividers in the circuit above. The one with R1, R2 and a potentiometer controls the regulator output voltage. According to MAX666's datasheet, the output voltage "Vout" can be "programmed" by adjusting the voltage divider such that "Vout", after being divided, appears to be 1.3V on pin 6 (VSET) of the regulator.

It is a "reverse" use of a voltage divider in terms of Vin and Vout as shown before. We can define the following Mathematica function to help us design the voltage divider.

voltageDivider[ vWanted_, vFixed_, Rpot_ , k_:  5, 
        rvalues_List:  E24] := 
      Module[{Vout, Vin, R1, R2, Rv1, Rv2, Rupper, Rdown, eqn1, eqn2, eqn3, 
          temp1, temp2}, 
eqn1 = {Rpot == Rv1 + Rv2, 
            (Rdown/(Rupper + Rdown)) == 
                (Vout/Vin) /. {Rupper ->  R1 + Rv1, 
                Rdown ->  
                  R2 + Rv2}}; 
eqn2 = {Rv1 == 
              Rv2}; 
eqn3 = {Rv2 == 
              k*R2}; 
  
temp1 = 
          FindInstance[{(eqn1 /. {Vout -> vFixed, 
                      Vin -> vWanted}), eqn2, 
                eqn3, {Rv1 > 0, Rv2 > 0, R1 > 0, R2 > 0}} // Flatten, {R1, 
              R2, Rv1, Rv2}]; 
If[temp1 == {}, 
          Print["Can't find appropriate R1, R2. Set them to zero."]; 
          temp1 = {R1 -> 0, R2 -> 0}, 
          temp1 = findclosest[#, rvalues] & /@ 
                Flatten[{R1, R2} /. temp1] // 
              Thread[Rule[{R1, R2}, #]] &]; 
  
temp2 = 
          FindInstance[{(eqn1 /. {Vout -> vFixed, 
                        Vin -> vWanted} /. temp1), {Rv1 > 0, 
                  Rv2 > 0}} // Flatten, {Rv1, Rv2}]; 
If[
          temp2 == {}, 
          Print["Can't find appropriate potentiometer ratios."]; 
          Return[{Plot[
                Vin /. Solve[eqn1 /. 
                        temp1 /. {Vout -> vFixed}, {Vin}], {Rv2, 0, 
                  Rpot}], {R1, R2} /. temp1, 
              vWanted/((Rpot + R1 + R2) /. temp1)}], 
          Return[{DisplayTogether[
                Plot[Vin /. 
                    Solve[eqn1 /. 
                          temp1 /. {Vout -> vFixed}, {Vin}], {Rv2, 0, 
                    Rpot}], 
                Graphics[{PointSize[0.02], 
                    Point[{Rv2 /. Flatten[temp2], vWanted}]}]], {R1, R2} /. 
                temp1, (Rv1/Rpot) /. temp2, 
              vWanted/((Rpot + R1 + R2) /. 
                    temp1)}]]
]

To power an ASIC chip (for neural stimulation) in the lab, I need 4.5 V derived from a 9 V battery. So 4.5 V is the voltage I wanted from pin 2 of MAX666. The fixed voltage 1.3 V on pin 6 is defined by MAX666, which comes from our voltage divider. I used a 1M potentiometer whose value is the third parameter passing to the function. The default k-value is 5 and the default resistor standard is E24. If you have better resistors like E96 (1% tolerance), you need to call the function as voltageDivider[4.5, 1.3, 10^6, 5, E96].

voltageDivider[4.5, 1.3, 10^6]

Now Mathematica has designed for us the fixed resistor values: (Subscript[R, 1]) = 910 kΩ,  
      (Subscript[R, 2])  =  100 kΩ, and the potentiometer ratio is nearly in the middle (52%). Also the last item is the total current cushioned by the voltage divider: about 2.2 μA. Since pin 6 is only going to draw current on the order of 10 nA, which is less than 1% of 2.2 μA. The Thumb of Rule 3: if the load draws less than 5% of the total current, the voltage divider will probably work fine.

Play Around with the Design Function

We can vary the k-value to see how the dynamic range for adjusting the output voltage changes.

DisplayTogether[voltageDivider[4.5, 1.3, 10^6, 
          1][[1]], voltageDivider[4.5, 1.3, 10^6, 
          10][[1]], voltageDivider[4.5, 1.3, 10^6, 
          100][[1]]]

One thing to remember, though, MAX666 is a voltage regulator, not an electric generator. So it is not true that you can turn the potentiometer and get 80 V output. Because to get that you need to put in at least 80 V to the regulator, which far exceeds its limit. So as stated in the datasheet, MAX666 has adjustable voltage output range between 1.3V and 16V.

Now let's go back to look at the MAX666 schematic again. There is the other voltage divider by R3, R4. It is for low battery power indicator. Still the fixed voltage on pin 3 of MAX666 is 1.3 V. Suppose we want the warning diodes to light up when the battery voltage drops below 5 V. Still we can use that design function, by putting a very small value for the potentiometer, which can then be ignored. But put a small enough k-value to make fixed value resistor larger .

voltageDivider[5.0, 1.3, 1.0, 0.000001]

So the result is that two fixed resistor {1.5 MΩ and 510 kΩ} can't give us exactly 5 V, but 5.12 V. Or you have E96 resistors

voltageDivider[5.0, 1.3, 1.0, 0.000001, E96]

which is very close to 5 V by using 1.43 MΩ and 499 kΩ resistors.

By the way, there is another reason sometimes to avoid using potentiometer in your circuit design. The legend has it that whenever someone open an instrument for repair, the first thing that he/she can't resist doing is to turn the potentiometers on the circuit board, if there is any. So if you are designing some kind of a "product" for people other than yourself in the lab, try to avoid using pot then.

Implementation

E24 = {10, 11, 12, 13, 15, 16, 18, 20, 22, 24, 27, 30, 33, 36, 39, 
          43, 47, 51, 56, 62, 68, 75, 82, 91};

E96 = {100, 102,  105,  107,  110,  113,  115,  118, 121 , 
          124 , 127,  130, 133,  137,  140 , 143, 147,  150,  154 , 
          158 , 162 , 165,  169 , 174, 178,  182,  187,  191 , 196,  
          200,  205,  210, 215,  221,  226,  232,  237 , 243,  249,  
          255, 261 , 267,  274,  280,  287,  294,  301 , 309, 316 , 
          324 , 332,  340 , 348,  357 , 365,  374, 383,  392,  402,  
          412,  422,  432,  442,  453, 464 , 475,  487,  499,  511,  
          523,  536,  549, 562 , 576 , 590,  604 , 619,  634 , 649,  
          665, 681,  698 , 715,  732,  750,  768,  787 , 806, 825 , 
          845,  866,  887 , 909 , 931,  953,  976};

closest[x_, y_List] := 
        Extract[y, Position[Abs[x - y], Min[Abs[x - y]]]] // 
          First;

findclosest[x_, y_List] := 
      Module[{tempx = 10^Floor[Log[10, x]], tempy = 10^Floor[Log[10, y]]}, 
        tempx closest[x/tempx, y/tempy]]

<< Graphics`Graphics`

voltageDivider[ vWanted_, vFixed_, Rpot_ , k_:  5, 
        rvalues_List:  E24] := 
      Module[{Vout, Vin, R1, R2, Rv1, Rv2, Rupper, Rdown, eqn1, eqn2, eqn3, 
          temp1, temp2}, 
eqn1 = {Rpot == Rv1 + Rv2, 
            (Rdown/(Rupper + Rdown)) == 
                (Vout/Vin) /. {Rupper ->  R1 + Rv1, 
                Rdown ->  
                  R2 + Rv2}}; 
eqn2 = {Rv1 == 
              Rv2}; 
eqn3 = {Rv2 == 
              k*R2}; 
  
temp1 = 
          FindInstance[{(eqn1 /. {Vout -> vFixed, 
                      Vin -> vWanted}), eqn2, 
                eqn3, {Rv1 > 0, Rv2 > 0, R1 > 0, R2 > 0}} // Flatten, {R1, 
              R2, Rv1, Rv2}]; 
If[temp1 == {}, 
          Print["Can't find appropriate R1, R2. Set them to zero."]; 
          temp1 = {R1 -> 0, R2 -> 0}, 
          temp1 = findclosest[#, rvalues] & /@ 
                Flatten[{R1, R2} /. temp1] // 
              Thread[Rule[{R1, R2}, #]] &]; 
  
temp2 = 
          FindInstance[{(eqn1 /. {Vout -> vFixed, 
                        Vin -> vWanted} /. temp1), {Rv1 > 0, 
                  Rv2 > 0}} // Flatten, {Rv1, Rv2}]; 
If[
          temp2 == {}, 
          Print["Can't find appropriate potentiometer ratios."]; 
          Return[{Plot[
                Vin /. Solve[eqn1 /. 
                        temp1 /. {Vout -> vFixed}, {Vin}], {Rv2, 0, 
                  Rpot}], {R1, R2} /. temp1, 
              vWanted/((Rpot + R1 + R2) /. temp1)}], 
          Return[{DisplayTogether[
                Plot[Vin /. 
                    Solve[eqn1 /. 
                          temp1 /. {Vout -> vFixed}, {Vin}], {Rv2, 0, 
                    Rpot}], 
                Graphics[{PointSize[0.02], 
                    Point[{Rv2 /. Flatten[temp2], vWanted}]}]], {R1, R2} /. 
                temp1, (Rv1/Rpot) /. temp2, 
              vWanted/((Rpot + R1 + R2) /. 
                    temp1)}]]
]