# Analog Circuit Design Problem -Window Comparator?

#### Mehmet Serdar Çelik

Joined May 28, 2016
8
Hello. I want to desgin an analog circuit. It has two threashold as positive and negative..Yeah it looks like a comparator..It's basic..If the signal is over positive threshold is output is 9V..or if the signal is under the negative threshold the output is again 9v..If the signal is between positive and negative threshold, the output is zero. I tried the illustrate this issue at the attached figures.

Firstly i tried to rectify the signal and than comparate it with opamps...Because i could not do this with two threshold..It worked but my output is not like square wave exactly..What is your suggestions? Thanks in advance.

#### Mehmet Serdar Çelik

Joined May 28, 2016
8
Thanks for answer. But window comparator behaves like that right?

My signal has positive and negative components, not only positive..And even under negative threshold i want the output is 9 volt..Can i explain the problem well?

#### Marley

Joined Apr 4, 2016
416
What threshold voltages do you want?
I assume the supply voltage is 9V (0 to +9V).

This can be done with the window comparator but you will need a resistor network on the input to change your positive and negative inputs to smaller, but both positive voltages.

#### Mehmet Serdar Çelik

Joined May 28, 2016
8
I illustrated an input and output diagram above..My input voltage changes in milivolts..Max value of it +10mV and -10mV..We can say my positive threshold is +2 mV and my negative threshold is -2mV...If the input signal is 2.1 mV my output must be +9V and if my input is -2.1mV, my output must be +9V too..For this value my diagram is like below..

#### ifixit

Joined Nov 20, 2008
652
It sounds like you just need to invert the window detector output.

You will need accurate comparators for your circuit.

What is the signals maximum frequency, or rate of change?

#### Mehmet Serdar Çelik

Joined May 28, 2016
8
My max frequency is about 500 hertz ,not more..Which accurate comparator do you suggest? Is negative threshold poosible on these comparators?

#### Marley

Joined Apr 4, 2016
416
OK. One way to do this will be to start with two resistors in series from 0V to the 9V supply. If both these resistors are the same value, the voltage where they join will be half the supply voltage. In this case 4,5V.

For example make both these resistors 200k. Thevenin's theorem says that this is equivalent to a single 100k resistor connected to a voltage of 4,5V.
If you now connect a 100k resistor from your signal source to the junction of the two 200k resistors, you will create a potential divider 1/2.

With an input of +2mV, the voltage at the junction will be (4.5V/2) + 1mV.
With an input of -2mV, the voltage at the junction will be (4,5V/2) - 1mV.
You can now use the window comparator as drawn above.

I hope you understand what I am doing here - I have not got anyway of making a diagram right now!
The problem is that it will be difficult to reliability measure voltages as small as this. The offset voltage of the comparators and circuit noise will be a problem. Also there will be a current coming "out" of the input. Your voltage source must be low impedance and able to cope with this current.

There are better ways to do this. I just wanted to give you an example. Hope this helps.

#### Marley

Joined Apr 4, 2016
416
Of course as I was writing my last post the problems became apparent. It will be better to amplify your signal before using the comparator.

What is your application? Does the application use a micro-controller? Could you use and ADC?

#### ifixit

Joined Nov 20, 2008
652
Have a look at the LM311. You may need to use the input offset adjust feature. The output can be referenced to ground.

Is this a one-of circuit?

#### Mehmet Serdar Çelik

Joined May 28, 2016
8
Emg signal is my application..I have an INA118 that has a big CMRR..I use it to reject the common mode signals and than amplify the signal..You know it the surface emg is max 0-10mV (peak to peak)...You know also the signal has positive and negative component..I only use analog design..After INA118 i amplify the signal and use an comparator..If the signal is bigger than positive threshold or smaller than negative threshold the output is positive (or 9v or 5v , its not important..) otherwise the ouput is zero..

#### Mehmet Serdar Çelik

Joined May 28, 2016
8
Any suggestion?

#### hp1729

Joined Nov 23, 2015
2,304
Have a look at the LM311. You may need to use the input offset adjust feature. The output can be referenced to ground.

Is this a one-of circuit?
Re: LM311
Or dual version, LM319.

#### ifixit

Joined Nov 20, 2008
652
The LM319 should work if offset nulling is not required. The following quick circuit may need tweaks to improve noise immunity.

#### Mehmet Serdar Çelik

Joined May 28, 2016
8
The LM319 should work if offset nulling is not required. The following quick circuit may need tweaks to improve noise immunity.

View attachment 106940

Thanks! Your circuit looks great but it doesn't work on Multisim..Do i make any mistake? The circuit is below.

#### blocco a spirale

Joined Jun 18, 2008
1,546
Q1 has no VCC connection.

#### ifixit

Joined Nov 20, 2008
652
I think you need to set V3 to 7mV RMS (0.007V to get 10mV peak and VCC to emitter of Q1.

This circuit has a few improvements. Each of the divider strings should have a ground reference. You can use an adjustment pot in the dividers to fine tune the slicing point and compensate for comparator offset error. You therefore could use the LM319 dual instead.

Good Luck.

#### Mehmet Serdar Çelik

Joined May 28, 2016
8
Thank you very much! I learn lot of things from you!

#### Tonyr1084

Joined Sep 24, 2015
6,263
May be out of my league, but I think I'd approach this with two comparators, one for the high threshold and one for the low threshold. Add to that a 2 input NAND gate. When both comparators are triggered (or not triggered) the NAND gate will invert the output. When either or both comparators are not triggered (or triggered) the NAND gate will hold a low (or high) output.

I once used a comparator with a floating reference. The reference was held by the same input the inverting input was held to, only, it was held through a large RC circuit. When both voltages floated around the same level the comparator remained silent. But when the non-inverting input suddenly rose (or fell) (due to light level changes) the comparator would drive an alarm alerting me to the presence of a light source or a shadow. In other words it was a motion detector with a photo-transistor. When the light level changed in the area, if the change was significant enough, it would trigger the alarm alerting me that something had changed (moved). Maybe a car drove into the field of view - maybe a person or a large enough animal (dog). With slow and subtle changes the two inputs remained balanced and no alarm would trigger. It was only when there was a fast rise or fall in the overall light level that the alarm would sound.

I think in simple terms. Your project, if you want 9V out when your sense is outside the window then two comparators and a NAND gate should do the trick. I think.

#### Tonyr1084

Joined Sep 24, 2015
6,263
Did you come up with a solution? If so, how does it compare to mine?

When Vin is <A2 ref, A2 Q2 (Q = outputs) is held to logic 0 (or "Low"). A1 Q1 is held logic 1 (or "High"). A3a input "a" = 1, b = 0, and Q3 (A3a output) = 1. Inputs c & d (A3b) are at 1 and A3b Q4 = 0.

When Vin is >A2 ref & <A1 ref A1 Q1 & A2 Q2 both = 1. A3a a & b both = 1 and Q3 = 0. Q4 = 1.

When Vin is >A1 ref Q1 = 0, Q2 = 1, Q3 = 1, Q4 = 0.

When you are in your window Q4 = 1. Whenever you're outside your window (high or low) Q4 = 0.

OH, and you don't need a dual power supply. And the inputs to A3c & A3d (unused NAND gates) should be held low (or high); they should not be allowed to float.

Last edited: