Raspberry Pi Project

advertisement
Electronics & Computer
Technology
Pi- LED Project
February 11th, 2015
Welcome to the Electronics & Computer
Technology Department’s Pi Project
Electronics and computers touch virtually every aspect of
modern life. The Electronics and Computer Technology
Department offers three exciting, hands-on degree and
certificate programs to prepare students for high-paying
careers in the fields of electronics technology, computer
servicing and networking, and electronic systems
technology (home theater and home automation,
residential and commercial security systems, and lowvoltage cabling and wiring).
Welcome to the Electronics & Computer
Technology Department’s Pi Project
The Electronics and Computer Engineering
Technology program provides fundamental and advanced
skills training in analog and digital circuits, electronic
communications, microprocessors and computers, and
industrial electronics.
The program prepares individuals either for initial
employment or for enhancement of existing skills in
electronics, or for transfer into Bachelor of Science
degree programs in Electronics or Industrial Technology
offered in the California State University system.
Welcome to the Electronics & Computer
Technology Department’s Pi Project
The Computers and Networking Technology program
provides training in electronics fundamentals as well as
in-depth study of operating systems, computer hardware,
wired and wireless networks, and servers.
Students train for industry-standard certification
examinations (A+, Network+, Security+, and Server+) and
prepare for careers as computer and networking service
technicians.
Welcome to the Electronics & Computer
Technology Department’s Pi Project
The Electronics Systems Technology fast-track
certificate offers hard- and soft-skills training leading to
employment with telephone, cable, or satellite providers;
electrical contractors; computer and networking
companies; security system specialists; and home
theater/home automation contractors.
The program offers hands-on training in low-voltage
wiring and cabling—including fiber optic, coax, and
unshielded twisted pair (UTP)—and terminations for
voice, video, and data systems.
Electronics
Do you like to make things? Are you curious about
how the electronic devices you use every day
actually work? If you are, then the Mt. SAC
Electronics & Computer Engineering Technology
degree and certificate programs are made just for
you!
Whether you want to go to work or continue your
education, Mt. SAC has the program just for you.
Electronics
The Mt. SAC Electronics Technology program covers
what you need to know to work in the exciting and
ever-changing electronics field.
Topics include
 Electronics fundamentals (DC and AC circuits)
 Analog and digital circuits and systems
 Microcontrollers and Interfaces
 Electronic communications systems
 Industrial electronics, motors, and programmable
logic controls
Electronics
Our laboratories have the latest
 Test equipment
 Assembly and fabrication equipment
 Digital development and logic trainers
 Communications modules
 Programmable logic controllers
 Computer simulation software
 Personal computers and Windows operating systems
CNET
The Computers and Networking Technology Associates
of Science Degree prepares students to become
Information Technology professionals capable of
working as computer and networking technicians.
CNET
The program provides foundations in basic electricity
and electronics, operating systems, and computer
service and troubleshooting, as well as more
advanced training in networks, servers, and security.
CNET
Students learn to install, configure, maintain,
troubleshoot and repair computers and networks.
Students will become fully prepared to take the
CompTIA A+, Network +, Server +, and Security +
certification exams.
CompTIA is an IT industry recognized benchmark for
the computer and network technician.
CNET
A solid foundation will be built upon which future
vendor specific IT certifications from Cisco,
Microsoft, and others can be pursued.
Students will receive specialized training on the
following hardware and software:
CNET










PCs with single, dual, and quad core processors
Network interface cards
Uninterruptible power supplies
Multimedia sound cards
Routers
Wireless networks
Operating systems (Windows, Linux, Apple)
LAN toolkits
Storage media
Media converters
CNET










