IEEE Spectrum November, 2014 - 28

along with an expanded general-purpose
input/output (GPIO) connector, and it relies
more heavily on HDMI for video output.
The Pi was first released in 2012 as a
"spiritual successor" to the BBC Microcom-
puter System, which was created by Acorn
Computers in 1981 for Britain's national Com-
puter Literacy Project. The naming scheme
for Pi models echoes that of the BBC Micro
series, and like the original BBC Micro, the Pi
has rapidly spread beyond the classroom.
The links to the BBC Micro are more than
just circumstantial. The Pi is built around
an ARM chip (a Broadcom BCM2835), and
while ARM currently dominates the world of
smartphones and tablets, the architecture
was originally developed to provide a high-
performance coprocessor for BBC Micros,
and it later powered the Archimedes line of
PCs. The Archimedes came with RISC OS, a
graphical user interface-based operating
system that has since been ported to the Pi.
I first used Acorn's dialect of BASIC way
back in the day on a BBC Micro. One of the
nice things about it was that it let you mix
28

|

nOv 2014

|

nORTh aMERICan

|

BASIC commands with assembly code for the
BBC Micro's 6502 processor. I was pleased
to discover that RISC OS has retained a great
deal of compatibility with the systems it grew
out of, right back to that original dialect.
RISC OS's version of BBC BASIC-ver-
sion VI-is, of course, greatly expanded com-
pared with its 8-bit ancestor: As I said when I
first tried it out, "it's like meeting someone you
palled around with in high school, and now
they own a business and have two kids." But
it still includes an in-line assembler for com-
bining machine code subroutines-now ARM
code, of course-with BASIC. The integration
allows for streamlined passing of variables
back and forth between a BASIC program and
machine code-for example, a set of BASIC
integer variables, A% through H%, are auto-
matically copied into the first eight registers
of the ARM chip when a subroutine is called.
This integration let me quickly write the
spinning wheel animation and display code
in BASIC, reaching back across the years
to cobble together commands to draw col-
ored segments of a circle and store the text

SPECTRUM.IEEE.ORG

top: Stephen CASS (2); bottom: rAndi Klett

the Model B+ Raspberry Pi [bottom of photo,
top left] has an upgraded version of the I/o
hardware in the Model B. Using a RasPio
breakout board [above], I connected a button
to the 40-pin GPIo header. Button presses
generate excuses [bottom left], which appear
on a monitor attached via an HDMI cable.

of excuses using "data" and "read"
commands. (When I started pro-
gramming, BASIC code would have
been too slow for the wheel's anima-
tion, but 30 years of Moore's Law has
solved that problem.) I needed to dip
into assembly only in order to read
the state of a button connected to the
GPIO hardware. The button triggers
the animation and has the program
select and display an excuse.
I wired the button to the Pi's GPIO
port using a $10 RasPiO Breakout
Pro, which provides basic protection
against miswiring. (Unlike the more
robust Arduino, which can handle
enough current to drive a servo, the Pi's
GPIO can be damaged if connected to
circuits that expose it to more than a
few milliamperes or exceed 3.3 volts.)
The Breakout Pro is designed for the
GPIO on earlier Pi models, but the
B+'s expanded port keeps the same
pin configuration for the first 26 pins,
so I was able to use the Breakout Pro
and simply ignore the B+'s extra pins.
Reading the GPIO hardware was a good
chance to get acquainted with the guts
of a system using a reduced-instruction-
set-computing architecture (so many reg-
isters!)-the last time I programmed on
the metal was for the 6502. The Pi's GPIO
pins are mapped into the system's mem-
ory as a series of 3-bit segments stored
within 32-bit status words, so my machine
code subroutine has to do some bit bash-
ing to set a GPIO pin as an input. Then my
subroutine reads the relevant GPIO sta-
tus word and passes it back to BASIC. (For
my code, I combined some snippets from
Bruce Smith's book Raspberry Pi Assembly
Language RISC OS Beginners and a
Raspberry Pi online forum.) My BASIC pro-
gram then simply uses a loop that calls the
subroutine and looks for any changes in the
status word, indicating a button press.
With the software written, all that was left
to do was build a case (from a few dollars'
worth of basswood) and hook the video out-
put up to an old monitor. And voilĂ ! A new era
of digitally driven excuses. -Stephen CaSS


http://SPECTRUM.IEEE.ORG

Table of Contents for the Digital Edition of IEEE Spectrum November, 2014

