problem with comparator circuit

Discussion in 'General Electronics Chat' started by minkey01, Sep 25, 2016.

Jul 23, 2014
177
0
Hi. This circuit that I did is suppose to be a single supply, non-inverting comparator with some hysteresis. As far as I understand comparators, it is suppose to compare the Vin with the Vref and if the Vin is higher the Vout should output the voltage size of the power, otherwise the output should stay near the ground.

It is not behaving like this. The output is just steadily increasing as Vin increases, kind of like a unity gain buffer.

Any ideas? Do you see any problems?

Thanks!

2. MrChips Moderator

Oct 2, 2009
12,624
3,451
There is too much negative feedback. Try removing R4 from the circuit.

Jul 23, 2014
177
0
Hi, MrChips. Doesn't that R4 set the hysteresis? Is there a formula to figure out a value for this?

I think R1 & R2 is a voltage divider that sets the threshold at .485V.

4. MrChips Moderator

Oct 2, 2009
12,624
3,451
For hysteresis, you want positive feedback.

Jul 23, 2014
177
0
Yes! I just came to that realization too. The original circuit that I was studying was an inverting. Mine is non-inverting.

I have the hysteresis resistors on the wrong input. Should go to the positive feedback like you said.

So just move R3 & R4? Do you know what R5 does?

Thanks Sir Frog Chips!!

Jul 23, 2014
177
0
oh I think R5 is just a pull-up resistor and can stay where it is.

this is the new circuit :

7. MrAl Distinguished Member

Jun 17, 2014
2,552
515
Hello,

The relevant equations are:

VinL=(E5*R2*R6*R7+E2*R2*R6*R7+E2*R1*R6*R7+E5*R2*R4*R7+E5*R2*R3*R7+E2*R2*R3*R7+E2*R1*R3*R7+E5*R2*R4*R6+E5*R2*R3*R6+E2*R2*R3*R6+E2*R1*R3*R6)/((R2+R1)*R4*R7)
VinH=-(E5*(R1*R6*R7-R2*R5*R7-R2*R4*R7+R1*R3*R7-R2*R5*R6-R2*R4*R6+R1*R3*R6))/((R2+R1)*(R5+R4)*R7)
EnL=(E5*R2*R4+E5*R2*R3+E2*R2*R3+E2*R1*R3)/((R2+R1)*R4)
EnH=(E5*(R2*R5+R2*R4-R1*R3))/((R2+R1)*(R5+R4))

VinL is the input voltage trip point when the output of the comparator is in the low state.
VinH is the input voltage trip point when the output of the comparator is in the high state.
EnL is the junction of R6, R7, and R3 when the output of the comparator is in the low state.
EnH is that same junction when the output of the comparator is in the high state.

VinL and VinH give us both trip points, so we can compute the hysteresis.
EnL and EnH are also required so we can check to see that neither diode is conducting. If either diode conducts then we have to modify the equations a little. EnL and EnH should never go below -0.2v or above Vcc+0.2v.

In the equations the variables are as follows...
E5 is Vcc, the 5.34v supply in your schematic.
E2 is the saturation voltage of the comparator, probably about 0.1v or so.
The resistors, R1, R2, etc., are the ones on the schematic.

To use the equations, enter all the known variables and compute the results. Check EnL and EnH to make sure they stay in range. Note that some values of resistors may not be a good idea. For example, i get better results if i change the 470k resistor to 47k, but it depends on your application.

If instead you want to solve for the resistors, we can solve for the 1M or the 470k resistor connected to the non inverting input. This will allow you to set the input hysteresis to whatever you need. We can do that, or you can just try different values, it's up to you.