Xem mẫu

Page i Programming the Parallel Port Interfacing the PC for Data Acquisition and Process Control Dhananjay V. Gadre Page ii Disclaimer: This netLibrary eBook does not include the ancillary media that was packaged with the original printed version of the book. R&D Books an imprint of Miller Freeman, Inc. 1601 West 23rd Street, Suite 200 Lawrence, KS 66046 USA Designations used by companies to distinguish their products are often claimed as trademarks. In all instances where R&D is aware of a trademark claim, the product name appears in initial capital letters, in all capital letters, or in accordance with the vendor`s capitalization preference. Readers should contact the appropriate companies for more complete information on trademarks and trademark registrations. All trademarks and registered trademarks in this book are the property of their respective holders. Copyright © 1998 by Miller Freeman, Inc., except where noted otherwise. Published by R&D Books, an imprint of Miller Freeman, Inc. All rights reserved. Printed in the United States of America. No part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written permission of the publisher; with the exception that the program listings may be entered, stored, and executed in a computer system, but they may not be reproduced for publication. The programs in this book are presented for instructional value. The programs have been carefully tested, but are not guaranteed for any particular purpose. The publisher does not offer any warranties and does not guarantee the accuracy, adequacy, or completeness of any information herein and is not responsible for any errors or omissions. The publisher assumes no liability for damages resulting from the use of the information in this book or for any infringement of the intellectual property rights of third parties which would result from the use of this information. Distributed in the U.S. and Canada by: Publishers Group West P.O. Box 8843 Emeryville, CA 94662 ISBN: 0-87930-513-4 Page iii To Chaitanya and Sangeeta Page v Foreword No other interface has been so constant since the PC was introduced in 1981. Originally implemented to provide a "high speed" interface to the latest generation of dot matrix and daisy wheel printers, the parallel port has become the most common interface used to connect a wide variety of peripherals. For many years, up until around 1989, printers were the only peripheral that took advantage of the parallel port. The port was viewed primarily as a "printer" port and other types of peripherals did not use it. Then companies such as Microsolutions and Xircom got the idea that you could actually use the port to get information back into the computer, and therefore use it as a bi-directional communication port. Being parallel, you could get much higher performance than using the PC`s serial port, with greater simplicity. The old parallel port became an easy-to-use interface for connecting peripherals. With a very simple register model, it is easy to get information into and out of the PC. The only drawback was that it was relatively slow. The CPU and platform performance was increasing at a tremendous rate, but the I/O capability of the PC stayed the same. While the CPU increased 100 fold, the parallel port remained stagnant. This all changed with the formation of the IEEE 1284 Committee in 1992. This committee, sponsored by the Institute of Electrical and Electronic Engineers, had the charter to develop new, advanced parallel port modes that would enable high speed bi-directional data transfer through the parallel port. The requirements was to do this and still be 100% compatible with "standard" parallel port. Working with industry groups and individuals, the IEEE 1284 committee produced its new standard in 1994. This standard, IEEE St. 1284-1994, defined new ways of using the parallel port for high speed communication. Page vi Two of these new modes are the EPP and ECP modes. Now, rather than being limited to a software-intensive, 50Kb-per-second port, you can get simple data transfer at rates approaching 2Mb per second. This 40 fold improvement in throughput is even more remarkable considering that the modes also remain backwards compatible with existing devices and interfaces. This standard has enabled a wide range of peripherals that take advantage of the parallel port. Almost all new peripherals provide support via the parallel port. This includes the traditional uses such as printers, scanners, CD-ROM, hard drive, port sharing, and tape, as well as some non-traditional uses. One of the most popular, non-traditional uses of the 1284 parallel port has been as a scientific and data acquisition interface. The past few years has seen tremendous growth in the use of this port for attaching control devices and for use as a simple interface for data acquisition instruments. The ability to have the same PC interface in the lab and on every portable computer makes this the ideal port to attach this type of equipment. In this book, Interfacing to the PC using the Parallel Port, Dhananjay provides a clear introduction and model on how to use the parallel port for these types of applications. This is the ideal reference book for anyone wishing to use the PC for interfacing to external devices. Dhananjay presents a step-by-step approach to the subject. Starting with the basic, "What is the Parallel Port?" and "What is Data Acquisition", he leads you up the path to designing peripheral interfaces and writing the software drivers necessary to control and communicate with your devices. I`m sure you`ll find this an invaluable tool in aiding your understanding of the parallel port and the concepts and implementations of data acquisition peripherals. LARRY A. STEIN Larry Stein is the Chair of IEEE 1284.3 and 1284.4 Committees. He was instrumental in the development of the IEE 1284 standard and served as chair of the EPP Committee. He is currently Vice-President of Warp Nine Engineering and is the chief architect of the Warp Nine interface cards and IEEE 1284 Peripheral Interface Controller Page vii Acknowledgments My interest in parallel printer adapters began in 1980 when Professor Vijaya Shankar Varma at the Delhi University asked me if I could build a resistor DAC for the parallel port. Since then, together with Dr. Pramod Upadhyay, we have enjoyed building and using many devices on the parallel port. It has been a pleasure working with them. Most of these gadgets were built at the Centre for Science Education and Communication (CSEC), University of Delhi. While we were at it, Professor Pramod Srivastava, Director of CSEC, was a constant source of suggestions and useful comments. He was an even bigger help in providing financial support for the projects. Since coming to the Inter-University Centre for Astronomy and Astrophysics (IUCAA) in Pune, India, Pravin Chordia has been a great help in building many of the devices. Arvind Paranjpye suggested the photometer interface problem, which was completed as another project. Manjiri Deshpande provided useful suggestions and evaluated some of the ideas presented here. Professor S.N. Tandon, my boss at the Instrumentation Laboratory, allowed me to use the facilities in the laboratory for building many of the projects described here. Working with him has been an education for me and I thank him for many of the things I learned from him. I learned the finer points of UNIX and Linux from Sunu Engineer. A brilliant programmer that he is, all the Linux-related projects would have been incomplete without his collaboration. He also read through many of the chapters in this manuscript and provided critical comments. Page viii This work has been possible, in no small measure, because of the atmosphere of academic freedom I enjoy at IUCAA, and I thank Professor J.V. Narlikar, Director of IUCAA, for creating this wonderful place and providing me with a chance to work here. Thanks are due to Dr. James Matey, Contributing Editor of Computers in Physics; to Joan Lynch, Managing Editor of EDN; to Jon Erickson, Editor-in-Chief of Dr. Dobb`s Journal; and to Lindsey Vereen, Editor-in-Chief of Embedded Systems Programming; for providing me the opportunities to write for their respective journals. I thank Jon Erickson (DDJ), Mike Markowitz (EDN), and Lindsey Vereen (ESP), for allowing me to use the material from their respective journals for this book. Larry Stein, of Warp Nine Engineering and Chairman of IEEE`s P1284 committee, was a great help in providing details about the EPP and ECP, and I thank him for that. Thanks are also due to Santosh Khadilkar for his help in organizing the manuscript for this book. This manuscript was prepared using the IUCAA computer centre facilities. I am delighted to thank my wife, Sangeeta, for her encouragement and her patience. She fought like a lone warrior in engaging and containing our son, Chaitanya, while I was busy. It was only because of her support that this work could be undertaken, and I cannot thank her enough. This acknowledgment would be incomplete without placing on record my deep sense of gratitude to the foresight of my parents, Aai and Nana, in providing me a decent education even in the face of severe financial crunch. I think nobody else would be happier than Aai and Nana in seeing this book in print. DHANANJAY V. GADRE PUNE, INDIA Dhananjay Gadre is a Scientific Officer with the Instrumentation Programme of the Inter-University Centre for Astronomy and Astrophysics, Pune, India. He has been working with the IUCAA for the past four years. Previously, he was a lecturer at the SGTB Khalsa College, University of Delhi, teaching undergraduate electronics for about four years. He is now a graduate student at the Microelectronics Research and Communications Institute, Electrical Engineering Department, University of Idaho, on study leave from IUCAA. Page ix Table of Contents Foreword v Acknowledgments vii Chapter 1 1 Introduction Why the Parallel Port? 1 What Is Data Acquisition? 2 Intended Audience 3 Organization of the Book 4 Chapter 2 7 How to Build a Computer Interface What Is an Interface? 7 Examples of Various Schemes for Data Acquisition 7 A Speech Digitizer 8 Data Acquisition for a CCD Camera 11 ... - tailieumienphi.vn
nguon tai.lieu . vn