RPi 简易 GPIO 硬件 & 软件教程

From eLinux.org
Jump to: navigation, search

返回信息中心教程页。


GPIO Hardware & Software Tutorials:


警告

虽然这些大部分的电路可以直接连接到RPi上,使用缓冲接口(例如提到的 Gertboard)仍是被建议的,将能设备保护避免损坏.或者,使用一个#Alternative Test Platforms进行实验.

GPIO引脚直接接入 ARM 处理器的核心,并且是静电敏感的,所以无论何时你应该尽量避免触碰这些引脚.如果你带有静电,例如脱下腈纶套衫,或走过尼龙地毯,触碰GPIO引脚会摧毁你的R-Pi,所以在触碰这些引脚或其他连接在它们上面的东西时,保证自己接地.

在连接底层设备时应该特别的小心,你可能损坏你的RPi, 你的设备,并对你或他人存在潜在的伤害. 你将自己冒受此种风险!

Aims

This tutorial is based on this thread and aims to introduce basic circuits which can be used with the RPi's General Purpose Input/Output (GPIO). Basic electronics knowledge will be required (i.e. familiarity with typical discrete components such as transistors, diodes and resistors).

It is highly recommended that additional GPIO Protection Circuits are used to protect the delicate GPIO pins if interfacing to RPi hardware.

Useful Links/Resources

  • The Electronics Club - An excellent resource for beginner electronics, explains many basic circuits.

Protection Circuits

In order to protect the Raspberry Pi hardware, it is highly recommended that the GPIO pins are protected in some form to avoid damage.

The following link will introduce some of the ways to do this:

GPIO Protection Circuits

Alternative Test Platforms

Until you have a RPi to test with, there are many alternative platforms available which will allow the testing of basic circuits. In addition, they may be interfaced with directly using the RPi in the future.

  • TI LaunchPad - A low cost development platform ($4.30 including free world shipping). Includes programmer/debug board, two processors (with 16 GPIO including I2C/SPI/UART, 8ch 10bit ADC etc).
  • Arduino - Common hobbyist development platform. Excellent community support and additional hardware.
  • STM32 Primer/EvoPrimer - Self-contained development platform. Mentioned since I may use one at some point (I bought the original Primer a long time ago). It includes a battery, acceleration sensors and built in display screen.

Completed Tutorials

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).

Basic Circuits

1. LED output

Directly driven (will need very low powered LED) or driven via transistor (allowing higher current). Includes example 8xLED Test Module.

3. Simple on/off switch input

With or without de-bouncing, protection resistors etc. Includes example 8xSwitch Test Module.

4. 12V relay driver circuit

12V relay driver circiut with opto-decoupler. Includes schema.

Planned Tutorials

Basic Circuits

1. LED output

Completed see above.


2. Small DC motor drive

MOSFET or Darlington Pair to provide high power drive and reverse bias diode to protect from motor coils.


3. Simple on/off switch input

Completed see above.


4. Analogue resistive sensor sampled as a digital input

Using a basic transistor switch circuit.

Intermediate Circuits

1. Shift Registers - Multiplexing Data

An introduction to using additional ICs. In this case, using a parallel to serial 8-bit shift register to read 8 digital inputs using two GPIO pins.


2. Analogue to Digital Circuit

Use of a ADC chip to sample inputs.


3. PWM Driving Circuit

For example motor speed control.


4. Alpha-numeric 2x16 LCD Display

(IN-PROGRESS) Control via 4-wire data (total 6 GPIO) and also alternative 2-wire interface circuit.


5. Interfacing to I2C Devices

Interfacing to an I2C device connected to one of the Pi's I2C buses.

Advanced Circuits

1. Control Hardware Over The Internet

Implement web control and monitoring of GPIO connected components.

2. Communicating With Other Micro-controllers

Communicate with other micro-controllers so that features such as ADCs can be used.

Contributing to this tutorial

This is an open project so please feel welcome to add your own sections and improve its content.

Please see the Talk:RPi Tutorial Easy GPIO Hardware & Software page to discuss this page.