Optocoupler sharing GND  - Page 1
Forum section: electronics / projects

author: mrburnzie
author_rank: Regular Contributor
timestamp: July 02, 2020, 04:31:53 pm
content: Hi everyone!I'm trying to isolate my 12V switches. I'm using an optocoupler TLP291 (4 channel).The same 12V powersupply is powering the board (with a 3.3V regulator) and the switches.This is my schematic. The same GND is used on the LED and the phototransistor side. Is this good for isolating? (I guess not)All the time I'm seeing optocouplers used in situations where the GND are NOT the same.What should I do? Any suggestions?

author: wraper
author_rank: Unknown
timestamp: July 02, 2020, 04:38:13 pm
content: It is not isolation if there is any connection between both sides.QuoteNot have connection between optocoupler sides.

author: mrburnzie
author_rank: Regular Contributor
timestamp: July 02, 2020, 04:43:02 pm
content: https://www.allaboutcircuits.com/projects/how-to-eliminate-ground-loops-with-signal-isolation/Something like this?

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 02, 2020, 04:46:46 pm
content: Quote from: mrburnzie on July 02, 2020, 04:31:53 pmIt's not.Just connect the LEDs' cathodes to the ground (reference) of your control signals.

author: mrburnzie
author_rank: Regular Contributor
timestamp: July 02, 2020, 05:19:19 pm
content: Can you please clarify?

author: Siwastaja
author_rank: Super Contributor
timestamp: July 02, 2020, 05:28:36 pm
content: The obvious question is, what are you doing?The very first thing we need to know is do you need isolation or not.

author: mrburnzie
author_rank: Regular Contributor
timestamp: July 02, 2020, 05:32:12 pm
content: I have 60 switches mounted on my box, that is inside a lock mechanism (a solenoid). The switch is basically detecting if the lock is open or closed. Its inside the lock and its a microswitch.

author: Etesla
author_rank: Regular Contributor
timestamp: July 02, 2020, 05:46:33 pm
content: I think most of us still don't know what you're actually trying to isolate.In general isolation implies that you have two totally different circuit with ZERO WIRES OR RESISTORS connecting them together.The main problem you run into is that you want your circuit to have only one power supply, yet to have two totally different circuits with two totally different grounds and zero wires connecting them, you need two power supplies.There are a bunch of ways around this. A common but pretty expensive approach is to use something like this:https://www.digikey.com/product-detail/en/cui-inc/PDS1-S12-S12-M-TR/102-2680-1-ND/4009557to get a new isolated 12V supply from your existing 12V supply. If its just a one off, you could also just use two power supplies to begin with if you had them lying around.

author: mrburnzie
author_rank: Regular Contributor
timestamp: July 02, 2020, 05:56:48 pm
content: To clarify what I have:https://www.szjunson.com/sale-7589970-steel-smart-cabinet-lock-electric-solenoid-bolt-lock-sense-switch.htmlOne of these. It has a solenoid and a switch inside.I have a driver for the solenoid, and the optocoupler part for the switch.

author: Siwastaja
author_rank: Super Contributor
timestamp: July 02, 2020, 06:15:28 pm
content: I don't see a point in optoisolating switches, unless there is a risk that the switches would somehow accidentally connect to power sources.Just remove that excess circuitry. If you are connecting switches to MCU pins, just connect switches between IO and ground, and add pullup resistors to the pins. Internal pull-ups configurable from the MCU are likely good for the job.Adding a series resistor (order of magnitude smaller than pullups) and a small capacitor say 10-100nF between the input pin and ground protects from ESD and noise.

author: mrburnzie
author_rank: Regular Contributor
timestamp: July 02, 2020, 06:24:35 pm
content: Okay, I was never sure when to use isolation when it comes to isolating GPIOs?3.3V is too low for cables over 5m?

author: Siwastaja
author_rank: Super Contributor
timestamp: July 02, 2020, 06:44:23 pm
content: Such long cables increase the risk of electromagnetic interference; I would just deal with it with RC filtering (the capacitors I mentioned in my previous post).Like 4.7kOhm pull-up first, after the pull-up a 1kOhm series resistor, then a 100nF capacitor to ground."Filtering the shit out of it" works because with mechanical switches, you don't need quick response. A 1kOhm + 100nF filter has approximately the response time of R * C = 1k * 100n seconds = 100 microseconds.Others may recommend heavier solutions. One of them is optoisolation. Optoisolation gives some robustness against EMI for two reasons not related to the isolation itself:1) They are SLOOW2) The LED requires quite some actual current to drive. A small inducted current cannot make it light.Isolation is nice, but note that you need a power supply so that current can flow through the switches, to the LEDs in the optoisolators. And to keep the sides isolated, this power supply needs to be isolated. Cheapish isolated DC/DC modules exist for this reason.

author: mrburnzie
author_rank: Regular Contributor
timestamp: July 02, 2020, 07:11:19 pm
content: Okay, thanks for the clearing it up for me!

author: Alex Eisenhut
author_rank: Super Contributor
timestamp: July 02, 2020, 08:27:03 pm
content: And just be careful in the future, if you do use opto-isolators: those ground symbols you are using probably connect to the same netlist internally to your tool. Just because you drew them on an opto-isolator and you don't see a wire, the tool won't care what you meant and will connect them all together when it comes time to make a netlist.Then you will have a connection to both sides on the PCB if you ever go to a PCB.And in any case, you should use two different ground symbols with two distinct names to be unambiguous.Usually I use "CGND" for "chassis" ground for the "dirty" stuff, ie outside of my circuit.