relay project; how to power avr from 120V mains

Go To Last Post
20 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am working on a simple relay project; having a avr switch a relay connected to 120v mains. In addition, I want the avr to be powered from the ac source. Do you guys have any experience with this? Keeping things simple would be using a external wall wart to power the electronics. Is there a small footprint ac to dc circuit so I can derive 5v from 120vac?

Tony

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How much current @5V is the AVR circuit consuming? If it is very small, you can use a resistive divider to drop down the 120V to say 10V, then do the usual - rectify, filter, regulate. No isolation though, so be careful.

Bear in mind that resistors have a voltage limit, so get suitable ones. You can connect several resistors in series to get the higher voltage rating.

If you think education is expensive, try ignorance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Try this,

The maximum the C1 value, the higher the output current. The R1 goes in series with the C1 for regular charging/discharging. The bridge works as a rectifier. The Z1 is polarized via the R2 and it's voltage regulates the +V.

This circuit needs some practice and you'll find that it is a good idea for small output currents. But be carefull on:
1. The C1 voltage
2. R1 power loss
3. R2 value
4. You must know that this circuit puts harmonics on the mains.

I hope I helped.

Michael

Attachment(s): 

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

emuler wrote:
How much current @5V is the AVR circuit consuming? If it is very small, you can use a resistive divider to drop down the 120V to say 10V, then do the usual - rectify, filter, regulate.
Use a capacitor instead of resistive divider (but add at least some current limiting resistor in series with the capacitor).

But just to reiterate. Whether you use a resistive divider or a capacitor, this is dangerous.

Stealing Proteus doesn't make you an engineer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Also,

Maybe a tranzorb before the R2 would be a good idea (for high voltage protection)

Michael

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I purposely did not suggest the capacitor approach because it is not very safe. High frequency components in the AC mains are passed on virtually unattenuated. These could be spikes or even due to an on-off switch that happens to switch on at the peak of the sine wave. A zero crossing switch ahead of the circuit is highly recommended. A loose connection in the AC mains supply is death for such a circuit. :(

If you think education is expensive, try ignorance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well some nice idee but some a lot wrong
1) What is relay coil voltage, if it is 12V WRONG. You need a lot of current to drive relay and it will be not a good solution. It is working but the capasitor is big (if you use 24V relay coil, C=330n for 230Vac, means 680 for 120Vac)
2) if 120Vac Yes you can use a smal X2 capasitor and drive a triac with AVR
Thierry

Thierry Pottier

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

A loose connection in the AC mains supply is death for such a circuit.

I found this out the hard way - damned thing worked fine in the lab but gave embarrassingly high failure rates in the field.

If you think education is expensive, try ignorance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just use the wall wart so nobody gets killed or nobody fries other equipment when programming the AVR etc..

- Jani

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Michael's circuit can even be simplified some. Only two rectifier diodes are needed. Connect mains neutral directly to the bottom of the zener (5v gnd), put R1 directly in series with C1. Discard the two "bottom" diodes of the bridge and R2. Use a metal oxide film resistor for R1, which will protect the circuit from excess harmonic current and it will act as a fuse. MOX resistors will not cause a flame or arc if overloaded. Use a *metallized* polypropylene film cap for C1. Do not use "film and foil" caps because they can fail hard shorted. With appropriate choices for R1 and C1 this circuit can be very reliable. I probably have over 60,000 of these in industrial use on 120,240, and 277 volts, with absolutely zero failures over 25 years. This circuit should only be used on sinusoidal power, not from square wave output UPSs, for example 8-)

Tom Pappano
Tulsa, Oklahoma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

emuler wrote:
I purposely did not suggest the capacitor approach because it is not very safe.
And I do not recommend the resistive divider approach, because the resistor in series needs to burn a lot of energy.

Say you want 10V AC from the 120V at 100mA (10V AC is relatively high, since this is before you rectify it, and that give you around 13V DC, but it is easy to calculate in my head :-)). Then you have to burn (120V - 10V) * 0.1A = 11W in the resistor. Not good.

Stealing Proteus doesn't make you an engineer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Motorola Mini USB Travel Charger

Works great! 85 cents! It's a bit tough to get open, but a x-acto razor saw on the sides did the trick.

Edit: the inner board dimensions are approximately 2.25 x 1.25 x 0.5 inches, very lightweight, switching supply, and it has nice contacts to solder wires on.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thanks for the ideas. At this point, it seems that I don't understand enough about power supply design to do this safely. I might explore using the motorola charger since I have a spare.

Tony

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If your device needs to be connected to anything outside the box it is living in, like a PC for downloading AVR firmware, you can't use the tricks presented above (unless with a safety isolation transformer is first used).

Safest way using mains is to have a transformer and accompanying fuses and off switches etc, and I don't know what legislation is involved if you manufacture this for your friend or sell it.

- Jani

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is that true if I use 100mA from 5V then it will draw the same amount of current from the mains?
0,1x120V=12W! and 23W for 230V (avg)
That's a lot of quiescence power.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yep, that is what happens when you power it directly off the line (without a transformer). With a transformer it is much more efficient as well as safer.

If you intend to use transformerles design and you sell this as a product or give to others, YOU MUST LABEL YOUR EQUIPMENT WITH A WARNING THAT THE EQUIPMENT CONTAINS LETHAL VOLTAGES AND MUST BE SERVICED BY QUALIFIED PERSONNEL ONLY. Make sure your professional indemnity insurance is up to date.

Also the circuit by "icarus1" has a misleading flaw in the drawing , in that an "earth" or "ground" symbol is used. This might cause an inexperienced
person to assume that it is at earth potential, IT IS NOT!. In Australia ( and I assume everywhere the
"L" side of the AC line is at earth potential and if you connect a oscilloscope to the circuit you would get a nice big "splat" & smoke, when you connect the earth clip of the oscilloscope. The earth clip is usually severely damaged to remind you that Kirchoffs laws must not be ignored.
Isolation transformers must be used in this case & the circuit diagram should mention this. Something QUALIFIED PERSONNEL would understand .

Lee

Charles Darwin, Lord Kelvin & Murphy are always lurking about!
Lee -.-
Riddle me this...How did the serpent move around before the fall?

Last Edited: Tue. Jun 9, 2009 - 02:25 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why not use a high voltage non-isolated buck converter?

That way you will have good efficiency and enough current for even a power hungry relay coil.

http://us.st.com/stonline/products/literature/an/13485.pdf

After reading the thread 3ngineer I encourage you to be cautious - if you're a little confused what isolation and safety are - playing round with non-isolated regulators is a bad and dangerous idea.

oddbudman

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This appnote might be helpfull for capasitive/resistive power supply design: Microchip AN954, Transformerless Power Supplies: Resistive and Capacitive
http://ww1.microchip.com/downloads/en/AppNotes/00954A.pdf

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You didnt give much specific info about your project but assuming it is one relay on line voltage and you want an avr to control it, maybe just buy one of these relay/powerpacks available from many suppliers.
You get a UL approved Line interface, power supply and a relay...you can safely put your avr on the low voltage dc side of the critter. You can buy them on ebay almost any day for about $10

http://www.sensorswitch.com/OnlineCatalog.aspx MP20

http://www.wattstopper.com/products/details.html?id=227&category=119&type=Commercial
and lots of others....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Also you could use an optocoupler after your bridge rectifier if you are looking for good isolation from the AC mains.