Shop OBEX P1 Docs P2 Docs Learn Events
Controlling 120VAC with a Propeller? — Parallax Forums

Controlling 120VAC with a Propeller?

MicrocontrolledMicrocontrolled Posts: 2,461
edited 2009-12-20 20:37 in Propeller 1
I am wanting to build remote controlled christmas lights for my grandparents so that they don't have to go into the cold to turn them on. I have gotten everything down exept for how to operate the high voltage. How do you control a relay with a Propeller? I've heard of "optoisolators" somewhere but I don't know what they are or what it takes to drive them. Can someone help me with a simple circuit?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Computers are microcontrolled.

Robots are microcontrolled.
I am microcontrolled.

But you·can·call me micro.

Want to·experiment with the SX or just put together a cool project?
SX Spinning light display·
My overstock is killing me.
PM me for absolutly FREE 8-pin Mini Din connectors.

Comments

  • LeonLeon Posts: 7,620
    edited 2009-12-19 13:50
    Use an SSR (solid-state relay), they have opto-isolators. You just send it a logic high and it turns on, and logic low to to turn it off.

    Something like this should do for 240V AC:

    uk.rs-online.com/web/search/searchBrowseAction.html?method=getProduct&R=0476652

    I like the more expensive ones with an LED which shows when they they are on.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM

    Post Edited (Leon) : 12/19/2009 1:57:46 PM GMT
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2009-12-19 15:19
    In cases such as this, I·am a strong advocate for X10 modules.· Can't be accused of pushing the envelope of anyone's expertise with them (UL-listed =·no worries.)· They are very easy to control with Stamps (having XON and XOFF commands.)· You don't have to have a Stamp, you could get the X10 mini-timer cheaply enough or use one of their remotes.· Another member, darco, has written a X10 Propeller object, but another member was recently having difficulty implementing it.·

    Anyway, searching [noparse][[/noparse]SSR] with this site's button turns up lots of examples of those means.

    At this late date you probably won't secure parts in time enough.
  • DynamoBenDynamoBen Posts: 366
    edited 2009-12-19 16:17
    Here is an example of relay relay control with a microprocessor. In this case the micro is a basic stamp but this is easily adaptable to the Prop (only difference is the stamp is 5V and prop is 3.3V).

    http://www.rentron.com/Files/Stamp/pc-relay4.gif

    The advantage with a relay is the ability to switch very high current loads, and there is no need for isolation which is necessary with an SSR.
  • MicrocontrolledMicrocontrolled Posts: 2,461
    edited 2009-12-19 16:32
    I like Leons suggestion as the easyest path, I can't search the other link at the moment. However, solid state relays seem to be pricy, if not easy. Any other ideas are appreciated.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Computers are microcontrolled.

    Robots are microcontrolled.
    I am microcontrolled.

    But you·can·call me micro.

    Want to·experiment with the SX or just put together a cool project?
    SX Spinning light display·
    My overstock is killing me.
    PM me for absolutly FREE 8-pin Mini Din connectors.
  • hover1hover1 Posts: 1,929
    edited 2009-12-19 16:41
    Clap On...Clap Off
  • DynamoBenDynamoBen Posts: 366
    edited 2009-12-19 16:44
    There are commercial RF controlled relays for this purpose. Without understanding the scope of what you intend on doing it seems this might be the most simple solution (beyond running the extension cord into the house or wiring a switched outlet outside).
  • TinkersALotTinkersALot Posts: 535
    edited 2009-12-19 17:36
    I've recently completed a nice lights display using these products:

    http://www.efx-tek.com/topics/fc-4.html
    http://www.efx-tek.com/topics/rc-4.html

    Hid a lot of complexity from my top level control program, because it just had to send commands to these lighting controllers. May be worth a look?
  • JonnyMacJonnyMac Posts: 9,208
    edited 2009-12-19 18:23
    If you're wanting to do a "dancing lights" type display with several channels the SSR route is the best way to go. SSRs aren't terribly cheap, but their quiet -- both audio (no click) and electrically (they turn on and off at the zero-cross which minimizes EMI). Even though you can find SSRs that will work down to 3v, I would suggest buffering your output pins with a ULN2803; this will let you control up to eight outputs without worrying about the load you're putting on the Propeller pins.

    Full disclosure: I'm 1/2 of EFX-TEK.
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-12-19 19:53
    If you want to have it cheaper you can use TRIACS combinde with optocouplers. But without an extra circuit that switches them on the zero-crossing of the AC you get more EMI

    As the propeller is really fast he should be able to detect the zero-crossing right well.

    If you switch ON/OFF only after some hours ONCE this doesn't matter.
    For something like dancing lights or phase-cutting of the AC you should use a zero-crossing circuit

    best regards

    Stefan
  • mctriviamctrivia Posts: 3,772
    edited 2009-12-19 20:17
    When doing this I have always used a trial and zero crossing opto isolator. Cheap and the isolator provides the zero crossing circuitry. The prop is fast enough to do 0 crossing but that requires more circuitry and what if switching different phases

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    24 bit LCD Breakout Board now in. $21.99 has backlight driver and touch sensitive decoder.
  • localrogerlocalroger Posts: 3,452
    edited 2009-12-19 20:42
    If you're just turning the lights on and off and not blinking them, by far the cheapest safe way to do this is to use a small NPN switching transistor like a 2N2222 to operate a SPST relay, which you should still be able to get from Rat Shack. The basic circuit for doing this is easy to find; don't forget the reverse EMF diode to keep the relay coil back voltage from frying the transistor. You don't need a 3.3V relay since you can use the transistor to switch a somewhat higher voltage such as 6V or 9V. The relay brand new retail should cost under $5.00. It's also much safer and easier to troubleshoot an iron relay if you aren't sure why it's not working.

    SSR's are nice, I use them often, but sometimes you want it to click smile.gif and SSR's are a specialty item you'll need to order and start at around $20. They are also prone to leak if they aren't loaded heavily enough. You can test the iron relay by unplugging the 120V and ohming out the high voltage circuitry; that doesn't work with SSR's since they won't act like switches for the voltage put out by a voltmeter.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2009-12-19 23:52
    I use a circuit like DynamoBen's/localroger's. One resistor, one transistor, one diode and one relay. I tend to use slightly lower resistors than 10k - usually 2k7. Transistor can be BC547 or 2n2222 or any small signal transistor. Diode =914 (for smaller relays). It may be a bit tricky getting a 3V relay, but usually you can run the relay coil off the high side of the regulator before it goes into the prop regulator. Eg if you have a 9V wall wart running the prop reg, get a relay with a 9V coil. I tend to use 5V, 9V and 12V coils depending on the circuit.

    I did once wire up my shed lighting system with a solid state relay. But at night the flouros glowed even when off, and I don't think solid state relays truly turn off. When a mechanical relay is off, it really is off. Plus mechanical relays are cheaper.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.smarthome.viviti.com/propeller

    Post Edited (Dr_Acula) : 12/20/2009 12:00:28 AM GMT
  • Jim FouchJim Fouch Posts: 395
    edited 2009-12-20 00:01
    I've used these (http://www.mpja.com/prodinfo.asp?number=16596+RL) and they can be driven right from a Prop pin and only pull 10-20 mA. And at ~$9 are pretty cheap.

    I'm actually thinking of building a wireless device that uses the XBees to control several 120AC devices like xmas lights. Would be cool to only have to run one extension cord and control the lights from inside the house. And with the XBees running only ~$22 it's pretty inexpensive.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jim Fouch

    FOUCH SOFTWARE
  • BTXBTX Posts: 674
    edited 2009-12-20 00:04
    Hi microcontrolled.

    Check this: http://pdf1.alldatasheet.com/datasheet-pdf/view/5039/MOTOROLA/MOC3041.html

    Check the suggested schema at page 4, you can do it by yourself at very low price, and works fine !!

    I usually use them to control three phase AC motors with the best results.
    Basically is the same as Leon suggested to you.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Regards.

    Alberto.
  • MicrocontrolledMicrocontrolled Posts: 2,461
    edited 2009-12-20 17:17
    Thanks, guys. This has really helped me.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Computers are microcontrolled.

    Robots are microcontrolled.
    I am microcontrolled.

    But you·can·call me micro.

    Want to·experiment with the SX or just put together a cool project?
    SX Spinning light display·
    My overstock is killing me.
    PM me for absolutly FREE 8-pin Mini Din connectors.
  • NakNak Posts: 36
    edited 2009-12-20 17:35
    Jim Fouch said...
    I've used these (http://www.mpja.com/prodinfo.asp?number=16596+RL) and they can be driven right from a Prop pin and only pull 10-20 mA. And at ~$9 are pretty cheap.

    Could these be used in a dimmer circuit? IOW can they be switched on and off at 60Hz part way through the AC sine wave?
  • JonnyMacJonnyMac Posts: 9,208
    edited 2009-12-20 20:10
    Nak said...
    Jim Fouch said...
    I've used these (http://www.mpja.com/prodinfo.asp?number=16596+RL) and they can be driven right from a Prop pin and only pull 10-20 mA. And at ~$9 are pretty cheap.

    Could these be used in a dimmer circuit? IOW can they be switched on and off at 60Hz part way through the AC sine wave?

    No, those SSRs have their own ZC circuitry inside and only switch on-and-off at the zero-cross. If you're looking for circuitry, www.doityourselfchristmas.com is a good resource.
  • NakNak Posts: 36
    edited 2009-12-20 20:37
    JonnyMac: Thanks!
Sign In or Register to comment.