Electronic – capacitor mosfet capacimeter

mosfet

I'm trying to make a circuit that charges a capacitor to 63%, a comparator go high, charge another capacitor and turn on a mosfet (2n7002) which discharges the first capacitor.
My problem I connect the mosfet (Q1) to C1 the max voltage is much lower than expected (as if R3 and Q1 forms a voltage divider). I tried testing this circuit on a protoboard.

Here how I expect this circuit to work (Vcc:5v R2:17k ):

1- switch closes; Q1 (acting as a switch open)

2- C1 charges ; comparator (U1) output 0v

3- when C1 is 63% charged U1 outputs 5v

4- when c2 is 63% charged Q1 'closes'

5- C1 discharges; U1 outputs 0v, Q1 'opens'; C2 discharges through D1

6- back to step one

U1's output is supposed to be connected to a micro controller(Pic and arduino).

Best Answer

When you power up this circuit and close the switch, the voltage on the non-inverting input rises high rapidly (caused by R1 and R2) and the op-amp output switches high, turns the MOSFET on and this shunts any current from the capacitor C1 hence C1 can't charge and the circuit won't work.

Assuming you have your inputs on your op-amp mistakingly swapped on the schematic....

This circuit will still have problems and the first is that negative feedback could tend to keep the voltage on C1 at a steady DC value i.e. there is no hysteresis in the circuit that lets it oscillate as you want. Of course it may oscillate but this is not an inherent feature of the design nor is any oscillation going to have defined amplitude limits.

The next problem is your assumptions about how C1 charges. The comparaotr will want to try and switch at 50% of the voltage after the switch and not 63%. The MOSFET will not switch at 63% of what C2 charges to - it will tend to want to switch at a voltage slightly greater than the threshold gate voltage for the MOSFET.

This circuit has problems.

Additional problems - the LM358 input bias currents will produce an offset voltage on C1 of up to about 0.1 volt so I would advise not using this type of op-amp in this application. Drain leakage current on the 2N7002 is about 1 uA so this could create a 1 volt error via the 1 Mohm resistor (R3).