2
\$\begingroup\$

Can you help me explain why my opto (LTV-817S) is behaving like this?

The schematic is shown below and the scope below that.

We are using an STM32 communicating with an ESP32 via USART at approx 38400 baud rate. The pulse width from the STM32 is approx 25.60 μs which is expected, but the pulse width at the transistor is a lot less and no comms take place.

enter image description here

enter image description here

\$\endgroup\$
4
  • 1
    \$\begingroup\$ That's what they do. Takes time to light up the LED, takes time to start getting current on the collector. If you want anything faster than that, you need a digital isolator- they would have a much faster isolated channel. Normal bitrate would be 50Mbps, could be even 200Mbps \$\endgroup\$
    – TQQQ
    Feb 20 at 20:03
  • 9
    \$\begingroup\$ @TQQQ If you look at the diagram, it takes almost no time to turn the LED on and get current through collector. The problem is exactly opposite, it takes time for the transistor to turn off. \$\endgroup\$
    – Justme
    Feb 20 at 20:22
  • 1
    \$\begingroup\$ It's turning on fast, turning off slow. Prob transistor coming out of saturation. You should get better speed by operating it outside of saturation, but easier and less susceptible to part-to-part variation just getting a faster device \$\endgroup\$
    – Pete W
    Feb 20 at 20:31
  • \$\begingroup\$ @Justme yeah, that too. \$\endgroup\$
    – TQQQ
    Feb 20 at 20:51

7 Answers 7

11
\$\begingroup\$

The LTV-817 is a "general purpose phototransistor photocoupler".

It is not rated for such fast data communications. So it is behaving as expected.

The transistor is on for quite a long time after the LED turns off.

The high current makes the LED shine brightly, making the transistor turn on fast and go into saturation, and since the transistor has no pin for biasing the base with a leak resistor, it just takes a long time for the transistor to turn off.

With a 1k pull-up, typical times are: turn-on delay 5us, fall time 15us, turn-off delay 2us, rise time 20us.

I don't think the rise time itself is a problem though. The problem is the delay before the signal even starts to rise.

So completely unsuitable for 38400 bit rate which has 26us per bit.

Assuming your VCC for the LED is 3.3V, the 220 ohm resistor drives the LED with about 7-8mA current.

Since it looks like the phototransistor stays on longer than you want, reduce the LED driving current so the charges in the phototransistor move out faster.

Or, change to a more suitable optocoupler capable of 38400 bps.

Another thing is: you are using scope probes in 1x mode. 1x probes have more capacitance and lower bandwidth, so the waveform is not like what it would really be. If you have 10x or selectable 1x/10x probes, as a rule of thumb, use the probes only in 10x mode, unless you know what you are doing and know you must use the 1x probe setting.

\$\endgroup\$
2
  • \$\begingroup\$ Do you have a source such as a video that explains the reasons for the 1x and 10x probes and when to apply them? \$\endgroup\$
    – JoeyB
    Feb 21 at 16:04
  • \$\begingroup\$ @JoeyB There should be plenty sources on EE.SE and you can find with any search engine too. Or you can read probe and scope manual. You will find that a generic 1x/10x probe with 150 MHz bandwidth has only less 10 MHz bandwidth in 1x mode. \$\endgroup\$
    – Justme
    Feb 21 at 17:55
7
\$\begingroup\$

Why does my opto behave like this?

Look at the rise time graph for a 1 kΩ load: -

enter image description here

I'm sure you can find an opto-coupler that is a lot faster than this and, one that has a digital push-pull output. All the main distributors have many on offer.

\$\endgroup\$
5
\$\begingroup\$

From LITEON data sheet:

rise/fall time optocoupler Although this test is for Idiode=5mA, you get the idea of its speed. To get a current-transfer-ratio near 1:1, transistor current gain (HFE) is likely quite high, which slows things down.
Of the four parameters td, tr, ts, tf, it would seem from your 'scope photo that ts is most bothersome.

  • td delay time
  • tr rise time
  • ts storage time
  • tf fall time

You might improve the fall time by using a X10 attenuator probe, but storage time dominates the delay.
A much smaller load resistor can help, but then the transistor won't work as a saturated switch, and you'd have to add a comparator to generate a clean logic output. As others have suggested, faster optocouplers are available - seems making this one work speedily is somewhat pointless.

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

The response time could be as high as 18us (see page 10 of the datasheet). Also, what is the drive current of the GPIO of the MCU? You are likely current-limited. Try driving the LED with more juice. Try reducing R2 for greater frequency response (see freq response graph on the bottom of page 13) If that doesn't work, your going to need a faster opto-coupler or digital isolator.

\$\endgroup\$
2
  • 3
    \$\begingroup\$ Why drive the LED with even more current? It already blindfolds the phototransistor, which is why it takes so long before it recovers. The correct solution would be to drive the LED with less current. \$\endgroup\$
    – Justme
    Feb 20 at 20:20
  • 1
    \$\begingroup\$ @Justme Good catch. I'm used to signals traveling left to right and didn't realize the logic is inverted with respect to the scope probes. \$\endgroup\$
    – MOSFET
    Feb 20 at 21:03
2
\$\begingroup\$

Claiming speed for these kinds of optos with a 100Ω load (large print) means you have to read the fine print to find out what the speed is with a much higher load resistor (the way folks normally use them) . It's approximately proportional, so with a 10kΩ load it will be ~100x slower. Unfortunately, the required input current goes up inversely proportional to the load resistance (constant CTR approximation) if you don't use some more complex circuit than just a load resistor and there are limits to the IRLED current (especially if you care very much about reliability and temperature range), so...

Doesn't help you with your present PCB (if you have one designed) but I would suggest in the future that you use a logic-output optoisolator such as the inexpensive and multiple-sourced 6N137. That kind of optoisolator uses a photodiode, not a phototransistor and the output is a Schottky clamped BJT. Switching times are in the 100ns region, so 200x faster.

In the meantime, I guess you could run your serial port at a slower baud rate.

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

A phototransistor can be roughly modeled as a transistor with a light-to-current converter and capacitor between the base and the emitter. When the LED is turned on, the capacitor will be charged up enough to turn on the transistor, and then charged up even more. When the LED is turned off, the transistor will remain on until the capacitor is almost fully discharged.

Optocouplers intended for higher-speed applications often have a separate lead for the base; adding a resistor between the base and emitter will allow the capacitance to be discharged more quickly, at the expense of reducing sensitivity.

Achieving maximum performance may require using an optocoupler which has two matched phototransistors--one on each side of the isolation barrier. The current to the LED could then be modulated so that it turns both transistors almost, but not quite, fully on. This would ensure that the output transistor's base couldn't build up excess charge that would prevent it from switching off immediately. Such optocouplers tend to be expensive, however, and would only be needed for more demanding applications.

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

Seems this optocoupler is naturally slow with 4us rise and 3us fall times.

So it is not sufficient for high speed switching.

enter image description here

\$\endgroup\$

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.