RPi Tutorial EGHS:GPIO Protection Circuits

This page is part of a work in progress.

Warnings
While most of these circuits may interface directly to the RPi, the use of a buffered interface (such as the one supplied by the Gertboard) is recommended which will help protect against damage. Alternatively, experiment with one of the Alternative Test Platforms.

'''Extreme caution should be exercised when interfacing hardware at a low level, you may damage your RPi, your equipment and potentially yourself and others. Doing so is at your own risk!'''

Aims
In order to protect the Raspberry Pi hardware, it is highly recommended that the GPIO pins are protected in some form to avoid damage. This page will introduce some circuits which can be used to protect the pins.

Note: Until RPi devices are available, I can not confirm this will work on a real RPi. For now, I shall be using the TI LaunchPad (see Alternative Test Platforms for details) to test the hardware on (as it is cheap and the logic levels similar).

THIS PAGE IS UNDER-CONSTRUCTION AND UNTESTED ON RASPBERRY PI HARDWARE

Why protect the pins?
While the GPIO pins can provide lots of useful control and sensing ability to the Raspberry Pi, it is important to remember they are wired directly into the internal core of the system. This means that they provide a very easy way to introduce bad voltages and currents into the delicate heart of the Raspberry Pi (this is not good and means it is easy to break it without exercising a little care).

Things we need to protect:

1) Drawing excess current from the pins (or short-circuiting an output)

2) Driving over-voltage on an input pin (anything above 3.3V should be avoided)

3) Static shocks, from touching pins without suitable grounding (often called ESD - ElectroStatic Discharge, occurs when your clothes etc build up an electrical charge as you move around)

All of these can potentially break your Raspberry Pi, damage the GPIO circuits or weaken it over time (reducing its overall life).

Physical Pin Protection
You must remember that the GPIO pin connections ( General Purpose Input/Output (GPIO)) also carry 3.3V, 5V and GND on the same 2x13pin header, so care must be taken when connecting and disconnecting wires that you don't accidentally connect these pins (i.e. 5V passed onto the GND or connected to 3.3V is likely to cause problems - if you are lucky the Polyfuse will kick in (can take an hour or so to reset), if you are unlucky you may break something permanently.

There are a number of ways to do this (depending on your requirements), such as using some jumpers (see photo) set to one side, strips of wire insulation (ideal for the NC - non-connection pins) or by using a full ribbon cable connector (like those used on IDE hard drives).

Photos required

Protection Circuits
There are many ways to protect the GPIO pins electrically, below explains some of the methods.

In many cases, the selected IC will also have electrical limits of their own (hopefully less restrictive than the Raspberry Pi), so you may end up blowing them instead. However, it is preferable to replace an IC (of less value and greater availability) which has been blown than to break your Raspberry Pi.

Please expand these sections with more information about options available and why some are better than others.

Transistor Switch
See the second part of the LED Driving Circuit (using Transistor Switching Circuit).

Buffer/Line Driver IC
These ICs provide an in-line connection which is buffered via an internal transistor switch to isolate the input from the output. Depending on its type, they can provide conversion between 3.3V logic and 5V logic, as well as the ability to switch the I/O direction.

Example IC: 74HC245 - 8 line driver, with direction control (74HCT245 is 5V version?).

Opto-Isolators
Opto-Isolators work by using an internal photo-LED and photo-sensitive transistor to transfer a digital signal (the LED is switched on, the transistor senses it and switches the circuit on).

This allows each side of the circuit to be fully isolated from each other, they can even be at different voltage levels if required (this is why they are often used in PSUs). Care must be taken when selecting a suitable IC as many it require a reasonable driving current to drive the internal photo-LED.

Example IC: ISP621-4X - 4 line (although the RPi may have issues driving this directly 10mA input).

Additional Info: arunet.co.uk - Using Opto-isolators with Microcontrollers

I/O Expanders
An alternative route, it to allow the Raspberry Pi to digitally interface over it's SPI or I2C connections to a purpose built I/O Expander chip. These chips are designed to allow multiple inputs/outputs to be fed to a processor over a few I/O pins (multiple I/O chips can be addressed separately too), they often have multiple high current channels available and can also include analogue to digital converters.

Protection is provided by allowing you to connect a wider range of circuits directly to the I/O Expanders pins, while the Raspberry Pi will send and receive standard logic level signals.

Example IC: PCA9555

External Processors
Much like using the above I/O Expanders, it is possible to interface directly with other microprocessors, for instance the TI LaunchPad or Andrino. Any additional features of the microprocessor will be at your disposal, such as built in ADCs and PWMs, timers or comms interfaces etc.

The external processor will need to be configured so that you can communicate with it, but you can also allow additional processing and control to be handled within the external processor as required. Also care must be taken to ensure suitable logic level conversions are done (3.3V to 5V and back again).

Example IC:

Andrino

MSP430G2553

Wireless Transceivers
Similar to using an external processor or I/O expander, normal logic levels can be used between the raspberry pi and the transceiver, clearly if the input/output is not physically connected, then there is good overall protection.