# replace buttons in voltage-divider with mosfets

I have this voltage divider (each press of a button generates a different voltage) I want to be able to enable the buttons with a +5V signal. I tried to replace the buttons with 2N7000 n-channel mosfets, but somehow I don't get the right voltage at "buttons". How should the mosfets be attached? Would it even work?

• Are you using a microcontroller to drive the circuit? A DAC (digital to analog converter) might be the easiest way if so. Sep 26 '13 at 11:18
• Were all the readings incorrect? How did you try to wire the transistors? Sep 26 '13 at 11:23
• @PeterJ: No, the data lines come out of a demultiplexer Sep 26 '13 at 11:57
• @Vasiliy: I've gotten strange readings everywhere. The drain was connected to the resitor side, the source to the other side and the gate was connected to the 5V signal Sep 26 '13 at 11:59
• You could replace the demultiplexer and all eight switches with a single fifty-cent cd4051. Sep 26 '13 at 17:24

I assume that "Buttons" is your output voltage.

The problem is that the 2N7000 needs a finite gate to source voltage (= Vgs) to turn it on hard in order for it to present a low resistance path. This voltage varies by device but is about 3V minimum for reliable operation.

If the The MOSFET gate is driven with +5V, the MOSFETs will "see" a Vgs of about 5V-Vd (as Vs ~= Vd when the MOSFET is on. As you progress up the divider chain Vd rises and (5-Vd) falls to a point where the MOSFET is not turning on fully.

Solutions

• Drive the gates with >= Vd_max + 3V ~+ 8V.
If your multiplexer is unable to provide 8V this will not work.

• Use very low Vgsth MOSFETs.
As the max Vd is almost 5V you would need VERY low Vgsth MOSFETS. Not really practical.

• Limit Vdmax to about 2V so that you always have 3V of gate drive above Vd (and Vs).
This is an easy solution and probably the most attractive one.

Solution 3 reduces the button voltage range from ~= 0-5V to ~= 0-2V.
If you have an ADC with 5V max range you are only using 2/5 = 40% of its range. Even at 8 bits with say 8 levels this gives you 2V/8 = 0.25V steps or 0.25V/5V = 1/20th of the ADC range per step. For an ADC with 8 bits and 256 levels that's 256/20 =~ 12 ADC steps / levels per button. Or you can consider the 1/20th of full scale per step to be 1/20 = 5% steps.

To identify buttons correctly you must not vary by > 2.5% per step.
1% resistors are probably good enough for this albeit a bit marginally so if you got values at either end of the error range. As you are using all 1K resistors they (probably) all come from the same source so probably will not have a +/- 1% change between values.

Implementation check:

Are the gate drive lines hard low when not driving, or do they float?
You may have to add gate resistors to clamp the gates low/off/to ground when not being driven on.

• The output voltage goes to an analog pin on an arduino.As I have understood, your 3rd solution would require that I lower the voltage on the gate to around 2V, and then adjust the range in the microcontroller to account for only using the lower range (<2V) ? Sep 26 '13 at 13:26
• @user29675 - I said lower the voltage of Vdmax, NOT the gate drive voltage. Drive the gates at 5V as before so Vgate > Vs_max by about 3V. | Call Sum(R23 ... R29) = Rsum. | If you make R22 = 12k then the R22-R23 junction voltage will be Rsum/(Rsum+12K) x 5V = 7/19 x 5 = 1.85V. Adjust R22 to make the max voltage some convenient value that is low enough to still give about 3V Vgs drive. The advantage of this method compared to most others is simplicity and ease of change - you need only to change a single resistor to make it work. Sep 28 '13 at 8:58

I'm assuming you can't change the nature of the BUTTONS signal -- that it has to take one of nine values between 0V and 5V, equally spaced, where 5V represents "no buttons pressed".

Approach #1:

Instead of replacing the buttons with transistors, you should just use three control signals feeding a simple R-2R network to generate the BUTTONS voltage directly.

Actually, you'll still need one transistor to open up the ground end of the R-2R network when you want to simulate "no button pressed".

Approach #2:

Instead of using discrete transistors, use CMOS "transmission gates", such as CD4016 or CD4066, to replace (or in parallel with) the switches.

Approach #3:

Just for completeness, there's an approach that allows the sources of the MOSFETs to be tied to ground so that they can be switched by your logic signals. It requires adjusting the values of the voltage divider, though. simulate this circuit – Schematic created using CircuitLab

Note that the leftmost MOSFET in this diagram corresponds to the rightmost switch in your diagram, and vice-versa.

• I think that's not really an option, as I have to work with 8 logic lines. Sep 26 '13 at 11:57
• I think Approach #2 would be the easiest option :) Sep 26 '13 at 14:07