Author Topic: Isolating analog signal with an optocoupler?  (Read 8699 times)

0 Members and 1 Guest are viewing this topic.

Offline sgnkaTopic starter

  • Contributor
  • Posts: 13
  • Country: us
Isolating analog signal with an optocoupler?
« on: August 12, 2023, 04:36:22 pm »
I have an AC signal (just mains voltage dropped down through a resistor chain) which I need to read on my microcontroller but it needs to be isolated. I'm aware there exist some analog optocouplers IL300 etc. but these are way too expensive for the BOM.

How can this be done with a simple optocoupler like a PC817? Is there a way we can use the transistor within the 817 as a linear   output commensurate with current through its LED?

I've seen optocouplers used for isolated voltage feedback in flyback SMPS circuits along with a TL431. Can that concept be used here?

Thanks.
 

Offline macboy

  • Super Contributor
  • ***
  • Posts: 2322
  • Country: ca
Re: Isolating analog signal with an optocoupler?
« Reply #1 on: August 12, 2023, 04:50:14 pm »
You could use a pair of optocouplers (LEDs in series) and an opamp. One opto will provide local feedback to the opamp in order to linearize the signal. The other will go to the isolated side. Unfortunately this requires power for the opamp on the non isolated side.
 

Offline Kim Christensen

  • Super Contributor
  • ***
  • Posts: 1819
  • Country: ca
Re: Isolating analog signal with an optocoupler?
« Reply #2 on: August 12, 2023, 04:51:38 pm »
You could use a tiny MCU with built in ADC and a simple dropper supply on the AC side, and then send the data digitally via an opto.

EDIT: Or just buy an isolated amplifier chip for a few dollars:
https://www.ti.com/lit/ds/symlink/amc1100.pdf
« Last Edit: August 12, 2023, 05:01:52 pm by Kim Christensen »
 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 15424
  • Country: de
Re: Isolating analog signal with an optocoupler?
« Reply #3 on: August 12, 2023, 04:57:51 pm »
The LED part in optocouplers usually has quite some temperature dependence. The phototransistor is often also a bit nonlinear, though not very temperature sensitive. So the linear OK like the IL300 use 1 LED and 2 photodiodes to compensate for the LED effect. The photodiode parts is usually quite linear and only weakly temperature dependent (would also compensate).

The obvious choice for the problem of reading an AC current with isolation is using a current transformer. For this one may reuse an toroidal inductor(especially current compensated type)  and an added wire for the primary.
 

Offline uer166

  • Super Contributor
  • ***
  • Posts: 1047
  • Country: us
Re: Isolating analog signal with an optocoupler?
« Reply #4 on: August 12, 2023, 06:20:11 pm »
Do you actually require galvanic isolation? Or do you need it to simply be safe.
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 22435
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Isolating analog signal with an optocoupler?
« Reply #5 on: August 12, 2023, 07:56:39 pm »
If you only need an on/off sense, or a few levels (nominal, over, brownout, 120/240...), a comparator (or similar effect by way of biasing the LED, or a few transistors, or an IC proper) can be wired on the mains side.

