Electronic – how to increase the voltage of a digital signal

gpiolevel-shiftinglevel-translationlogic-levelraspberry pi

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.

Best Answer

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.