11
\$\begingroup\$

I have almost no knowledge in electronics and electricity. I've encountered the concept of open-drain output recently and I think I got the idea. What I have understood is that it is a transistor connected to an output pin, acting as a sink. Therefore, such pin will always output a zero value.

Maybe I simplified it too much and I missed something.

Anyway, I was wondering why this kind of outputs are needed.

As far as I know, if we were to output a one through such pin, we would have to connect an external pull-up resistor. Why not have that resistor already connected internally?

Thanks for any answer you can give. Also, apart from beign a noob in electronics, I'm new to this forum, so I'm sorry if this question is too theoretical. In case it is, I would apreciate some recommendations of forums where to ask these kind of questions.

\$\endgroup\$
1
  • \$\begingroup\$ It is an interfacing detail limited to the "Physical Layer", despite the name "tri-state", it is not ternary logic in the sense of (0,1, -1), but instead (0,1, X-DON'T CARE) to support certain bus architectures and electrical interfaces. \$\endgroup\$
    – crasic
    Commented Apr 6, 2021 at 16:29

7 Answers 7

25
\$\begingroup\$

The main reason is that it allows for multiple endpoints to coexist on the same line and transmit. The outputs can only pull one way, so the effect is like a wired OR gate. If the outputs were push-pull, then the device that is asserting will fight against the ones that aren't. It would short the IO line and result in damage. Whereas, in an OD configuration, the current is limited to that of the pull-up.

\$\endgroup\$
8
  • 5
    \$\begingroup\$ It's wired-or in active-low logic and wired-and in active high logic. \$\endgroup\$
    – The Photon
    Commented Apr 7, 2021 at 0:28
  • 9
    \$\begingroup\$ A good practical example of this is the I2C bus. \$\endgroup\$
    – Genorme
    Commented Apr 7, 2021 at 6:31
  • \$\begingroup\$ @ThePhoton why that way around? If I have multiple active-low IRQ inputs all wired together, the net result is that the line is asserted (goes low) if any of the inputs go low. With reference to the voltage levels, that looks like an AND gate, not an OR gate. \$\endgroup\$
    – Alnitak
    Commented Apr 7, 2021 at 11:28
  • \$\begingroup\$ @Alnitak, if they're active-low inputs, then a low voltage is a logic '1'. So if any of the inputs going to a low voltage produces a low level, that's an OR function, not AND. \$\endgroup\$
    – The Photon
    Commented Apr 7, 2021 at 15:07
  • 3
    \$\begingroup\$ @ThePhoton That's the answer I expected, except that logic chip truth tables aren't written with 1's or 0's, they're written with L or H. If you treat the network of inputs and outputs as a black box that doesn't "know" whether it's being used in an active-high or an active-low configuration it makes more sense IMHO to reference the voltage levels, not the logic levels. \$\endgroup\$
    – Alnitak
    Commented Apr 8, 2021 at 13:15
18
\$\begingroup\$

Sometimes a device is designed to interface with a variety of different equipment that may use a range of logic-1 input voltage levels. If the outputting device always outputted a logic-1 of 5 volts then it might damage equipment connected to it that requires a logic-1 level of 3.3 volts. There's no risk of damage should the output be purely open-collector (or drain) but, it requires a pull-up resistor to be fitted for it to work.

Another reason is that you can tie several open-collector (or drain) outputs together to form a wired-OR logic i.e. any of the the transistors operating will pull down the pull-up resistor thus you get extra logic functionality for the addition of just one resistor.

\$\endgroup\$
1
  • 3
    \$\begingroup\$ To expand a bit: it's very common to have digital sensors used in industrial equipment that use open-drain outputs. It's also common that they'll be capable of handling 0 to 12V or even 24V supply voltage on the open-drain (or open-collector) output. Things like optical sensors and shaft encoders are typically so equipped. \$\endgroup\$
    – TimWescott
    Commented Apr 6, 2021 at 16:01
10
\$\begingroup\$

(A pre-note: open-drain is the MOS version of bipolar open-collector. Functionally they are the same: they can only sink current to make a 'low' signal.)

The very first logic families, RTL and DTL, were essentially open-collector. Fun fact: the Apollo Guidance Computer was built entirely from just one type of open-collector RTL IC: a dual 3-input NOR gate. Deeper dive here: http://www.righto.com/2019/09/a-computer-built-from-nor-gates-inside.html

Three-state logic didn’t come until later in the 1960s and early 1970s, with the introduction of TTL with totem-pole drive, and soon after, MOS.

Owing to the influence of those pre-TTL chips, early logic buses didn’t use 3-state capability, instead relying on open-collector drivers for multi-card bus connections and shared signals like interrupts or bus requests.

Ok, so what's good about open-collector? It has the nice property that no two drivers can ‘fight’ each other if they drive at the same time, since OC drivers can only sink current. Also, open-collector makes wire-OR logic width expansion very easy: just connect another open-collector driver to the shared signal.

For computer buses, open-collector has a couple of drawbacks however. The power used to drive a ‘low’ is shed in the pull-up; and the rise time is slow owing to lack of active high-drive. This limits performance.

Because of these drawbacks, and the emerging wide availability of 3-state logic in both TTL and MOS, by the 1980s computer buses (examples: Multibus, ISA bus, NuBus, VME, etc.) had abandoned open collector for timing-critical paths, only keeping it for low-speed sideband signals.

Today, open-collector shows up with some slow buses like I2C and SMBus, where its benefit of non-clashing drivers and known idle state makes implementing a controller network simpler.

Open-collector also allows mixed voltage devices to be used together on the same bus (caveat, with tolerant I/O.) This makes level shifting to higher or lower voltages easier than using push-pull outputs. With open-collector you only need 1 resistor to set the 'high' level.

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

The key is that an output can have more states than "high" and "low". There is also "weak high", "weak low", and "high resistance" (HI-Z).

The transistor on the output can take on the states "low" (transistor on) and "high resistance" (transistor off).

If you connect multiple outputs like this together, you have a guarantee that there won't be a pair of one output driving "high" and one output driving "low", which would be a short circuit.

In order for this to be useful, you also need a "weak high" driver on the line that keeps the voltage near the "high" state if all the other drivers are in HI-Z mode, but doesn't fight too hard against drivers outputting "low".

Typically, you'd use a resistor to Vcc as this "weak high" driver. The supply voltage minus the forward voltage of the transistor, divided by the resistor value is the drive strength, usually a few mA, required to pull the line to the "low" state:

\$I=\frac{V_{cc}-V_f}{R}\$

If the output is a BJT, \$V_f\$ is typically around \$0.7\textrm{V}\$, if the output is a FET, it will be rather small and it makes more sense to think of this setup as a resistor divider with your pull-up resistor and \$R_{ds\_on}\$ of the transistor.

Check the datasheet for the drive strength provided by the output driver, and make sure the resistor you use for the "weak high" driver is large enough.

\$\endgroup\$
3
\$\begingroup\$

An internal pull-up resistor means you don't get to choose the current / voltage level used for the signal. An external pull-up can have the resistance you want (defining the current) and can be connected to different voltage levels. Some open-drain pins can tolerate much larger voltages than regular IO pins (which are typically limited to supply voltage).

\$\endgroup\$
3
\$\begingroup\$

Short answer: you can connect their outputs, for example to form wired logic or create busses.

The more common logic outputs, like TTL totem-pole outputs or CMOS outputs are bidirectional. (clarification: I ment they can push and pull current, not that they can be used as inputs) This means that it will try to connect the output to the HIGH or the LOW voltage levels (exact values depend on the family), in a low-resistance path. If you connect two of those outputs together, an unfortunate case can happen when one is trying to push HIGH and the other is LOW - thus creating a low-resistance path between the two, resulting in damage of the circuit - notably one of the output drives is very likely to fail.

Open-collector or open-drain outputs in contrast can only pull current. This means you need an external pull-up resistor to create the HIGH voltage level (and you can choose it's value and power rating, witch might come useful in some situations). This means it's safe to connect their outputs, and that actually forms an AND-gate, since if any of them want to push LOW, it will become LOW (assuming positive logic again). This means it's super easy to create a 8 input AND gate from OC outputs, witch might come useful in some situatuions.

Another possible use is the creation of busses. The simplest example I could come up with is an interrupt line for a processor. Many devices might want to trigger an interrupt (timers, peripherals, etc.), but there's only one interrupt line. If every device uses open-collector outputs, then any of them can pull the line down to trigger an interrupt. More complex examples might include multi-device busses like I2C where any of the devices might want to talk to the rest of them, but plain old PS/2 keyboards also use an open-collector interface for 2-line bidirectional communication.

I must mention that it's possible to do all that without OC/OD outputs, but might be harder. Wired logic can be replaced with gates, and OC busses might be implemented with tri-state logic instead (where we have HIGH-LOW-Z modes, the later being "pretend I'm not even here") - but then extra work might need to be done to ensure that at a time only one device want to drive the bus. With OC outputs, big logic gates can be avoided, and mistakes on bus driving only corrupt the data but not damage the devices.

Also, some OC devices might have higher voltage tolerances, for example the 74x41 BCD decoder can drive 70V for Nixie tubes.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Another option in some cases is to use devices which have a strong low-side drive but a weak internal pull-up. If e.g. a pull-up is guaranteed to pull up somewhere between 50uA and 500uA, and the low side drive is guaranteed to be capable of driving at least 10mA, and one connects sixteen such devices, the overall circuit may waste 8mA whenever any of the devices is pulling low, but the circuit will work if one doesn't mind wasting that much current. \$\endgroup\$
    – supercat
    Commented Apr 7, 2021 at 14:46
2
\$\begingroup\$

Open-collector (or open-drain) outputs are needed for many reasons.

For example, many devices can pull the same signal low to indicate they need attention, but since no device pushes high, only a resistor does, so they can coexist on the same wire.

Another reason is to allow for powering down parts of the circuit for power consumption. Many chips cannot tolerate an input being pushed high while they are unpowered, so it is best to have a pull-up to the switched off power supply, and drive that pin as open-drain.

And if open collector outputs are strong enough, they are perfectly capable of driving loads if necessary, like relay coils or LEDs - either current flows, or it doesn't flow. There is no need to drive relay coils or LEDs with push-pull outputs.

\$\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.