Interfacing the Raspberry Pi to the World

27
Interfacing the Raspberry Pi to the World Up close and personal with P1 (and P5!) @OmerK | OSHCAMP 2012 | 15 Sep 2012

description

Presentation from the Open Source Hardware Camp held at Hebden Bridge on 15-16 Sepmtember 2012. Event details at: http://oshug.org/event/oshcamp2012

Transcript of Interfacing the Raspberry Pi to the World

Page 1: 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

Page 2: Interfacing the Raspberry Pi to the World

omer.kilic.name

Page 3: Interfacing the Raspberry Pi to the World

Agenda

● Mechanical Details● Electrical Details● Software Details● Tips for headless operation● Questions

Page 4: Interfacing the Raspberry Pi to the World

Mechanical

● Standard 100mil (2.54mm) spacing– P1 2x13 way→

– P5 2x4 way→

Page 5: Interfacing the Raspberry Pi to the World

M/F Jumper Cables

Page 6: Interfacing the Raspberry Pi to the World

M/F Jumper Cables

Page 7: Interfacing the Raspberry Pi to the World

IDC Cable

Re-use old floppy cables!

Page 8: Interfacing the Raspberry Pi to the World

http://www.raspberrypi.org/archives/1404

Page 9: Interfacing the Raspberry Pi to the World

“Breakout” boards

Pi Cobbler from Adafruit

Page 10: Interfacing the Raspberry Pi to the World

Pi Plate from Adafruit

Slice of Pi from Ciseco

More at: http://elinux.org/RPi_Expansion_Boards

Page 11: Interfacing the Raspberry Pi to the World

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

Page 12: Interfacing the Raspberry Pi to the World

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

Page 13: Interfacing the Raspberry Pi to the World

Revision 2

Page 14: Interfacing the Raspberry Pi to the World

Power (5V)

Page 15: Interfacing the Raspberry Pi to the World

Electrical

3.3V!

Page 16: Interfacing the Raspberry Pi to the World

3.3V

Page 17: Interfacing the Raspberry Pi to the World

http://www.flickr.com/photos/56601859@N00/3064468115

Page 18: Interfacing the Raspberry Pi to the World

Use protection

● Level Shifting– Logic buffers (74HCT242)– Birectional translators (TXB0108)– Discrete shifters (FETs + Rs)

● Current limiting R

Page 19: Interfacing the Raspberry Pi to the World

Recommended Distro

Occidentalis by Adafruithttp://learn.adafruit.com/adafruit-raspberry-pi-educational-linux-distro/overview

Page 20: Interfacing the Raspberry Pi to the World

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

Page 21: Interfacing the Raspberry Pi to the World

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

Page 22: Interfacing the Raspberry Pi to the World

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

Page 23: Interfacing the Raspberry Pi to the World

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

Page 24: Interfacing the Raspberry Pi to the World

Software – PWM

● No kernel module (or libgpio) support, memory mapped voodoo necessary.

● WiringPi example:– pinMode(1, PWM_OUTPUT);– PwmWrite(500);

Page 25: Interfacing the Raspberry Pi to the World

Libraries

● Python– Quick2wire, Rpi.GPIO

● C– WiringPi, pihwm

● Bindings also available for Java(!), Ruby, Erlang

Page 26: Interfacing the Raspberry Pi to the World

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

Page 27: Interfacing the Raspberry Pi to the World

Questions?