Author Topic: Optocoupler with floating wire  (Read 2013 times)

0 Members and 1 Guest are viewing this topic.

Offline crgarciaTopic starter

  • Regular Contributor
  • *
  • Posts: 67
  • Country: ar
Optocoupler with floating wire
« on: June 19, 2022, 09:32:05 pm »
I am making a PCB that inputs the output of a latching relay to detect if this one is on or off.
1516738-0

To detect mains, I'm using this circuit:
1516732-1

the AC optocoupler is an LDA210: datasheet

The problem is that sometimes it detects mains when there is no. I was thinking that this could be because the wire is "floating" when the relay is off.
The optocouplers have an average CTR of 8500%, which it might make them too sensitive.

What can I do to make this more stable when the relay is off?
Would it help if I use larger resistors instead of the 300k ones?
I guess I cannot pull-down the mains wire [/size] ::)

Full project url: https://github.com/crgarcia12/electronics-homeassistant-lightscontroll



« Last Edit: June 19, 2022, 09:33:39 pm by crgarcia »
 

Online Benta

  • Super Contributor
  • ***
  • Posts: 7179
  • Country: de
Re: Optocoupler with floating wire
« Reply #1 on: June 19, 2022, 09:49:12 pm »
It would probably help more if you placed the 100n caps across the LEDs. And why use an obsolete coupler?
What's the purpose of the 4u7 caps?
« Last Edit: June 19, 2022, 09:52:24 pm by Benta »
 
The following users thanked this post: crgarcia

Offline ejeffrey

  • Super Contributor
  • ***
  • Posts: 4849
  • Country: us
Re: Optocoupler with floating wire
« Reply #2 on: June 19, 2022, 09:55:15 pm »
If that CTR is accurate that circuit will turn on with as little as 1-2 volts on the AC line, or with just a few microamps leakage current, easily picked up by capacitive coupling or AM radio reception.  Increasing the 300k resistor wont necessarily help if the interference is capacitive coupling.  Instead I would reduce the 10k resistor on the receiver to a smaller number and add a line to neutral capacitor on the input to shunt away high impedance capacitive coupling or antenna behavior  make sure to use a line to neutral rated capacitor.
 
The following users thanked this post: crgarcia

Online Benta

  • Super Contributor
  • ***
  • Posts: 7179
  • Country: de
Re: Optocoupler with floating wire
« Reply #3 on: June 19, 2022, 10:00:43 pm »
If that CTR is accurate that circuit will turn on with as little as 1-2 volts on the AC line

Minimum CTR is 300%, so it's not.
 
The following users thanked this post: crgarcia

Offline crgarciaTopic starter

  • Regular Contributor
  • *
  • Posts: 67
  • Country: ar
Re: Optocoupler with floating wire
« Reply #4 on: June 19, 2022, 11:43:09 pm »
It would probably help more if you placed the 100n caps across the LEDs. And why use an obsolete coupler?
What's the purpose of the 4u7 caps?

The 4u7 are there to smooth the AC wave so that the ESP detects a constant LOW. In the other hand, I didn't really know how to properly calculate the right value of the caps, so I did some simulations with fastlab and it looked like that value would smooth the curve and "turn on" would be fast enough (simu link)

Why would the caps in the LED size would be better? I tried to put as little things as possible in that side because it's mains

Did not know the opto was obsolete  :'(

If that CTR is accurate that circuit will turn on with as little as 1-2 volts on the AC line, or with just a few microamps leakage current, easily picked up by capacitive coupling or AM radio reception.  Increasing the 300k resistor wont necessarily help if the interference is capacitive coupling.  Instead I would reduce the 10k resistor on the receiver to a smaller number and add a line to neutral capacitor on the input to shunt away high impedance capacitive coupling or antenna behavior  make sure to use a line to neutral rated capacitor.

The typical CTR is 8500, the minimum is 300. I tried the circuit with 1.1MΩ and still worked, so it's pretty high.

Since I have those resistors, the V across the Led is 1.7V. Can I place the cap just before the optocoupler (after the resistors) and use a low V SMD cap? I don't have too much space left in that PCB

What value of Capacitor could I use for that? Or any hints on how to calculate it?


Thank you both!
« Last Edit: June 20, 2022, 06:16:59 am by crgarcia »
 

Online Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 5372
  • Country: nl
Re: Optocoupler with floating wire
« Reply #5 on: June 21, 2022, 05:15:30 pm »
With mains and other similar voltage, you always have to be careful about the voltage rating of your parts. With a 230Vac (rms) you already have 310V peak, and voltage surges can be much higher, and your parts have to be able to withstand those without failure. Old fashioned "regular" 1/4W THT resistor are normally limited to a working voltage somewhere between 100V and 200V, and SMT resistors (especially the smaller ones) are rated for even smaller voltages. So you have to use "special" resistors, or put multiple of them in series to get to be able to use them for high enough voltages.

If the minimum CTR of your opto is 300, and the typical is 8500, then what do you design for?
For how many of your products do you find it acceptable to fail after they have been put on the pcb, put into an enclosure and shipped to customers? (That is quite something different then a single prototype "working" on your bench.
Opto couplers also do not age well, and the CTR is expected to get lower over time.

Your optocoupler has a 3pF capacitance, and this could be a path for erroneous measurements.
Once you use proper resistors on the primary side (those are safety critical) you can put a simple low voltage capacitor directly over the optocoupler LEDs (These limit the capacitor voltage to about 1V anyway). Short peaks may go right by your big electrolytics, and ceramic capacitors are much better at filtering high frequency stuff.

Alternatively, maybe you can do some filtering in software, quite similar to debouncing mechanical switches, but you can start by measuring (ether with an oscilloscope and/or with your ESP32 itself) what sort of durations you get for the pulse widths.

 
The following users thanked this post: crgarcia

Offline crgarciaTopic starter

  • Regular Contributor
  • *
  • Posts: 67
  • Country: ar
Re: Optocoupler with floating wire
« Reply #6 on: June 22, 2022, 05:31:29 am »
Exactly as you say Doctorandus_P

Now I have the device for 4 days working in my bench and it has no issues at all. Even when this is something I am not going to sell or ship, and just use at home, I would really like to make it safe and reliable

In terms of safety, I am using first a 80mA fuse and then two 1W 2512 series resistors RMCF2512FT150K (datasheet). They are rated for 200V/400V peak (the max I could find)

1518658-0

I tried to calculate for 300% and with a margin:

1518664-1

It seems there is consensus that to give stability, I need a capacitor at the led side:
 How can I calculate the Farad of the capacitor that I need?
 Are there other things beside Voltage and Farad that I need to take into consideration?

Thank you!

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->