In an earlier video I showed you how to configure an operational amplifier as a non inverting amplifier.
But there are many many more things you can do with an operational amplifier.
Today I am going to show you the op-amp comparator and a fun demo circuit too.
(hello!)
So let's say you've got an LM324 quad op-amp that you bought from
Radio Shack, Jameco, the Cuban black-market, whatever.
And let's power it with a nine volt battery.
And let's say you've got two different voltages on the inverting and non inverting terminals
of the operational amplifier.
Let's label them V+ and V-.
If V+ is greater than V-, the output of the op-amp will jump up to the positive
rail of the op-amp's power supply.
In this case, that's nine volts. Actually because op-amps are not perfect
it will be slightly less than that, but nine volts is close enough.
If V+ is less than V-, the output of the op-amp will go down to the negative
rail of the op-amp's power supply. In this case that's just zero volts at ground.
And that's basically how a comparator circuit works.
So let's do some numeric examples.
In this situation, five volts is greater than three volts, so the output of the
operational amplifier goes high to nine volts.
Swapping those around,
now the V- voltage is greater than the V+ voltage
so the op-amp outputs zero volts.
Now it's important to realize that comparators are extremely sensitive to voltage differences.
Let's say V- is a very precise 2.500 volts.
If V+ is 2.51 volts the output will go high.
If V+ is 2.49 volts the output will go low.
Alright I think you get the idea so let's build a comparator in hardware and get it
to do something.
Let's power this circuit with a regulated five volts so that all of the voltages are
guaranteed to be stable over time.
On the inverting terminal of the op-amp I'm going to put a voltage divider that will give
me a reference voltage of 0.45 volts.
On the non-inverting terminal of the op-amp I'm going to connect the output of a potentiometer.
The value of the potentiometer doesn't matter - I am just using it as an adjustable voltage divider
so I can vary V+ from zero volts to five volts
and see how the comparator reacts.
And on the output of the operational amplifier let's put a resistor and an LED.
As I vary the voltage at V+ it goes higher and lower than 0.45 volts.
This toggles the comparator's output high and low
which turns the LED on and off.
On the oscilloscope the yellow line is the constant 0.45 volt reference
and the red line is the voltage that I am creating with my potentiometer.
When the potentiometer voltage is greater than the reference voltage, the LED turns
on, and vice versa.
Now there's no reason why you're limited to using a potentiometer
as a voltage source here.
You could use an audio signal, or voltage from a photovoltaic cell
or maybe the voltage from your car's RPM meter. Whatever you want.
And of course you can make V- whatever voltage you want too,
to function as the comparator's tripping point.
And on the output of the op-amp you don't just have to power an LED.
You could put a transistor there and use it to switch motors on and off. Or switch
a relay or whatever you want.
Now let's move on to something a little more interesting. Let's make a clap sensitive circuit.
Here's the circuit diagram. The first part should look familiar.
It's a microphone being powered up, then the signal goes through a high pass filter
to remove the five volt DC offset.
Then it's going to an op-amp configured as a non inverting amplifier with a gain of
a hundred and one.
So this will give us a nice amplified audio signal
By the way I should mention that I am only amplifying the top half of the audio signal here
because I don't really care about retaining audio quality
I only care how loud it is.
Okay so I take that amplified signal and connect it to the comparator on the right.
When the amplified sound crosses the 0.45 volt threshold
the comparator will go high and it will turn the LED on.
Here's what that looks like on the oscilloscope.
And of course there's nothing stopping you from changing the volume threshold.
If you add a potentiometer at V- you can adjust the threshold voltage to make the
circuit more or less sensitive to sound. Now the only problem with this circuit is that
it only keeps the output high while the volume is loud.
(hello!) (hello!)
As soon as it is quiet it turns off.
Now I can fix that by adding another circuit called a peak detector
and check out this next video to see how that works.