Opamp Comparator oscillating GND and VCC

Thread Starter

anishkgt

Joined Mar 21, 2017
547
Hi All,

i am trying to keep the out of the opamp to GND when the input at the inverting pin goes above 0.2v set ref. At the moment it oscillates at GND and VCC. How can i achieve it ?

cs1.JPG
R4 and C1 makes the low pass filter.
 

AlbertHall

Joined Jun 4, 2014
10,915
As your input goes above and below the 0.2V reference voltage so the output switches between high and low.
You can see the effect of the reference voltage as the high part of the output waveform is wider than the low part.

What are you trying to achieve?
 

Thread Starter

anishkgt

Joined Mar 21, 2017
547
Ah Thank you that explains the pwm.

I'll try to explain the whole idea behind this. The source of the signal is from the mains but parallel to Microwave Oven Transformer (MOT) with its secondary rewound with 3AWG cable for spot welding. When the MOT is OFF there is a voltage of 1.2vac at the primary and when the secondary are shorted a voltage 0.2vac. The MOT switch ON is controlled via two SCR in a back-to-back configuration. Basically a TRIAC. So the voltage at the primary is the leakage from the SCR's which am using it as an advantage to avoid a button.

Lets assume we have a push button switch to switch ON the spot welder. We press it and that switches ON the MOT and we spot weld nickel tabs to 18650 cells. All looks good and Hunky-Dorey. Now lets say you have to build a battery pack of 300 cells and pressing the switch 300 times or a foot switch would be........a little uncomfortable or your legs get exhausted while pressing the pedal 300 times to spot weld those cells.

Here we are replacing the 'SWITCH' by sensing when both electrodes makes a contacts on the nickel tabs. When it does current is drawn from the MOT and that draw will show a voltage drop at the primary and that voltage-drop is something that am trying to sense which would fed into an Arduino to activate the MOT.
 

AlbertHall

Joined Jun 4, 2014
10,915
So, let me get this clear. The voltage must be off, then press the electrodes against the tab, then turn on the voltage?
Does the voltage need to be switched off before the electrodes are removed?
Is the voltage to be applied for a specific time or does the operator decide when the weld is complete?
 

Thread Starter

anishkgt

Joined Mar 21, 2017
547
So, let me get this clear. The voltage must be off, then press the electrodes against the tab, then turn on the voltage?
Does the voltage need to be switched off before the electrodes are removed?
Is the voltage to be applied for a specific time or does the operator decide when the weld is complete?
“The voltage must be off” you mean the mains ? The opamp out I am guessing. I would just need the some output either high or low when the secondary are shorted. I could achieve it by adding a diode but wanted a second opinion. The signal is fed into a MCU and with code the MOT would be switched ON. The max weld time would be 500ms with the lowest being 10ms.
 

Thread Starter

anishkgt

Joined Mar 21, 2017
547
Did that and it does work but are there any other concerns ? the max time 240vac would pass through would be 500ms.
Capture1.PNG
 

Alec_t

Joined Sep 17, 2013
11,896
C1 will need a discharge resistor.
If Vin can be 240VAC then the whole circuit would be at a dangerous potential and components would need to be mains-voltage rated. 500mS is more than enough time to electrocute you!
1.2VAC is hardly enough to drive an optocoupler to give you mains isolation, but perhaps you could wind a small isolating transformer to go in series with the MOT primary?
 
Last edited:

Thread Starter

anishkgt

Joined Mar 21, 2017
547
C1 capacitance is quite low. That is part of R4 which makes the RC filter.

Yet to try this on pre-board but from the looks of it, seems to work.
Capture1.PNG
 

Alec_t

Joined Sep 17, 2013
11,896
I'd be inclined to change some of those values, to avoid an electrolytic cap and bearing in mind the high voltages possible.
Try :-
R4=100k,
Replace C1,C2 by a single 33n,
R5 = 2 x 470k in series,
R1 = 2 x 470k in series,
D2 = 3V zener.
I still think some form of mains isolation should be used, unless there's no prospect of anyone touching any part of the circuit.
 

Thread Starter

anishkgt

Joined Mar 21, 2017
547
Thanks that did help me avoid a beefy cap.

The pcb will be inside an enclosure so that would take care of anybody accidentally touching it.
 

Thread Starter

anishkgt

Joined Mar 21, 2017
547
This just crossed my mind, would it be ok to have the neutral from the mains connected to GND in this circuit or should it be isolated as shown.

 

Alec_t

Joined Sep 17, 2013
11,896
I'd leave it isolated. Depending how your property is wired and your power company operates you might trip a ground-leakage circuit-breaker if you short neutral to ground. In principle they are already shorted at some point. In the USA this is at the consumer panel, but in the UK it may only be at the generator station and there can be several volts between neutral and ground at the consumer end.
 

AlbertHall

Joined Jun 4, 2014
10,915
I'd leave it isolated. Depending how your property is wired and your power company operates you might trip a ground-leakage circuit-breaker if you short neutral to ground. In principle they are already shorted at some point. In the USA this is at the consumer panel, but in the UK it may only be at the generator station and there can be several volts between neutral and ground at the consumer end.
Agreed.
Then for the circuit to work properly the ground on the isolated side must be connected to mains earth.
I suggest that the lower ends of C19 and D8 should be disconnected from neutral and connected to the mains earth.
 

Thread Starter

anishkgt

Joined Mar 21, 2017
547
Thank you guys. Appreciated.

So am trying to avoid the earth wiring as much as possible since i'd only need the transformer connected to Earth and nothing else.

"I suggest that the lower ends of C19 and D8 should be disconnected from neutral and connected to the mains earth." why would would it be needed. I mean i don't get it really, would it work ?
 

Thread Starter

anishkgt

Joined Mar 21, 2017
547
Wouldn't resistors R21 & R36 drop voltages when a 1.2vac and .2vac goes through because that is what am trying to sense here.
 

AlbertHall

Joined Jun 4, 2014
10,915
"I suggest that the lower ends of C19 and D8 should be disconnected from neutral and connected to the mains earth." why would would it be needed. I mean i don't get it really, would it work ?
As the circuit stands, if there is any spike of voltage between neutral and earth then C19 couples that spike direct to IC6 input.
D8 limits the voltage at the mid point of the R21, R36 divider but, again, as it stands that limited voltage is referenced to mains neutral and it would be better referenced to the IC6 0V (mains earth).
 
Top