4
\$\begingroup\$

Often in MCU boards I see optocouplers even when the power supply is the same on both sides. Example:

schematic

simulate this circuit – Schematic created using CircuitLab

Here +3V3 and +12V have the same GND so there is no galvanic isolation between the MCU and the external world.

I guess using an optocoupler is more robust that connecting directly the wire to the MCU, but I wonder if there is a good reason to do that instead of using, say, a BJT or a line driver.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ This simply looks like a bad way of using a photo transistor in place of a plain old BJT. Guessing the BOM was too cheap or something... \$\endgroup\$
    – Lundin
    Mar 2, 2021 at 10:29
  • 1
    \$\begingroup\$ "Often in MCU boards I see", and I don't think I have ever seen it. You should give actual examples (more than one, since you have seen it often), it may be that you are mistaken. \$\endgroup\$
    – pipe
    Mar 3, 2021 at 11:40
  • \$\begingroup\$ Surely the main point here is to isolate the +ve rail - since they have significantly different voltages? \$\endgroup\$
    – MikeB
    Mar 3, 2021 at 15:40

6 Answers 6

8
\$\begingroup\$

No, there is no good reason to use an expensive and large optocoupler if you're sharing ground. The optocoupler's prime advantage is isolation. The common use of this appears to be cargo cult adoption from cheap expansion kits for development boards. You can protect the pin with cheaper discrete components, or multiple "discrete components" integrated into a small package.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Optocouplers are pretty cheap nowadays, at less than 2 cents per piece at medium quantities, comparable with discrete transistors. So calling them "expensive" is an overstatement. \$\endgroup\$
    – jpa
    Mar 3, 2021 at 7:11
  • 1
    \$\begingroup\$ @jpa Cheapest I can see on Digikey is 6c in 4000 quantity. Prebiased BJT, <1c, so 6x price difference. So, relatively expensive, if not absolutely expensive :) \$\endgroup\$
    – awjlogan
    Mar 3, 2021 at 8:51
6
\$\begingroup\$

In that case arguably there is no advantage, except maybe for better protection from transient coming into the driving stage. 99% of the times an opto is used when there is a different ground reference, more than different supply: if the ground is the same a transistor can usefully translate without too much problem.

In your example the long wire designation indicates that there could be ESD, EFT and other stuff coming so the opto helps protecting the MCU, in this case. It could be argued that if the ground is the same maybe discrete protection circuitry could be cheaper. We talking cents here. If speed is not an issue an opto is simply more robust.

\$\endgroup\$
5
\$\begingroup\$

Usually, there is no good reason. But without seeing the PCB routing, there might be some benefits for keeping the MCU ground current path separate from the outside world current path.

Sometimes the reason might simply be that at some point in history somebody made a circuit that was isolated, and then it got copied around and got modified to be non-isolated but still the opto-isolator was left in the circuit because it then requires no further modifications.

Sure it looks cool just because there is a mysterious opto-isolator component so people think it is better and provides more isolation.

And to think of it, it is slightly more robust, as if some event happens that causes catastrophal damage on either LED or transistor, there is a chance that the other half of the chip survives and stops the damage from spreading.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ A catastrophic event on the input of an opto may cause it to effectively fail permanently open, but damage will generally be confined to the LED itself, and the reported state in case of failure will be predictable (reporting that no LED current is present). Whether or not those advantages are useful in all the places people employ optos, there are some where they can offer value even when grounds are connected. \$\endgroup\$
    – supercat
    Mar 2, 2021 at 20:08
4
\$\begingroup\$

In the approach you have described, you are right, the design does not properly exploit the benefits of electrical isolation. The fact that there is a long wire connected to an external switch introduces risk of electrical noise/voltage transients riding the incoming signal. The Optocoupler LED may provide some limited benefits in preventing such transient voltages being passed onto the GPIO of the microcontroller, but in general the effects of strong transients would usually be transferred to the ground circuit and likely effect the microcontroller anyways.

That being said, this approach does secure your microcontroller from low voltage transients(say ~50V) that may have blown a transistor but the optocoupler LED maybe able to survive it.

Overall, this is not a good approach to achieve electrical isolation.

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

My 2 cents. It just shows the ground (negative) for each circuit, usually they would not share that ground. It does NOT show them actually connected and the space between them indicates they are not. But they could be for ease of development or 100 other reasons. In the case of cheap relay cards, its a simple way to switch the coil voltage using pretty much any signal as the LEDs in there turn on with hardly any current. It also makes sense as a lot of common relays use 12 or 24 volts DC. You don't want that getting back to your micro or control circuit. Keep your iron hot and your tip clean ladies and gentlemen. This information is provided purely for entertainment purposes.

\$\endgroup\$
4
  • 2
    \$\begingroup\$ If the grounds were separate they would have different symbols. \$\endgroup\$
    – JRE
    Mar 2, 2021 at 21:34
  • \$\begingroup\$ @JRE 'should' is not the same as 'would'... \$\endgroup\$
    – MikeB
    Mar 3, 2021 at 15:40
  • \$\begingroup\$ Its common to take short cuts and poorly drawn schematics are common. They are different, not connected, however they could be. \$\endgroup\$ Mar 4, 2021 at 2:29
  • \$\begingroup\$ Yeh Mike it could. \$\endgroup\$ Mar 4, 2021 at 2:31
0
\$\begingroup\$

Presumably, the long wire, the resistor, and the switch are not on the MCU board, and are not part circuit that the designer actually designed.

What he produced with the optocoupler is an input that can take a lot of unforseen abuse without propagating damage to the MCU, in combination with some noise immunity provided by the LED's relatively high current draw.

Of course that input could take a lot more abuse if it was tied to a separate ground, but perhaps there are other reasons why that wasn't possible.

\$\endgroup\$
2
  • \$\begingroup\$ Just to be clear: yes, the switch is not on the MCU board but it is part of the system. So the designer knew what he was doing. \$\endgroup\$
    – Mark
    Mar 5, 2021 at 5:31
  • \$\begingroup\$ "perhaps there are other reasons why that wasn't possible" - costs for example? Keeping separate power supplies require DCDC converters are they are quite expensive. Maybe an explanation? \$\endgroup\$
    – Mark
    Mar 5, 2021 at 5:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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