Shop OBEX P1 Docs P2 Docs Learn Events
Using relays-Help! (probably an easy answer) — Parallax Forums

Using relays-Help! (probably an easy answer)

ccc11223ccc11223 Posts: 10
edited 2012-06-18 22:11 in General Discussion
I'm trying to control an AC socket using a BS2. I know how to do this using a 5vdc relay, but the relays i find in that range are not rated very high for current about 1A max. I am looking for a relay roughly 5A and NC. Would i be best off trying to buy a suitable 12vdc relay, and use a transistor with an external 12vdc to control that relay, or is there a better option?

Thanks for any help you can give

Comments

  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-06-18 09:02
    I use 10 amp and 12 amp 240VAC rated relays, even for 5 amps of 120VAC. But these tend to be driven by 12VDC and require a 2n2222 to boost the voltage to drive them. The ones I use are also mounted on a socket in a DIN rail. That makes the AC wiring safer and secure. I can even add a circuit breaker or fuses or pilot lights and more.

    I'd have to say "Yes" - using 12VDC relays for AC mains is safer and saner. Those 5VDC relays were never really intended for anything but switch a small consumer appliance on and off. And circuit board were never intended for 5 amps of current - not enough copper to run safe and cool.

    In many cases you can use 2n3904 transistors, but the 2N2222 will handle more current and last longer - maybe forever. A 12VDC 10amp relay coil requires about 60-80 millamps to engage. The 2n3904 is rated about 200 milliamps, the 2n2222 is rated about 500 or more milliamps. And don't forget to add a flyback diode on the coil. Any diode of 1 amp and 50volts or more will do well.

    There are a lot of switching power supplies that offer both +5VDC and +12VDC that are appropriate for handling everything.
  • ccc11223ccc11223 Posts: 10
    edited 2012-06-18 10:06
    thanks for the help. i will do that. One last question though, what valued resistor should be used to connect the 2n2222 to the output pin?
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-06-18 11:07
    The resistor value is not too critical and mainly is for protecting the microcontroller.

    With a 2n3904 or 2n2222, the gain is about 60 times.
    So working backwards from 100 milliamps at the 12 volts (more than enough for the relay coil, but transistor full on)

    100milliamps/60 = something less that 2 milliamps would drive the relay.

    E=IxR or E/I = R

    so at 5 volts/.002 = 2500 ohms or less would work for 5 volts

    or at 3.3 volts/.002 = 1650 ohms or less

    Many people might just suggest using 240 ohms to protect the microcontroller. But the less millamps you have on one pin, the more you have to use on other pins. Banks of 8 pins often have a shared limit of so many milliamps and the microcontroller has a total limit of milliamps for all pins on or it gets too hot. Remember, the wires inside are tiny.

    There is not a good reason to drive the pins at 20-25 milliamps just because that is near their limit unless you need to drive an LED or something. Even then, it might be wise to use a buffer chip and to protect the microcontroller.

    If you are worried, check the coil resistance of the relay and figure out how many milliamps it will use. But I found most are 60 millamps or less.
  • kwinnkwinn Posts: 8,697
    edited 2012-06-18 12:57
    A solid state relay is an alternative to mechanical relays and has the advantage of requiring a very low drive current and voltage. Typical current is 10 - 20mA and 1.8V. Usually they can be driven by the micro's I/O pin through a current limiting resistor.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-06-18 22:11
    Yes, that Parallax relay board is quite handy. Often you don't need more than a couple.

    At first I preferred Solid-state relays because I thought that everything solid-state must be better, newer technology. But in the case of switching a lot of power, relays have had a long history of development and refinement. But they do make noise.

    Driving a relay with 10-20ma directly from the microcontroller may work if that is all you are doing, but at least some microcontrollers can only deliver 30ma total to a bank of 8 pins. So if you want 8 relays and all on at the same time, you may still need a buffer/driver chip to boost the current.

    The biggest drawback with solid-state relays is that they tend to only be available in SPST Normally open (off). Mechanical relays can easily be gotten in DPDT so that other configurations and complete cut off of both sides of a circuit are possible.

    There was a time that SSR were larger than the mechanical, and they do tend to run hot.

    So there are places that one or the other is best suited. In autonomous robotics, the automotive industry has long provide a lot of weather-proof 12vdc relays with high amps - up to 80amps of 12vdc for a reasonable cost.

    Also, 120VAC power switching circuits are not very safe on a circuit board. These should be wired and enclosed in a fire-proof enclosure AND fused. Generally, AC is best avoided in projects for kids at there are serious and real hazards of shock and fire.
Sign In or Register to comment.