Interfacing the Raspberry Pi to the World
-
Upload
omer-kilic -
Category
Technology
-
view
7.435 -
download
0
description
Transcript of Interfacing the Raspberry Pi to the World
Interfacing the Raspberry Pito the World
Up close and personal with P1 (and P5!)
@OmerK | OSHCAMP 2012 | 15 Sep 2012
omer.kilic.name
Agenda
● Mechanical Details● Electrical Details● Software Details● Tips for headless operation● Questions
Mechanical
● Standard 100mil (2.54mm) spacing– P1 2x13 way→
– P5 2x4 way→
M/F Jumper Cables
M/F Jumper Cables
IDC Cable
Re-use old floppy cables!
http://www.raspberrypi.org/archives/1404
“Breakout” boards
Pi Cobbler from Adafruit
Pi Plate from Adafruit
Slice of Pi from Ciseco
More at: http://elinux.org/RPi_Expansion_Boards
Electrical● P1
● Power● 3.3V (max I: ~50mA)● 5V (max I: Power Supply - 700mA)
● 17 GPIO Pins, multiplexed with:● UART● I2C● SPI● PWM
● P5● 4 extra GPIO pins● Power
● More signals broken out to S2 and S5 (Camera and flat panel connectors)● Fiddly!
http://elinux.org/RPi_Low-level_peripherals
Revision 2 – Changes
● Fuses protecting the USB outputs have been removed– Power the board via back-feeding hub
● JTAG on P1● I2C peripherals swapped● P5 – New header: 4 more GPIO + Power● P6 – Reset Jumper● Mounting holes!!!!!!!!!!!!
http://www.raspberrypi.org/archives/1929
Revision 2
Power (5V)
Electrical
3.3V!
3.3V
http://www.flickr.com/photos/56601859@N00/3064468115
Use protection
● Level Shifting– Logic buffers (74HCT242)– Birectional translators (TXB0108)– Discrete shifters (FETs + Rs)
● Current limiting R
Recommended Distro
Occidentalis by Adafruithttp://learn.adafruit.com/adafruit-raspberry-pi-educational-linux-distro/overview
Software
● Peripherals are memory mapped– Access via /dev/mem
● Faster, needs root, hacky, dangerous!
– Use kernel modules/sysfs● /sys/class/gpio/gpioX/value etc.● Slower, doesn't need root, easier, (relatively) safer
Software – GPIO● /sys/class/gpio/ (export|direction|value|interrupt|unexport)● Example:
– echo 17 > /sys/class/gpio/export– echo “out” > /sys/class/gpio/gpio17/direction– echo “1” > /sys/class/gpio/gpio17/value
● Interrupt support– Use poll() on /value
Software – I2C
● /dev/i2c-0 and /dev/i2c-1● Install the i2c-utils package
– i2cdetect, i2cdump, i2cget, i2cset
● Support for kernel hardware modules:– echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device
● i2c-dev details:– http://kernel.org/doc/Documentation/i2c/dev-interface
Software – SPI
● /dev/spidev0.0 and /dev/spidev0.1– Chip select pins
● Support for kernel hardware modules:– Need to rebuild kernel!
● spidev details:– http://kernel.org/doc/Documentation/spi/spidev
Software – PWM
● No kernel module (or libgpio) support, memory mapped voodoo necessary.
● WiringPi example:– pinMode(1, PWM_OUTPUT);– PwmWrite(500);
Libraries
● Python– Quick2wire, Rpi.GPIO
● C– WiringPi, pihwm
● Bindings also available for Java(!), Ruby, Erlang
Tips for headless operation
● Use 240/16 (CPU/GPU) RAM split– No need for graphical stuff
● Setup avahi/zeroconf– No need to remember IP address
● ssh raspberrypi.local
● Setup mosh– Great for intermittent networking
Questions?