Lecture Raspberry Pi
Lecture Raspberry Pi
Lecture Raspberry Pi
• Introduction to
Raspberry Pi
1
What is a Raspberry Pi?
• A credit card sized PC
• Plugs into a TV or monitor
• Inexpensive(ish) ~$35 each
• Capability:
– Programming
– Electronic Projects
– Office
– Play HD Videos
2
Application and Uses
Robotics
● Game emulation
● Education (Python is the
primary language used)
● Powerful enough to be used as personal
computer
● Thousands of projects
3
Kit Components
• Essential:
– Raspberry Pi board
– Prepared Operating System SD Card
– USB keyboard
– Display (with HDMI)
– Power Supply
• Highly suggested extras include:
– USB mouse
– Internet connectivity - LAN cable
– Case
CPU
ARM Processor,700MHz
–
Low power draw
–
GPU
Broadcom Video
Specialized graphical instruction sets
•
RAM
512MB (Model B)
5
System on Chip (SoC)
What is System on Chip?
A complex IC that integrates the major functional elements
into a single chip or chipset.
programmable processor
on-chip memory
accelerating function hardware (e.g. GPU)
both hardware and software
analog components
•
Benefits of SoC
Reduce overall system cost
Increase performance
Lower power consumption
Reduce size
6
Programming Languages
• The Raspberry Pi Foundation recommends Python
• Any language which will compile for ARM
processor can be used.
7
Power
5v micro
USB
connector
GPIO
(General
Purpose
Input &
Output)
10/100Mb
Ethernet
10
General Purpose Input/Output
(GPIO)
–
Pins can be configured to be input/output
–
Reading from various environmental sensors
•
Ex: IR, video,temperature, 3-axis
orientation,acceleration
–
Writing output to dc motors, LEDs for status.
11
12
General Purpose Input/Output (GPIO)
General Purpose Input/Output (GPIO) is a generic pin on a chip
whose behavior can be controlled by the user at run time.
14
General Purpose Input/Output (GPIO)
All the pins have 3.3V logic levels and are not 5V-safe so the output
levels are 0-3.3V and the inputs should not be higher than 3.3V.
15
Internals LAN Controller
DSI
(display
interface) CSI
(camera
interface)
SOC (System On a Chip)
Broadcom BCM2835 700Mhz
16
Storage
SD Card Slot
(supports SD cards up to 32GB) 17
Models A and B Specification
Two Models A & B, priced at $25 and $35
respectively
● Model A/B:
○ Broadcom BCM2835 (CPU & GPU(Graphics
Processing Unit)
○ 256/512MB RAM
○ 1/2 USB 2.0 Ports
○ None/Ethernet Port
○ HDMI
○ Audio
○ SD Card Slot
○ Micro USB for power
18
Blinking of LED
import RPi.GPIO as GPIO import RPi.GPIO as GPIO
import time import time
GPIO.setmode(GPIO.BCM)
GPIO.setmode(GPIO.BCM) GPIO.setup(18, GPIO.OUT)
GPIO.setup(8, GPIO.OUT) while (True):
while (True): GPIO.output(18,True)
GPIO.output(8,True)
time.sleep(1)
time.sleep(1)
GPIO.output(8,False) GPIO.output(18,False)
time.sleep(1) time.sleep(1)
GPIO.cleanup()
19
Interfacing of Switch and LED
import RPi.GPIO as IO
import os
import time
from time import sleep
IO.setwarnings(False)
IO.setmode(IO.BOARD)
IO.cleanup()
switch=5
led=8
IO.setup(switch,IO.IN)
IO.setup(led,IO.OUT)
while True:
print(IO.input(sensor))
if(IO.input(sensor)==1):
IO.output(led,True)
print('done1')
else:
IO.output(led,False)
print('done2')
20
ARM Processor
ARM is a 32-bit load / store architecture
The only memory accesses allowed are loads and stores
Most internal registers are 32 bits wide
Most instructions execute in a single cycle
21
Processor Modes
• ARM has seven basic operating modes
– Each mode has access to its own stack space and a different subset of
registers
– Some operations can only be carried out in a privileged mode
Mode Description
Supervisor Entered on reset and when a Supervisor call
Exception modes
cpsr
spsr spsr spsr spsr spsr
https://www.arm.com/.../ppt/ARM_Processors_and_Architectures_Uni_Program_.p
25
Some useful links
Raspberry Pi official website
–
http://www.raspberrypi.org/
•
Raspberry Pi wiki
–
http://elinux.org/RaspberryPiBoard
•
Raspberry Pi verified peripherals
–
http://elinux.org/RPi_VerifiedPeripherals
•
The MagPi
–
http://www.themagpi.com
•
Raspberry Pi on Adafruit Learning System:
–
http://learn.adafruit.com/category/learn-raspberry-pi
26