# Driving 5V logic output to 3V3 logic input and an LED simultaneously

Background: I'm attempting to control an ATX power supply. I want to read its 5V power good signal and send it to a 3V3 Raspberry Pi Pico GPIO input, and simultaneously power an indicator LED.

I think I've worked out the individual components of this circuit but I'm having trouble putting it all together.

• Dropping 5V logic to 3V3 logic: a 6.8k and 3.3k voltage divider works, although I'm not sure if those are appropriate magnitudes. I don't know if it's sensible to use a voltage divider for something that is always powered either. The ATX spec guarantees minimum 2.4V logic high, which would be divided to 1.6V, above the 1.3V minimum HIGH threshold for the Pico. The Pico is not 5V tolerant.
• Driving an LED: I suspect it's not best practice to drive directly from the signal, especially if I want to also use that signal for logic. I guess I should use a 2N3904 transistor from the +5VSB rail. I have seen it done though.
• I gather the transistor base should have say, a 1K resistor. Can I use R1 from the voltage divider for this?

From the ATX spec:

PWR_OK signal characteristics .
Signal Type +5V TTL compatible
Logic level low <0.4V while sinking 4ma
Logic level high 2.4V-5V output while sourcing 200μa
High state output impedance 1kΩ from output to common

Here's my initial circuit:

The simulator reports 750mV at LOGIC, which isn't going to work. Playing around suggested a digital buffer might be appropriate. I have no real idea, but this provides 2.9V to LOGIC, which is sufficient:

Changing the buffer for another resistor and dropping the values by 2 orders of magnitude gets me closer to the right voltage but I'm really just guessing at this point.

• Am I on the right track? Can it be simplified?
• I also considered using the LED in series to drop the voltage for the logic input, but I want the option of not populating the LED in the circuit.
• Am I doing something weird to step down 5V to 3V3 only to use 5V for the LED again?
• I hope to use this circuit "for real" so I'm interested in doing things correctly and reliably rather than relying on something that will mostly probably work.
• You need a series resistor at the base of BJT. What you measure as 0.75 V is VBE_on voltage. Oct 14, 2021 at 9:57
• If you need to indicate that power good is asserted and the RPi Pico is working, then you could use a voltage divider for the input to the RPi and drive the LED from the RPi. Oct 14, 2021 at 16:29

You should consider using an N channel MOSFET instead of a BJT to drive the LED. MOSFET gates have much higher impedance than a BJT base and would therefore moot concerns of the impedance having some impact on the level of the output of the divider.

• All CMOS Logic contains Nch FET's and Pch FET's too. That's redundant. There's no need to add anything with 74HC etc CMOS family logic, It can easily drive with <= 100 ohm source impedance (400mV /4mA ) to an LED (Not CD4xxx series as @WidlarFanboy101 has suggested it is a higher resistance driver closer to 1k ohm @ 5V and >3k at 3.3V) Oct 14, 2021 at 15:24
• Thanks for the tip - It at least works in the simulator and I believe I have a 2N7000 lying around so I will try it this weekend. If not I will try a level shifter or transceiver as mentioned in other responses. Oct 14, 2021 at 19:31

• All CMOS 5.5V logic has a driver impedance of 50 Ohms nominal +/- large tolerance can easily turn on an LED indicator at logic levels with a current limiting R. Consider it already a buffer. Iol = ___ @ Vol=0.8 Vol/Iol= Ron

• 3.3V Logic is 5V tolerant when limited by 10k in series with internal ESD diode clamps as long as 3.3 is derived from the same 5V for sequencing

R Ratios of 60 to 66 % are fine for 3.3V/5V, with lots of margin for low speed signals.

• "All CMOS 5.5V logic has a driver impedance of 50 Ohms nominal" - do you have a reference for that? Oct 14, 2021 at 7:06
• @ReversedEngineer No, but it's true. Have you tried computing $Rout$ for all devices @ 4.5 & 5.5 or 6V. $V_{OL}/I_{OL}=R_{OL}$ and similar for $R_{OH}$ to make a better generalization , perhaps for all parts in all families I have seen 10 to 100 ohms over ambient range of temp and for some devices 33 to 66 ohms. So the mean I say is 50 with a wide tolerance. Some may spec 12.5mA max , others 16 mA and some 32 mA in the 25 ohm range like 74ALCxx and ARM's Oct 14, 2021 at 15:08

