TomGeorge:
Hi, you want to buffer a tri state output, how are you going to detect that the output is High-Z.
Exactly my question. It seems like there ought to be a way using bipolar transistors for the driver circuit. When the pin is High-Z, there would be no base current flowing, so the bipolar would be in the "off" state. Using a pair of bipolars (one triggered by logic HIGH, the other LOW), it would be possible to have three states -- HIGH = NPN on; LOW = PNP on; High-Z = neither on. Unfortunately, I haven't yet been clever enough to work out an arrangement where this doesn't leave both MOSFETS enabled when the driver BJTs are both off ... mostly thanks to the fact that BJTs inconveniently conduct in ways other than intended for the application.
TomGeorge:
Two output pins would be better, one output is the logic state, Hi or Low, the other High-Z on or off.
For sure, yes. However, it would also be a design well within my capabilities, and I wouldn't have posted the question if that were an option.
BTW, this is an academic question that also has an immediate practical use in a design I'm working on. I'm using an ATmega 1284 and still managed to run out of pins. I do have other options -- shift registers, using 4-bit LCD I/O, or hooking things up to the ICSP pins -- which I'm trying to avoid here. It just struck me as an interesting puzzle that would be helpful to solve, but I managed to drain a laptop battery and get through three episodes of Eureka while trying to come up with something that simulated correctly, and ultimately still failed to do so.
TomGeorge:
What happens when you disable a motor drive shield, aren't all the H-bridge switches OFF, hence High-Z?
Not sure -- I've never used one. I seem to remember them taking two pins to drive, but I could be wrong.
123Splat:
low side logic level MOSFET with a moderate gate to ground resistance.
Unless I'm missing something, that would only accomplish a single polarity output. The example schematic uses two LEDs in reverse parallel. (I know, this doesn't show in the screenshot -- the simulator replaces the schematic symbol with a virtual LED lens that lights up.) Basically, this represents a single 2-pin bi-color LED. Logic HIGH should drive the LED green, LOW should drive the LED red, and High-Z should leave the LED off. You can achieve this effect directly from the I/O pin by connecting one leg of the LED to the pin (through a resistor naturally) and the other pin to 1/2 Vcc, then toggle the pin HIGH/LOW, or set it as an input. But then you're limited to the current capacity of the pin. I'm trying to emulate this with a higher-voltage, higher-current supply.
Keep in mind, the question is meant to be a theoretical exercise (with practical application), so suggestions that skirt around the problem domain by using LED driver ICs or whatever don't really solve the puzzle -- they just avoid it. I can think of plenty of alternate solutions, but that's no fun! I really want to come up with a single-pin way of driving this circuit.