8
\$\begingroup\$

I've "scanned" through all possible combinations of values for the current-limiting resistor for the LED input of the CNY17-4 optocoupler, as well as the output pull-up. At 25 kHz, I couldn't achieve a clean square wave with any combination. I tried with a BS170 gate as a load, as well as with no load. This, however, has no effect.

In all cases the best I can achieve is either a sufficiently square wave that is however very asymmetrical (despite a 50% MCU-generated PWM signal), or I can make it symmetrical, but then both the rising and falling edges are visibly curved and shaped like fins.

Am I doing something wrong, or is it inherently impossible to achieve a clean square wave output at 25 kHz or higher, without adding more complexity in terms of additional successive components that modify/shape the signal?

I know there are finished high-speed optocoupler components, but I'm wondering if a general-purpose one can achieve this, and if yes, what would the simplest additional circuitry (using discrete components), be in order to sufficiently "clean" the output? Would a push-pull or a Schmitt-trigger suffice?

\$\endgroup\$
6
  • 1
    \$\begingroup\$ The simplest thing to clean up a poor square wave would be an inverter. Schmitt input inverter if you want it extra-clean. \$\endgroup\$
    – Hearth
    Dec 30, 2022 at 18:38
  • 1
    \$\begingroup\$ Adding a schematic of what you did should be interesting. Thanks. \$\endgroup\$
    – Antonio51
    Dec 30, 2022 at 19:28
  • \$\begingroup\$ @Hearth: What do you mean by inverter? A p+n mosfet? that has even more gate capacitance than a single bs170 and due to the poor current it spends too much time in no man's land hence heats up quickly at 25kHz \$\endgroup\$
    – mo FEAR
    Dec 30, 2022 at 20:10
  • 1
    \$\begingroup\$ @moFEAR I'm just thinking of a logic inverter. A 74HC series inverter would work. \$\endgroup\$
    – Hearth
    Dec 30, 2022 at 20:53
  • \$\begingroup\$ Could you put a PWM chip on the other side of the isolation? I2C optocoupler separation - which IC? has a few suggestions. \$\endgroup\$ Dec 31, 2022 at 15:53

5 Answers 5

6
\$\begingroup\$

First, understand what an optoisolator is doing. Or, how.

A traditional IR LED + phototransistor isolator is akin to a photodiode in parallel with B-C. The photocurrent draws some load current by itself, which flows into the B-E junction, multiplying by hFE, and then the collector carries the bulk of load current. Current flows C-E (or I suppose you could reverse it and go E-C, at some penalty to inverted hFE, among other details), and the diode's full capacitance is present as Miller capacitance. (That is, for the C-E voltage to change, this capacitor must be dis/charged by base (input!) current.) Finally, the fT of the phototransistor itself tends to be rather low.

All this, together, means that using it as a saturated switch, gives rather poor results:

  • To get reliable switching operation, we need to choose IF high enough that, at minimum CTR, IC(sat) is still adequate to switch the load current.
  • Normally, the CTR range is rather grotesque (ungraded types typically span 50-300%!), so we need to run pretty high IF to be sure the output will switch.
  • High IF means relatively high injected base [photo]current, when the part in question happens to have high CTR. Which means large B-E storage charge, which can only discharge through its own current flow (recombination). This can take 10 or 20µs.
  • Conversely, if CTR is low, maybe the on and off delays are fairly symmetrical after all. It's not easy to control.
  • The rising and falling slopes are limited by photocurrent, capacitance, and voltage swing (Miller effect).

To be clear, storage time is where the transistor was driven into low VCE (saturation), by application of excess IB so as to force some hFE(sat), typically 10 or so. The B-E charge looks like recovery of any PN diode, i.e. charge has to be removed from the junction before it turns off. If left to self-discharge*, it takes quite long. This period can be shortened by discharging the base externally. Typically a B-E resistor is used, sized for 10-100% of IB(on). (Which, just to hint at the perpetual argument of "are transistors charge-controlled or not", this is very much like the gate charge of a MOSFET -- it just happens that BJTs draw base current too, enough that they can be used as current amplifiers, at least within a certain scope.)

*Like a battery being discharged, which is actually no accident; very similar physics underly both phenomena. Just... an extremely small battery, a ~0.7V potential, holding some ~nC charge, with a self-discharge lifetime of ~10µs. That's pretty damn fast for a battery, but still an eternity for some electronic circuits.

