Author Topic: Optocoupler sharing GND  (Read 2146 times)

0 Members and 1 Guest are viewing this topic.

Offline mrburnzieTopic starter

  • Regular Contributor
  • *
  • Posts: 139
  • Country: cs
Optocoupler sharing GND
« on: July 02, 2020, 04:31:53 pm »
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?

"Talk is cheap, show me the code"

Anyone need of freelance software/hardware developer, hit me up!
 

Offline wraper

  • Supporter
  • ****
  • Posts: 17952
  • Country: lv
Re: Optocoupler sharing GND
« Reply #1 on: July 02, 2020, 04:38:13 pm »
It is not isolation if there is any connection between both sides.
Quote
What should I do?
Not have connection between optocoupler sides.
 

Offline mrburnzieTopic starter

  • Regular Contributor
  • *
  • Posts: 139
  • Country: cs
"Talk is cheap, show me the code"

Anyone need of freelance software/hardware developer, hit me up!
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15802
  • Country: fr
Re: Optocoupler sharing GND
« Reply #3 on: July 02, 2020, 04:46:46 pm »
This is my schematic. The same GND is used on the LED and the phototransistor side. Is this good for isolating?

It's not.

Just connect the LEDs' cathodes to the ground (reference) of your control signals.
 

Offline mrburnzieTopic starter

  • Regular Contributor
  • *
  • Posts: 139
  • Country: cs
Re: Optocoupler sharing GND
« Reply #4 on: July 02, 2020, 05:19:19 pm »
Can you please clarify?
"Talk is cheap, show me the code"

Anyone need of freelance software/hardware developer, hit me up!
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 9337
  • Country: fi
Re: Optocoupler sharing GND
« Reply #5 on: July 02, 2020, 05:28:36 pm »
The obvious question is, what are you doing?

The very first thing we need to know is do you need isolation or not.
 

Offline mrburnzieTopic starter

  • Regular Contributor
  • *
  • Posts: 139
  • Country: cs
Re: Optocoupler sharing GND
« Reply #6 on: July 02, 2020, 05:32:12 pm »
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.
« Last Edit: July 02, 2020, 05:39:04 pm by mrburnzie »
"Talk is cheap, show me the code"

Anyone need of freelance software/hardware developer, hit me up!
 

Offline Etesla

  • Regular Contributor
  • *
  • Posts: 154
  • Country: us
Re: Optocoupler sharing GND
« Reply #7 on: July 02, 2020, 05:46:33 pm »
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/4009557
to 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.
 

Offline mrburnzieTopic starter

  • Regular Contributor
  • *
  • Posts: 139
  • Country: cs
Re: Optocoupler sharing GND
« Reply #8 on: July 02, 2020, 05:56:48 pm »
To clarify what I have:
https://www.szjunson.com/sale-7589970-steel-smart-cabinet-lock-electric-solenoid-bolt-lock-sense-switch.html

One of these. It has a solenoid and a switch inside.

I have a driver for the solenoid, and the optocoupler part for the switch.
"Talk is cheap, show me the code"

Anyone need of freelance software/hardware developer, hit me up!
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 9337
  • Country: fi
Re: Optocoupler sharing GND
« Reply #9 on: July 02, 2020, 06:15:28 pm »
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.
 

Offline mrburnzieTopic starter

  • Regular Contributor
  • *
  • Posts: 139
  • Country: cs
Re: Optocoupler sharing GND
« Reply #10 on: July 02, 2020, 06:24:35 pm »
Okay, I was never sure when to use isolation when it comes to isolating GPIOs?

3.3V is too low for cables over 5m?
"Talk is cheap, show me the code"

Anyone need of freelance software/hardware developer, hit me up!
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 9337
  • Country: fi
Re: Optocoupler sharing GND
« Reply #11 on: July 02, 2020, 06:44:23 pm »
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 SLOOW
2) 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.
 
The following users thanked this post: mrburnzie

Offline mrburnzieTopic starter

  • Regular Contributor
  • *
  • Posts: 139
  • Country: cs
Re: Optocoupler sharing GND
« Reply #12 on: July 02, 2020, 07:11:19 pm »
Okay, thanks for the clearing it up for me!

"Talk is cheap, show me the code"

Anyone need of freelance software/hardware developer, hit me up!
 

Offline Alex Eisenhut

  • Super Contributor
  • ***
  • Posts: 3550
  • Country: ca
  • Place text here.
Re: Optocoupler sharing GND
« Reply #13 on: July 02, 2020, 08:27:03 pm »
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.
Hoarder of 8-bit Commodore relics and 1960s Tektronix 500-series stuff. Unconventional interior decorator.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf