The_MagPi_04.pdf
(
8701 KB
)
Pobierz
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
I
I
S
S
S
S
U
U
E
E
0
0
4
4
A
A
U
U
G
G
2
2
0
0
1
1
2
2
W
W
i
i
n
n
a
a
M
M
a
a
g
g
P
P
i
i
C
C
a
a
s
s
e
e
i
i
n
n
o
o
u
u
r
r
c
c
o
o
m
m
p
p
e
e
t
t
i
i
t
t
i
i
o
o
n
n
(
(
P
P
a
a
g
g
e
e
1
1
1
1
)
)
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
E
E
B
B
E
E
N
N
&
&
L
L
I
I
Z
Z
:
:
T
T
h
h
e
e
I
I
n
n
t
t
e
e
r
r
v
v
i
i
e
e
w
w
http://www.themagpi.com
RaspberryPiisatrademarkofTheRaspberryPiFoundation.
ThispagewascreatedusingaRaspberryPicomputer.
CoverphotobyAndrewEdney@ConnectedDigitalWorld
WelcometoIssue4,
Thismonththeteamareveryproudtoannoucethatforthefirsttime,
TheMagPihasbeencreatedentirelyusingRaspberryPicomputers.
Aspromised,webringyouourinterviewwithEben&Lizfromthe
RaspberryPiFoundation.
Wehavesomenewarticles,aswellasourpopularseries,covering
hardwareprojects,programmingandothergeneraloperatingtips.
Wehavereceivedagoodresponsetoourrequestforvolunteers.Thereare
nowafewnewadditionstotheteam,howeverwearestilllookingfor
morehelp,sopleasedocomeforth!
AshStone
ChiefEditorofTheMagpi
TEAM:
Ash Stone
ChiefEditor/Administrator/Header
Jason 'Jaseman' Davies
Writer/Website/PageDesigns
Meltwater
Writer/Photographer/PageDesigns
Chris 'tzj' Stagg
Writer/Photographer/PageDesigns
Bobby 'bredman' Redmond
Writer/PageDesigns
Darren Grant
Writer/PageDesigns
0The0Judge0 (Matt)
Administrator
Antiloquax
Writer
W.H. Bell & D Shepley
Writers
Rob McDougall
Writer
Colin Norris
Editor/Graphics(CCaveHeader)
Andrius Grigaliunas
Photographer
Lix
PageDesigns/Graphics
2
Contents
04
IN CONTROL
M ore i n terfaci n g ti ps from Darren at Tan d y.
08
3-AXIS ACCELEROMETER WITH MICRO SOLDERING
A ch eap 3-axi s accel erom eter sol u ti on by Rob M cDou g al .
11
WHAT'S ON GUIDE & COMPETITION
Fi n d ou t wh ere Raspberry J am ' s are h appen i n g an d a ch an ce to wi n a l i m i ted ed i ti on M ag P i case.
12
KERNOW PI LAUNCH
Ash Ston e atten d s a speci al l au n ch - I n trod u ci n g th e P i to Corn i sh sch ool s.
14
EBEN & LIZ: THE INTERVIEW
We pu t you r q u esti on s to Eben an d Li z U pton from th e Raspberry P i Fou n d ati on .
19
LETTER OF THE MONTH
M aki n g A G PI O I n terface Bu ffer by J El l eri n g ton .
20
HOW TO CUSTOMISE YOUR LXDE MENU
J asem an sh ows you h ow to u n -cl u tter you r LXDE m en u .
22
COMMAND LINE CLINIC
M ore ti ps from Bred m an on con trol l i n g Li n u x from th e com m an d prom pt.
24
C CAVE
Th e secon d part of ou r i n trod u cti on to C prog ram m i n g .
28
THE SCRATCH PATCH
A frog g er-l i ke g am e by An ti l oq u ax.
30
THE PYTHON PIT
Th i s m on th
Th e P yth on
P i t d em on strated
keyu p/keyd own
even ts i n
a fu n
g am e by An ti l oq u ax an d
J asem an .
32
FEEDBACK & DISCLAIMER
3
IN CONTROL
INTERFACING PROJECTS FOR BEGINNERS
PART 3
BY DARREN GRANT
We have already used the Raspberry Pi GPIO outputs to drive light emitting diodes, but it is
not possible to directly drive anything larger because of power limitations. In this part we
look at using a transistor to control devices that require more power.
So what do we mean when we talk about the
Raspberry Pi GPIO ports being low powered?
Power is measured in Watts and is calculated
from the available Voltage multiplied by the
available current. By default the Raspberry Pi
GPIO provides an output of 3.3 Volts and up
to 8 milliamperes. This means that our avail-
able power output is limited to 3.3V x 0.008A
= 0.0264W or 26 milliwatts. While it is possible
to increase the output current to 16mA using a
software setting this still only gives us an abso-
lute maximum of 0.05W for a single GPIO pin,
it is however not advisable to run at this level
for any sustained period of time especially if
multiple IOs are in use. So I would advise you
to consider the default values the maximum.
COLLECTOR
BASE
EMITTER
NPN Transistor Symbol
A transistor has three terminals called Collec-
tor, Base & Emitter. When a small current is
applied to the Base terminal it allows a much
larger current to pass between the collector
and emitter terminals.
The amount of current that can be switched
depends on the transistor chosen and the
amount of current available to the base ter-
minal. This is known as the DC current gain
shown as h
FE
in a transistor data sheet. For
the
PN2222A
transistor the h
FE
Value is 100,
to switch a 150mA load we need only apply
1.5mA to the base, well within the capability of
the Raspberry Pi GPIO and gives us the ability
to switch up to 0.5W.
26mW is a tiny amount of power that is inad-
equate for the requirements of higher powered
devices such as motors and ilament lamps
that typically have multi-watt power require-
ments. However, it is possible to use the out-
puts to act as control signals for electronically
activated switches, making it possible to con-
trol virtually anything with the right equipment.
There are a number of different components
that can be used as power switching devices,
the one chosen will depend on the application
and equipment to be controlled.
A typical transistor is a relatively low powered
device that on its own could not be used for
example to switch a 50W car headlamp but
could easily switch a bank of high brightness
LEDs or a small buzzer.
The Transistor
We are going to be looking at a low power
transistor switching circuit. With the vast num-
ber of transistors available from an electron-
ics catalogue you may be thinking that they
are complicated. However transistors can be
used in two ways, either as an ampliier or as
a switching device. For our purposes, using
them as an electronic switch simpliies things.
Transistors can only be used for DC Voltages,
so can
NOT
be used for switching AC mains
electricity. A key advantage of a transistor
is that it as it has no moving parts it can be
switched very quickly, thousands of times a
second if required and has a very long opera-
tional life compared to a mechanical relay.
4
IMPORTANT
Before connecting anything to the Raspberry Pi
please be aware that incorrect connections could
cause damage. Please take care.
GPIO22
Pin 15
GPIO21
Pin 13
3.3V
+
Pin 01
R4
R6
GPIO18
Pin 12
R1
R2
R3
R5
GPIO17
Pin 11
0V
Pin 06
SW1 - Tactile Switch J5, J8, Y5, Y8
SW2 - Reed Switch
R1 - 470Ω Resistor D5, H5
R2 - 1kΩ Resistor I1, I5
R3 - 10kΩ Resistor D8, H8
R4 - 10KΩ Resistor
R5 - 1kΩ Resistor
R6 - 1kΩ Resistor
LED1 - Red LED C4, C5
TR1 - 2N2222 D21, D22, D23
BZ1 - Mini 3.3V Buzzer X21, B21
Wire link X4, B4
Wire link X8, B8
Wire link E23, Y23
Pin 06
Pin 12
Pin 01
Pin 11
Pin 15
Pin 13
Alarm System Circuit
+3.3V
BZ1
To demonstrate the use of a transistor, we will
construct an alarm system that will sound a
small buzzer when activated.
LED1
R1
R3
R4
R5
IO0
IO2
TR1
R6
R2
IO3
Circuit Description
IO1
SW1
SW2
We will be using two outputs and two inputs.
The first output is the familiar LED circuit that
will be used to indicate when the alarm is
armed. The second output is connected via re-
sistor R2 to the base of the transistor, the resis-
tor is necessary to limit the amount of current
supplied to the base of the transistor so that
there is just enough to switch it on. The collec-
tor of the transistor is connected to a buzzer so
that it will sound when the output connected to
the base of the transistor is set high. Although
we could use the transistor to switch a higher
voltage for example 5V, to keep things simple
we are using a 3.3V buzzer so that the whole
0V
circuit can be powered from a single voltage.
The first input is the same small push-button
switch as in previous experiments, this will be
used to arm and disarm the alarm. The second
input is a magnetically operated reed switch.
A magnet would be attached to a door and
the switch to the door frame so that the switch
will be opened and closed when the door is
opened and closed. If you don’t intend to use
the circuit on a real door and prefer not to buy
a reed switch for the purpose of experiment-
5
Plik z chomika:
mru2
Inne pliki z tego folderu:
The MagPi (94) 2020-06.pdf
(36479 KB)
The MagPi (93) 2020-05.pdf
(38148 KB)
The MagPi (92) 2020-04.pdf
(10314 KB)
The MagPi (90) 2020-02(1).pdf
(34207 KB)
The MagPi (90) 2020-02.pdf
(34207 KB)
Inne foldery tego chomika:
Advanced Photoshop
Web Designer
Zgłoś jeśli
naruszono regulamin