Download - Raspberry pi

Transcript
Page 1: Raspberry pi

Raspberry Pi.. what we have learned so far ..

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

http://wolfpaulus.com

Page 2: Raspberry pi

General Purpose Computer

Headless Server

Embedded System

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 3: Raspberry pi

Model B

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 4: Raspberry pi

“From a position in the mid-1990, when 17-year-olds came to the University with a grounding in several computer languages, hardware hacking, and often even with assembly language, we gradually found ourselves in a position where, by 2005, these kids were arriving having done some HTML - with a bit of PHP and Cascading Style Sheets if you were lucky.”

Why ?

RaspberryPiPrototype Model A

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 5: Raspberry pi

May 2011 Video of the Raspberry Pi, recorded by tech journalist Rory Cellan-Jones with his phone, goes viral.

Feb 29th 2012Google shows more searches for “Raspberry Pi” than “Lady Gaga” andhardware suppliers’ Websites crash under the load of up to 7 orders per second.

June 2012 Raspberry Pi User Forum has 20K members who have written more than 100K posts.

Feb 2013 One Million Raspberry Pi sold

H!tory

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 6: Raspberry pi

Model B

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 7: Raspberry pi
Page 8: Raspberry pi

Model A

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 9: Raspberry pi

• AROS

• Android 4.0 (Ice Cream Sandwich)

• Arch Linux ARM

• Debian Squeeze

• FreeBSD

• Firefox OS

• Gentoo Linux

• Google Chrome OS

• NetBSD

• Raspberry Pi Fedora Remix

• Open webOS

• Raspbian (Debian Wheezy port with faster floating point support)

• RISC OS

• Slackware ARM

• QtonPi (Linux distribution based on the Qt framework)

Operating Sy"ems

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 10: Raspberry pi
Page 11: Raspberry pi

Creating a bootable SDCardMac OS X System Information Tool

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 12: Raspberry pi

Download the compressed image file from http://www.raspberrypi.org/downloads

Un-compress the archive, to get to the image file.

df -h, to determine which drive is used for the SDCard

$ sudo diskutil unmount /dev/disk2s1$ sudo dd bs=1m if=./2012-09-18-wheezy-raspbian.img of=/dev/rdisk2$ sync$ sudo diskutil eject /dev/rdisk2

Creating a bootable SDCard

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 13: Raspberry pi

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 14: Raspberry pi

Configu#ngRa$berry Pi

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 15: Raspberry pi

DemoCopyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 16: Raspberry pi

Configu#ngRa$berry Pi

• sudo raspi-config

• Expand the disk image from 2GB all the way ...

• Re-boot

• sudo raspi-config

• Configure Local

• Configure Keyboard Layout

• Configure TimeZone

• Change Password

• Enable SSH

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 17: Raspberry pi

Ra$berryPi LXDE

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 18: Raspberry pi

Ra$berryPi

$ cat /etc/network/interfaces

auto loiface lo inet loopbackiface eth0 inet dhcp

allow-hotplug wlan0iface wlan0 inet manualwpa-roam /etc/wpa_supplicant/wpa_supplicant.confiface default inet dhcp

$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf..network={

ssid=”SSID”psk=”******“proto=RSNkey_mgmt=WPA-PSKpairwise=CCMPauth_alg=OPEN

}

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 19: Raspberry pi

Ho"name“raspberrypi”

Change Hostname:

sudo nano /etc/hostname

sudo nano /etc/hosts

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 20: Raspberry pi

Ra$berry PiHeadless Server

Pt.2Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 21: Raspberry pi

Steps to make a Raspberry Pi Supercomputerhttp://www.southampton.ac.uk/~sjc/raspberrypi/pi_supercomputer_southampton_web.pdf

MPI: A High Performance Message Passing Libraryhttp://www.open-mpi.org/

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 22: Raspberry pi

apt-get update - updates current list of available packagesapt-get upgrade - updates currently installed packagesapt-get install package-name - installs or upgrades package-name

apt-cache search name - searches the package list for nameapt-get remove package-name - removes packageapt-get --purge remove package-name - removes package and configuration filesapt get autoclean - removes files, needed during upgrade process apt-get autoremove - removes not longer needed dependencies

Advanced Packaging Tool (APT)

