1
\$\begingroup\$

I'd like to protect a serial connection with a H11L1M (I can easily get some at work and it works from 3 to 16 V).

The problem is this optocoupler is inverting and has the following truth table:

Input Output
H L
L H

Is it possible to drive the LED from the anode? I mean when the device is not emitting on TX, the LED is high (so the output is low) and when TX is high, the LED is not grounded so the output is high.

Would that work? Do I need to add a pull-down resistor?

https://i.imgur.com/h8OEqlN.png

\$\endgroup\$
2
  • \$\begingroup\$ What device drives the LED? Some microcontrollers can drive negative currents without a problem. \$\endgroup\$ Commented Dec 4, 2023 at 8:49
  • \$\begingroup\$ The device will be a Raspebrry PI. I use one of its GPIO from UART \$\endgroup\$
    – Manitoba
    Commented Dec 4, 2023 at 8:57

1 Answer 1

0
\$\begingroup\$

The optoisolator is not inverting, it works like all other optoisolators basically. Of course it may depend on your viewpoint but it does not change how it or all other optoisolators work.

There is no logic input to LED so you can define how it works. There is no definition of high input, but it means LED being on. When there is current through LED, there is also current through output on normal optoisolator, and typically this is wired so that a normal opto will pull a wire low for a data line. This just has logic level output instead of open collector, but very weak, so you need a pull-up anyway.

If you want output to be low when input is low, you connect the LED so that when TX is low, it will turn on the LED, which will pull output low and your RX is low.

That's exactly how your schematic already works.

The turn-on time and turn-off time max of 4us can limit your baud rate severely. It does say typically 1us and 1 Mbps with NRZ coding, but max is still 4us.

The pull-up resistor is from datasheet examples so it should work fine.

As 115200 bps has 8.68 us per bit, it might not be a good idea to use an optocoupler that can skew the signal by about 46% of the bit length.

For example, in MIDI, the requirement is much stricter, 2us max skew with only 31.25 kbps, but in that system, the signal could go through multiple optoisolators.

\$\endgroup\$
5
  • \$\begingroup\$ Thanks for your help. My baudrate is 115200, would it be sufficient ? If I understand correctly your explanation, the following schematic would work ? i.imgur.com/KC6e00w.png How to find out the required value for the pull-up resistor ? \$\endgroup\$
    – Manitoba
    Commented Dec 4, 2023 at 9:43
  • \$\begingroup\$ Thanks for your edit. Is the capacitor required as it seems to be used only for performance tests ? What would you recommend to achieve a better rate ? \$\endgroup\$
    – Manitoba
    Commented Dec 4, 2023 at 10:05
  • \$\begingroup\$ Also, do I need to add a resistor to the input to provide sufficient current to the LED ? I was thinking of something like that: i.imgur.com/zS50gbE.png \$\endgroup\$
    – Manitoba
    Commented Dec 4, 2023 at 10:26
  • \$\begingroup\$ @Manitoba All digital ICs require a bypass capacitor right next to the power pins for proper operation. Do not leave it out or you might end up in a design that does not work properly, depending on how far the next capacitor is. And if you want a better baud rate, buy an opto rated for higher speed. \$\endgroup\$
    – Justme
    Commented Dec 4, 2023 at 11:05
  • \$\begingroup\$ @Manitoba Of course you need a resistor when driving a LED, otherwise you will burn the LED or the IO pin. Don't use more current than what the LED needs with safe margin, and do check if the IO pin can provide that. \$\endgroup\$
    – Justme
    Commented Dec 4, 2023 at 11:14

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.