Opamp Comparator oscillating GND and VCC

MrAl

Joined Jun 17, 2014
13,720
Hi,

You talked about two voltages i think:
0.2v and 1.2v.

Which one do you want to use to force the output to go low?
 

MrAl

Joined Jun 17, 2014
13,720
1.2 goes low and .2 goes high.
Hi,

Ok then the values do not look right.

I take it you want it to go low when the input ramps up to 1.2, then if it ramps down to 0.5 say it still stays low, then if it ramps down to 0.21 it still stays low, but if down to 0.2 it goes high again right?

First, the input gain is not really optimal. Actually every far away from optimal.
Since you have an op amp, you can do a lot that makes it work really well, or at least should.

For example, make the op amp (first stage) so that it outputs a nice healthy signal, like 0.4 to 2.4 at least. That's double what you wanted, but then the next stage has more to work with.

Right now the first stage gain is around 1/2, which means you only get 0.1v out with 0.2v input.
Better is to get 0.4v output with 0.2v input.
Then, 1.2v input gives you 2.4v output.
Now you have something better to work with at the last stage..

The input high trip point would be 2.4, and the low trip point would be 0.4. This is decent with a power supply of 5v.

The trip points then have to be set to 0.4 and 2.4, which is easy to do.

When testing, you have to make the input source change from 0.2 to 1.2 and back down again gradually. That's the only way to test this well enough to be sure it works right because there is hysteresis.

Also why such a bid diode for D3 and why R7?
 

Thread Starter

anishkgt

Joined Mar 21, 2017
549
Hi,

Ok then the values do not look right.

I take it you want it to go low when the input ramps up to 1.2, then if it ramps down to 0.5 say it still stays low, then if it ramps down to 0.21 it still stays low, but if down to 0.2 it goes high again right?

First, the input gain is not really optimal. Actually every far away from optimal.
Since you have an op amp, you can do a lot that makes it work really well, or at least should.

For example, make the op amp (first stage) so that it outputs a nice healthy signal, like 0.4 to 2.4 at least. That's double what you wanted, but then the next stage has more to work with.

Right now the first stage gain is around 1/2, which means you only get 0.1v out with 0.2v input.
Better is to get 0.4v output with 0.2v input.
Then, 1.2v input gives you 2.4v output.
Now you have something better to work with at the last stage..

The input high trip point would be 2.4, and the low trip point would be 0.4. This is decent with a power supply of 5v.

The trip points then have to be set to 0.4 and 2.4, which is easy to do.

When testing, you have to make the input source change from 0.2 to 1.2 and back down again gradually. That's the only way to test this well enough to be sure it works right because there is hysteresis.

Also why such a bid diode for D3 and why R7?
The D3 and R7 are to clamp the high voltage. Was silly but that was what i was trying to achieve.

So you say after rectification there should be amplification and then a comparator ? is that what your saying.
 

Thread Starter

anishkgt

Joined Mar 21, 2017
549
I take it you want it to go low when the input ramps up to 1.2, then if it ramps down to 0.5 say it still stays low, then if it ramps down to 0.21 it still stays low, but if down to 0.2 it goes high again right?
Maybe i wasn't clear when i explained. here is the working principle and how i came up with the idea.

The Transformer when in the OFF State, that is no voltage or current is flowing though it but it does have some voltage in flowing into it, i guess that is some sort of leakage current from the SCR or the Snubber circuit. This voltage can be seen with a DMM when probing at the primary terminals, that is the 1.2vac. While in the OFF state, when shorting the secondary terminals there is a change in voltage. The voltage drops from 1.2vac to .2.

This would be handy for my project as a way to automatically switch ON the transformer via a microcontroller when a voltage drop is detected.

in other words 1.2vac is OFF and .2vac is ON. The comparator, with a Vref of 2.5v would set its output to LOW at 1.2 and higher and HIGH when the Vin is .2vac or lower.
 
Last edited:

MrAl

Joined Jun 17, 2014
13,720
Hi,

I think you can get some gain just be changing the feedback resistor on the prec rectifier to a higher value, like maybe 400k.

The comparator resistors will have to be changed.
I calculated (in k ohms):
R3=2.6315789
R4=50
R6=10

and this sets exactly 1.2v and 0.2v trip points.

All you have to do then is get the gain of the prec rectifier op amp to give you 0.2v and 1.2v when the input AC is the same.

You can test the comparator part by just running the sine wave into the comparator, and look for pulsing output that changes at 0.2 and 1.2 volts. That's a test.
 

MrAl

Joined Jun 17, 2014
13,720
I am not sure if i understood this but i can't get seem to get anything beyond this
View attachment 150814


and seems to not get what i am after too.

Hello again,

The mains voltage can be clamped with two back to back zeners after the first 100k resistor.

Also, i dont think you need another op amp but lets keep it in mind that you would not mind having a third one.

I took a closer look at this and now that i am getting a better feel for what you want to do, i see we have to add a little input offset to the first op amp. 1/2 volt should be good enough. So say 4.5k to +5 and 500 ohms to ground, and the junction goes to the non inverting input of the first op amp.
The reason for this is because of two things:
1. The response for falling input 1.2vac to 0.2vac.
2. The filtering needed for the output of the rectifier.

What happens is that the output comparator trips on the upper peak of the input when going to 1.2vac, but will trip on the lower peak (the valley) when going from 1.2vac to 0.2vac, so we need less than 0.2vac ripple, which means the response will get very slow. If we add 1/2 volt input offset, then the output will always be offset by 1v (gain=2). That gives us more to work with above the 0.2v.
The reason this got a little more complicated is because 0.2v is a low voltage to detect when we are filtering it into a pseudo DC voltage.

The output filter could then be 100 ohms and 20uf with a 50k on the output of the op amp rectifier.

The last question then becomes one about the response time needed to detect the two extremes.

Going from 0.2v to 1.2v, how fast do you need to detect that the voltage went over 1.2vac ?
Going from 1.2v to 0.2v, how fast do you need to detect that the voltage went below 0.2vac ?
These two question are very important because they set the boundaries on the filter specifications.
Note using a peak detector for example will cause an extremely long time delay going low, so we need to sort of average the output and use that instead of the very peak.
In answering these two question, be sure to allow as long a time as possible. That is, the absolute longest time your application can tolerate. I say this because if the time is short then a completely different design may be needed ... one that detects only the peaks of the input ... which is more complicated. Note that even with a digital peak detector solution the fastest we can hope for is probably around 1/2 to 1 cycle.
Reasonable for the analog solution we have been working with is maybe 300ms.
 

Thread Starter

anishkgt

Joined Mar 21, 2017
549
Thanks you appreciate you taken time to write this. Myself being a beginner I was expecting something simpler but none the less if this would get the job done then I would just go with it.

Would it be possible for you to draw the arch magic for me please ?
 
Top