Go Down

Topic: 220V detector - again (Read 1 time) previous topic - next topic

guy_c

May 20, 2019, 09:10 pm Last Edit: May 21, 2019, 06:30 am by guy_c
I was interested in this subject because I wanted to implement easy roll back to manual of commands implemented with Arduino. For this I needed to use the 220V appearing in the electricity box when manually switching a wall switch for example. Here is the schematic and here a waveform with 330nF. I think that with 660nF the signal could go directly to a digital input. Hope this can be useful :)

ReverseEMF

#1
May 20, 2019, 09:44 pm Last Edit: May 20, 2019, 09:44 pm by ReverseEMF
Looks like the peak voltage is around 1.2V, which isn't even high enough for a 3.3V Arduino Digital Input -- which needs to be at minimum 60% of VCC [you didn't mention what style of Arduino we're talking about, here].

From the official Arduino documentation for the definition of "HIGH":


Quote
The meaning of HIGH (in reference to a pin) is somewhat different depending on whether a pin is set to an INPUT or OUTPUT. When a pin is configured as an INPUT with pinMode(), and read with digitalRead(), the Arduino (ATmega) will report HIGH if:

    a voltage greater than 3.0V is present at the pin (5V boards)

    a voltage greater than 2.0V volts is present at the pin (3.3V boards)
"It's a big galaxy, Mr. Scott"

Please DON'T Private Message to me, what should be part of the Public Conversation -- especially if it's to correct a mistake, or contradict a statement!  Let it ALL hang out!!

septillion

But the signal is "low" when there is mains. :)

If you use a capacitive dropper instead of resistors you can drive the opto harder without generating heat.
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

Grumpy_Mike

The links just take you to a span site that wants to download Cookes to you otherwise it will not let you see anything.
If you read the how to use this forum sticky post it will tell you how to post images here.

herbschwarz

Hi All,
I suggest the 1N4007 diode should be used as a half wave rectifier
so that only one 120K resistor is required. You do not need the
integrating capacitor(s). Just go with the square wave output.
Herb

guy_c

#5
May 21, 2019, 06:24 am Last Edit: May 21, 2019, 06:33 am by guy_c
The links just take you to a span site that wants to download Cookes to you otherwise it will not let you see anything.
If you read the how to use this forum sticky post it will tell you how to post images here.
Thanks, I tried it with IE (browser I never use) and show the images w/o any problem(!). Yet Ill redo just in case imgur 'sometimes' does nasty things

succeeded to oploads the schematic but for the waveform I got
"Your attachment has failed security checks and cannot be uploaded. Please consult the forum administrator." Yet its a waveform and not porn!

guy_c

But the signal is "low" when there is mains. :)

If you use a capacitive dropper instead of resistors you can drive the opto harder without generating heat.
Thanks,

the 240K isnt a dropper but a current limiter. Capacitive dropper wont limit the current to the ir LED in case of high freq components such as when sw1 is turned on or heavy loads (A/C etc) are started / stopped and so I would not recommend that

guy_c

Hi All,
I suggest the 1N4007 diode should be used as a half wave rectifier
so that only one 120K resistor is required.
Herb
Thank you good point!

Hi All,
You do not need the
integrating capacitor(s). Just go with the square wave output.
Herb
Can you please shade some more light om this idea?

Grumpy_Mike

Quote
I tried it with IE (browser I never use) and show the images w/o any problem(!).
You probably let the site down load stuff to your computer, without it there is a dark filter over the image and while I can just about make out the waveform the other image was too dark to see.

What format is your picture you are trying to attach to a post?

guy_c

You probably let the site down load stuff to your computer, without it there is a dark filter over the image and while I can just about make out the waveform the other image was too dark to see.
no downloads whatsoever unless to somewhere out of my control and I'd be surprised that imgur does this. I asked IE to show me the downloads and there is nothing new and I think that it is not allowed to dnload cookies w/o asking first

What format is your picture you are trying to attach to a post?
122,880 bytes jpg

septillion

the 240K isnt a dropper but a current limiter.
It's dropping the voltage isn't it? So yes, it's (also) a dropper ;)

Capacitive dropper wont limit the current to the ir LED in case of high freq components such as when sw1 is turned on or heavy loads (A/C etc) are started / stopped and so I would not recommend that
That's why in a normal capacitive dropper design you combine a capacitor with a inrush limiting resistor. To get best of both world, so to say.

PS Yes, you can call cookies a form of download. But yeah, you will not see them in your download list. So I would rather call it a cookie wall what the site uses. And yes, it's annoying. But so are all free photo sites :/
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

ReverseEMF

#11
May 21, 2019, 04:09 pm Last Edit: May 21, 2019, 04:41 pm by ReverseEMF
Can you please shade some more light om this idea?
Simple.  Remove the capacitors. 

Here's a distillation of all the ideas presented so far:



Adjust the values as needed.

I set the max LED current to around 550µA.  I set it relatively high, so the Opto's transistor gets driven way into saturation, to produce a nice square-ish wave on the output.

So, at 220VAC, that's a peak voltage of 220VAC * √2 = 311V
311V minus the Opto diode's forward drop of around 1.1V = 310V
310V/550µA = 563k
563k - 24k = 539k  which is the desired capacitive reactance of C1, at 50Hz.
Using the formula for Capacitive Reactance we get the following capacitor value:
C = 1/(2*π*50*539k) = 5.9 nF  and the closest standard value to that is 5.6nF, or 5600pF. I would use an "Open Mode" Class-Y, fail safe AC capacitor [Y1 or Y2].

I chose 24k for the resistor to limit current to the Opto's photo diode to within it's max operating range, should a high frequency spike come along.  Assuming these events are few, and fast, nothing should blow -- if you expect more noise, and nastiness, then, perhaps, bump that up, or make it a higher wattage.
"It's a big galaxy, Mr. Scott"

Please DON'T Private Message to me, what should be part of the Public Conversation -- especially if it's to correct a mistake, or contradict a statement!  Let it ALL hang out!!

herbschwarz

Regarding the caps: Assume the transistor is off: the cap is charging.
This takes time because the resistor limits the current, so the cap
voltage ramps up. When the transistor turns on, it quickly discharges
the cap. So, without the cap, the waveform would be like a square wave
because the transistor collector current can change quickly from +5V
to almost 0V.
Herb

guy_c

Regarding the caps: Assume the transistor is off: the cap is charging.
This takes time because the resistor limits the current, so the cap
voltage ramps up. When the transistor turns on, it quickly discharges
the cap. So, without the cap, the waveform would be like a square wave
because the transistor collector current can change quickly from +5V
to almost 0V.
Herb
Yes but how do you convert this square wave into a logic state of the switch which is what -to the best of my understanding- the program needs.
I am aware of statements like if(digitalRead, somepin)==HIGH but is there an if(somethingRead, somepin)==SQUARE_WAVE?

guy_c

It's dropping the voltage isn't it? So yes, it's (also) a dropper ;)
with the smily I must agree
That's why in a normal capacitive dropper design you combine a capacitor with a inrush limiting resistor.
I do not know what 'inrush' one should take but the one limiting the current to the max specified by the spec minus the impedance of the capacitor which may be null.

I once plugged the ac adapter of my $2k asus lap and the 63A physical fuse blow and I had to call the electric company. They must have miscalibrated the 'inrush' resistor in their supply :(

Go Up