# Discharging capacitor through potentiometer in ADSR circuit

I'm trying to build a circuit for generating ADSR envelopes for use in an ananlog synthesizer, and a part of the circuit acting in a way I can't understand. Here is the part of the circuit that is giving me the problem (not the entire circuit): simulate this circuit – Schematic created using CircuitLab

(If this looks like a strange circuit, remember that this is only the part that is not working, stripped to its most simple form.)

The first op amp is outputting around 7 V DC. The gate voltage of the mosfet is 0 V. My problem is this: as I increase the resistance of R3, the voltage across C1 increases (it very quickly approaches 7 V as R3 is increased to some tens of kiloohms), and this only occurs if the mosfet is connected (gate voltage at 0). If I remove the mosfet from my breadboard, then R3 does not affect the voltage over C1, it simply remains discharged as I want it to.

I really have no idea why this is happening. Is there something I don't know?

Your MOSFET actually looks like this: simulate this circuit – Schematic created using CircuitLab

Every MOSFET has an internal diode so called body diode. It is a result of how the MOSFET is constructed. (the 3 bars in the symbol represent the sandwich of 3 differently doped silicon layers. n-p-n. Of which 2 are connected. The unconnected p-n pair results in this diode)

Since you have $7V$ comming from OA1, there will be a current through D2, R2, M1 and finally R3. This current will charge C1.

If the rest of your circuit allows it you could reverse M1. Then the body diode will not allow current to flow that way. Only if you make the M1 low impedance (switching it on) will current be allowed to flow that way.

• Oh right, thanks! I know about those, but I never thought about it. The function of M1 was supposed to be a switch that passes or blocks currents in both directions, through either D1 or D2. So in one state, current can flow through either D1 or D2, and in the other state current should flow in neither direction. Any tips? Jun 1, 2016 at 20:49
• ... use a JFET instead? Jun 1, 2016 at 23:22
• An analog switch maybe? Like TS5A3166 Jun 1, 2016 at 23:37
• @Warloxx: That's a massive MOSFET or MMOSFET. Tip: place a short wire or a text character off to the right of your diagram to force CircuitLabs to scale it to fit in the 640 pixel wide (I think) column on EE.SE. Jun 2, 2016 at 22:14
• +1 -- ALWAYS draw your MOSFETs with that diode (when applicable, which is almost always with discrete packaged devices)! IMO it's poor form for libraries of symbols to not include it in their symbols. Jun 2, 2016 at 22:25