# Extremely simple OpAmp comparator circuit not working

I decided to make my own ADC and I tried to use the following circuit to do it.

According to my knowledge, when a 5V signal is applied to the mosfet gate and then pulled to ground, the capacitor should discharge and when it discharged to 5V, It should pull the output of OpAmp to V2'S VCC.

Then I can use the capacitor discharge formula to calculate the voltage. But when I tried it, it is not working. The OpAmp is outputting 0V.

simulate this circuit – Schematic created using CircuitLab

I did some troubleshooting and found out the OpAmp wasn't working probably. I separated it from the circuit and tried this circuit:

simulate this circuit

According to my knowledge, the opamp should output 3.7V or near it because it is not a rail-rail opamp, but instead, it is outputting 0V. I have tried using an lm393 instead of lm358, but it is still not working.

So is there anything wrong with my circuit?

Edit: I have the opamp successfully output a voltage but the voltage is extremely low (0.08 v) and it is unusable, I have fixed my circuit to something like this:

simulate this circuit

This circuit works but the opamp outputs very low voltages, so is my circuit right? Or did I destroy it again?

• You should not be putting 10V on a input when VCC is only 5V. Check the datasheet for allowed input voltage ranges. – Unimportant Jan 12 '19 at 13:04
• And on the first circuit you have the non-inverting input tied to the op-amp's V+. Section 6.5 of the datasheet shows you that the maximum input voltage is V+ - 1.5. You have probably latched it up if you haven't destroyed it with the 10 V. – Transistor Jan 12 '19 at 13:09
• Without current limited voltage sources both circuits will destroy the ESD protection diodes in the LM358. NEVER apply voltage above/below the supply lines of an IC unless the datasheet says you can. – Bimpelrekkie Jan 12 '19 at 13:13
• I decided to make my own ADC and I tried to use the following circuit to do it How is this an ADC? You're violating at least 3 ratings of the LM358 and very likely you destroyed as well. A tip for next time: study circuits that others made, figure out how they work, why they are as they are. You're trying to "design" while ignoring the work of others, take it from me: that's a recipe for disaster and a waste of your time. – Bimpelrekkie Jan 12 '19 at 13:17
• Destroying parts goes along with this kind of stuff. If you kill a few cheap parts, you learn to look out for things in the future. How to look up operating conditions, what conditions you should not exceed. Better you do that on an opamp than on something high powered that can hurt you or set your house on fire. – JRE Jan 12 '19 at 15:59

I have the opamp successfully output a voltage but the voltage is extremely low (0.08 v) and it is unusable, I have fixed my circuit to sth (sic) like this:

Figure 1. OP's modified circuit.

Assuming that you forgot to change the component from the default TL081 which is not a rail to rail op-amp your circuit will (not) work as follows:

• Inverting input, V-, is at 1 V.
• Non-inverting input, V+, is at 5 V.
• Since V+ > V- the output should switch high.

If this doesn't work then you have either chosen the wrong op-amp or you have damaged it.

R1 + R2 sum to 200 Ω which will pass $$\ I = \frac {V}{R} = \frac {10}{200} = 50 \ \text {mA} \$$. 10k resistors would be more than adequate to bias an op-amp input.

I recommend that you forget this project for now and build and experiment with basic op-amp amplifiers, inverting and non-inverting, with feedback to control the gain and get them to work while reading and understanding the theory and the fairly simple maths. You can try adjust the input voltages close to the power rails and see when the circuits cease to operate.