0
\$\begingroup\$

I have a device which requires a 5 V logic input. That input ordinarily needs to be high and the device is activated when the input goes low. I need to drive this from a 3.3 V output (Raspberry Pi GPIO) which is low when the Raspberry Pi is booting.

In summary: when the RasPi's 3.3 V pin is low, the 5 V input needs to be high and vice versa.

What is the best way to achieve this? I'm thinking of using a PNP transistor but I'm struggling to understand how to drive this, as the 3.3 V input isn't enough to stop the transistor passing current.

I've seen a few example circuits that pair the PNP with an NPN but these all require the input to the NPN to be high before the PNP passes current.

Is a Logic Level Converter a more sensible way to achieve this?

\$\endgroup\$
5
  • \$\begingroup\$ Are you asking about the voltage levels required, or the logic sense of the signals? Is the main problem the fact that the output of the RasPi is low when booting, but you want your "device" to see a logic high during the boot process? If that's the case, then all you need is a simple inverter. \$\endgroup\$
    – SteveSh
    Jan 8, 2021 at 22:28
  • \$\begingroup\$ And does everything run off the same supply, or are multiple supplies involved? \$\endgroup\$
    – SteveSh
    Jan 8, 2021 at 22:29
  • \$\begingroup\$ Use an NPN transistor as an inverter. PNP is not required. As you noted the PNP circuit does not do what you want. \$\endgroup\$
    – user253751
    Jan 8, 2021 at 22:35
  • 2
    \$\begingroup\$ What is the device with 5V input? What specs does the 5V input have, does it use TTL or CMOS levels? \$\endgroup\$
    – Justme
    Jan 8, 2021 at 23:10
  • \$\begingroup\$ Also how much board + wire distance is there between the two devices? \$\endgroup\$
    – Reinderien
    Jan 8, 2021 at 23:49

3 Answers 3

4
\$\begingroup\$

You need an inverter.

If you go shopping, you can find a logic family that will work correctly with a 3.3V input and output 0-5V. 74HCTxx an 74ACTxx families do this, for instance. If you're doing surface-mount, you can get a one-gate inverter that'll do it.

You can also use an NPN transistor and a few resistors. This will be slower, and may not meet the input slew rate specifications for the following stage - but it'll probably work.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
3
  • \$\begingroup\$ Thank you :) I've tried the NPN circuit and it works as desired for this use case \$\endgroup\$
    – phil-lavin
    Jan 8, 2021 at 23:15
  • \$\begingroup\$ you may not need that, 5V TTL compatible inpouts can accept 3.3V CMOS signals without any amplification. \$\endgroup\$
    – Jasen
    Jan 9, 2021 at 12:41
  • 1
    \$\begingroup\$ He says he needs an inverter. If that's true he needs something, and it may as well do the level-shifting at the same time. But yes -- if the inverter were unnecessary then a quick check of the datasheet of the relevant part to see if 3.3V would work is a good idea. \$\endgroup\$
    – TimWescott
    Jan 9, 2021 at 19:02
1
\$\begingroup\$

In addition to other suggestions, a one-transistor noninverting circuit can perform this 3.3V-to-5V logic conversion

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
3
  • \$\begingroup\$ OK... but the OP said it needs to invert. So how is this applicable? \$\endgroup\$
    – Reinderien
    Jan 10, 2021 at 17:36
  • \$\begingroup\$ Measuring low when booting, could mean open (input-configured) pin (a voltmeter to ground would measure this as 'low') or could mean pulldown (output-configured) I/O pin, latched LOW. The 'need to invert' may be inessential in the first case. \$\endgroup\$
    – Whit3rd
    Jan 11, 2021 at 3:23
  • \$\begingroup\$ V1 should be at (3.3V/2)+0.5V, or about 2V. That's so that the converter has similar input threshold to CMOS logic. With 3.3V, the threshold is about 2.8V - much higher than 1.65V. \$\endgroup\$ Aug 30 at 16:48
0
\$\begingroup\$

Reading into your problem somewhat: your circuit is going to be off-board since it's connected from the Raspberry Pi, which implies some (unstated) distance where the signal travels over wire connected to the GPIO header. It's unlikely that you'll be using shielding over this connection so the signal may be vulnerable to some amount of environmental noise.

The Raspberry Pi has published voltage levels for its GPIO pins. These can inform the design of a simple, inverting Schmitt trigger that will offer some amount of immunity against noise at the receiving end. Assuming that the RPI is configured to have a \$V_{DDIO} = 3.3 \text{V}\$, the GPIO output will have \$ V_{OLmax} = 140 \text{mV} \$, \$ V_{OHmin} = 3.0 \text{V} \$. Hysteresis transitions of perhaps 0.5 - 2.5V should be safe, in turn making a circuit like this possible:

schematic

simulate this circuit – Schematic created using CircuitLab

transient

This will reject a certain amount of noise (switching, interference, etc.) at the input side, and still achieve your invert-and-shift.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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