# Help with op-amp circuit

Discussion in 'General Electronics Discussion' started by overture3d, Oct 6, 2012.

1. ### overture3d

22
0
Sep 28, 2012
I am trying to set up a circuit that will take in an input signal, and if the input is above a certain voltage, the circuit will output 5V, and if the input is lower, it will output 0V. I think I have seen this done with an op-amp, but I am not sure how.

2. ### Raven Luni

798
8
Oct 15, 2011
A comparator (thats the name for it). This is the simplest way of using an op amp. To set your threshold voltage, use a resistor divider and feed it to [+] input, then feed your input voltage to the [-] input. You might also want to add a bit of hysteresis depending on your application. You do this by placing a resistor from the output back to the [+] input. I cant remember how you calculate the values - something to do with the parallel combination of your divider.... Anyway this should hopefully be enough for you to follow up on or maybe one of the experts will give a better answer

3. ### BobK

7,682
1,686
Jan 5, 2010
You can use either an op amp or a comparator chip for this. Just make sure that the range of inputs covers the range of voltages you want, and that it can operate at the supply voltage you want (probably 5V) Many comparators are open collector, which means you need a resistor to pull the output up to the level you want for a positive output. This actually allows you to output a different high voltage than the supply voltage. The LM339 is a popular comparator that comes 4 to a package.

Bob

4. ### Merlin3189

250
69
Aug 4, 2011
Just like to add, don't forget to add a little bit of positive feedback if using an op-amp as a comparator.
The standard school textbook circuit, with the signal to the + input and the reference Voltage (usually a potential divider) to the - input, tends to oscillate as the signal passes through the switching level.
If your signal is changing quickly and you don't care about a few spurious off/on/off/on... transitions, then this may not matter. But if you are using the output to feed into other digital circuitry - counters particularly - then a single clean transition is necessary.
A simple high value resistor from the output to the + input is usually enough.