Newnes is an imprint of Elsevier
30 Corporate Drive, Suite 400, Burlington, MA 01803, USA
Linacre House, Jordan Hill, Oxford OX2 8DP, UK
Copyright © 2005, Elsevier Inc. All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted in
any form or by any means, electronic, mechanical, photocopying, recording, or otherwise,
without the prior written permission of the publisher.
Permissions may be sought directly from Elsevier’s Science & Technology Rights De-
partment in Oxford, UK: phone: (+44) 1865 843830, fax: (+44) 1865 853333, e-mail:
permissions@elsevier.com.uk. You may also complete your request on-line via the Elsevier
homepage (http://elsevier.com), by selecting “Customer Support” and then “Obtaining
Permissions.”
Recognizing the importance of preserving what has been written, Elsevier prints its
books on acid-free paper whenever possible.
Library of Congress Cataloging-in-Publication Data
(Application submitted.)
British Library Cataloguing-in-Publication Data
A catalogue record for this book is available from the British Library.
ISBN: 0-7506-7778-3
For information on all Newnes publications,
visit our Web site at www.books.elsevier.com
04 05 06 07 08 09 10 9 8 7 6 5 4 3 2 1
Printed in the United States of America.
Dedication
v
This book is dedicated to my wife Cristen, in recognition of her uncomplaining
acceptance of yards of PVC conduit in hallways, pounds of gel-cells in the living room,
and never-ending snarls of wire and motors throughout the house.
This page intentionally left blank
Contents
vii
About the Author xi
What’s on the CD-ROM? xii
Chapter 1: Introduction 1
1.1 History of this Book and What You’ll Get From Reading It 1
1.2 Target Readership and Required Skills and Tools 5
1.3 Conventions Used in the Text 7
Chapter 2: Microcontrollers, Single-Board Computers and
Development Tools 9
2.1 The Division of Labor 9
2.2 Candidate Microcontrollers for ‘Hard’ Tasks 13
2.3 The Atmel AVR and its Development Hardware Up Close 17
2.4 Candidate x86-based SBCs for ‘Soft’ Tasks 21
2.5 The Advantech PCM-5820 Single-Board Computer Up Close 27
2.6 Selecting an Inter-Module Communications Protocol 32
Chapter 3: Some Example Sensor, Actuator and
Control Applications and Circuits (Hard Tasks) 41
3.1 Introduction 41
3.2 E2BUS PC-Host Interface 44
3.3 Host-to-Module Communications Protocol 49
viii
Contents
3.4 Stepper Motor Controller 52
3.5 Speed-Controlled DC Motor with Tach Feedback and Thermal Cutoff 70
3.6 Two-Axis Attitude Sensor using MEMS Accelerometer 79
3.7 RS-422—Compatible Indicator Panel 90
Chapter 4: The Linux-Based Controller (A Soft Task) 115
4.1 A Brief Introduction to Embedding Linux on PC Hardware 115
4.2 Configuring the Development System and Creating Our Custom Kernel 117
4.3 The Linux Boot Process—Creating a Bootable CompactFlash Card 123
4.4 Creating a Root Filesystem for our Embedded System 128
4.5 Creating a Bootable Linux System-Restore CD-ROM Disc 136
4.6 Using the Parallel Port as a General-Purpose I/O Interface in Linux 142
4.7 Implementing Graphical Control Interfaces 149
4.8 Infra-Red Remote Control in Linux Using LIRC 175
4.9 Introduction to Machine Vision Using Video4Linux 189
4.10 Customizing Your BIOS—The Structure of a Modern BIOS 201
Chapter 5: Encryption and Data Security Primer 209
5.1 Introduction 209
5.2 Classes of Algorithm 214
5.3 Protecting One-Way Control Data Streams 217
5.4 Protecting One-Way Telemetry 218
5.5 Protecting Bidirectional Control/Data Streams 220
5.6 Protecting Logged Data 222
5.7 Where to Obtain Encryption Algorithms 224
ix
Contents
ix
Chapter 6: Expecting the Unexpected 227
6.1 Introduction 227
6.2 Dangerous Exception Conditions and Recovering From Them 228
6.3 On-Chip vs. Off-Chip Watchdog Hardware 230
6.4 Good Power-On Reset Practices 232
6.5 A Few Additional Considerations for Battery-Powered Applications 235
Chapter 7: Contents of the Enclosed CD-ROM 237
Index 237
This page intentionally left blank
xi
About the Author
Lewin A.R.W. Edwards was born in Adelaide, Australia. He worked for five years
in Melbourne, Australia on government-approved encryption, desktop protection
and data security products for DOS, Windows and OS/2. For the next five years, he
worked in Port Chester, New York for Digi-Frame, Inc., where he designed both the
hardware and firmware of a range of multimedia digital picture frame appliances.
These devices ranged in complexity from small pocket-size still-image viewers up
to fully networked wall-mounted devices with audio and full-motion video support.
He currently lives in New York City and works as a short-range radio digital design
engineer for a well-known manufacturer of wireless security and fire safety products.
His earlier works include Embedded Systems Design on a Shoestring, (a book about low-
cost embedded systems development, principally targeted at ARM7 platforms), as
well as articles on specialized design considerations for the microcontrollers used in
electronic toys, commentary on Universal Plug’N’Play, reverse-engineering Internet
appliances, and other topics of interest.
xii
What’s on the CD-ROM?
Included on the accompanying CD-ROM:
■ A free version of the schematic capture and PCB CAD software used to pre-
pare this book. (Refer to the license agreement included with the software for
usage restrictions and limitations.)
■ Atmel AVR Studio® 4.08.
■ Full schematics and sourcecode for the projects described in this book.
■ Ready-made disk images for the miniature Linux distribution used as a basis
for the book’s PC-side software.
■ Distribution archives of the sourcecode for all GNU software used, along with
application-specific patches, where appropriate.
Introduction
1
C H A P T E R
1
1.1 History of this Book and What You’ll Get From Reading It
Over the course of roughly a year, after completing my first book, I resurrected an old
pet project of building an autonomous submarine (referred to as the E-2 project) with
certain fairly challenging functionality requirements. In the course of developing this
idea, I spent many hours on the Internet and elsewhere, researching techniques for
rapid development of various electromechanical control systems and platforms to run
fairly complex signal-processing algorithms. Although there are, of course, thousands
of useful projects and snippets of information to be obtained from the Internet and
books on hobbyist robotics, I found that nobody else seemed to have my exact priori-
ties. In particular, there is apparently no single reference that gathers together at
least introductory solutions to all the embedded design issues that affected my proj-
ect: a need to use low-cost (open-source) tools and operating systems, a requirement
for several features with fairly hard real-time requirements, and a desire to use cheap,
off-the-shelf consumer grade components wherever possible. Available resources on
many topics concentrate either on very expensive off-the-shelf industrial compo-
nents, or on tightly constrained systems built around a single microcontroller, with
delicately optimized, nonportable code to control peripherals—and a very limited
range of peripheral support, at that. These latter system design restrictions are un-
avoidable when you’re working to tight power requirements, space constraints, or a
rock-bottom bill of material (BOM) cost, but it’s an inordinate amount of effort to
build and tune such systems for a one-off project or a prototype. Furthermore, learn-
ing all the details required to assemble such a system is an enormous task; it’s easy to
get lost in fine-tuning details without ever managing to field a complete, working sys-
Không có nhận xét nào:
Đăng nhận xét