3
\$\begingroup\$

I'd like my Raspberry Pi GPIO port to communicate with a digital circuit that works at 2x the GPIO voltage. The communication will be at a relatively high frequency (up to 500kHz).

The main question is how do I amplify the voltage on a GPIO output pin. Will a simple 2n2222 transistor suffice? My main worry is the frequency. (Also getting the right circuit diagram and capacitor/resistor values.)

(Bonus question is for the other direction: how to reduce the input voltage. My first thought is a two-resistor voltage divider, but then again, will it work well at 500kHz?)

edit:

Obviously, I haven't heard of level-shifting and level translators. :)

However, the translators that I can see are all 3V3 <-> 5V. I'd like something bidirectional, that could operate around 7V and comfortably withstand 9V. What is the standard next step (if there is one) above 3.3/5? (I assume there are no 3V3 <-> 7V translators ;), but maybe there's a 9V or 12V standard that has 5V on the lower end and I could serialize 3V3 <-> 5V <-> 9V ?)

Or maybe there's a simple way to roll my own translator for my unusual voltage needs? (with 500kHz in mind, of course)

edit:

Thanks everyone for suggesting a voltage translator.

Indeed, there seems to exist a higher standard - for 15V CMOS.

If I understand correctly, the signal input and output voltages can be controlled by the "power supply" voltages provided for a chip. So I can use whatever weird voltages I want, as long as I can find an appropriate power supply.

Some candidates include TI CD40109B, CD4504 and Pololu 2595.

\$\endgroup\$
4
  • \$\begingroup\$ What's wrong with the obvious answer of using level translators? This is exactly what they are intended for. \$\endgroup\$ Apr 1, 2015 at 14:49
  • \$\begingroup\$ Similar question about bidirectional level shifters. electronics.stackexchange.com/questions/97889/… \$\endgroup\$
    – Matt B.
    Apr 1, 2015 at 15:59
  • \$\begingroup\$ Similar, but different, since it talks about the most popular conversion, i.e. 3v3-5v, which is not good for me. \$\endgroup\$
    – Billy Bob
    Apr 1, 2015 at 16:03
  • \$\begingroup\$ The BSS138 used in sherrillbc's answer has a gate-source limit of 20V which is useful for your 9V high side voltage. A lot of these small FETs have an 8V limit which wouldn't work for you. Just saying ;-) \$\endgroup\$
    – carveone
    Apr 1, 2015 at 17:03

3 Answers 3

7
\$\begingroup\$

For this very same purpose I have used the BSS138 mosfet with 10k pull-ups. I was able achieve 250k reliable communication with a micro running at 16MHz. A step up to 500kHz will surely work, I just could not reliably test this with a slow micro.

Also, the term for what you are describing is known as Level Shifting;

enter image description here

You can pick a board up using these same mosfets at Spark Fun.

\$\endgroup\$
3
  • \$\begingroup\$ Using 1k resistors rather than 10k, I've reliably run the circuit for an SD Card @ 2MHz. \$\endgroup\$ Apr 1, 2015 at 16:12
  • \$\begingroup\$ Though for higher voltages with larger swings the performance will be reduced. There is also a limit as to how low you can go based on how much current the I/O pin driving the shifter can sink. \$\endgroup\$ Apr 1, 2015 at 16:17
  • 1
    \$\begingroup\$ The Philips tech note that mentioned this circuit also mentions using two mosfets face-to-face to do isolation. Like this: electronics.stackexchange.com/questions/106254/…. I like this because I have battery powered PICs talking to USB powered FTDI serial interfaces, either of which can then be turned off without worrying about what's driving the line of whom. \$\endgroup\$
    – carveone
    Apr 1, 2015 at 17:00
2
\$\begingroup\$

You might be able to use this. It's an 8 channel bidirectional level translator: -

enter image description here

One side works with logic level of 1.2 to 3.6 volts and the other side works at logic levels of 1.6 to 5.5 volts.

I would have thought that if your high side voltage logic is 6.6 volts, then supplying an input pin with a logic level of 5 volts (76%) would still be OK. When feeding out a 6.6 volt logic level you should protect the device with a 1kohm series resistor.

Or, you could use this device, the TXS0108E: -

enter image description here

Speeds in excess of 2Mbpsec according to the data sheet.

\$\endgroup\$
1
\$\begingroup\$

I don't think transistor solution will work at 500kHz. Maxim Integrated has these nice ICs you can use. MAX3002,for example, converts any voltage to any voltage, is bidirectional and has no direction pin.

\$\endgroup\$
2
  • 4
    \$\begingroup\$ 500 Kelvin-Hertz is not a meaningful measure in this context. \$\endgroup\$ Apr 1, 2015 at 14:48
  • \$\begingroup\$ I tried to fix it, but the minimum edit is six chars... \$\endgroup\$
    – drxzcl
    Apr 1, 2015 at 19:31

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.