Ra$berryPi APT

Sources to retrieve packages from:/etc/apt/sources.list

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 23: Raspberry pi

Install: sudo apt-get install tightvncserverStart: tightvncserverStop: tightvncserver -kill :1

Ra$berryPi VNC Server

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 24: Raspberry pi

DemoCopyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 25: Raspberry pi

Ra$berry PiCamera Server

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 26: Raspberry pi

Ra$berry PiCamera Server

1.) Get the mpeg-streamer source code:svn co https://mjpg-streamer.svn.sourceforge.net/svnroot/mjpg-streamer mjpg-streamer

2.) Installing build dependencies sudo apt-get install libjpeg8-dev imagemagick

3.) make4.) Starting the Camera Stream./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so -w ./www"

<p  align="center">    <img  src="http://<IP>:8080/?action=stream"  width="1280"  height="960"  /></p>

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 27: Raspberry pi
Page 28: Raspberry pi

DemoCopyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 29: Raspberry pi

Ra$berry PiEmbedded Sy"em

Pt.3Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 30: Raspberry pi

Arduino UNO : Arduino MEGA : Raspberry Pi

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 31: Raspberry pi

UNO MEGA DUE Pi

Operating Voltage

SRAM

FLASH-Memory

Clock Speed

USB Host

Network

Audio / Video

Current I/O pins

Digital I/O Pins

Analog Input Pins

Price

5 V 5 V 3.3 V 3.3 V

2 KB 8 KB 96 KB 512 MB

32 KB 256 KB 512 KB up to 64 MB

16 MHz 16 MHz 84 MHz 700 MHz

n/a n/a 1 2

n/a n/a n/a 10/100 wired Ethernet RJ45

n/a n/a n/aHDMI, Composite Video,

TRS-audio jack

40 mA 40 mA total 130 mA 2 to 16 mA

14 (6 PWM) 54 (15 PWM) 54 (12 PWM) 17 (1 PWM)

6 1612

2DAC Analog Out 0

$30 $59 $50 $35

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 32: Raspberry pi

MCP3008 8-Channel 10-Bit ADC With SPI Interface

Ra$berryPi wi& ADC

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 33: Raspberry pi

I2C

SPI

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 34: Raspberry pi

I2C connects the same two signal lines to all slaves. I.e. addressing is required and all devices need a unique addressSDA - Serial DataSCL - Serial Clock

Ra$berryPi Inter-IC Bus - I2C

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 35: Raspberry pi

SPI requires four signals: clock (SCLK)master output/slave input (MOSI)master input/slave output (MISO)slave select (SS) or (CS) chip-select

Ra$berryPi Se#al Pe#pheral Interface Bus - SPI

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 36: Raspberry pi

pi@raspberrypi ~ $ cat /etc/modprobe.d/raspi-blacklist.conf# blacklist spi and i2c by default (many users don't need them)blacklist spi-bcm2708blacklist i2c-bcm2708

Loading Kernel Modules:- Edit the raspi-blacklist.conf, so that the i2c module gets enabled.- Add the following lines to /etc/modules 

i2c-dev i2c-bcm2708

Reboot, and confirm ls /dev/i2c* shows

/dev/i2c-0 /dev/i2c-1

Installing Dependencies:sudo apt-get install python-smbus i2c-tools

With i2c devices connected, run somthing like this, to discover devices addresses.sudo i2cdetect -y 0

I2C

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 37: Raspberry pi

pi@raspberrypi ~ $ cat /etc/modprobe.d/raspi-blacklist.conf# blacklist spi and i2c by default (many users don't need them)blacklist spi-bcm2708blacklist i2c-bcm2708

Loading Kernel Modules:Edit the raspi-blacklist.conf, so that the spi module gets loaded, Reboot, and confirm with lsmod that ‘spidev’ and ‘spi_bcm2708’ are now loaded and ls /dev/spi* shows two spi devices: /dev/spidev0.0 and /dev/spidev0.1

Installing Dependencies:sudo apt-get install python-dev git-core

Install Python bindings for Linux SPI access through spidev:cd ~git clone git://github.com/doceme/py-spidevcd py-spidev/sudo python setup.py install

... which creates /usr/local/lib/python2.7/dist-packages/spidev.so

