45
\$\begingroup\$

Since the advent of the many microcontroller development boards, like Arduino, there have been a number of relay modules sold to drive mains AC loads.

A lot of these seem to use an optocoupler, driver transistor and a relay to drive the load (example on Amazon)

Why are they implemented like this?

Some of my thoughts:

  • Relays provide as good or better isolation than most optocouplers
  • There is still a driver transistor present, so it is not component saving
  • There is still inductive kickback protection, so it is not component saving
  • Optocouplers are not as cheap as transistors, so additional cost compared to just a driver transistor
  • There is no need to meet any regulatory requirements as these are DIY products
  • I have never seen small mains relays driven by optocouplers in commercial equipment
  • A number of these boards don't seem to be designed brilliantly (no regard to clearance or creepage), so even if the optocoupler is simply to provide two layers of isolation, the board fails at this.
\$\endgroup\$
3
  • 10
    \$\begingroup\$ Cargo-cult design? Maybe the designers are copying schematics from each other without thinking about it too much. As you said yourself, they don't seem to be designed well in general. \$\endgroup\$
    – AndrejaKo
    Feb 27, 2013 at 10:17
  • 1
    \$\begingroup\$ 16A@250V is a lot of power and it does seem that the design is pretty naive on a lot of these. \$\endgroup\$ Feb 27, 2013 at 14:31
  • 1
    \$\begingroup\$ Currently, a combination of Kaz and The Photon's answers seem most plausible. Industrial controls could be improved by use of optocouplers, and these hobbyist boards have likely cloned them. \$\endgroup\$ Feb 28, 2013 at 0:38

8 Answers 8

22
\$\begingroup\$

