If you read any about interfacing to the Pi GPIO pins you are bound to come across the dire warnings - Be Careful. These pins connect directly to the microprocessor without any protection. You can destroy the Universe if you wire something wrong.
OK. Maybe not that dire, but you get the idea. You may get away with interfacing directly with the GPIO pins (I know I have) but even if your circuit is designed perfectly, accidents still happen. Something can fall across the circuit board and short things out. So it is wise to protect your Pi.
I am building an interface that will connect to hard-wired alarm circuitry. That means lots of lines running lots of places and just that many more opportunities for bad things to happen. This protection is also a good idea since a lot of people using the Pi will likely be from the younger and less experienced crowd. This is what the Pi was developed to encourage, so having a safe way to interface to the most flexible I/O on the device is critical.
Here are some of the options for protecting a logic circuit.
Zener Diode - A Zener diode is one that allows no reverse current to flow until a threshold is reached. Above that threshold, current will flow. A 3.3V Zener diode between a GPIO pin and ground can protect it from any over voltage that is applied. Any voltage above 3.3V will just be shunted to ground.
Mike Cooke has provided a design for a screw terminal break-out board for the Raspberry Pi GPIO that uses Zener diodes for protection. The design may be found here: Raspberry Pi Breakout Box.
Transistor - A transistor can be used to switch a known safe logic level.
Line Driver or Buffer - Chips that contain multiple transistor switches internally. These are easier to install and provide a cleaner design when you have many lines to protect.
Opto-Isolators - Chips similar to Buffers but these use pairs of internal LEDs and optical sensors instead of transistors. This provides total circuit isolation and can be useful in a noisy electrical environment.
A Bi-directional Logic Level Converter seemed like the perfect thing to use. However, I tried the TXB0108 provided by Adafruit and had problems. It seemed to work fine in my prototyping board, but when I put things together, I found that it had problems driving some TTL chips. I checked it with a multimeter and found it only put out 2.5 volts when asserted on the 5V side. This wasn't enough for an input into the MAX232N that is used for the RS-232 interface.
I am interested in hearing from anyone else who has tried this chip.
The GPIO pins that are used for output on my interface are protected by transistors which control relays. That is more than adequate protection. I am still pondering what route to take now for protecting the inputs. Opto-isolators are something I am already familiar with (and probably already have some) so I am leaning toward that option.
Eventually, I will build a new version of my interface so that I can apply all that I have learned along the way. I already regret not leaving pins open for I2C. That will have go in the next revision.