Servers and workstations
Hubs and gateways
Laser & inkjet printers
Network analyzer (Fluke)
Switches
Modems
Patch panels
Print servers
RAID systems
Optical Fiber
CNET
At the end of a student's journey through the CNET
program they will pick up not only knowledge that
comes from rigorous studies but also from the hands
on approach to the laboratory experiments.
CNET
In our opinion, what makes this program so valuable is
the close inter-discipline relationship the students
gain from a solid understanding of fundamental
electronics.
CNET students take introductory courses in alternating
and direct current electronics as well as digital
electronics.
Electronics & Computer Technology
For a complete inspection of the Electronics and
Computer Technology program, please visit
http://electronics.mtsac.edu.
Introduction
The objective of today’s presentation is to give the
student a practical hands on experience with the
Raspberry Pi.
This will include configuring the Pi, building an
electronics circuit, and programming the Pi to control the
circuit.
What is the Raspberry Pi? Link
Introduction
Professor Simon Cox and his team at the University of
Southampton connected 64 Raspberry Pi boards to build
an experimental supercomputer, held together with Lego
bricks.
The project was able to cut the cost of a supercomputer
from millions of dollars to thousands or even hundreds.
Introduction
System on a Chip
System on a Chip
What does System on a Chip (SoC) mean?
A system on a chip (SoC) combines the required
electronic circuits of various computer components onto
a single, integrated chip (IC).
A SoC is a complete electronic substrate system that may
contain analog, digital, mixed-signal or radio frequency
functions.
System on a Chip
Its components usually include a graphical processing
unit (GPU), a central processing unit (CPU) that may be
multi-core, and system memory (RAM).
Because a SoC includes both the hardware and software,
it uses less power, has better performance, requires less
space and is more reliable than multi-chip systems. Most
system-on-chips today come inside mobile devices like
smartphones and tablets.
System on a Chip
A distinction between a microprocessor and a
microcontroller should also be explained.
A microprocessor is an integrated circuit (IC) which has
only the central processing unit (CPU) on it. Such as the
Intel i7 CPU.
Microcontrollers have a CPU, memory, and other
peripherals embedded on them.
System on a Chip
A microcontroller can be programmed to perform certain
functions.
A very popular microcontroller is the Arduino Uno.
The difference between a SoC and a microcontroller
often times is defined by the amount of random access
memory (RAM).
A SoC is capable of running its own operating system.
System on a Chip
The SoC we will use today is the Raspberry Pi B+.
The heart of this credit card sized computer is the
Broadcom BCM2835 chipset that contains an ARM CPU
and a Videocore 4 graphics processing unit.
The B+ has a 700 Mhz CPU and 512 MB of RAM.
Pi Assembly and Raspbian Install
We will now discuss how to assemble the components that
make up the Raspberry Pi.
You will need the following (should be on the bench):
• Raspberry Pi B+ board
• HDMI to DVI cable
• Monitor or TV
• Micro SD card
• USB keyboard and mouse
• Micro USB power supply
Pi Assembly and Raspbian Install
We will now bake (assemble) the Pi!
Once you have it put together, power it on.
You should see the New Out Of Box Software (NOOBS)
operating system installer.
Pi Assembly and Raspbian Install
Pi Assembly and Raspbian Install
Pi Assembly and Raspbian Install
Select the Raspbian [RECOMMENDED] option, change the
language to English (US), change the keyboard to US, and
click install.
While the OS is installing we will discuss some electronics
information.
Voltage, Current, and Resistance
When a potential difference exists between two charged
bodies that are connected by a conductor, electrons flow
in the conductor. This flow is from the negatively charged
body to the positively charged body.
The voltage does not flow, only the charge. Voltage
supplies the “push” or “pressure”.
Voltage, Current, and Resistance
Plumbing Analogy
It is difficult to keep straight the concepts of
voltage, current, charge, resistance, etc., but for
electrical circuits there is a helpful analogy with
plumbing systems. Wires are, of course, like pipes;
current is like the rate of water flow (gallons per
minute); and resistance is like friction in the
pipes. Now, here is the most helpful part of the
analogy: voltage is like water pressure, and
batteries and generators are like pumps. Like all
analogies, however, it doesn't quite work.
Voltage, Current, and Resistance
Voltage can also be looked at as water pressure.
Voltage, Current, and Resistance
We are mainly concerned with the potential
difference between two points.
Ground is the reference point and is considered to
have zero potential.
Voltage, Current, and Resistance
Voltage, Current, and Resistance
Electric current – directed flow of free electrons.
Moves from a region of negative potential to a
region of positive potential.
Therefore it can be stated that electric current
flows from negative to positive.
Breadboarding Basics
What is a Breadboard?
What is the purpose of a breadboard?
What circuit are we going to breadboard today?
How to use a breadboard
How does a breadboard work?
Are these wires connected?
Which is Correct???
Longer
Lead of
LED goes
on top
Connect Circuit to Pi
Now that you have a working resistor and LED circuit, we
can now connect it to the Raspberry Pi.
Located on the Pi is a 40 pin general purpose input output
(GPIO) connector.
Connect Circuit to Pi
The 40 pins can be connected to various inputs or
outputs.
In our experiment we will connect our LED circuit to two
of the outputs.
Connect Circuit to Pi
Connect Circuit to Pi
To connect the GPIO header to the breadboard we will
use a 40 pin cable.
The red stripe on the cable indicates pin number 1, which
is in the upper left corner of the GPIO header.
Connect Circuit to Pi
We will connect the ribbon cable as follows:
Pin 6 will be used for ground (common to both LEDs)
Pin 11 will be used for our output to the Blue LED
Pin 12 will be used for our output to the Red LED
Connect a black or brown wire to pin 6, and a red or
orange wire to pin 11 and pin 12 on the ribbon cable.
Plug the black wire to the negative side of the circuit and
the red wire to the positive side.
Connect Circuit to Pi
Your project should look like this:
Program the Pi
Now that the Pi is setup and the electronics are
connected, we will now begin programming the GPIO
output using a programming language known as Python.
Python is an interpreted, object-oriented, high-level
programing language.
Python’s simple, easy to learn syntax emphasizes
readability, which makes it easy to maintain and update.
Program the Pi
Python is included in the Raspbian distribution.
We will run a simple python program to verify that our Pi
is ready to go.
Logon to the Pi with the username of pi and the password
of raspberry
Program the Pi
You should now see the shell prompt like:
Program the Pi
Type sudo python and you should see the following:
Type quit() to exit from the python interpreter.
This shows us that Python is installed and ready for
action.
Program the Pi
We will now write our first Python program.
Type sudo nano helloworld.py and press Enter.
Nano is a text editor that can be used to type our code.
Type print “Hello World!”;
Program the Pi
Once you have the code written, press CTRL and x at the
same time and press y to save the file.
Now type sudo python helloworld.py You should see:
Program the Pi
We will now write some code to control the LED circuit.
Type sudo nano led.py and press Enter.
Program the Pi
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11,GPIO.OUT)
GPIO.output(11,GPIO.HIGH)
time.sleep(1)
GPIO.output(11,GPIO.LOW)
GPIO.cleanup()
Note, these are
capital O’s, not
0’s (zeroes).
Add code to
light up pin 12.
Program the Pi
Once you have the code written, press CTRL and x at the
same time and press y to save the file.
Now type sudo python led.py You should see your LEDs
light up for 1 second and turn off.
Modify your code to make the LEDs blink 3 times.
Program the Pi
Be sure to
use a tab
instead of
space here
Add code
for pin 12!
{
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11,GPIO.OUT)
for i in range (0,3):
GPIO.output(11, GPIO.HIGH)
time.sleep(1)
GPIO.output(11, GPIO.LOW)
time.sleep(1)
GPIO.cleanup()
Putting it all Together
You now have the skills to build a complete light show
system!
Enjoy!
Questions?
Are there any comments?
Download