Bebop to the Boolean Boogie, Clive Maxfield
Click picture to order from Amazon.com.
Bebop is the MTV version of an embedded how-to
book. It's fun. It's a fast read. You'll find neither calculus nor much
about basic electronics. It's focus is entirely on logic design, and is
designed as a primer for those without much grounding in this area.
Hardware designers who have been at this for a couple of years
probably have the material down pat. It seems, though, that the
embedded world is evolving into two camps - digital design and
firmware - with less and less communication between the two.
Increasing specialization means there are fewer people who can deal
with system-wide problems. If you are an embedded software guru who
just doesn't understand the electronics part of the profession, then
get this book and spend a few delightful hours getting a good
grounding in digital design basics. Then watch the startled looks as
your water cooler discussions include comments about state machine
design.
Bebop covers all the basic bases, from the history of number
systems (much more interesting than the tiresome number system
discussions found in all elementary texts), to basic logic design,
PALs, and even PCB issues. I often run into engineers who have no idea
how chips are made - the book gives a great, wonderfully readable,
overview of the process.
Its discussion of memories is fast-paced and worthwhile. A chapter
about DRAM RAS/CAS operation would be a nice addition, as would
something about Flash, but there's a limit to what you can pack into
450 pages.
I found the chapter about Linear Feedback Shift Registers the most
interesting. This subject never goes away. It pops up constantly on
the embedded systems Internet listservers (comp.realtime and
comp.arch.embedded), often under the guise of CRCs. These pages are
worthwhile even for experienced digital engineers.
And yes, the seafood gumbo recipe in Appendix H is worth the price
of the book alone.
Computer Approximations - John Hart
Lest we forget, computers generally have no
intrinsic knowledge of tangents and cosines. Either a runtime routine
in a compiler’s library implements an approximation routine or a
co-processor (possibly buried inside the CPU’s core) runs a hardware
version of an approximation.
Many embedded applications make massive use
of trig and other complex functions to massage raw data sampled by the
system. Yet a number of these systems are bound by memory or processor
constraints to the point where the programmer must write his own low
level trig functions. Sometimes the overhead of a C’s floating point
library is just more than a small system can stand.
Don’t believe me? In the last two weeks
three friends called looking for trig approximation algorithms. OK -
one writes embedded compilers, and needed to tune his runtime package.
The others were all squeezing complex computations into the tight
confines of 8 bit microcontrollers.
The bible of applied math is The
CRC Standard Mathematical Tables (CRC Press, West Palm Beach, FL).
Whenever I can’t remember a basic identity drilled unsuccessfully
into my unwilling head I’ll pull this volume out. Its section on
series expansions, for examples, gives formulas we can use for
computing any trig function. For example, sin(x)=x-(x**3)/3! +
(x**5)/5! - (x**7)/7! ….
A little thought shows this series may be
less useful than we’d hope. Limited computer resources means that at
some point we’ll have to stop summing terms… when? Stop too soon
and get poor accuracy. Go on too long and get too much accuracy at the
expense of computer time.
The art of computer approximations is
establishing a balance between accuracy and computational burden.
Nearly all commonly used approximations do use polynomials. The trick
is figuring out the best mix of coefficients and terms. Though the
math behind this is rather interesting, as practicing engineers who
have to deliver a product yesterday most of us are more interested in
canned solutions.
If you find yourself in a similar
situation, run to the nearest Computer Literacy bookstore (or contact
them on the Web at www.clbooks.com) and buy Computer
Approximations by John F. Hart (1968, John Wiley & Sons, NY
NY). To my knowledge there’s no more complete book on the subject.
Though the book contains a detailed
analysis of the art of approximating, the meat is in it’s Tables of
Coefficients. There you’ll find 150 pages of polynomial coefficients
for square and cube roots, exponentials, trig and inverse trig, and
logs. The coolest part of this is the large number of solutions for
each function: do you want a slow accurate answer or a fast fuzzy one?
Hart gives you your choice.
It’s not the easiest book to use. Mr.
Hart assumes we’re all mathematical whizzes, making some of it heavy
going. Do skim over the math section, and figure out Hart’s basic
approach to implementing an approximation. His notation is quite
baffling: until I figured out that (+3) +.19400 means multiply .194
times 10**3 none of my code worked.
Unhappily this book is out of print. Sometimes you can find a used copy
around; check Amazon (try this link)
and other vendors. Also check out
my free app note here.
The Digital I/O Handbook, Jon Titus and Tom O'Hanlan
The Digital I/O Handbook, by Jon Titus and Tom O'Hanlan, (ISBN:
09759994-0-0) is a 75 page introduction to using digital inputs
and outputs with microprocessors.
The book starts with a quick introduction to logic, which
emphasizes the electrical, rather than the Boolean, nature of real
devices.
A chapter on outputs is equally practical. The authors talk about
using buffer chips and transistor circuits to drive relays (solid
state and otherwise) and optoisolators. The chapter on inputs
talks about real-world problems like bounce and circuit isolation.
You'll learn how to compute the values of pull-ups, LED resistors,
and the like.
The final chapter on interfacing to sensors walks the reader
through using thermal switches, Hall-effect sensors, encoders and
more.
What I like most about the book is its mix of hardware and
software. Most pages have a bit of code plus a schematic. All code
snippets are in C.
This is a great introduction to the tough subject of tying a
computer to the real world. It's the sort of quick-start of real
value to people with no experience in the field.
The
Elements of Style, William Strunk and E. B. White
Click picture to order from Amazon.com.
Software has two missions: to DO something, and to
COMMUNICATE the programmer’s intent to future maintainers, or to
people wishing to reuse portions of the code. In my opinion, any bit
of code that doesn’t do BOTH of these things really well is totally
unacceptable.
But the code itself, the C, C++ or whatever, is not
particularly easy to read. Well written comments are the basic
structure of any program. The comments describe the intent, the
complexities, the tricks and the issues. Code just obfuscates these.
Great comments are a basic ingredient of great code.
That means the comments have to be well written, in
English (at least for those of us working in English-speaking
countries), using the noun-verb form. Each sentence starts with an
upper-case letter; the rest of the sentence uses appropriate cases.
Comments that don’t conform to the basic rules of grammar are
flawed.
Donald Knuth talked about this at length. He felt that
the literate programmer:
-
Is concerned with the excellence of style
-
Can be regarded as an essayist
-
With thesaurus in hand, chooses variable names
carefully
-
Strives for a comprehensible progra
-
Introduces elements in a way that’s best for
human understanding, not computer compilation.
And so, I’ve long believed the best programming book
ever is “The Elements of Style,” by William Strunk and E. B. White
(Allyn & Bacon; ISBN: 020530902X). In a mere 105 pages the authors
tell us how to write well. Just five bucks from Amazon.com. Or, you
can get it for free at http://www.bartleby.com/141/index.html.
Unfortunately, most developers are notoriously bad at
writing prose. We NEED the help that this book contains.
One rule: “Use active voice”. Doesn’t that sound
better than “the use of the active voice is required”? It’s also
shorter and thus easier to write! Another: “Omit needless words,”
a great improvement over “writers will examine each sentence and
identify, characterize, and excise words in excess of those essential
to conveying the author’s intent.”
An appendix lists words that are often misused. English
is quite a quirky language; it’s easy to make really stupid
mistakes. One example: mixing up the verb ‘effect’, the noun
‘effect’ and ‘affect’.
The book makes an interesting comment about signing
letters: “Thanking you in advance.” This sounds as if the writer
meant, "It will not be worth my while to write to you
again." Instead write, "Thanking you," and if the favor
which you have requested is granted, write a letter of acknowledgment.
I like that!
My biggest pet peeve about poor writing is mixing up
“your” and “you’re.” I’ve seen billboards with these words
confused – talk about advertising your ignorance!
The book gives 18 simple rules, far fewer than the nuns
attempted to beat into my brain so long ago. Follow them and your
comments, and thus the code, will improve.
Embedded Ethernet and Internet Complete,
Jan Axelson
Click
picture to order from Amazon.com
Jan Axelson’s latest book extends her coverage of
communications protocols from RS-232 to the PC’s parallel port to
USB to (in this volume) Ethernet and the Internet. Like all of her
works, it’s clear and complete.
Ms. Axelson starts with a brief overview of the basics
of networking, with an overview of the datagrams, protocols and
required hardware. She goes on to describe how routing is accomplished
using both UDP and TCP/IP. Technical readers will already be familiar
with much of this information, but it’s presented in a very readable
fashion that’s easy to understand.
Much of the book covers serving up Web pages and
working with dynamic data on the web. Sure, there’s been plenty of
coverage in hundreds of books of these subjects, but she presents
everything in the context of embedded systems, especially systems with
limited resources. And that’s where the real strength of this book
lies.
Like her previous work, this is a practical, how to use
networking in an embedded system book. Two primary hardware platforms
are covered: the Dallas TINI and Rabbit Semiconductor’s RCM3200.
I’ve used the Rabbit parts a lot, and find them powerful and fun to
work with.
If you’re already a networking whiz this book
probably won’t add much to your knowledge. But for those anxious to
learn how to add Ethernet and/or Internet connectivity to any embedded
system, especially small ones, the practical examples and clear
writing will get you going quickly.
Ms. Axelson’s web site (www.lvr.com)
has long been the place to go to learn about USB, RS-232 and other
subjects. It’s already filling with lots of useful information about
networking that serves as a companion to the book. Check it out!
Embedded Ethernet and Internet Complete by Jan Axelson,
ISBN# 1-931448-00-0.
Embedded Systems Building Blocks, Jean LaBrosse
Click picture to order from Amazon.com.
Jean LaBrosse is back with an update of his
“Embedded Systems Building Blocks” (R&D Books, ISBN
0-87930-604-1). I’ve always been a fan of his articles and books,
and think this latest is a valuable addition to any embedded library.
The book is a collection of drivers for some of
the more common embedded problems. It starts with a 40 page
introduction to managing real time problems, largely in the context of
using a RTOS. This section alone is worthwhile for anyone trying to
learn about using an RTOS, though I’d also recommend getting his
“uC/OS-II, The Real Time Kernel”
Included code (also on the companion CD-ROM)
covers the following:
-
Keyboard handler, for keypads arranged in
matrices that are software scanned.
-
Seven
segment LED driver, for multiplexed arrays of LEDs
-
A complete LCD driver package for units based on
Hitachi’s HD44780 chip
-
A time of day clock package, which manages time in an
year:month:day and hours:minutes:seconds format. It’s Y2K
compliant, to boot!
-
If your real time code works with multiple delay and
timeout issues, his timer manager is a useful chunk of code. It
manages up to 250 software timers; all are driven off a single
timer interrupt source. His example shows this running from a 1/10
second interrupt rate; I’d be interested to see if it can be
scaled to higher rates on reasonably small CPUs.
-
Discrete I/O drivers for inputs and outputs, with edge
detection code. I like the way he abstracts the hardware to
“logical channels”, which makes it so much easier to change
things, and to create software stubs for testing before hardware
is available.
-
Fixed point math – one of the best discussions I’ve
seen on this subject, which is critical to many smaller embedded
apps. Fixed point is a sort of poor man’s floating point: much
smaller code that runs very fast, but you sacrifice resolution and
range.
-
ADC and DAC drivers, with a good discussion of managing
these beasts in engineering units rather than un-scaled bits.
An appendix includes Jean’s programming
conventions, a firmware standard. I passionately feel that firmware
standards are the starting point of writing decent code. An
alternative standard is available at www.ganssle.com/misc/fsm.doc.
Much of the code is targeted at applications
using the uC/OS RTOS. It’s rather easy to port the code to any RTOS,
and in many cases even to use it with no RTOS (though you’ll have to
delete some of the OS function calls).
When I read the first version of his book my gut
reaction was “well, I could write this stuff easily myself.”
That’s true; most of this code is not terribly complex. But why
bother? Why re-invent the wheel? The best developers find ways to buy,
recycle, and borrow code, rather than write every last routine.
On to more book reviews.
Back to home page.
The Ganssle Group
PO Box 38346, Baltimore, MD
21231
Tel: 410-504-6660, Fax: 647-439-1454
Email info@ganssle.com
© 2008 The Ganssle Group
|