Optos are useless even for gross accuracy signal coupling (>50% error) because the gain is so unreliable.  Unless you use a linearized one like IL300, indeed (and even then, it's only within about 20% untrimmed).

The preferred solution is a sigma-delta modulator on one side, logic isolator (can be opto, or inductive and capacitive monolithic solutions are common these days), filter (or other demodulator basically).  Bandwidth is limited (it's basically a 1-bit ADC/DAC), though solutions up to a few 100 kHz are available.  More, you might want a proper RF system instead, whether that's direct coupling via transformer (perhaps diplexing bands between a LF opto channel if needed) or modulated on a higher carrier (or lower for that matter; you can make an isolated chop amp, with some cleanup needed around Fsw of course).

There's also the possibility of resistors, which, I forget what the actual rules are, if isolation only needs to be some resistance (megs --> ~uA maximum leakage), or there are additional requirements (galvanic path something or other?).  They need to be rated for transient voltage at the very least (hi-pot and surge).

Tim
« Last Edit: August 12, 2023, 07:59:57 pm by T3sl4co1l »
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 2286
  • Country: au
Re: Isolating analog signal with an optocoupler?
« Reply #6 on: August 12, 2023, 09:19:43 pm »
I have an AC signal (just mains voltage dropped down through a resistor chain) which I need to read on my microcontroller but it needs to be isolated. I'm aware there exist some analog optocouplers IL300 etc. but these are way too expensive for the BOM.
I've seen optocouplers used for isolated voltage feedback in flyback SMPS circuits along with a TL431. Can that concept be used here?
Yes, but that is a single set point.

Quote
How can this be done with a simple optocoupler like a PC817?
Is there a way we can use the transistor within the 817 as a linear output commensurate with current through its LED?
Yes, but the gain and temperature spreads are massive on opto-couplers.

Since this is AC mains, why not simply create a precision zero cross circuit, and you measure the pulse width. (A low current version of TL431 can help here)
Or, you can use a voltage detector + opto to create a current to pulse width generator and MCU looks for smallest pulse width.
The pulse width gives you the amplitude of the sine wave.

 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 6533
  • Country: de
Re: Isolating analog signal with an optocoupler?
« Reply #7 on: August 12, 2023, 09:32:37 pm »
As the OP does not state what is to be measured, this is a guessing contest.
Presence of AC?
Voltage of AC?
Waveshape of AC?
etc., etc.

 
The following users thanked this post: thm_w

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 16243
  • Country: fr
Re: Isolating analog signal with an optocoupler?
« Reply #8 on: August 12, 2023, 09:40:55 pm »
Isolated from what? That's the first question.
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 6533
  • Country: de
 

Offline Terry Bites

  • Super Contributor
  • ***
  • Posts: 2663
  • Country: gb
  • Recovering Electrical Engineer
Re: Isolating analog signal with an optocoupler?
« Reply #10 on: August 12, 2023, 10:10:03 pm »
Is your application sensing or measuring a signal or both?
A small transformer is a simple and safe solution. It could even be a home brew CTR.
If you go down the linear isolation route you need an iso power supply on the hot side. That can be very inconvenient.
Consider using isolated ADCs and digital isolation, its chepaer to implement than a decent linear iso amp. (Last time buy on that front now).

OMG. IL300s and their kin. Too far much addon circuitry and assorted power supplies for my liking!
ACPL-7900 anyone. Hall or GMR current sense?


 

Offline Tomorokoshi

  • Super Contributor
  • ***
  • Posts: 1212
  • Country: us
Re: Isolating analog signal with an optocoupler?
« Reply #11 on: August 12, 2023, 10:12:44 pm »
...
I'm aware there exist some analog optocouplers IL300 etc. but these are way too expensive for the BOM.
...

In addition to all the other comments and questions brought up here:

1. Who set the requirements for isolated measurement of AC power line voltage?
    1. How necessary is it to the design?
    2. Which standards will apply to the design?

2. Who set the requirements for the itemized BOM cost?
    1. What percentage of the target BOM is an IL300?

3. How is engineering amortized across the production run?
    1. Is it worth it to design your own when you can buy a solution?
    2. Are you confident you can design your own within the schedule?
 

Offline jonpaul

  • Super Contributor
  • ***
  • Posts: 3730
  • Country: fr
  • Analog, magnetics, Power, HV, Audio, Cinema
    • IEEE Spectrum
Re: Isolating analog signal with an optocoupler?
« Reply #12 on: August 13, 2023, 01:34:24 am »
1:1 120/240 isolation transforer for voltage

CT for current

Low cost, passive exact ratios.

Opts are inherenty non linear and CTR changes with time.

Typical limits are +200% -50% CTR

Jon
The Internet Dinosaur..
passionate about analog electronics since 1950s
 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 2286
  • Country: au
Re: Isolating analog signal with an optocoupler?
« Reply #13 on: August 13, 2023, 03:08:15 am »
You could use a tiny MCU with built in ADC and a simple dropper supply on the AC side, and then send the data digitally via an opto.
With the low prices of small MCUs that's a valid idea, but it needs care to pick a small MCU that can start from low energy, or a small MCU plus a power pulse scheme.

Nuvoton have released a MCU that is designed for energy harvesting type power, with a spec'd 200uA max startup.
https://www.nuvoton.com/products/microcontrollers/8bit-8051-mcus/low-power-mug51-series/
 

Offline schmitt trigger

  • Super Contributor
  • ***
  • Posts: 2500
  • Country: mx
Re: Isolating analog signal with an optocoupler?
« Reply #14 on: August 13, 2023, 03:45:51 am »
Some times the simplest is the optimal solution.
Like someone already mentioned, a small steel core transformer, 230/115 volts primary and 6.3 volts secondary, which should be completely unloaded, save for the resistor divider to accommodate the microcontroller’s input range.

It will have a couple of degrees of phase error, which should be of no consequence if only the voltage’s magnitude is to be measured.
 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 2286
  • Country: au
Re: Isolating analog signal with an optocoupler?
« Reply #15 on: August 13, 2023, 06:09:49 am »
Some times the simplest is the optimal solution.
Like someone already mentioned, a small steel core transformer, 230/115 volts primary and 6.3 volts secondary, which should be completely unloaded, save for the resistor divider to accommodate the microcontroller’s input range.

It will have a couple of degrees of phase error, which should be of no consequence if only the voltage’s magnitude is to be measured.
:) 'Simplest' is relative.   ???
Yes, it is 'one component', but what a heavy, bulky, expensive and non-automation friendly 'single part' that steel core transformer is !

 In contrast, SMD opto couplers start from  about 2c/200+ at lcsc, and can be pick and placed.
 

Offline gnuarm

  • Super Contributor
  • ***
  • Posts: 2247
  • Country: pr
Re: Isolating analog signal with an optocoupler?
« Reply #16 on: August 13, 2023, 07:06:37 am »
Some times the simplest is the optimal solution.
Like someone already mentioned, a small steel core transformer, 230/115 volts primary and 6.3 volts secondary, which should be completely unloaded, save for the resistor divider to accommodate the microcontroller’s input range.

It will have a couple of degrees of phase error, which should be of no consequence if only the voltage’s magnitude is to be measured.
:) 'Simplest' is relative.   ???
Yes, it is 'one component', but what a heavy, bulky, expensive and non-automation friendly 'single part' that steel core transformer is !

 In contrast, SMD opto couplers start from  about 2c/200+ at lcsc, and can be pick and placed.

