220VAC Detecting by PIC18FXX

MikeML

Joined Oct 2, 2009
5,444
@cmartinez
to make the sim run, put a new 1megΩ resistor from the minus end of V1 to Gnd∇. In any Spice, all parts of a circuit must have an Ohmic connection to ∇. The opto makes it such that the stuff to the left is "floating". To check if isolation is working, plot the current through the new resistor...

Your circuit needs a little work. I will post one in a few minutes...
 

cmartinez

Joined Jan 17, 2007
8,218
I noticed that the circuit's output is idle high, and not low, as I had thought. So here's a better idea. Maybe we could connect the output to a 555 timer, configured as a missing pulse detector.
That should be quick enough if designed correctly.
 

cmartinez

Joined Jan 17, 2007
8,218
Because the signal is going to end up as a digital 0-1 level anyway, I don't see what is wrong with a simple 240v relay?
Max.
Neither do I. In my case, it's just that I'd like to learn the details on how something like this is supposed to work.
But on the other hand, one would have to take into consideration the range of the control signal of the relay you're proposing. Designing your own circuit would allow you to tweak it into tighter tolerances.
I guess it all depends on the OP's original intent, anyways.
 

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
Is it me or did you guys miss the part "not a zero crossing one". If you are tagging along and learning, then continue by all means. I am A-OK.

The relay approach was one that I came up first. But since this thing will be running all year long I thought of trying to make it with common parts I have lying around. And that is how I came up with the circuit. It's simple and can be repaired without buying components.
The X2 capacitor approach was also more expensive to me than the circuit I showed as the caps are not common in my junk and is actually expensive than the parts I am using. Not that I do not have them. I do, but limited and I have seen them go bad often as I get to replace them from time to time for customers. That is why I am avoiding that.
I got the answer from John. His circuit seems simple enough than the one I am planning. So I will experiment with it and my one with a couple more RC filtering as AK suggested.

I like to post it but I will again violate the tos. Still happy that I got the answer before lock down.
ta-ta for now.
 

cmartinez

Joined Jan 17, 2007
8,218
Is it me or did you guys miss the part "not a zero crossing one"
Riff, I did get you, and understood what you wanted. It's just that I'm pretty sure that a ZCD is the best starting point to reach your goal... stay tuned, 'cause I think I'm on to something.
 

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
By all means but do check the first post.
My circuit does not need ZCD. I just need the PIC to know of AC mains failure.
 

cmartinez

Joined Jan 17, 2007
8,218
By all means but do check the first post.
My circuit does not need ZCD. I just need the PIC to know of AC mains failure.
And here it is... (more or less)
Using Mike's circuit, this version delivers a logic high when AC mains is absent. The point is to use an OR gate at the opto's outputs to deliver the signal.

Three things about it though:
  • Output level is not TTL. This is because I suck at analog electronics. With time, I'm pretty sure I could've adjusted it, but I gotta get busy.
  • The values of the RC filter at the output need to be adjusted too.
  • I'm pretty sure someone else could come up with an even simpler, more elegant idea. This attempt of mine is for learning purposes only.
Have a good one!
 

Attachments

bertus

Joined Apr 5, 2008
22,270
Hello,

I would place a diode anti-parallel to the opto led, as it will break when the reverse voltage is higher as about 5 Volts.

Bertus
 

MikeML

Joined Oct 2, 2009
5,444
Not to say simplicity, in the OP reliability was mentioned, the relay would not be switching any current so should last 'For ever'!
Max.
Regular power relays do not do well when switching a couple of mADC. They need a small arc to keep the oxide off the contacts. By the time you buy a relay rated for this service, your wallet will wish you had used an opto...
 

MikeML

Joined Oct 2, 2009
5,444
Hello,

I would place a diode anti-parallel to the opto led, as it will break when the reverse voltage is higher as about 5 Volts.

Bertus
I anticipated that. With the 1K and 100nF capacitor across the opto input LED, there will never be more than a few mV reverse voltage there. If you use the diode in place of the 1K, you should still have the capacitor, too. I have modeled this extensively and build some circuits and posted the results on a forum that is less nervous about off-line LEDs...
 

cmartinez

Joined Jan 17, 2007
8,218
Regular power relays do not do well when switching a couple of mADC. They need a small arc to keep the oxide off the contacts. By the time you buy a relay rated for this service, your wallet will wish you had used an opto...
Yup... that's happened to me before with electro-mechanical relays... but I'm under the impression that Max was referring to an SSR

BTW, that last circuit is rather nice. And probably lots cheaper than an SSR too!
 

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
Thanks MAX. I did thought about the relay. Not a component I can get from junk most of the time u know.
But the last one @MikeML showed seems simple enough and I can get those parts quite easily.
I will look into it.
Thanks to all the suggestions guys. This thread was well worth it.
 
Top