Difference between revisions of "Raspberry Pi Interfacing"
Chris Tyler (talk | contribs) (→Precautions) |
Chris Tyler (talk | contribs) (→Precautions) |
||
(5 intermediate revisions by the same user not shown) | |||
Line 24: | Line 24: | ||
== Precautions == | == Precautions == | ||
− | The BCM2835 is directly connected to | + | {{Admon/caution|You can Destroy Your Raspberry Pi|The BCM2835 is directly connected to the pins on the GPIO pin header connector. Therefore, when you connect to the GPIO pin header, you are directly attaching to the SOC, and an over-voltage or over-current condition can seriously and irreversibly damage or destroy the SOC and render the Raspberry Pi useless.}} |
Two conditions lead to disastrous consequences; | Two conditions lead to disastrous consequences; | ||
− | # Grounding a pin which | + | # Grounding a pin (which may be expected to be an input) when it is configured as a high output (3.3 volts, often written as 3v3), either through the GPIO configuration or the PinMux configuration. This will cause a large current flow, probably damaging the Raspberry Pi. Likewise, connecting a pint which is expected to be an input to 3v3 when it is configured as a low output (0v) will have a similar effect. |
# Connecting any pin to a voltage greater than 3v3 or less than 0v. | # Connecting any pin to a voltage greater than 3v3 or less than 0v. | ||
− | To fully protect a pin, attach a moderate resistance (220+ ohms) and a reversed zener diode to ground rated just above 3v3. | + | To fully protect a pin, attach a moderate resistance (220+ ohms) and a reversed zener diode to ground rated just above 3v3. If you don't do this, double- and triple-check your circuits before attaching them to your Pi -- having another pair of eyes look at your circuit is also a good idea. |
It is also important to protect the Pi against: | It is also important to protect the Pi against: | ||
# [http://en.wikipedia.org/wiki/Electrostatic_discharge Electrostatic discharge] (however, it should be noted that the Pi is reasonably ESD-tolerant) | # [http://en.wikipedia.org/wiki/Electrostatic_discharge Electrostatic discharge] (however, it should be noted that the Pi is reasonably ESD-tolerant) | ||
− | # Excessive current draw (including total current drawn by all attached devices) | + | # Excessive current draw (including total current drawn by all attached devices). |
− | # Over/under-voltage from the power supply | + | # Over/under-voltage from the power supply. |
+ | # Short circuits due to stray tools, wire snippets, solder blobs, hardware, foil, conductive work surfaces, or liquids. Keep your workspace clean and clear while hardware hacking. | ||
+ | |||
+ | == Using the Raspberry Pi with a Breadboard == | ||
+ | |||
+ | There are three ways to attach the Pi's GPIO pin header to a [http://en.wikipedia.org/wiki/Breadboard solderless breadboard]: | ||
+ | # Use an [http://en.wikipedia.org/wiki/Insulation-displacement_connector IDC] ribbon cable assembly which terminates in a [http://en.wikipedia.org/wiki/Dual_in-line_package DIP] adapter plug or a small PCB with two rows of pin headers 0.3" apart. | ||
+ | # Use female-to-male [http://en.wikipedia.org/wiki/Jump_wire jumper wires]. The female end is connected to a selected pin in the GPIO pin header, and the male end is attached to the breadboard. | ||
+ | # Use micro test clips (J-clips, grabber clips) to attach to individual header pins. The micro test clips can be attached to wires inserted into the breadboard, or you can use double-ended test clip cables and attach to devices plugged into the breadboard. | ||
+ | |||
+ | == Logic level pain: 3.3 volt vs 5 volt signalling == | ||
+ | |||
+ | "TTL" digital signals were traditionally 5v signals -- 5v indicated a "1", 0v indicated a "0". More recent devices use 3v3 or 1v8 signals. | ||
+ | |||
+ | The Raspberry Pi uses 3v3 signalling. [http://www.arduino.cc/ Arduino]-compatible devices generally use 5v. Other devices vary. | ||
+ | |||
+ | Sometimes, no signal conversion is necessary between 3v3 and 5v signalling systems. For example, a 3v3 output driving a 5v input will often work, because the 3v3 "high" ("1") level is more than half of the 5v signalling level and therefore properly registers as a high signal. | ||
+ | |||
+ | However, connecting a 5v output to a 3v3 input presents problems. A simple solution can be to use a voltage divider (pair of resistors) to tap 3v3 from the 5v signal. When a bidirectional signal is used, an active bidirectional voltage converter is required. |
Latest revision as of 11:57, 2 October 2012
Contents
Available Interfaces
The Raspberry Pi (model B, revision 1 or 2) is equipped with these standard interfaces:
- USB 2.0 (x2)
- 10 or 100 Mbps ethernet on twisted pair
- HDMI at up to 1080p30 resolution (1920x1080, progressive scan, 30 frames/second). Note that DVI-D and HDMI are equivalent except for the connectors and the inclusion of sound in HDMI - therefore, the Pi can be connected to a DVI monitor with the appropriate HDMI to DVI-D cables and/or adapters.
- Composite video (NTSC/NTSC-J or PAL/PAL-M format). This output can be used to drive older video monitors, or small composite LCD displays.
- Analog stereo audio (on a 3.5 mm (1/8") TRS jack).
- Pin header exposing GPIO, SPI, I2C, serial, and (in board revision 2) JTAG. All of these signals are provided at TTL 3v3 (+3.3 volts DC (VDC) +/-10% for a logical "high" or "1", 0 VDC for a logical "low" or "0"). A +5 VDC supply is also provided.
- CSI - Camera serial interface. The connector accepts a [fttp://en.wikipedia.org/wiki/Flexible_flat_cable flexible flat cable].
- DSI - Display serial interface, for connection to a small LCD panel or similar interface. The connector accepts a [fttp://en.wikipedia.org/wiki/Flexible_flat_cable flexible flat cable].
For custom-designed devices, the GPIO pin headers (and sometimes the audio output and/or USB connections) are usually used.
PinMux
The Broadcom BCM2835 system-on-a-chip used in the Raspberry Pi, like other SOCs, uses pin multiplexing (pinmux) to select which signals will be present on the pins/balls of the chip. This is done because the number of available signals exceeds the number of available pins.
Precautions
Two conditions lead to disastrous consequences;
- Grounding a pin (which may be expected to be an input) when it is configured as a high output (3.3 volts, often written as 3v3), either through the GPIO configuration or the PinMux configuration. This will cause a large current flow, probably damaging the Raspberry Pi. Likewise, connecting a pint which is expected to be an input to 3v3 when it is configured as a low output (0v) will have a similar effect.
- Connecting any pin to a voltage greater than 3v3 or less than 0v.
To fully protect a pin, attach a moderate resistance (220+ ohms) and a reversed zener diode to ground rated just above 3v3. If you don't do this, double- and triple-check your circuits before attaching them to your Pi -- having another pair of eyes look at your circuit is also a good idea.
It is also important to protect the Pi against:
- Electrostatic discharge (however, it should be noted that the Pi is reasonably ESD-tolerant)
- Excessive current draw (including total current drawn by all attached devices).
- Over/under-voltage from the power supply.
- Short circuits due to stray tools, wire snippets, solder blobs, hardware, foil, conductive work surfaces, or liquids. Keep your workspace clean and clear while hardware hacking.
Using the Raspberry Pi with a Breadboard
There are three ways to attach the Pi's GPIO pin header to a solderless breadboard:
- Use an IDC ribbon cable assembly which terminates in a DIP adapter plug or a small PCB with two rows of pin headers 0.3" apart.
- Use female-to-male jumper wires. The female end is connected to a selected pin in the GPIO pin header, and the male end is attached to the breadboard.
- Use micro test clips (J-clips, grabber clips) to attach to individual header pins. The micro test clips can be attached to wires inserted into the breadboard, or you can use double-ended test clip cables and attach to devices plugged into the breadboard.
Logic level pain: 3.3 volt vs 5 volt signalling
"TTL" digital signals were traditionally 5v signals -- 5v indicated a "1", 0v indicated a "0". More recent devices use 3v3 or 1v8 signals.
The Raspberry Pi uses 3v3 signalling. Arduino-compatible devices generally use 5v. Other devices vary.
Sometimes, no signal conversion is necessary between 3v3 and 5v signalling systems. For example, a 3v3 output driving a 5v input will often work, because the 3v3 "high" ("1") level is more than half of the 5v signalling level and therefore properly registers as a high signal.
However, connecting a 5v output to a 3v3 input presents problems. A simple solution can be to use a voltage divider (pair of resistors) to tap 3v3 from the 5v signal. When a bidirectional signal is used, an active bidirectional voltage converter is required.