The-MagPi-issue-14-en.pdf

(7212 KB) Pobierz
I ISSUE14 - -JUL2013
G e e t tp r r i in t t e ed c cop i i e e s s
a a t t t th e em a agp i i . . c com
A Magazine for Raspberry Pi Users
I I / /O a and l log i i c c e e x xp a an s s i ion
Robo t t i i c c a a r rm c con t t r ro l l
P a a r r a a l l l l e e l lp r ro c c e e s s s s i ing
Boo t t c c a amp r r e epo r r t t
LEDm a a t t r r i i x x
Ch a a r rm
J JAVA
Th e e c c a am e e r r a a
modu l l e e
Win a 512MB
Raspberry Pi
& interfacing
goodies
R a a s spb e e r r r r y yP i i i i s s a a t t r r a ad e em a a r r k ko f fTh e eR a a s spb e e r r r r y yP i iFound a a t t i ion . .
Th i i s sm a ag a a z z i in e ew a a s s c c r r e e a a t t e edu s s i ing a aR a a s spb e e r r r r y yP i i c compu t t e e r r . .
h t t t tp : : / / / /www . . t themagp i i . .com
1098470513.040.png 1098470513.041.png 1098470513.042.png 1098470513.043.png 1098470513.001.png 1098470513.002.png 1098470513.003.png 1098470513.004.png 1098470513.005.png
14
Welcome to the 1 4th issue of The MagPi - another fully loaded guide to all things Raspberry Pi!
This month we begin our journey in introducing the newest module in the Raspberry Pi world, the
camera, with a great guide written by James Hughes on setup and basic operation. The conclusion of
this article will be found in next month's edition where James builds on these foundations with hints and
tips on advanced usage.
We reload the Matrix with part two of the interesting Pi Matrix article, take a look at the Guzunty board
and review the ever popular South West Raspberry Pi Boot Camps.
We bring you more on the programming languages Charm, Scratch and Python plus bring you the first
MagPi article on the popular language, Java.
I am pleased to report that all pre-order Volume 1 MagPi bundles ordered via Kickstarter or
themagpi.com have now shipped. We will soon have individual issues coming to print. We hope you
enjoy the printed editions and thank you again for your support and patience in helping make the dream
a reality.
Ash Stone
Chief Editor of The MagPi
The MagPi Team
Ash Stone - Chief Editor / Administration / Proof Reading
W.H. Bell - Issue Editor / Layout / Graphics / Administration
Bryan Butler - Page Design / Graphics
Ian McAlpine - Layout / Tester / Proof Reading
Chris 'tzj' Stagg - Tester
Colin Deady - Layout / Proof Reading
Matt Judge - Website / Administration
Aaron Shaw - Layout
Shelton Caruthers - Proof Reading
Meltwater - Proof Reading
Sai Yamanoor - Tester
James Nelson - Proof Reading
Adrian Harper - Layout
Paul Carpenter - Tester
Dave Allan - Tester
Claire Price - Proof Reading
Phil Tesseyman - Tester
Steve Drew - Layout
2
1098470513.006.png 1098470513.007.png 1098470513.008.png 1098470513.009.png 1098470513.010.png 1098470513.011.png 1098470513.012.png
Contents
RASPBERRY PI CAMERA MODULE
Part 1 : Getting to grips with the camera module
4
PYTHON CONTROL: ROBOTIC ARM
8
Controlling the Maplin robotic arm with Python
12 MUNTS I/O EXPANSION BOARD
Using an ARM Cortex-M0 microcontroller
BUILD A GUZUNTY PI
14
Make a low cost hardware expander
9
PI MATRIX PART 2
16
Control individual LEDs and give the Pi Matrix a workout
THIS MONTH'S EVENTS GUIDE
21
Barnsley, Lima, Singapore, Liverpool
RASPBERRY PI BOOT CAMPS
22
What are the ingredients for a fun filled family Pi day?
CHARM PART 3
Charm syntax and semantics
24
FRESHLY ROASTED
A beginners guide to Java
28
THE PYTHON PIT
32
Using a simple client-server model for parallel calculations - part 3
COMPETITION
35
Win a 51 2MB Model B Raspberry Pi and interfacing goodies!
FEEDBACK
Have your say about The MagPi
36
Boot Camp photographs on pages 3, 22 and 23 by Alex Sheppard
Prototype camera mount on the front cover is courtesy of Grasping Hand
3
1098470513.013.png 1098470513.014.png 1098470513.015.png 1098470513.016.png 1098470513.017.png 1098470513.018.png 1098470513.019.png 1098470513.020.png 1098470513.021.png 1098470513.022.png 1098470513.023.png 1098470513.024.png
BASIC OPERATION
Getting to grips with the camera module
The Raspberry Pi camera - part 1
James Hughes
DIFFICULTY : BEGINNER
Guest Writer
A few weeks ago, the Raspberry Pi Foundation
launched their first peripheral, a 5MP camera.
Priced at $25, the same price as the model A, it’s
a very small PCB on which is an Omnivision
OV5647 camera module. It connects to either the
Model A or Model B Raspberry Pi using a 1 5cm
1 5 way ribbon connector.
image taking tasks. Firstly though, a description
of how the camera module came to be...
History
From its first launch the Raspberry Pi has had a
connector on it to attach a camera to the GPU
(the VideoCore 4 Graphics Processing Unit on
the Raspberry Pi). This connection uses the CSI-
2 electrical protocol and is a standard used in
most mobile phones. It is an extremely fast
connection, which on the Raspberry Pi is
capable of sending 1 080p sized images
(1 920x1 080 x1 0bpp) at 30 frames per second,
or lower resolution at even higher frame rates. It
had always been intended at some point to
release a camera module that could use this
connection, as the ability to stream high speed
video data through the GPU without any
interaction with the ARM processor would always
make the camera much more efficient than any
USB attached webcam. It would also enable the
use of the GPU’s ability to encode H264 video,
or JPEG images in hardware.
Over the course of this series I will take you
through initial connection of the camera to your
Raspberry Pi and will show you some of the
basic commands used to take both still and video
imagery. At the end, some of the more
sophisticated features will also be explained. Not
every option will be covered (new options are
being added all the time so it’s difficult to keep
up) but hopefully this article will give enough
information for you to be able to cover most
It turns out that productising a tiny PCB like the
camera board is not a quick task! The prototype
was re-designed to remove some unnecessary
components, but more importantly, to move the
camera crystal, used for timing, to the PCB itself.
4
1098470513.025.png 1098470513.026.png 1098470513.027.png 1098470513.028.png 1098470513.029.png 1098470513.030.png 1098470513.031.png 1098470513.032.png
eachendoftheconnector.
Electromagneticcompatibility(EMC)testinghad
shownthatthe25Mhzclockprovidedbythe
GPUcausedtoomuchinterferenceasitpassed
uptheribboncabletothePCB.Addingacrystal
tothePCBitselfstoppedthisinterference.A
couplemoreboarddesignslater,tohelpwith
productionlinemanufactureandtesting,and
eventually,aboutayearafterthefirstprototypes,
theproductionboardwasready.
Meanwhile,workhadbeenongoingtowritea
coupleofapplicationstomakeuseofthe
camera,toupdatetheGPUfirmwaretosupport
thecamera,andtoimprovethecameratuningas
thebasictuningalreadyinplacehadanumberof
obviousdefects.
Itshouldslideupeasily,andbeabletopivot
aroundslightly.Fullyinserttheribboncableinto
theslot,ensuringitisstraight,thengentlypress
downthetabstoclipitintoplace.Thecamera
PCBitselfalsorequiresyoutopullthetabsaway
fromtheboard,gentlyinsertthecable,thenpush
thetabsback.
Cameratuningisacomplextask,whichhas
beencoveredontheRaspberryPiwebsite,soI
won’trepeatithere.Sufficeittosay,theend
resultsarewellworththeextraeffortputinby
DavidPlowmanwhileatBroadcom.Thanks
David.
So,withthehistoryoutoftheway,let’stakea
lookatgettingyourcameragoing.
Settingup
Firstly, it’simportanttostartwithawarning.
Cameraslikethesearestaticsensitive.You
shouldearthyourselfpriortohandlingthePCB(a
sinktap/faucetorsimilarshouldsufficeifyou
don’thaveanearthingstrap).
Thereareonlytwoconnectionstomake,the
ribboncableneedstobeattachedtothecamera
PCBandtheRaspberryPiitself.Youneedtoget
ittherightwayroundorthecamerawillnotwork.
OnthecameraPCB,thebluebackingonthe
cableshouldbeawayfromthePCB,andonthe
RaspberryPi itshouldbetowardstheethernet
connection(orwheretheethernetconnector
wouldbeifyouareusingamodelA).
ThePCBconnectorisalittlemoreawkwardthan
theoneonthePi itself.Thereisavideoat
connectionsbeingmade.
So,wenowhavethehardwareallattached,we
nowneedtomakesurewehavethecorrect
softwareinstalled.Asexplainedabove,thereare
somecommandlineappstoinstall,anda
firmwareupgradewiththecameradriverand
tuningtoinstall.Thisprocessmaynotbe
necessaryinfutureasnewerdistro’sare
AlthoughtheconnectorsonthePCBandthePi
aredifferent,theyworkinasimilarway.Onthe
RaspberryPi,youneedtopullupthetabson
5
1098470513.033.png 1098470513.034.png 1098470513.035.png 1098470513.036.png 1098470513.037.png 1098470513.038.png 1098470513.039.png
Zgłoś jeśli naruszono regulamin