About CTR: mind that, just because you've selected a tight bin, doesn't mean it will hold over time. Indeed, the LED ages, slowly but surely. See: ANO006 Lifetime of Optocouplers - Würth Elektronik


So what can we do? The above explanation hints at some likely options:

  • Choose a narrow CTR bin so that operation can be optimized better to start.
  • Run at as high IF and IC as possible, given operating temperature and design lifetime. (Lower CTR is probably preferable here; actually, I don't know offhand how well this trades off in phototransistors specifically, but it's generally the case that high gain means high Miller effect. Can anyone support this?)
  • Reduce the output voltage swing, and especially prevent saturation.
  • Discharge the base current if possible.

The last two are frequently seen; indeed, take close note of the conditions in your selected part: CNY17 Datasheet - Vishay page 3, "linear operation" shows RL = 75Ω, and quite reasonable switching rates (well, reasonable in comparison to what you were seeing!). But if CTR = 100% and IF = 10mA, that's 10mA into 75Ω or a mere 750mV output signal! You will need a comparator to convert that to a meaningful digital level. (Or perhaps another BJT, with a bit of level shifting -- Δ200mV is enough to get reasonable switching from a common-emitter stage, at least if the temperature range isn't too demanding, so 750mV would be more than enough. It will need a little biasing.)

The other way to keep voltage swing small, is to cascode the phototransistor. That is, the emitter is grounded, and the collector feeds the emitter of another BJT (which is common-base). This can get close to digital logic levels as such, or a folded cascode (the common-base transistor is complementary i.e. PNP) can deliver a bit less than full supply swing.

Since the CNY17 provides the base pin, we can even implement the last item -- but be careful, because this dramatically reduces CTR! Typically 47-100k of B-E resistance is about all that's reasonable, reducing CTR to maybe 10 or 20% while improving switching times to single µs range.

The final** alternative is to not use a phototransistor at all. As mentioned, many of the shortcomings are intrinsic to it -- it needs enough area to gather the incident light, but this simultaneously increases capacitance. And the base can't have low resistance because any wiring placed on it will block light.

Instead, we can use a photodiode, and run its current into a regular BJT. The diode can then be biased from a fixed supply, doing double duty: the bias voltage reduces its capacitance (junction capacitance drops with increasing reverse bias voltage), and the fixed supply disconnects it from Miller effect. Dramatic improvement!