First, a possibly more permanent link to this product is here. And the schematic is here. (Edit 7/29/2015: Ironically my two links are now broken and OP's Amazon link is still useful)

Two reasons it makes sense to use optoisolators here:

  • The controlling device might be very far away so that it doesn't share a common ground reference with the relay board (except as connected through a long cable). Using the optoisolator means the control signal is used purely as a differential signal between Vcc and the control signal, both sourced from the controller circuit; ground potential differences won't affect the operation.

  • The relay coil voltage is not necessarily the same as the controller's Vcc. It could even be generated by an off-line (unisolated) supply. The optoisolator then provides isolation between the potentially unisolated JD-VCC supply and the controller circuits.

\$\endgroup\$
7
  • 1
    \$\begingroup\$ Slightly off topic These exactly same modules go for $2.25 (maybe even less) so the $7.99 link is a bad price. ledsee.com/index.php/arduino-modules2013-02-16-10-32-17/… \$\endgroup\$
    – jippie
    Feb 27, 2013 at 20:29
  • 1
    \$\begingroup\$ I think these are both very valid reasons when needed, and are why most industrial control system inputs will be optoisolated. But my gut feeling is that they sound like rare use cases, especially for hobbyist boards that are <$50. \$\endgroup\$ Feb 27, 2013 at 20:34
  • 2
    \$\begingroup\$ @Cybergibbons, I admit the 2nd one is kind of a stretch. But I think the first would be pretty common...Also I imagine these boards weren't originally designed just to work with Arduinos --- that's just a market they found where they can sell a lot of them --- they could also be used in general industrial controls, etc. \$\endgroup\$
    – The Photon
    Feb 27, 2013 at 21:31
  • 2
    \$\begingroup\$ And in industrial controls you might a have a ground-loop or induced transient problem with a much shorter cable length due to big switching loads etc in the environment. \$\endgroup\$
    – The Photon
    Feb 27, 2013 at 21:33
  • 2
    \$\begingroup\$ @DwayneReid, maybe if you choose the right opto. But generally a transistor is cheaper than an optocoupler, and a low cost optocoupler is likely to have a CTR less than 1.0. \$\endgroup\$
    – The Photon
    Jul 29, 2015 at 16:38
15
\$\begingroup\$

Probably a number or reasons, but the most important being that it will prevent transient voltage from damaging the driving transistor. And depending on the application, it will help prevent AC noise from interfering in the rest of the circuit.

You bring up some good points, however optocouplers are commonly used to isolate components from potentially dangerous outside sources. They are cheap and simple to implement. And they can potentially offer more protection than a diode. And of course, as you pointed out:

A number of these boards don't seem to be designed brilliantly (no regard to clearance or creepage), so even if the optocoupler is simply to provide two layers of isolation, the board fails at this.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Wouldn't a flyback diode be a cheaper way to prevent the transient back EMF damaging the transistor? \$\endgroup\$ Feb 27, 2013 at 14:18
  • 1
    \$\begingroup\$ I think Garrett means from the input side, which I hadn't considered. Most optocouplers can take a wide range of inputs. \$\endgroup\$ Feb 27, 2013 at 14:30
  • 3
    \$\begingroup\$ @Rocketmagnet: The speed at which a relay can switch off will be a function of the amount of reverse voltage that is allowed to appear across it. Using a simple diode across a relay may be effective from a protection standpoint, but will cause the relay to behave "sluggishly". \$\endgroup\$
    – supercat
    Feb 27, 2013 at 16:07
8
\$\begingroup\$

I suspect a big part of the reason has to do with the idea that if there are two isolation barriers, there will continue to be an isolation barrier even if one is accidentally or intentionally bridged. When working with circuits, especially if one is a klutz, one may sometimes briefly short things which really shouldn't be shorted (e.g. because a scope ground clip decides to come undone and flail itself across the board). Adding an extra layer of isolation reduces the likelihood that such an accident will cause significant damage to anything. Most mass-produced products will never be on anyone's workbench, much less a workbench belonging to a klutz, but many home-brew products will spend a great deal of time on such workbenches. Further, home-brew boards are often made without solder mask, greatly increasing the likelihood that of stray ground clip or probe making an unwanted contact.

In addition to providing protection against accidental bridging, if there are two full isolation barriers it may be possible (if one is careful) to bridge one while doing diagnostics involving the other while maintaining an isolation barrier between the two main parts of the system. For example, if one wants to determine the amount of time that elapses between the processor setting an output and a solenoid receiving power, one could start by confirming the relay-coil ground and contact-side ground were isolated, bridging the relay ground and CPU ground, and measuring the time between the CPU output and the relay coil. One could then isolate the relay-coil ground and CPU ground and--after double-checking that they really were isolated, bridge the relay-coil ground and contact-side ground and measure timings between the coil and the things they control. Performing such measurements in a system with only single isolation would probably require having a scope with two probes that were isolated from each other. Such rigs exist, but they're generally expensive.

\$\endgroup\$
6
\$\begingroup\$

Relays actually provide rather poor AC isolation to a VERY noisy source of disturbances- a mechanical contact switching arcing as it switches a load that is inevitably more or less inductive, and often at mains voltage, with dv/dt that can be hundreds of volts per microsecond.

Cheap small relays typically are particularly bad, and making them better tends to make the relay more expensive, bigger and less efficient.

Circuits with multiple inputs and outputs are particularly prone.

When properly employed, an opto can help prevent disturbances caused through coil-contact coupling from affecting circuits.


There is no shortage of examples in this forum of grief from this source (relay plus random resets when loads are switched, for example), and plenty of examples of good robust appliance and industrial designs where optos are used in conjunction with relays.

\$\endgroup\$
4
\$\begingroup\$

A very good reason is to have separate power supplies for the logic and the power interface parts. Logic section is in normal design powered at 5V or 3.3V, and galvanically isolated from the power section, where the most common supply is 24V, so an optocoupler is necessary.

It is true that it can be avoided using a relay with coil rated for 5V, but many relays are not available with this coils, and it would be necessary to have a much higher power on the 5V side, with a bigger DC/DC converter.

It is more common to use the field unregulated supply, 12V or 24V, automotive or industrial (relays do not need a very precise voltage), and a small galvanically isolated DC/DC converter to derive the 5V / 3.3V for just the logic section, so the isolated couplers are necessary.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ There are loads, upon loads of 5V relays to be had. Thousands at Mouser alone. Some of your other points are valid enough, but that paragraph is unnecessary hyperbole. \$\endgroup\$
    – Asmyldof
    May 14, 2016 at 12:02
4
\$\begingroup\$

I suspect that this is just a case of hobbyists who are trying to start a circuit board selling business. They may be complicating their board simply to make it look more complicated, because complication justifies the existence of electronics and appears to add value.

I'm sure if you contact the vendor, they will have a convincing story that their circuit is how it has to be done, and they have it ready-made, the easiest thing is to just buy their board.

Everything you need to control an AC load with a small voltage and current can be found in a single component: a solid state relay like this one.

Any board that can drive 20 mA into an LED can use this, which means that you don't need a special board.

\$\endgroup\$
3
  • 3
    \$\begingroup\$ I like SSRs a lot. They do have downsides - failure mode is often on, and they have a not-insignificant on resistance. \$\endgroup\$ Feb 27, 2013 at 20:35
  • 1
    \$\begingroup\$ SSR product link is broken \$\endgroup\$
    – Birla
    May 7, 2018 at 4:10
  • 1
    \$\begingroup\$ @Birla Looks like the Wayback Machine has a copy; we can band-aid with that a quick fix. \$\endgroup\$
    – Kaz
    May 7, 2018 at 13:04
2
\$\begingroup\$

The most important reason is the coil in the relay is a pretty complex load in the circuit. As we know, a diode is required to protect the circuit from the reverse current inducted from the coil when power off the relay. Some time this method is not enough for a poorly configured power supply, as most DIY modules have. Controllers often get an impulse or even been fired by the relay. I do think if the power supply is robust enough, the optical isolator is not necessary.

\$\endgroup\$
1
\$\begingroup\$

when using A relay most time you will wish to separate the mcu digital GND AND VDD from the relay(s) GND and vcc , then you get very clean mcu GND AND VDD lines .....

if a relay give back EMS , high sharp and fast voltage pick and -- NO - flyback diode and tvs protection . the transistor inside the optocoupler will destroy from relay side , so the main resean , is total separation of gnd , power lines.

if the relay is use for AC it can emit EMC to the circuts from the , GND , VCC , so , optocoupler will solve most of this

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Welcome to EE.SE. Please fix your formatting. \$\endgroup\$
    – winny
    Jun 1, 2018 at 8:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.