• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

converting 220v ac signal to logic signal

Status
Not open for further replies.

emb

Member
HI All,,,

I have a push button on the 220v AC side connected to neutral line...I need it to produce a logic signal when it pressed.

what i think to do something like this

wrrrrrrrrrr.png

any modification ?
is there any disadvantages using this approach ?
is there any other method better to use ?

regards
 

JimB

Super Moderator
Most Helpful Member
i think to do something like this
What you have there is a good safe option.

any modification ?
You may need to add some de-bouncing circuitry to the input to the micro.
You could use an opto-isolator instead of a relay. May be cheaper if you have several inputs, but you will also have to rectify and smooth the signal into or out from the opto-isolator.

JimB
 
  • Like
Reactions: emb

Nigel Goodwin

Super Moderator
Most Helpful Member
It's perfectly fine, and will work - however, it's somewhat large, expensive, and crude - but for simplicity, and safety (as a mains relay is intrinsically isolating) it's hard to beat.

A 'nicer' method would be an opto-isolator, but it's not as simple as a relay.
 
  • Like
Reactions: emb

emb

Member
thank you all :)

i searched about opto-coupler method and find the following circuit

frwr.jpg
how can i choose the value of R1,R2 and R3 values ? ZD value?

regards
 

Colin

Active Member
A capacitor-fed power supply would be much simpler and much cooler.
100n in half-wave allows 3.5mA or 7mA in full wave so you can work out the value you need.
 
  • Like
Reactions: emb

ronsimpson

Well-Known Member
Most Helpful Member
i think to do something like this
I use a 5 volt wall wort. (cell phone charger) We all have boxes of them laying around.
Input 110/220 ac, output 5V dc
The turn on has a small delay. The turn off will have a long delay unless you put a load on it. I usually put 10mA LED + resistor load so I can see what is happening.
 
  • Like
Reactions: emb

AnalogKid

Well-Known Member
Most Helpful Member
As you can see, there are several different methods to do what you want, each with different characteristics. How fast a response do you kneed? That is, does the uC need to see a signal the instant AC is present, or is a short delay acceptable. For example, the relay method will energize and release within about 1/10th second of when the switch is pressed and released. The signal from a 5 V wall wart will activate a little slower, maybe 1/2 second, but might release much slower, like a few seconds.

ak
 
  • Like
Reactions: emb

emb

Member
hi all,,

i found the following circuit using optocoupler

ggg.jpg

any modification ?

should i use protective elements ?

the power rating of the resistors ?



regards :)
 

Nigel Goodwin

Super Moderator
Most Helpful Member
C1 is the crucial component, it MUST be a special capacitor rated for this use - it must be X-rated.

R3 should probably be a fusible type, as it's there as a fuse - R1 and R2 are just to discharge the capacitor.

BTW, this circuit provides AC pulses on the output, not a DC voltage.
 

emb

Member
C1 is the crucial component, it MUST be a special capacitor rated for this use - it must be X-rated.

R3 should probably be a fusible type, as it's there as a fuse - R1 and R2 are just to discharge the capacitor.

BTW, this circuit provides AC pulses on the output, not a DC voltage.
I simulate the circuit the output was 5v .
when the button pressed the output goes low and still low while button pressed..

Is there a problem in simulator ?

When I remove the bridge the output was AC pulses when the button pressed :)

Regards :)
 

emb

Member
I don't use simulators, but they often don't work as in real life.

There's no AC smoothing in that circuit, so the output will be a pulse not DC.

Did you have the simulator input as DC instead of AC?.

No .. it's a.c. input :)

What should I do to get DC output ?
 

alec_t

Well-Known Member
Most Helpful Member
when the button pressed the output goes low and still low while button pressed
How were you checking the output? A DMM will average the signal and show it as very close to 0V, whereas in fact it is a series of very brief 5VDC pulses (one pulse per half-cycle).
 
  • Like
Reactions: emb

Diver300

Well-Known Member
Most Helpful Member
You could just use a 240 Vac powered 5 V supply, such as a mains driven USB supply that you have kicking around. All your isolation and smoothing is taken care of in the power supply. You may need a load resistor to discharge the output as with no other load it could take some time to decay.

If you do use a relay, I would suggest a much smaller load resistor than 10 kΩ. I would use something like 500 Ω to ensure 10 mA flows though the contacts when they close to help keep the contact working. The actual current needed depends on the relay and a minimum current is often quoted for them.
 
  • Like
Reactions: emb

emb

Member
Why are you switching the neutral?, normally never done.
Live side only.
Max.
I have a switch already connected to neutral :)


How were you checking the output? A DMM will average the signal and show it as very close to 0V, whereas in fact it is a series of very brief 5VDC pulses (one pulse per half-cycle).
yes i used DMM and i check the output on the oscilloscope it was as you say..

ghj.png
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top