Opamp Comparator oscillating GND and VCC

MrAl

Joined Jun 17, 2014
11,494
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 ?
Hi,

I can draw a circuit for you, but i need that last bit of information.
I have to know how fast you NEED this to be. That is, how fast does it have to actually detect the 0.2 or the 1.2vac input.
For example, 100ms, 500ms, 1000ms ?
The longer, the better because the easier it is to do then.
 

Thread Starter

anishkgt

Joined Mar 21, 2017
549
100ms to 500ms would be just fine.

If you don’t mind me asking, why would this be so complicated when the simulation worked just fine as a simple comparator. I can understand there a lot more from what is seen in a simulation than real circuits.

I don’t need very much accuracy in the detection just a average or close to accurate would just be fine.
 

MrAl

Joined Jun 17, 2014
11,494
100ms to 500ms would be just fine.

If you don’t mind me asking, why would this be so complicated when the simulation worked just fine as a simple comparator. I can understand there a lot more from what is seen in a simulation than real circuits.

I don’t need very much accuracy in the detection just a average or close to accurate would just be fine.
Hi,

Well the simulation you did was not effective in testing the circuit. That means it looked like it worked when really it did not work well enough, yet. A few modifications and it will work however.

To test it you have to actually do what you said you want it to do: detect rising and falling sine amplitudes. To test that, you have to modulate the input sine wave from 0 to maybe 1.5vac then back down to 0vac, and see where and when it trips. It's not good enough to drive the input at say 1.2vac and see that it tripped, then drive it at 0.2vac, or something like that. The simulation must change the input from maybe 0.19vac to 1.21vac or something like that, and back down again. That way you see the whole story.

I dont think you have to worry too much though, a few modifications and it should work.
I'll draw you up a schematic but give me a little while to do it. Check back in a few hours or so and i'll post a new reply here.
 

MrAl

Joined Jun 17, 2014
11,494
Hello again,

Here is the new schematic and a screen shot of the simulation.
The equations for the comparator are included on the schematic. Solve for R3 and R4, choose R6 to be something reasonable like 10k. Note the set points have to change to 1.2v and 2.2v because of the 1v output offset.

This simulation switches between two sine sources, one is 2.0v and the other is 0.4v. The desired signal limits were 1.2v and 0.2vac, but to get that signal when adding two sine waves through two equal value resistors we have to take into account the fact that one source is zero when the other is active, and when both are active we only get 1/2 the contribution from each source, which amounts to 1.2vac. So when the 0.4vac source is active alone, we get 0.2vac, and when both are active we get 1.2vac, which are the right limits.
Note a better way to test it would be to 'ramp' up and down the sine source, but i could not find the modulator in the software. If we find that we can test again using that method instead.

Looking at the simulation, we can see that there is about a 10 cycle delay before the output changes state after the input jumps up to 1.2vac. There is about a 30 cycle delay before it changes back when the input jumps back down to 0.2vac.
The disconnected long line at the top of the schematic is for testing the output comparator only. It should be connected to test the trip points of the comparator but disconnected for the total simulation. It is shown disconnected in the schematic and simulation files below so the simulation was the total simulation.

As you can see in the simulation output, we have to be able to see the output switch one way and then back to the original state or else we cant be sure it is working right at all.

Other notes:
Check the power dissipation of the first 100k resistor and the two zener diodes.

Here are the files...
 

Attachments

Last edited:

Thread Starter

anishkgt

Joined Mar 21, 2017
549
Thank you. why is there an offset used for opamp 1, 4.5K and 500R ? What does Vop1 and vo1 mean ? What is R8 and R10 doing ? I see there is part of the mains voltage going there to R8, what does it do ?

i just changed
R6 = 100K
R3 = 2.1K
R4 = 100K

I seemed to get a what i need but setting v2 to 1.2 i get a square wave as attached
Capture.JPG


Here is my version just added the dual zener diode back to back and a dc offset at the opamp 1.
Capture1.JPG
 

MrAl

Joined Jun 17, 2014
11,494
Thank you. why is there an offset used for opamp 1, 4.5K and 500R ? What does Vop1 and vo1 mean ? What is R8 and R10 doing ? I see there is part of the mains voltage going there to R8, what does it do ?

i just changed
R6 = 100K
R3 = 2.1K
R4 = 100K

I seemed to get a what i need but setting v2 to 1.2 i get a square wave as attached
View attachment 151014


Here is my version just added the dual zener diode back to back and a dc offset at the opamp 1.
View attachment 151015

Hi,

The offset is used because we can not properly sense a 0.2vac signal turned into 0.2vdc. The reason is that the 0.2vdc has ripple, and some of that ripple would have to go below zero during normal operation. Since we cant operate the circuit below zero with only a single power supply, we add an offset so that we can detect 0.2vdc as 1.2vdc. Then we can detect 1.2vdc (caused by the input) as 2.2vdc. So we just move everything up by 1 volt.

The various labels like Vop1 are just there so that we can click on them to see the waveforms after we run a simulation. It's better than just clicking on an unnamed node because the named nodes like Vop1 do not change when we add or remove something from the circuit.

The mains voltage goes to R8 for TESTING THE COMPARATOR ONLY. For normal overall testing we dont connect that. Disconnect that for normal testing. The testing of the output comparator can be done using the input sine wave, as a SEPARATE test. The input is increased up to say 3vac, and ONLY the comparator is then tested for upper and lower trip points. This helps to ensure the resistor values on the comparator are the right values, or at least close. Once this test is done however, the line has to be broken so that the circuit works normally.

The values i provided in the asc file were the tested values. The circuit works as you describe using those values. This means you should not change any values. Also, be sure to disconnect the mains from R8 as above.
 

Thread Starter

anishkgt

Joined Mar 21, 2017
549
I've drawn a schematic with a trim pot instead of a fixed value just incase i need to change the reference. Are the GND and neutral correct here. In the previous schematic i understand there has to be one going to Mains Earth as well. Not sure which one.
CS.JPG
 
Last edited:

Thread Starter

anishkgt

Joined Mar 21, 2017
549
I did not have the R4 so just jumped it and left the PE floating. To test I just turned the POT till CS turned on.

Is the pot connected correct ?
 

crutschow

Joined Mar 14, 2008
34,464
Pin 7 is the output and that has R35 wouldn’t that help here.
No.
R35's path is to ground so it's a pull-down.

Do you know what open-collector output means?
An open collector output can only sink current, not source it.
You need resistors from Pin 1 and pin 7 to +5V to pull the outputs high.
 

Thread Starter

anishkgt

Joined Mar 21, 2017
549
Well i just added a 10k and things don't seem to be working as expected. I just checked the voltage at the primary of the MOT and they dropped down to 0.8vac at non-contact and 0.0 at contact. Earlier it was 1.2 and 0.2.

Would it help reducing resistance R18 to maybe something lower from 39R to 22R in the snubber circuit. As that is seen at the primary of the MOT when not powered on.
Capture.JPG
 
Last edited:
Top