switching window comparator logic

Thread Starter

clark.donaldson

Joined Aug 19, 2019
24
hi there-
i'm learning about electronics and working with an LM319. i'm using a standard window comparator circuit (http://datasheetcafe.databank.netdna-cdn.com/wp-content/uploads/2015/09/LM319-Circuit.gif).

instead of getting V+ when the signal is in range, i'd like to get an "off" signal - and I'd like the V+ while the signal is out of range. simply changing the "pull-up" resistor to a "pull-down" resistor doesn't seem to be the solution.

any suggestions?
 

AlbertHall

Joined Jun 4, 2014
8,301
Swap the reference voltage inputs to the comparators. Connect the upper reference to the non-inverting input and the lower reference to the inverting input.

[EDIT] Sorry got that backwards - upper reference to inverting input and lower reference to non-inverting input.
 
Last edited:

Thread Starter

clark.donaldson

Joined Aug 19, 2019
24
is that the only way? i noticed that i was able to get an LED to perform in either direction, by reversing it and changing the reference.

also, i am curious about the small bias offset created by the pull-up resistor. it seems that the output rests at approximately 0.3v rather than 0. is there a standard way of compensating for this?
 

Thread Starter

clark.donaldson

Joined Aug 19, 2019
24
Swap the reference voltage inputs to the comparators. Connect the upper reference to the non-inverting input and the lower reference to the inverting input.

[EDIT] Sorry got that backwards - upper reference to inverting input and lower reference to non-inverting input.
I've now tried this and it doesn't seem to work as hoped.
Is there a chance that the pull-up resistor needs to change in some way also?
 

crutschow

Joined Mar 14, 2008
23,291
simply changing the "pull-up" resistor to a "pull-down" resistor doesn't seem to be the solution.
No it wouldn't.
The output requires a pull-up resistor.
The comparators have an open-collector output transistor that pulls the output to ground.
The outputs tied together thus act as an AND gate for a positive outputs.
This means that when in the "window", the output is high.
If you try to invert the input references, you will end up with the output always being low.

So if you want the output inverted, you can add a logic inverter, common-emitter transistor, or use a spare comparator for that purpose (if you use an LM339).
 
Last edited:

Thread Starter

clark.donaldson

Joined Aug 19, 2019
24
If you try to invert the input references, you will end up with the output always being low.
This is indeed what happens.

To use an extra comparator as an inverter, is it as simple as connecting the non-inverting input to ground and sending the output of the window comparator to the inverting input?
 

crutschow

Joined Mar 14, 2008
23,291
To use an extra comparator as an inverter, is it as simple as connecting the non-inverting input to ground and sending the output of the window comparator to the inverting input?
Close. ;)
Connect the non-inverting input to a reference voltage, such as one of the comparator references.
Otherwise its input trip point would be at 0V and you would need the input signal to go slightly below ground for it to reliably switch.
 

Thread Starter

clark.donaldson

Joined Aug 19, 2019
24
Fantastic. That seems to work great.
One last stupid question (I'm sorry, I'm quite new to this) - if I want two simultaneous outputs (inverted and non-inverted), I'm sure they both need their own pull-up resistors. But would a 1k serial resistor at the output be enough to sufficiently separate the two comparators from each other?
 

crutschow

Joined Mar 14, 2008
23,291
I'm sure they both need their own pull-up resistors. But would a 1k serial resistor at the output be enough to sufficiently separate the two comparators from each other?
The two window comparators can share a single pull-up resistor, as shown in the schematic you referenced in post #1, if that's what you are asking.
Not sure what "serial resistor" you are referring to. :confused:
 
Last edited:

Thread Starter

clark.donaldson

Joined Aug 19, 2019
24
Thanks for the help!

I meant if i have the two comparators, as in post #1, to output the regular voltage - but also a third comparator to output the inverted voltage.

It seems like the way to go is to have the pull-up resistor at the "regular" output, but then use two 1k resistors to send one signal to "out" and the other to the third comparator. This seemingly works fine.

The issue I'm finding now, though, is that I was hoping to use a diode drop to compensate for the offset. It seems that having a diode at the output of a comparator is a mistake, though - nothing seems to pass through it.

Also, I'm curious about how hysteresis might work in this design. Adding a 1M resistor between output and the + input for each comparator, seems to ground the output also.
 

crutschow

Joined Mar 14, 2008
23,291
I'd like to use the signal to discharge a capacitor.
What is charging the capacitor?
A power MOSFET can be added to discharge a capacitor to a very low voltage.
Starting with the original schematic above, I have a 10k resistor for the upper threshold, but none for the two tied-together inputs.
The + inputs need a resistance for the 1 megohm feedback resistor to generate the hysteresis.
The hysteresis voltage is then the output swing times the divider attenuation between the 1 megohm feedback resistor and the input resistor.
 

Thread Starter

clark.donaldson

Joined Aug 19, 2019
24
What is charging the capacitor?
An audio signal....I was also hoping to use an envelope following circuit, potentially to smooth out the comparator output at a certain frequency - so the diode was going to serve several purposes..

The + inputs need a resistance for the 1 megohm feedback resistor to generate the hysteresis.
Thank you, I didn't know it was contingent on an input resistor.
 
Top