The-MagPi-issue-8-en.pdf
(
17779 KB
)
Pobierz
I
I
S
S
S
S
U
U
E
E
0
0
8
8
D
D
E
E
C
C
2
2
0
0
1
1
2
2
VisitourKickstarter
http://kck.st/TvkdvG
forprintedMagPi!
A
A
M
M
a
a
g
g
a
a
z
z
i
i
n
n
e
e
f
f
o
o
r
r
R
R
a
a
s
s
p
p
b
b
e
e
r
r
r
r
y
y
P
P
i
i
U
U
s
s
e
e
r
r
s
s
C
C
a
a
t
t
c
c
h
h
S
S
a
a
n
n
t
t
a
a
u
u
s
s
i
i
n
n
g
g
h
h
o
o
m
m
e
e
a
a
u
u
t
t
o
o
m
m
a
a
t
t
i
i
o
o
n
n
T
T
h
h
i
i
s
s
I
I
s
s
s
s
u
u
e
e
.
.
.
.
.
.
Wina512MB
RaspberryPi
•
•
S
S
k
k
u
u
t
t
t
t
e
e
r
r
•
•
N
N
a
a
n
n
p
p
y
y
•
•
P
P
i
i
G
G
a
a
u
u
g
g
e
e
•
•
P
P
i
i
b
b
o
o
w
w
•
•
C
C
E
E
S
S
I
I
L
L
P
P
i
i
•
•
C
C
+
+
+
+
•
•
A
A
d
d
a
a
•
•
M
M
y
y
S
S
Q
Q
L
L
•
•
P
P
y
y
t
t
h
h
o
o
n
n
P
P
i
i
t
t
M
M
e
e
r
r
r
r
y
y
C
C
h
h
r
r
i
i
s
s
t
t
m
m
a
a
s
s
F
F
r
r
o
o
m
m
T
T
h
h
e
e
M
M
a
a
g
g
P
P
i
i
h
h
t
t
t
t
p
p
:
:
/
/
/
/
w
w
w
w
w
w
.
.
t
t
h
h
e
e
m
m
a
a
g
g
p
p
i
i
.
.
c
c
o
o
m
m
RaspberryPiisatrademarkofTheRaspberryPiFoundation.
ThismagazinewascreatedusingaRaspberryPicomputer.
WelcometotheeightheditionoftheMagPimagazine,
It’sChristmas!Inthisissuewehopetoenticeyouintosomefestiveprojectstotryaftergorgingyourselftothebrimwith
Christmaspudding.
Inthismonth’sedition,weintroduceyoutoasimplehomeautomationprojectallowingyoutocontrollightsand
appliancesinyourhouseusingthepowerofthePi!JustintimetocatchMrClaus!WegetyourSkutterprojectinmotion
withMorphy’sarticleonaddingwheelstoyourbase.GordonteachesushowtolightupaXmastree,wehavemoreon
usingthePitocontrolanArduinoandBendescribeshowtocontrolservosattachedtothePiusingtheInternet!Ifthis
isn’tenoughwehavemoreoftheoldfavouritesplusanintroductiontoSQL.
Asperalways,wehavesomegreatgiftsforyoutowininourmonthlymagazine.TheMagPiwouldliketosayabig
thankyouyetagaintoPCSupplieswhothismonthhasoutdonethemselvesbyofferingupa512MBRaspberryPifor
grabs!
Inadditiontothiswehavesomeexcitingnewsforyouthismonth.AsofDecember1st,weattheMagPi,aresoexcited
tobeabletoofferourreadersthepossibilityofaprintedversionofalleightissuesofthemagazine!Thisissomething
whichgetsconstantlyrequestedofusfromourreaders.Alleightissueswillbebeautifullywrappedupinlimitededition
MagPibindermakingitagreatgifttoyourselforanyofyourlovedonesofanyage.Formoreinformationonthisplease
visitwww.kickstarter.com/projects/themagpi/themagpimagazinefromvirtualtoreality
Onbehalfofthewholeteam,thankyouagainforallyoursupport.WehopeyouhaveafantasticChristmasandwewill
seeyouintheNewYear(1stofFebruary).Whilewehavenotmanagedtosqueezeitintothisissue,youmightbe
interestedinwww.xmas4all.co.ukfromwhichyouwillbeabletocontroltheirRaspberryPipoweredChristmaslights!
AshStone
ChiefEditorofTheMagPi
MagPi team
Ash Stone-ChiefEditor/Administrator
Chris 'tzj' Stagg-Writer/Photographer/PageDesigns
Colin Deady-Writer/PageDesigns
Jason 'Jaseman' Davies-Website/PageDesigns
Matt '0the0judge0'-Website/Administrator
Meltwater-Photographer/PageDesigns/Admin.
Aaron Shaw-PageDesigns/Graphics
Ian McAlpine-PageDesigns/Graphics
Lix-PageDesigns/Graphics
Sam Marshall-PageDesigns/Graphics
W. H. Bell-PageDesigns
Guest writers
Bodge N Hackitt-Writer
Geoff Johnson-Writer
Andrea Stagi-Writer
Ben Schaefer-Writer
Gordon Henderson-Writer
A
lex Kerr-Writer
Luke Guest-Writer
Richard Wenner-Writer
2
Contents
04
SKUTTER RETURNS
Digoutthetoolboxforthenextthrillinginstallment,byBodgeNHackitt
08
HOME AUTOMATION - SANTA TRAP
ControlyourhomewithaRaspberryPiandcatchSantaintheact!byGeoffJohnson
11
THIS MONTH'S COMPETITION
Wina512MbRaspberryPiModelB,fromPCSuppliesUK
12
CONTROL YOUR ARDUINO WITH PYTHON & RASPBERRY PI
ThepowerofRaspberryandthesimplicityofArduinousingNanpy,byAndreaStagi
14
PI GAUGE
Controlservosovertheinternet,byBenSchaefer
17
BOOK PROMOTION - GETTING STARTED WITH PYTHON
SimonMonk'snewbookcoveringbasictofullGPIOpythonexamples.
18
PIBOW INTERVIEW
AninterviewwiththedesignersofthePiBowcase,byChrisStagg
20
CESIL POWERED CHRISTMAS TREE
Christmasfromthe70'susingtheCESILprogramminglanguage,byGordonHenderson
22
WELCOME TO THE C++ CACHE
UsingbasicvariablesandSTLstrings,byAlexKerr
24
BEGINING ADA
ThesecondinstallmentinourAdaprogrammingtutorial,byLukeA.Guest
26
DATABASE BOOTCAMP
GetyourteethintosomeStructuredQueryLanguage(SQL),byRichardWenner
29
THIS MONTH'S EVENTS LIST
RaspberryJamsandothercommunityevents
30
THE PYTHON PIT
Creatingmultipledesktopwidgets,byColinDeady
32
THE YEAR OF THE MAGPI
3
Addingamotorisedbase
DIFFICULTY: ADVANCED
Part2
A simple switching “H bridge”
Thi s di agram shows a si mpl i fi ed versi on of
such a ci rcui t. Cl osi ng swi tches 1 and 2
effecti vel y connects the posi ti ve rai l of the
power suppl y to the + termi nal on the motor
and ground to the – termi nal and the motor
runs forwards. Al ternati vel y, cl osi ng swi tches
3 and 4 connects the ground to the + termi nal
and the posi ti ve rai l to the – termi nal and the
motor runs i n reverse.
I n the l ast arti cl e we l ooked at some physi cal
means of addi ng motors to a robot and
i nvesti gated adapti ng some motori sed
el ectroni c toys as a potenti al source for robot
bases.
I n
thi s
arti cl e
I
wi l l
begi n
to
expl ai n
how you
can
bui l d
your very own
DC el ectroni c motor
There
i s
a
potenti al l y
dangerous
si tuati on
i f
dri ver
modul e
and
wri te
a
basi c
control
swi tches 1
and 4 or 3 and 2 are cl osed. Thi s
program for i t.
woul d
create
a
short
ci rcui t
between
Power
Suppl y
+
and
Ground
whi ch
can
be
very
We wi l l start by re-exami ni ng the standard DC
motor that was covered i n the previ ous arti cl e.
probl emati c
to
say
the
l east.
Care
must
be
taken
when
control l i ng
thi s
ci rcui t
to
ensure
that thi s si tuati on can never happen.
To make the motor run
forwards we appl y a
power source between
the + and
– termi nal s
I n real i ty we can’ t have four physi cal on / off
swi tches
on
the
motor
and
to
make
i t
run
i n
reverse,
l i ke
thi s
as
we
need
to
control
the
si mpl y
swap
the
power
source
termi nal s
ci rcui t usi ng the GPI O on the Raspberry Pi .
around.
There are el ectroni c sol uti ons to thi s. One
possi bi l i ty i s the use of el ectromagneti c rel ays
to cl ose these “swi tches” , however the
Raspberry Pi i s not abl e to del i ver enough
power from the GPI O to di rectl y acti vate such
a rel ay wi thout havi ng
The motor dri ver modul e we are goi ng to
create wi l l need to be a ci rcui t whi ch i s abl e to
do thi s swappi ng around of the power suppl y
termi nal s
el ectroni cal l y.
Thi s
can
be
accompl i shed usi ng a “H bri dge ci rcui t” .
somethi ng
i n-between
such
as
a
transi stor.
Thi s
l eads
us
to
the
second
possi bl e
sol uti on
whi ch
i s
to
si mpl y
use some transi stors as swi tches.
Transistors as switches
The transi stor i s arguabl y the most i mportant
el ectroni c i nventi on ever created. I ts
devel opment i s responsi bl e for everythi ng
from portabl e musi c pl ayers to the processor
used i n the Raspberry Pi .
4
We
wi l l
be
l ooki ng
at
N PN
type
transi stors.
draw when our roboti c base i s trundl i ng al ong
the
Thi s
devi ce
has
three
termi nal s
cal l ed
base,
fl oor.
One
way
to
accuratel y
obtai n
thi s
col l ector and emi tter.
measurement
i s
to
make
the
base
move
on
the
ground
and
measure
the
current
that
i s
Connecti ng a power suppl y across the
col l ector and emi tter al l ows the transi stor to be
used as a swi tch. Wi thout a connecti on to the
base, the “i nternal resi stance” of the transi stor
i s extremel y hi gh and the “swi tch” i s off.
bei ng drawn. H ere i s the method I
used wi th
my Bi g Trak:
Connect the mul ti meter i n seri es between the
battery/power suppl y and one of the motors i n
the Bi g Trak.
I f
we
appl y
a
current
to
the
transi stor
base
then
the
i nternal
resi stance
wi l l
drop
by
a
correspondi ng
amount
and
more
current
wi l l
fl ow from the col l ector to the emi tter.
The transi stor i s abl e to vary i ts i nternal
resi stance very qui ckl y, tens of thousands of
ti mes per second. (I t’ s thi s feature that al l ows
transi stors to be used as ampl i fi ers) .
The amount that the current affects the
i nternal resi stance of the transi stor i s defi ned
by a rati o known as the “DC current gai n” and
i s referred to as “h
FE
” .
I n our case we want to suppl y a current to the
base that wi l l make the i nternal resi stance be
near zero – j ust l i ke a cl osed swi tch. Thi s i s
cal l ed “Transi stor Saturati on” and there i s an
equati on whi ch tel l s us the current we need to
appl y to the base to make thi s happen,
I
B
=I
C
/h
FE
where I
C
i s the col l ector current and I
B
i s the
base current. I n order to fi nd out what thi s
current i s i t’ s necessary to measure the
current that’ s drawn by the motor. Thi s means
an experi ment i s needed!
The second motor must al so be connected to
the power suppl y and acti ve otherwi se onl y
one motor wi l l try to dri ve the whol e Bi g Trak
whi ch
wi l l
resul t
i n
an
i naccurate
measurement.
H owever
we
onl y
need
to
measure
the
current
drawn
by
one
of
these
For thi s you wi l l need your motori sed base (i n
my case i t’ s the modi fi ed Bi g Trak) , a power
suppl y (some batteri es) and a mul ti meter.
two i denti cal motors.
Add some wei ght to the Bi g Trak whi ch
approxi mates the expected overal l wei ght of
the fi ni shed robot. I n the case of the Skutter
thi s i ncl udes addi ng the robot arm.
I f you don’ t own a mul ti meter yet, they are an
essenti al tool for anyone who i s i nvol ved i n
el ectroni cs and al l ow you take a wi de range of
measurements
i ncl udi ng
vol tage,
current,
Compl ete the ci rcui t between the batteri es and
motor, i ncl udi ng the mul ti meter i n seri es as
shown. As the Bi g Trak rol l s al ong the fl oor,
take a measurement of the current whi ch i s
bei ng drawn. U nder the expected l oad for the
Skutter usi ng thi s method, one of the two bi g
trak motors wi l l draw a current of 2. 5 Amps.
resi stance,
capaci tance and
h
FE
.
M apl i ns sel l
one for £7. 99 (CODE: N 20AX) .
I t i s possi bl e to obtai n a good mul ti meter for
under ten pounds from a vari ety of retai l ers.
DC
motors
draw
di fferent
currents
under
di fferent
condi ti ons.
I f
a
motor
i s
“free-
CAU TI ON :
When
motor
stal l i ng
was
tested
wheel i ng”
then
the
motor
wi l l
draw
a
the
current
drawn
was
approxi matel y
20
comparati vel y smal l current.
Amps.
Al ternati vel y a “stal l ed” motor (a motor that i s
prevented from turni ng) wi l l draw an extremel y
hi gh current. The harder we make a motor
work, the more current i t wi l l draw. I n our case
we
Continuedoverpage...
want
to
measure
the
current
the
motors
5
Plik z chomika:
mikson9
Inne pliki z tego folderu:
The-MagPi-issue-15-en.pdf
(7217 KB)
The-MagPi-issue-14-en.pdf
(23474 KB)
The-MagPi-issue-13-en.pdf
(13564 KB)
The-MagPi-issue-12-en.pdf
(17969 KB)
The-MagPi-issue-11-en.pdf
(19578 KB)
Inne foldery tego chomika:
Gry
Schematy i inne pdfy
Tutoriale i filmiki z najciekawszymi pomysłami
Zdjęcia(płytka i przykładowe wynalazki z jej użyciem)
Zgłoś jeśli
naruszono regulamin