Isolators like 6N136 and SFH6345 use this approach. The CTR is fairly low after all (min. 15%), but it's far faster, and doesn't suffer nearly as much from a wide voltage swing, i.e. you get reasonable logic levels just with a pull-up resistor. These are suitable for USART communications, medium speed SPI, isolated gate drivers, etc. (Beware: 6N136 is terrifically noise-sensitive. Notice most datasheets give the common mode immunity for a 10V step, whereas others do it for 100 or 1000V. The dV/dt is essentially irrelevant, they don't even test at enough signal level to upset anything in the first place. SFH6345 however has improved shielding and discards the base pin, giving it excellent immunity.)

There are also fully digital types, like 6N137, which dispense with all analog design responsibilities: just wire it up with suitable voltages and currents, and it either works or it doesn't.

**There are some interesting tricks we can play with the three-terminal phototransistor. I once constructed a TIA (transimpedance amplifier) using it as the combined signal source and input amplifier; the feedback path effectively compensates for the photocurrent (holding the transistor's current and therefore transconductance stable), and some cascoding keeps the transistor's voltage swing minimal. I got a solid 600kHz or so bandwidth, with quite reasonable linearity; presumably it could've been compensated even higher as the response was dominant single pole, though I didn't see an obvious way to do that at the time. (For what it's worth, LEDs are good up to 10MHz or so; the phototransistor is by far the limitation here.) But this is pretty much a curiosity; the other options are much faster and cheaper.


As for non-optical solutions -- you may find them preferable. Several technologies are used today: magnetic coupling (yes, tiny transformers embedded on-chip!) such as Analog Devices and Silicon Labs; capacitive coupling such as TI; and others using these or similar methods. These can be pricey (ADuMxxxx can be over $5), but they also offer multiple channels per part. Meanwhile, optos can run $1/each pretty easily, when you need the better performing types; it adds up. The bandwidth can be much higher (over 50Mbps is available). Other differentiators may include fail-safe logic (i.e., output goes to default level when input powers down; or upset prevention, I've only seen AD detail this feature but I don't know about others). EMI is a potential downside, as these work by communicating in short, very high frequency pulses (since the capacitors or transformers are very small); they're generally fine under commercial limits, but it's something to be aware of.

Conversely, if you need really high isolation, optics may be your method of choice once again -- using fiber optics instead. Fiber provides extremely high isolation: it's the method of choice for equipment such as MV motor drives and HVDC link inverters. Using modulated lasers, it's suitable out to extremely high bandwidths as well (hence the medium of choice for long distance communication).

\$\endgroup\$
3
  • 4
    \$\begingroup\$ I upvoted this. I don't know why it was downvoted, except possibly "TL;DR" ;) \$\endgroup\$
    – PStechPaul
    Dec 30, 2022 at 22:34
  • \$\begingroup\$ Thanks @PStechPaul. Constructive criticism is welcome! \$\endgroup\$ Dec 31, 2022 at 0:02
  • \$\begingroup\$ @Tim Williams: TL; and too general, but did read it. The Würth report regarding the lifetime was interesting! \$\endgroup\$
    – datenheim
    Jan 1, 2023 at 17:19
6
\$\begingroup\$

Does a general purpose optocoupler such as CNY17-4 support clean 25kHz PWM?

Hardly any simple opto-coupler supports decent pulse width accuracy. The rise and fall times are usually quite asymmetrical and, will vary with temperature.

I'm wondering if a general purpose one can achieve this

If you want accuracy and repeatability then you might be wasting your time with a single general-purpose opto-isolator.

Would a push-pull or Schmidt-trigger suffice?

There are pretty decent (and more complex) optically coupled devices that get a lot closer than a simple opto-coupler but, there will always be a small duty cycle error compounded by variable rise and fall times with temperature.

The best method that I've come across is to use two opto-couplers; one dealing with the positive edge and the other dealing with the negative edge. The outputs of both are combined (such as) using a fast D type flip flop to recover the original waveform with decent fidelity duty cycle.

A similar method is also used with magnetic couplers of data such as Analog Devices' ADuMxxxx digital isolation technology.

\$\endgroup\$
0
4
\$\begingroup\$

At 25kHz, I couldn't achieve a clean square wave with any combination.

With an "equivalent" 4N33 (slower), I tried a "high" frequency value (100 kHz).
To be tested at 25 kHz .............
Results of simulation to be compared with a complete device test.

Get something like this (change only R1 = 1k "red" or 100k "green").
Should try also with R3 bigger ...

enter image description here

\$\endgroup\$
1
  • \$\begingroup\$ I also don't think this deserved a downvote, although I think the simulation is somewhat more optimistic than what may be realized with actual components. LTspice has a model for CNY17 so it would be interesting to try that. \$\endgroup\$
    – PStechPaul
    Dec 30, 2022 at 22:39
3
\$\begingroup\$

I've had the same issue with optocouplers in the past and now I simply don't use ones that don't have active outputs. Here's an example from the datasheet for Broadcom's HCPL-0710-500E: optoisolator datasheet snip

They claim 8ns maximum pulsewidth distortion and 20ns maximum propagation delay: enter image description here

all datasheet snips from https://docs.broadcom.com/doc/AV02-0641EN

To find an optoisolator of this nature I simply use the filters on digikey (or your vendor of choice) and only select CMOS/Push-pull/Totem-pole output types, for example: https://www.digikey.com/short/1vb9z3bd

\$\endgroup\$
2
\$\begingroup\$

I ran a simulation in LTspice for a CNY17-3 at 100 kHz, and it shows a fairly consistent 1 us rise and fall time with the resistors I have chosen. Other values show much longer rise or fall times and insufficiently low logic zero output. This may be fast enough for some purposes, but not enough for 25 kHz PWM where 1% duty cycle would be only 20 ns wide.

CNY17 Optocoupler at 100 kHz

\$\endgroup\$
2
  • \$\begingroup\$ You could put a CMOS Schmitt trigger on the output and tell us from which duty-cycle pulses start to go through. Shortest pulses will be aeten up. Plotting the ratio of input-pulsewidth/output-pulsewidth would show the limits well. \$\endgroup\$
    – datenheim
    Jan 1, 2023 at 17:23
  • \$\begingroup\$ Unless there is an extreme need to minimize parts cost, best idea is to just use a properly rated high speed optocoupler. \$\endgroup\$
    – PStechPaul
    Jan 2, 2023 at 4:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.