5

I am new to electronics. I want to make a power switch controller by a digital pin as shown on the following figure.

How to do this safely?

enter image description here

Update: I forgot to let you know the bulb is just an example for the sake of drawing. The real scenario, it is a female socket into which any equipment male socket is inserted.

  • 2
    possible duplicate of [Control 220V AC line using MCU](http://electronics.stackexchange.com/questions/14533/control-220v-ac-line-using-mcu) – Kellenjb Jun 24 '11 at 15:45

3 Answers3

13

Updated after update of the question. Changes are regarding the zero-crossing

The best solution for an incandescent lamp is an SSR (Solid State Relay) with zero-crossing detection. (Zero-crossing switching increases the bulb's life.) An SSR module is the most convenient, but they're not cheap.

enter image description here

If you want to switch other (unknown) loads you better pick a random-switching SSR, i.e. without the zero-crossing circuit.

If price is an issue you can better build the SSR from discrete components. Below is an example using the MOC3041 as opto-triac. Will cost about 2 euros.

enter image description here

Again, the MOC3041 has a zero-crossing circuit. For other loads than an incandescent bulb use the random switching MOC3051.

Not as nice, but easier: an electromechanical relay:

enter image description here

The transistor is needed because the microcontroller can't supply the required current for the relay, so you have to amplify this current.


About the zero-crossing: you may have noticed that incandescent bulbs always fail when they're switched on. That's because the mains phase can be near its maximum when switching on. Combined with the low resistance of a cold bulb this results in a high current peak, which may burn the filament. When you switch on a zero crossing you avoid these peaks.

stevenvh
  • 145,145
  • 21
  • 455
  • 667
  • I have the vague impression that I've seen a *very* similar answer before ;-). But that's OK, the answer is to-the-point. +1 – Federico Russo Jun 24 '11 at 12:31
1

There's many things you can do to separate the relay from the digital side. You could opto-isolate it. You could use a peripheral driver chip. You could set up a darlington pair transistor arrangement.

Personally I'd just use a driver chip - it's quick and easy.

Most driver chips are just glorified darlington pairs anyway.

One commonly used driver is the ULN2803

Majenko
  • 55,955
  • 9
  • 105
  • 187
  • +1: Could you give me a more detailed info? – Second Person Shooter Jun 24 '11 at 11:47
  • @Matt - the ULN2803 *is* common, but only if you have to switch several loads. For just 1 relay a single transistor will do nicely. – stevenvh Jun 24 '11 at 12:25
  • @xport - what do you want to know more about? – stevenvh Jun 24 '11 at 12:26
  • @xport: @stevenvh is right: if you need to switch one relay just use a transitor. The 2803 is basically an IC with 8 copies of the transistor circuit in his answer. So if you want to switch 8 bulbs go for the 2803. – Federico Russo Jun 24 '11 at 12:34
  • Or a single element driver chip - the 2803 was just an example of what is available. I'd prefer a darlington pair to a single transistor personally. – Majenko Jun 24 '11 at 12:57
  • @Matt - while a single transistor will have a \$V_{CE(SAT)}\$ less than 500mV, for a darlington this is often as high as 2V, which may be an issue if your power supply is 5V. A BC847C has a \$H_{FE}\$ more than 400, so to switch most relays you'll need \$I_B\$ less than 1mA. You don't really need the darlington. – stevenvh Jun 24 '11 at 13:09
  • @stevenvh, Matt: the BCV47 darlington has a \$V_{CE(SAT)}\$ of (only) 1V. May still be a bit much for a 5V relay, but most relays work with higher voltages anyway. – Federico Russo Jun 24 '11 at 13:35
  • @federico Yes, I am used to working with 12V relays, not 5V... – Majenko Jun 24 '11 at 13:35
0

Depends on the current form your digital output. Is it a microcontroller, some circuit, a switch, or something else? If it is a low current output, you have to use some kind of simple transistor, as example, to control the relay.
Also check that the relay is rated for 240V. Depending on what controls what, some kind of isolation between the circuits might be good.

varesa
  • 639
  • 1
  • 7
  • 26