I suggest feeding the PG signal into a logic buffer. As the PG signal does not make much sense without the power supply being turned on, a typical motherboard has a pull-up resistor of say 4k7 ohms from PG pin to 5V (not the SB5V). The logic buffer can be powered from the SB5V, and you can decide if a buffer with Schmitt trigger input is beneficial and whether you like an inverting buffer. The buffer output is strong enough to drive a LED with 5V and a voltage divider to drop the output to 3.3V for Raspberry Pi 3.3V input, or the buffer could be one with open drain output so you can use built-it pull-up resistor on Raspberry Pi. Simply a transistor would also do in place of logic gate, just decide where the output LED or pull-up resistor would go to, 5VSB, 5V, 3.3V, or the Raspberry Pi 3.3V. If you use a buffer, and power it with 3.3V (from Rpi or 3.3V or from 5VSB via 3.3V regulator), make sure the buffer input can tolerate 5V. Also make sure the buffer won't try to push 3.3V into GPIO pins of unpowered Raspberry Pi.

Thanks for sharing!

Fundamentally, you have the right concept here: take the 5V logic, step it down, and fan it out to the inputs of your circuits of interest. However, there are a couple technical details getting in the way of your implementation. I will try to summarize below.

1. it looks like the logic output style of the ATX is TTL. This is an older style of digital logic that uses BJTs as the fundamental logic element (as opposed to MOSFETs). Although still widely used today, one thing to look out for with this style of logic is that your output HIGH voltage will depend on the amount of current drawn by the receiving circuits.

2. Resistive voltage dividers are a great way to step down voltages because they’re very linear, but in digital applications they aren’t always as reliable due to a couple factors such as, current drive requirements, logic-high voltage level uncertainty, propagation delay, etc.

3. Your BJT LED driver is a solid choice, but comes with a couple quirks. The most important one here is that, for all intents and purposes, the base to emitter junction is essentially a p-n diode. So as soon as you provide enough voltage to forward bias the junction, the base to emitter behavior will more-or-less follow the IV characteristics of a diode (the current will run-away while the voltage drop stays locked in at around 750mV). You’ll want to include a resistor in series with the base pin to avoid destructive results (I.e. burning out the BJT due to excessive current draw). You should be able to find a reference circuit with properly sized resistors if you search “BJT LED driver”.

For this application, I would recommend looking for a type of device called a level shifter or digital transceiver. It essentially would replace the voltage divider + buffer portion of your circuit in the second image you shared. These ICs are designed for this exact application, where you have an input and an output device that don’t share the same logic levels, or even logic styles. Essentially you hook up the 5V power supply to VCCA pin of the level shifter, the Pi’s 3.3V power supply to the VCCB pin of the level translator, and then you can connect your ATX pin to the A-input pin of the level translator and the pi GPIO pin to the B-output. This will ensure that the high and low logic voltages will be in the correct range for the Pi, and referencing the same high and low supplies as the pi. The CD4504B may be a good device for you to consider, although it’s quite old and doesn’t have a very user friendly data sheet. There are a lot of newer ones out there these days, the only catch being most of them are in surface mount packages.

Lastly, addressing the LED driver portion, once you’ve included the base series resistor, you could use a level translator with two or more channels, hook up the ATX signal to two A-input channels, then drive the Pi with one B-side output channel, and drive the LED driver with the other b-side channel. This would be consider better practice as you’re sort of isolating the BJT current from the Pi GPIO current. That way any excessive current draw from the BJT wouldn’t effect the signal being received by the pi GPIO pin.

Hope this helps!

• Unfortunately the CD4054 output side supply voltage is rated to be 5V minimum so it can't be used for logic level conversion to 3.3V logic. There must also be a simpler solution - real life motherboard manufacturers would not bother to spend even 10 cents for a special dual-supply level conversion chip just for reading a TTL level power good signal, if three resistors that cost 0.1 cents in total works getting it to 3.3V or any other logic level for a CMOS chipset to read. Oct 14, 2021 at 8:53