Controlling 120v AC

I know this has been covered a million times, but I'm still struggling to claim that I have a total grasp on the subject, and want to be able to make such a claim before I do anything dangerous!

So, I want to control some 120v AC devices - simply turn them on or off with a GPIO pin from an arduino. These devices will all be pretty tame - small pumps (~20w maybe), 200w resistive heaters, etc.

I see schematics out there like this:

But I'm not confident I understand the circuit. Firstly, I hear people talking about opto-isolators, and triacs, and solid state relays. The schematic I posted above appears to be using a conventional, mechanical relay, plus an opto-isolator. When would you choose mechanical, versus solid state? Would I be correct in assuming that SSRs have opto-isolators built in, and as such don't need additional isolation?

Also, I've seen people talk about using a triac and an opto-isolator together to essentially "make your own" SSR. When is this a valid choice?

If using an SSR, where are people getting them? I was browsing in a thread a few weeks ago where someone was mentioning SSRs for controlling AC (like I'm trying to do) for a few bucks each. The best I can seem to find is more like $10 each:

http://www.mpja.com/prodinfo.asp?number=5954+RL

Other thoughts, schematics of working designs, etc. appreciated.

Pick one suitable to the amps and volts you want. Any of those shown as of this date can be controlled with 5 VDC. Watch the current draw on the big ones. If you are switching motor loads, you may need to add a snubber circuit to handle the inductive load

I'm certainly no expert say take this with a grain of salt...

When would you choose mechanical, versus solid state?

The big difference is the "switching time", cost, and reliability. A mechanical relay takes considerably longer to switch on and off, is general less expensive, but wears out considerably faster. For certain applications (like pulse-width modulation) a relay won't work. But, if you want simple on/off control a relay is a good choice.

From a debugging perspective, relays that have an audible "click" are nice. You can listen for the click to know if everything is working up-to and including the relay. An SSR with a status-LED is almost as good but I prefer the "click" so my eyes can be focused on other things (like a monitor).

Would I be correct in assuming that SSRs have opto-isolators built in, and as such don't need additional isolation?

I don't think it's a requirement. If you want / need the isolation you definately want to make certain the SSR includes it.

If using an SSR, where are people getting them?

From Opto 22. But I don't use them with Arduino. I get them for my "day job".

Something important I spotted on another thread...

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1254153622/all#2

The disadvantage with a SSR over a relay is that there is a little current leakage

Less than suggested IME and not a problem normally. However an SSR can drive an octal based relay to switch at least 10 amps. You can switch 50 with a contactor.

For a triac (like BT136) use an optotriac (like MOC3063). You find schematics in the optoriac datasheet.

Just a few points on that first schematic posted.
It is quite a poor circuit:-

  1. Why use all those resistors in series when a 180R would do instead. In fact as it is an LED in the opto isolator any value from 100 to 330R will do.
  2. There is absolutely NO POINT in using an opto isolator if you are going to connect the grounds of both sides together. Either don't do it or don't use an opto isolator.

Just a point from later:-

Would I be correct in assuming that SSRs have opto-isolators built in

Yes all the ones i have seen have opto isolators built in, but just check the data sheet to make sure.

Mike, regarding connecting the grounds together, lemme make sure I understand you. Are you saying that you'd connect grounds on each side of the isolator individually, but then not connect the two sides together?

If I used solid state relays, it appears that they typically have a + and - connection for each side. Assuming there is an opto-isolator built in to the SSR, I don't see how you'd separate the ground on each side of it.

Would it be correct to connect them to a GPIO pin and ground (respectively) on the control side, and then connect the switched side between 120V AC line and the device I'm controlling? I'm looking at a datasheet for an SSR from opto22 and it looks like it's really that simple (current limiting resistor built in for the LED, built-in snubber) - or am I missing something?

Are you saying that you'd connect grounds on each side of the isolator individually, but then not connect the two sides together?

Yes the ground between the arduino and the power of your circuit should not be joined. That is the whole point of an opto isolator to isolate the two circuits. If you do join the grounds then there is little point in having the opto.

it appears that they typically have a + and - connection for each side

Yes some do have other don't, if there is then keep them separate as they are not joined inside.

connect them to a GPIO pin and ground (respectively) on the control side, and then connect the switched side between 120V AC line and the device I'm controlling?

Yes that's how to do it, they should be isolated from each other.

it looks like it's really that simple...... or am I missing something?

No it is that simple, you are paying for it in the price of the SSR. You might be able to make one out of parts for slightly cheaper.

Why would one use an optical isolator to control a relay when a relay already offers isolation of the coil circuit from the contact circuits? I've never seen that done before.

Lefty

The high and low voltage sides aren't completely isolated from each other. While I've never seen it first hand, I know from coworkers that under extreme stress a relay can fail so a molten hot contact falls across the coils introducing high voltage to the low voltage side.

When a life and high voltage are commingled, optical-isolation is sometimes a good idea. Even for relays.

Clearly my understanding is low in this area, but aren't the opto-isolators used here just as much for blocking noise as for providing safety?

but aren't the opto-isolators used here just as much for blocking noise as for providing safety

Basically no. The clue is in the name "optical isolator".

I know from coworkers that under extreme stress a relay can fail so a molten hot contact falls across the coil

No way, the coil is no where near the contacts, someone is either having you on or is really really bad at making stuff.

So, anything we can or should do to help eliminate noise when controlling 120v AC?

I'm wondering because I've seen in some old threads where people doing similar things (building a controller for a fish tank) had "noise problems" from their SSR circuits, but I either didn't see or didn't understand the solution(s).

In my application, the arduino will be in an enclosure several feet away from the relays, which will be built into a powerstrip of sorts.

I think that the right hand side of your circuit is unnecessarily complicated. You can remove the transistor and resistor and place the opto where you now have the transistor. I.e., use the opto directly to switch the relay.

You can (or should) use a separate power supply for the right hand side. That way you'll get real optical isolation, as Grumpy_Mike already emphasised.