But they don't provide much more than on/off type of information. 

As others have pointed out, the problem is not well specified.  I don't see where the OP has returned to provide any more information.  But, his original post does ask or a "linear" response.  That's what Sherlock Holmes calls a clue.

As many others have said, it is hard to get a linear response through an optocoupler... very hard.  But in many cases, the resistor chain he is currently using can be adequate.  If the requirement is for safety, the resistor chain can use a very large resistor to provide adequate isolation.  If that drops the voltage too much, an op amp can be used to restore the proper value to match the ADC.  But there's many a slip between cup and lip.   Much more info is required.
Rick C.  --  Puerto Rico is not a country... It's part of the USA
  - Get 1,000 miles of free Supercharging
  - Tesla referral code - https://ts.la/richard11209
 

Online DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6529
  • Country: es
Re: Isolating analog signal with an optocoupler?
« Reply #17 on: August 13, 2023, 07:12:08 am »
Optocopuplers have bad current transfer linearity, i.e. don't expect to have the double at the output when supplying 2x current to the led.
If you require precision either - A transfer digital pulses (You'll need a fast optocopupler) or B - Use an isolated op-amp.
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 2286
  • Country: au
Re: Isolating analog signal with an optocoupler?
« Reply #18 on: August 13, 2023, 07:18:58 am »
As others have pointed out, the problem is not well specified.  I don't see where the OP has returned to provide any more information.  But, his original post does ask or a "linear" response.  That's what Sherlock Holmes calls a clue.

As many others have said, it is hard to get a linear response through an optocoupler... very hard.
Of course, that's why I suggested a pulsed approach, simple parts can take the voltage and deliver a pulse thru the optocoupler.
The OP did not say if they wanted Zero-Cross and voltage measurement, so I've focused on voltage measurement.
 

Offline Smokey

  • Super Contributor
  • ***
  • Posts: 3285
  • Country: us
  • Not An Expert
Re: Isolating analog signal with an optocoupler?
« Reply #19 on: August 13, 2023, 07:30:47 am »
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 4043
  • Country: nl
Re: Isolating analog signal with an optocoupler?
« Reply #20 on: August 13, 2023, 11:14:18 am »
A problem with opto isolators is that their transfer characteristic is not very lineair, and it may also drift a lot with temperature.

The power supplies with TL431 and an opto solve this by not providing a direct feedback of the output voltage, but they feed back a digital signal of the time when the TL431 has detected an output voltage that is high enough.

And you can do something similar. Voltage to frequency converters were quite common at some time, and you can also make a voltage to PWM duty cycle by comparing the analog voltage with a triangle waveform. But all these solutions require a fair bit of extra circuitry. In these modern times it makes more sense to just uses some microcontroller with ADC and then send some uart signal through an optocoupler (uart only needs one optocoupler)

There are also "standard solution" for galvanic isolation of I2C. It's more complicated, but also more integrated into some IC so the complication does not have to bother you so much.

And of course you can also just buy the whole thing. Signal isolators are quite common in industrial applications and you can buy readily made modules inclusive a housing that fits on a DIN rail and screw connectors, and from Ali / Ebay they are not very expensive.
 

Offline sgnkaTopic starter

  • Contributor
  • Posts: 13
  • Country: us
Re: Isolating analog signal with an optocoupler?
« Reply #21 on: August 14, 2023, 07:44:45 pm »
My apologies, guys. I've been away for a bit, and I see that my post left out key info.
Yes - the requirement is to get the voltage of the AC mains but on the secondary side of the optocoupler.
It doesn't have to be super accurate, so I think I'll go with measuring the width of the pulse on the secondary side of the opto and try estimating the amplitude.
Thanks!
 

Offline uer166

  • Super Contributor
  • ***
  • Posts: 1047
  • Country: us
Re: Isolating analog signal with an optocoupler?
« Reply #22 on: August 14, 2023, 09:11:39 pm »
I'll ask again, do you need galvanic isolation or not? If you are okay tying your MCU reference to protective earth, just use appropriately sized resistor dividers from the mains to your MCU. That can be considered reinforced isolation in the safety context.

You have to watch for max allowed leakage and number of resistors (something like 5-8 1206 packages at 1.6MOhm is what I use). It is simultaneously the simplest, cheapest, and depending on ADC the most accurate solution. The only downside is having to reference your MCU to protective earth, but that happens automatically anyway if you connect your MCU to a PC for example.
 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 2286
  • Country: au
Re: Isolating analog signal with an optocoupler?
« Reply #23 on: August 14, 2023, 10:22:03 pm »
My apologies, guys. I've been away for a bit, and I see that my post left out key info.
Yes - the requirement is to get the voltage of the AC mains but on the secondary side of the optocoupler.
It doesn't have to be super accurate, so I think I'll go with measuring the width of the pulse on the secondary side of the opto and try estimating the amplitude.
Thanks!
That's what I understood.
See attached simple dual-slope voltage to pulse opto design, that gives zero cross and mains voltage in pulse width.
CAP charges to voltage determined by mains, and discharges at somewhat regulated ~500uA so dT is proportional to mains voltage.

Precision is determined by the current accuracy : mains resistors ratios. 
C1 value is less critical, but don't use something terrible. Start with a film capacitor.
addit : Possibly something like  GRM31C5C1H104JA01L COG 100nF 50V 5% 1206 1.8mmT  ~7c/500 at lcsc

PSSI2021SAY claims typ 0.15 %/K, not sure I believe that ? (0.3% is more typical) 
You may want to test some variants, if temperature stability is important, or measure temperature in your MCU and do some simple correction ?

« Last Edit: August 14, 2023, 10:37:07 pm by PCB.Wiz »
 

Offline uer166

  • Super Contributor
  • ***
  • Posts: 1047
  • Country: us
Re: Isolating analog signal with an optocoupler?
« Reply #24 on: August 15, 2023, 12:01:02 am »
Some times the simplest is the optimal solution.
Like someone already mentioned, a small steel core transformer, 230/115 volts primary and 6.3 volts secondary, which should be completely unloaded, save for the resistor divider to accommodate the microcontroller’s input range.

It will have a couple of degrees of phase error, which should be of no consequence if only the voltage’s magnitude is to be measured.
:) 'Simplest' is relative.   ???
Yes, it is 'one component', but what a heavy, bulky, expensive and non-automation friendly 'single part' that steel core transformer is !

 In contrast, SMD opto couplers start from  about 2c/200+ at lcsc, and can be pick and placed.

That's why you don't use a voltage transformer to measure mains voltage. By requiring full mains on the primary the volt-second requirement pushes the size up. You can't measure voltage directly with an opto without bending over backwards with S-D modulation etc.. If you need galvanic isolation use a current transformer instead, such as https://www.lcsc.com/product-detail/Current-Transformers_ZHE-MING-LANG-XI-ZMPT107-1_C125191.html designed specifically to measure mains voltage. You have to do a voltage->current conversion via a resistor chain, pass that through CT, and convert the current back to voltage via a burden resistance. This is pretty accurate and cheap (33 cents for linked part).
 
The following users thanked this post: ledtester, BrianHG


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf