Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Tài liệu Newnes Open-source Robotics and Process Control Cookbook (2005) YYePG LotB ppt
Nội dung xem thử
Mô tả chi tiết
Open-Source Robotics
and Process Control Cookbook
This page intentionally left blank
Open-Source Robotics
and Process Control Cookbook
Designing and Building Robust,
Dependable Real-Time Systems
by Lewin A.R.W. Edwards
AMSTERDAM • BOSTON • HEIDELBERG • LONDON
NEW YORK • OXFORD • PARIS • SAN DIEGO
SAN FRANCISCO • SINGAPORE • SYDNEY • TOKYO
Newnes is an imprint of Elsevier
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 Department in Oxford, UK: phone: (+44) 1865 843830, fax: (+44) 1865 853333, e-mail:
[email protected]. 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
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 lowcost 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 prepare 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
C H A P T E R 1
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 priorities. In particular, there is apparently no single reference that gathers together at
least introductory solutions to all the embedded design issues that affected my project: 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 components, 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 unavoidable 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, learning 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-
2
Chapter 1
tem. Irritatingly, many of the tweaks and most of the careful planning you do to get
that system operational will have to be thrown away if you move into actual production, or if you need to build some more units with slightly different components.
What I was searching for while developing the E-2 project was a way to build
various hard real-time modules (sensors and actuators) that could easily and cheaply
be interfaced to a general-purpose computer running Linux. The Linux box served
as a testbed for algorithms which would later be ported down into a smaller, cooler,
more power-efficient processing module of some kind. I needed a solid basis of
known-good code and techniques so that I could strike out from that point and build
my own customized system. I also wanted a simple up-and-running guide to building
embedded Linux distributions. For the initial, nonfieldable prototype of my submarine, I didn’t have an exact idea of how much CPU horsepower I would need in the
final version—so I didn’t want to get tied to a specific microcontroller architecture,
nor did I want to get bogged down in trying to tweak and tune many real-time tasks
on a single microcontroller. I also wanted to use a few peripherals—such as cameras
—which are easiest interfaced through a general-purpose operating system.
These requirements may sound a chord with your own working life. Chances are
you’ve encountered situations where it would be useful to automate some long-term
data-gathering experiment or create a simple automated controller for a programming, manufacturing or other task. In this vein, three other instances where I have
applied the techniques in this book are:
■ The development of a range of successful (commercially-fielded) networked
multimedia appliances, designed for unattended advertising and art-gallery
applications.
■ The development of specialized, almost wholly automatic mechanical failure
testing apparatus for certain consumer electronics articles.
■ Construction of an automatic high-speed datalogger that monitors a radio
link and extracts DTMF messages targeted at specific receivers.
The second item above is of particular interest, because it demonstrates nicely
how this book can be of practical value in process control and testing applications.
During 2002, I briefly worked for a small division of a multinational company whose