IEEE Spectrum November, 2014 - Cover1
IEEE Spectrum November, 2014 - Cover2
IEEE Spectrum November, 2014 - 1
IEEE Spectrum November, 2014 - 2
IEEE Spectrum November, 2014 - 3
IEEE Spectrum November, 2014 - 4
IEEE Spectrum November, 2014 - 5
IEEE Spectrum November, 2014 - 6
IEEE Spectrum November, 2014 - 7
IEEE Spectrum November, 2014 - 8
IEEE Spectrum November, 2014 - 9
IEEE Spectrum November, 2014 - 10
IEEE Spectrum November, 2014 - 11
IEEE Spectrum November, 2014 - 12
IEEE Spectrum November, 2014 - 13
IEEE Spectrum November, 2014 - 14
IEEE Spectrum November, 2014 - 15
IEEE Spectrum November, 2014 - 16
IEEE Spectrum November, 2014 - 17
IEEE Spectrum November, 2014 - 18
IEEE Spectrum November, 2014 - 19
IEEE Spectrum November, 2014 - 20
IEEE Spectrum November, 2014 - 21
IEEE Spectrum November, 2014 - 22
IEEE Spectrum November, 2014 - 23
IEEE Spectrum November, 2014 - 24
IEEE Spectrum November, 2014 - 25
IEEE Spectrum November, 2014 - 26
IEEE Spectrum November, 2014 - 27
IEEE Spectrum November, 2014 - 28
IEEE Spectrum November, 2014 - 29
IEEE Spectrum November, 2014 - 30
IEEE Spectrum November, 2014 - 31
IEEE Spectrum November, 2014 - 32
IEEE Spectrum November, 2014 - 33
IEEE Spectrum November, 2014 - 34
IEEE Spectrum November, 2014 - 35
IEEE Spectrum November, 2014 - 36
IEEE Spectrum November, 2014 - 37
IEEE Spectrum November, 2014 - 38
IEEE Spectrum November, 2014 - 39
IEEE Spectrum November, 2014 - 40
IEEE Spectrum November, 2014 - 41
IEEE Spectrum November, 2014 - 42
IEEE Spectrum November, 2014 - 43
IEEE Spectrum November, 2014 - 44
IEEE Spectrum November, 2014 - 45
IEEE Spectrum November, 2014 - 46
IEEE Spectrum November, 2014 - 47
IEEE Spectrum November, 2014 - 48
IEEE Spectrum November, 2014 - 49
IEEE Spectrum November, 2014 - 50
IEEE Spectrum November, 2014 - 51
IEEE Spectrum November, 2014 - 52
IEEE Spectrum November, 2014 - 53
IEEE Spectrum November, 2014 - 54
IEEE Spectrum November, 2014 - 55
IEEE Spectrum November, 2014 - 56
IEEE Spectrum November, 2014 - 57
IEEE Spectrum November, 2014 - 58
IEEE Spectrum November, 2014 - 59
IEEE Spectrum November, 2014 - 60
IEEE Spectrum November, 2014 - 61
IEEE Spectrum November, 2014 - 62
IEEE Spectrum November, 2014 - 63
IEEE Spectrum November, 2014 - 64
IEEE Spectrum November, 2014 - 65
IEEE Spectrum November, 2014 - 66
IEEE Spectrum November, 2014 - 67
IEEE Spectrum November, 2014 - 68
IEEE Spectrum November, 2014 - 69
IEEE Spectrum November, 2014 - 70
IEEE Spectrum November, 2014 - 71
IEEE Spectrum November, 2014 - 72
IEEE Spectrum November, 2014 - 73
IEEE Spectrum November, 2014 - 74
IEEE Spectrum November, 2014 - 75
IEEE Spectrum November, 2014 - 76
IEEE Spectrum November, 2014 - 77
IEEE Spectrum November, 2014 - 78
IEEE Spectrum November, 2014 - 79
IEEE Spectrum November, 2014 - 80
IEEE Spectrum November, 2014 - 81
IEEE Spectrum November, 2014 - 82
IEEE Spectrum November, 2014 - 83
IEEE Spectrum November, 2014 - 84
IEEE Spectrum November, 2014 - 85
IEEE Spectrum November, 2014 - 86
IEEE Spectrum November, 2014 - 87
IEEE Spectrum November, 2014 - 88
IEEE Spectrum November, 2014 - Cover3
IEEE Spectrum November, 2014 - Cover4
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1217
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1117
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1017
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0917
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0817
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0717
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0617
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0517
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0417
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0317
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0217
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0117
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1216
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1116
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1016
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0916
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0816
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0716
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0616
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0516
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0416
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0316
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0216
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0116
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1215
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1115
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1015
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0915
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0815
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0715
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0615
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0515
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0415
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0315
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0215
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0115
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1214
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1114
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1014
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0914
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0814
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0714
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0614
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0514
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0414
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0314
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0214
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0114
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1213
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1113
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1013
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0913
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0813
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0713
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0613
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0513
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0413
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0313
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0213
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0113
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1212
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1112
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1012
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0912
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0812
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0712
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0612
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0512
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0412
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0312
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0212
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0112
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1211
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1111
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1011
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0911
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0811
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0711
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0611
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0511
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0411
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0311
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0211
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0111
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1210
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1110
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1010
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0910
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0810
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0710
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0610
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0510
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0410
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0310
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0210
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0110
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1209
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1109
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1009
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0909
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0809
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0709
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0609
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0509
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0409
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0309
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0209
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0109
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1208
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1108
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1008
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0908
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0808
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0708
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0608
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0508
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0408
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0308
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0208
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0108
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1207
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1107
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1007
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0907
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0807
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0707
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0607
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0507
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0407
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0307
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0207
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0107
https://www.nxtbookmedia.com