SPI

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 38: Raspberry pi

IN =[0000 0001][1CNL ----][---- ----]

(8+channel) <<4OUT=[---- ----][---- -XXX][XXXX XXXX] (10bit)

((r[1] & 3) << 8) + r[2] Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 39: Raspberry pi

IN =[0000 0001][1CNL ----][---- ----]

(8+channel) <<4OUT=[---- ----][---- -XXX][XXXX XXXX]

r[0] ((r[1] & 3) << 8) + r[2]

r = spi.xfer2( [1, (8+chnnl)<<4, 0] ) return ((r[1] & 3) << 8) + r[2]

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 40: Raspberry pi

1 #!/usr/bin/python 2 import spidev 3 import time 4 5 # Performs SPI transaction, CS will be held active between blocks 6 # Generally, SPI transfer can transport up to 8KBytes 7 def readadc(chnnl): 8 if (chnnl > 7) or (chnnl < 0): 9 return -1 10 r = spi.xfer2( [1, (8+chnnl)<<4, 0] ) 11 return ((r[1] & 3) << 8) + r[2] 12 13 # Sends a String to an 7-Segment LED display, connected via SPI 14 # The maximum speed of the SPI clock input is 250kHz. 15 # SPI mode 0 (CPOL = 0, CPHA = 0); 16 # the clock line should idle low, and data is sampled on the rising edge of the clock. 17 def sendDisplay(s) : 18 spi.xfer2([118]) # clear screen 19 ca = list(s) # convert the string into a char array 20 spi.xfer2([ord(ca[0]),ord(ca[1]),ord(ca[2]),ord(ca[3])]) 21 return 22 23 # Simple moving average of the list. Up to length item are included. 24 # The new value is added to the given list while the 1st value might be removed. 25 def movavg(list, length, value): 26 list.append(value) 27 if length < len(list) : 28 del list[0] 29 sum=0 30 for x in list[:] : 31 sum+=x 32 return sum / len(list)

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 41: Raspberry pi

33 34 # Declare Global Variables 35 # 36 spi = spidev.SpiDev() 37 pause = 0.5 38 adc_channel = 0 39 movavg_window = 3 40 l = list() 41 42 # Main Loop 43 # 44 while True: 45 time.sleep(pause) 46 47 spi.open(0,0) # Connects the spi object to /dev/spidev-0.0 48 value = readadc(adc_channel) # Read the current ADC Channel value 49 spi.close() # Done with this SPI channel for now 50 51 ma = movavg(l, movavg_window, value) 52 sa = '%04d' % ma 53 54 print value # Show current sensor value in console 55 56 spi.open(0,1) # Connects the SPI object to /dev/spidev-0.1 57 spi.mode=0 # SPI mode 0 (CPOL = 0, CPHA = 0); 58 spi.max_speed_hz = 250000 # Set SPI clock speed to 250kHz. 59 sendDisplay(sa) # update the display 60 spi.close() # Done with this SPI channel for now

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 42: Raspberry pi

3.3V

Ground SPI

Light Sensor

LED-Display

ADCSPI

CS

CS

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 43: Raspberry pi

Light Sensor

LED-Display

SPI

CSCS

SPIADC

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 44: Raspberry pi

DemoCopyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 45: Raspberry pi

Se#al AccessRa$berry Pi

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 46: Raspberry pi

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 47: Raspberry pi

USB to TTL Serial Cable

$10

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 48: Raspberry pi

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 49: Raspberry pi

USB to Serial$ 20

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 50: Raspberry pi

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 51: Raspberry pi

FTDI Basic Breakout - 3.3V

$ 15

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 52: Raspberry pi

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 53: Raspberry pi

DemoCopyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 54: Raspberry pi

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 55: Raspberry pi

BootingRa$berry Pi

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 56: Raspberry pi

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 57: Raspberry pi

60MB Boot Partition easily accessible from your PC

rootfs and tmpfs

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 58: Raspberry pi

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 59: Raspberry pi

Summary.. what we have learned so far ..

General Purpose Computer

Headless Server

Embedded System

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

Page 60: Raspberry pi

(anks for coming

Copyright © 2012-2013, Wolf Paulus. A Tech Casita Production. All rights reserved.

http://wolfpaulus.com


Top Related