EEVblog Electronics Community Forum
Electronics => Projects, Designs, and Technical Stuff => Topic started by: sgnka 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.
-
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.
-
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 (https://www.ti.com/lit/ds/symlink/amc1100.pdf)
-
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.
-
Do you actually require galvanic isolation? Or do you need it to simply be safe.
-
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
-
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.
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.
-
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.
-
Isolated from what? That's the first question.
-
https://www.eevblog.com/forum/beginners/newbies-please-read-before-posting-24542/ (https://www.eevblog.com/forum/beginners/newbies-please-read-before-posting-24542/)
-
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?
-
...
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?
-
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
-
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/ (https://www.nuvoton.com/products/microcontrollers/8bit-8051-mcus/low-power-mug51-series/)
-
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.
-
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.
-
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.
-
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 (https://uk.rs-online.com/web/c/semiconductors/amplifiers-comparators/isolation-amplifiers/).
-
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.
-
Isolation Amplifier?
https://www.analog.com/en/parametricsearch/11062#/ (https://www.analog.com/en/parametricsearch/11062#/)
-
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.
-
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!
-
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.
-
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 ?
-
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 (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).
-
Have you ever looked into those power metering IC's? They measure(RMS) voltages and current, calculate power and push it through an isolation barrier i a way that is easily readable by an uC.