ebook img

Programming the parallel port : interfacing the PC for data acquisition and process control PDF

325 Pages·1998·3.14 MB·English
by  Gadre
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Programming the parallel port : interfacing the PC for data acquisition and process control

Programming the Parallel Port Interfacing the PC for Data Acquisition and Process Control Dhananjay V. Gadre CMP Books Lawrence, KS 66046 CMP Books an imprint of CMP Media LLC 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 CMP is aware of a trademark claim, the product name appears in initial capital letters, in all capital letters, or in accordance with the ven- dor’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 CMP Media LLC, except where noted otherwise. Published by CMP Books, an imprint of CMP Media LLC. 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 writ- ten 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 com- pleteness 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 informa- tion in this book or for any infringement of the intellectual property rights of third par- ties which would result from the use of this information. Distributed in the U.S. and Canada by: Publishers Group West 1700 Fourth Street Berkeley, CA 94710 1-800-788-3123 ISBN: 0-87930-513-4 NP 11-02 R&D Developer Series To Chaitanya and Sangeeta This Page Intentionally Left Blank Foreword No other interface has been so constant since the PC was introduced in 1981. Origi- nally 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 inter- face 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 par- allel, 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 perfor- mance 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. v Two of these new modes are the EPP and ECP modes. Now, rather than being lim- ited 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 applica- tions. 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. Start- ing 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 driv- ers necessary to control and communicate with your devices. I’m sure you’ll find this an invaluable tool in aiding your understanding of the par- allel 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 instru- mental 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 Con- troller. vi Acknowledgments My interest in parallel printer adapters began in 19980 when Professor Vijaya Shan- kar Varma at the Delhi University asked me if I could build a resistor DAC for the par- allel 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 Com- munication (CSEC), University of Delhi. While we were at it, Professor Pramod Srivastava, Director of CSEC, was a con- stant source of suggestions and useful comments. He was an even bigger help in pro- viding 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 pro- grammer that he is, all the Linux-related projects would have been incomplete with- out his collaboration. He also read through many of the chapters in this manuscript and provided critical comments. vii 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 Pro- gramming; 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 commit- tee, 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 manu- script 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, Chait- anya, 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. viii Table of Contents Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v Acknowledgments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii Chapter 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Why the Parallel Port?....................................................................1 What is Data Acquisition?..............................................................2 Intended Audience..........................................................................3 Organization of the Book................................................................4 Companion Code on the FTP Site...................................................6 Chapter 2 How to Build a Computer Interface . . . . . . . . . . . . . . 7 What is an Interface?.......................................................................7 Examples of Various Schemes for Data Acquisition......................7 A Speech Digitizer..........................................................................8 Data Acquisition for a CCD Camera............................................11 Signal and Timing Diagram Conventions.....................................14 Hardware Components..................................................................15 Digital Components......................................................................20 Chapter 3 The Parallel Printer Adapter. . . . . . . . . . . . . . . . . . . 25 Anatomy of the Parallel Printer Port.............................................26 The DATA Port.............................................................................29 The CONTROL Port.....................................................................31 The STATUS Port.........................................................................33 Printing with the Parallel Adapter.................................................36 Using the Parallel Printer Adapter................................................37 ix

Description:
Why purchase expensive add-on cards or bus interfaces when you can develop effective and economical data acquisition and process controls using C programs? Using the under-employed printer adapter (that is, the parallel port of your PC), you can turn your computer into a powerful tool for developing
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.