5

I am looking for a simple circuit to invert a tristate output from a microcontroller, hopefully using only BJTs. What I mean by this is that the truth table would look like:

IN   OUT
H    L
L    H
Z    Z

An ordinary inverter circuit / NOT gate will not do, because I don't want current to flow through the output if it isn't flowing through the input.

1 Answers1

6

Here's the simplest bipolar circuit I can think of. When the input is high-z it will float at 2.5V (1/2 the supply voltage) and a current of ~4.5mA will flow down through resistors R1-R4. R1 and R4 keep the Base-Emitter voltages of Q1 and Q2 down to ~0.45V, so both transistors will be off.

When the input is pulled to Ground (or +5V) there is twice as much voltage across R1 and R2 (R3 and R4) so the Base-Emitter voltage goes up to 0.6V or higher and Q1 (Q2) turns on, pulling the output high (low).

I chose low value resistors to get a strong output drive. If your MCU can't provide the required input drive current (~9mA) then just increase all the resistor values while keeping the ratios the same (eg. 1k and 4.7k). If you need to operate on a lower supply voltage then reduce the values of R2 and R3 and/or increase the values of R1 and R4 to get a high-z Base-Emitter voltage of ~0.45V.

schematic

simulate this circuit – Schematic created using CircuitLab

Bruce Abbott
  • 55,540
  • 1
  • 47
  • 89
  • Hmm, after trying this out in my use case, I think it might not quite meet the requirements. It's true that current does not flow through the output when the input is at high impedance, if the output is at 2.5v. But if it is at some other potential, it seems that it does. For instance, if I am using this to trigger a low side switch (NPN), with the emitter to ground, then the switch does turn on when the input is at high impedance. Have I missed anything? I am looking at this using the "Circuit Simulator" applet. – Sean Purser-Haskell Oct 31 '15 at 13:37
  • Nice, sort of like a class-C inverting amp with horrendous cross-over drive loss :-) Also to note that the output may not have quite the same rail to rail characteristics as a modern CMOS microcontroller but will hopefully be enough. – KalleMP Oct 31 '15 at 18:09
  • The 470 Ohm resistors could perhaps be replaced by a diode strings with a Vf of around Vcc/2, This will make the drive less sensitive to transistor characteristics by over driving them. – KalleMP Oct 31 '15 at 18:13
  • 1
    "current does not flow through the output when the input is at high impedance, if the output is at 2.5v. But if it is at some other potential, it seems that it does." - Shouldn't matter what it's driving - if the inverter transistor is off then it's off. However you should not be driving another grounded Emitter transistor directly - you should have a resistor in series with its Base to limit current. A resistor from Base to Emitter is also recommended, to stop leakage current and noise from turning the transistor on. – Bruce Abbott Nov 01 '15 at 01:26
  • Turns out that I swapped the npn and pnp. That's what I get for staying up late. Thanks, Bruce! – Sean Purser-Haskell Nov 01 '15 at 05:58