10
\$\begingroup\$

I frequently work on projects in which I use optocouplers for isolating digital +5VDC control signals (for example, from a microcontroller) from the rest of the circuit. However, since these work by illuminating an LED inside the device, there can be several tens of milliamps load on the microcontroller pins. I am looking for advice on what would be the best practice for buffering this control signal with an additonal stage, so that the microcontroller effectively sees a high impedance, and thereby reducing the current that it needs to provide?

enter image description here

Just naively off the top of my head, I can think of a few things which might work:

  1. Simply use an op amp as a unity gain buffer amplifier.

  2. Use a dedicated comparator chip to compare the input signal with, for example, +2.5VDC.

  3. Use a MOSFET as a kind of signal amplifier.

However, upon doing some reading, I have come across a whole bunch of chips that I have never used before, but sound like they may be designed for this kind of thing. For example:

  • A Differential Line Driver (MC3487)
  • A Differential Line Receiver (DC90C032)
  • A Line Transceiver (SN65MLVD040)
  • Buffer gates and drivers (SN74LS07, SN74ABT126)

I really have no experience with any of these and am a little overwhelmed by the amount of stuff available! So can anyone help me to learn the differences between these devices, and which ones of them would / wouldn't be suitable in this case. Is there a best / standard way of achieving what I describe?

edit:
Since I could be switching up to around x30 outputs, I do not want to be concerned at all about loading the microcontrollers, and so will not be considering connecting directly to the DIO pins. Therefore, I think I will go for a logic buffer IC. I am going to try using the SN74LVC1G125 "Single Bus Buffer Gate With 3-State Output" for each input, and see how that works out.

\$\endgroup\$
2
  • \$\begingroup\$ For a drop-in single-component solution, P-channel MOSFET. \$\endgroup\$
    – Reinderien
    Commented Sep 18, 2017 at 19:02
  • \$\begingroup\$ On a related note, microcontroller pins usually can sink more current than they can source. See this question. \$\endgroup\$ Commented Sep 19, 2017 at 2:34

4 Answers 4

12
\$\begingroup\$

You have many options.

  1. If you need to connect very few optocouplers, you can connect them directly to the GPIO of your microcontroller (through a resistor), provided that:

    • You do not exceed the GPIO output current.
    • You do not exceed the total port current.
    • You do not exceed the total gnd/vdd current.
  2. If you need to connect more optocouplers, you can try to use low-current, high current transfer ratio optocouplers such as SFH618 (https://www.vishay.com/docs/83673/sfh618a.pdf), and connect them directly to your GPIOs (through a resistor).

  3. Or, you can use a BJT or MOSFET (see schematics below). Some notes:

    • Remember to put the pull-down/pull-up resistor, which ensures that the MOSFET/BJT are OFF when the GPIO is not initialized yet (e.g. during reset).
    • Pull-up or down resistor might be omitted if your MCU has GPIO pin with pull-up/down always enabled during reset.
    • If using MOSFETs, remember to use logic level MOSFETs (e.g. BSS138).
    • If you use the active-low solution, make sure that the high level voltage of the GPIO is VDD. I.e. do not use a 3.3V-GPIO and VDD = 5V in the active low solution!.
  4. Still, if you need to drive many optocouplers (e.g. 6) you can use the 74LS07 you mentioned, as it allows a 40mA per pin, and you'll have to mount only one component (instead of 6 BJTs/MOSFETs). Remember that, unlike CMOS, TTL ICs are instrinsically pulled-up! However, you might still want the pull-up resistor (the datasheet also recommends not to leave inputs floating). And, since '07 is not inverting, this solution will be active LOW. The 74ABT126 is CMOS so you MUST use anyway the pull-up resistor!

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Also can use emitter / source followers \$\endgroup\$
    – Russell McMahon
    Commented Sep 20, 2017 at 10:29
  • \$\begingroup\$ +1. This can be used to make them active high, provided that the GPIO is powered with the same VDD (like in the active low configuration (with PNP)). However I wouldn't use a MOSFET then, as they tend to have a large Vth (and a large dispersion of it, which might impact the calculation of the led current). This might be a problem if you have a 2.5V or 3.3V GPIO (you need \$V_{TH}+V_{OV} + V_{LED} + I_{LED}R\$. If this value is too close to VDD, then the drop on R will be small, and the depedence of the current on Vth will be therefore high). \$\endgroup\$
    – next-hack
    Commented Sep 20, 2017 at 10:59
12
\$\begingroup\$

A simple BJT like MMBT3904 or any switching BJT will do the job. You can get a reel of 100 for two bucks.

enter image description here

\$\endgroup\$
9
\$\begingroup\$

The differential line drivers are not designed for driving LEDs. These buffer chips drive (or receive) a differential signal on two wires. The voltage swing may be 1.3 volts to 1.7 volts. Not enough to turn an LED on or off.

The TTL buffers are ideal for this application, but rather than connect to the high side of the LED as drawn in your schematic they should connected to the low side of the LED, since TTL is good at sinking current and poor at sourcing current.

However if you have only a few optocouplers to connect then a NPN BJT is an even simpler way to drive the LED.

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

I recommend for Logic level output to use the H11L1 which has a CMOS Schmitt logic gate driver and runs with a minimum of 1.4mA ~$1 (10) 3~16V

For low cost open Collectors , ranked with a wide range of current gain from 80% to 300% minimum http://www.taiwansemi.com/products/datasheet/TPC816%20SERIES_B1612.pdf

This means if you only need logic levels out or 1mA, that is at least 80% of what your drive it with which isn't much power load on the CPU.

So search for what matters. thousands of choices cost vs performance.

For speed more current helps but some device$ switch in ns others in us.

\$\endgroup\$

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