From the Author .........
From its origin as a simple printer interface, the personal computer’s parallel port has evolved into a place to plug in just about anything you might want to hook to a computer. The parallel port is popular because it’s versatile—you can use it for output, input, or bidirectional links—and because it’s available—every PC has one.
Printers are still the most common devices connected to the port, but other popular options include external tape and disk drives and scanners. Laptop computers may use a parallel-port-based network interface or joystick. For special applications, there are dozens of parallel-port devices for use in data collection, testing, and control systems. And the parallel port is the interface of choice for many one-of-a-kind and small-scale projects that require communications between a computer and an external device.
In spite of its popularity, the parallel port has always been a bit of a challenge to work with. Over the years, several variations on the original port’s design have emerged, yet there has been no single source of documentation that describes the port in its many variations.
I wrote this book to serve as a practical, hands-on guide to all aspects of the parallel port. It covers both hardware and software, including how to design external circuits that connect to the port, as well as how to write programs to control and monitor the port, including both the original and improved port designs.
This book focuses on several areas related to the parallel port:
Using the New Modes Some of the most frequently asked parallel-port questions relate to using, programming, and interfacing the port in the new, advanced modes, including the enhanced parallel port (EPP), the extended capabilities port (ECP), and the PS/2-type, or simple bidirectional, port. This book covers each of these. Examples show how to enable a mode, how to use the mode to transfer data, and how to use software negotiation to enable a PC and peripheral to select the best mode available.
Microsoft’s Visual Basic is one of the most popular programming languages for PCs, and this book includes programming tools to help in writing Visual-Basic programs that access the parallel port.
One tool is a Visual-Basic form that enables users to find, select, and test the parallel ports on a system. You can use the form as a template, or beginning form, for applications you write. Also included is a set of routines that simplify reading and writing to the parallel port’s registers and reading and changing individual bits in a byte. Because Visual Basic doesn’t include functions for performing simple reads and writes to a port, the companion disk included with this book includes DLLs that add these abilities to Visual Basic. Versions are included for use with both 16-bit and 32-bit programs.
Besides the general-purpose programming tools, I’ve included a variety of example circuits with Visual-Basic code for controlling and monitoring external circuits. The examples include popular applications such as switching power to a load, reading analog signals, expanding the number of inputs and outputs that the port can access, and interfacing to a microcontroller circuit. One example shows how to use the parallel port to communicate with chips that use asynchronous serial interface. A chapter on real-time control shows how to write programs that trigger external events, such as a signal transition at the parallel port or time or calendar information. There are discussions and examples of using the parallel port as the power source for low-power external circuits.
The proper cable can mean the difference between a link that works reliably and one that doesn’t. This book shows how to choose an appropriate parallel-port cable, and how to design the circuits that interface to the cable.
Although the parallel port was originally intended as an interface between a PC and a printer or other peripheral, it’s also become a popular interface for transferring information between two PCs. This book shows how to set up a PC-to-PC link using the parallel ports and either the operating system’s built-in tools or your own programs.
Every programmer has a favorite language. The choices include various implementations of Basic, C/C++, and Pascal/Delphi, and assembly language. For the program examples in this book, I wanted to use a popular language so as many readers as possible could use the examples directly, and this prompted my decision to use Microsoft's Visual Basic for Windows.
A big reason for Visual Basic’s popularity is that the programming environment makes it extremely easy to add controls and displays that enable users to control a program and view the results. However, this book isn’t a tutorial on Visual Basic. It assumes you have a basic understanding of the language and how to create and debug a Visual-Basic program.
I developed the examples originally using Visual Basic Version 3, then ported them to Version 4. As much as possible, the programs are designed to be compatible with both versions, including both 16- and 32-bit Version-4 programs. The companion disk includes two versions of each program, one for Version 3 and one for 16- and 32-bit Version 4 programs.
One reason I decided to maintain compatibility with Version 3 is that the standard edition of Version 4 creates 32-bit programs only. Because Windows 3.1 can’t run these programs, many users haven’t upgraded to Version 4. Also, many parallel-port programs run on older systems that are put to use as dedicated controllers or data loggers. Running the latest version of Windows isn't practical or necessary on these computers. Of course, in the software world, nothing stays the same for long. Hopefully, the program code will remain compatible in most respects with later versions of Visual Basic.
Essentials: Defining the Port: Port Types • System Resources • Addressing • Interrupts • DMA Channels • Finding Existing Ports. Configuring: Port Options • Drivers • Adding a Port. Port Hardware: Connectors • The Circuits Inside • Cables. Multiple Uses for One Port: Security Keys. Alternatives to the Parallel Port: Serial Interfaces • Other Parallel Interfaces • Custom I/O Cards • PC Cards
Accessing Ports: The Signals: Centronics Roots • Naming Conventions • The Data Register • The Status Register • The Control Register • Bidirectional Ports. Addressing: Finding Ports. Direct Port I/O: Programming in Basic • Other Programming Languages. Other Ways to Access Ports: LPT Access in Visual Basic • Windows API Calls • DOS and BIOS Interrupts
Programming Issues: Options for Device Drivers: Simple Application Routines • DOS Drivers • Windows Drivers • Custom Controls. Speed: Hardware Limits • Software Limits
Programming Tools: Routines for Port Access: Data Port Access • Status Port Access • Control Port Access • Bit Operations. A Form Template: Saving Initialization Data • Finding, Selecting, and Testing Ports
Experiments: Viewing and Controlling the Bits: Circuits for Testing • Output Types • Component Substitutions. Cables & Connectors for Experimenting. Making an Older Port Bidirectional: Cautions • The Circuits • The Changes
Interfacing: Port Variations: Drivers and Receivers • Level 1 Devices • Level 2 devices. Interfacing Guidelines: General Design • Port Design. Cable Choices: Connectors • Cable Types • Ground Returns • 36-wire Cables • Reducing Interference • Line Terminations • Transmitting over Long Distances. Port-powered Circuits: When to Use Port Power • Abilities and Limits • Examples
Output Applications: Output Expansion. Switching Power to a Load: Choosing a Switch • Logic Outputs • Bipolar Transistors • MOSFETs • High-side Switches, Solid-state Relays • Electromagnetic Relays • Controlling the Bits • X-10 Switches. Signal Switches: Simple CMOS Switch • Controlling a Switch Matrix. Displays
Input Applications: Reading a Byte: Latching the Status Inputs • Latched Input Using Status and Control Bits • 5 Bytes of Input • Using the Data Port for Input. Reading Analog Signals: Sensor Basics • Simple On/Off Measurements • Level Detecting • Reading an Analog-to-digital Converter • Sensor Interfaces • Signal Conditioning • Minimizing Noise • Using a Sample and Hold
Synchronous Serial Links: About Serial Interfaces. A Digital Thermometer: Using the DS1620 • The Interface • An Application • Other Serial Chips.
Real-time Control: Periodic Triggers: Simple Timer Control • Time-of-day Triggers • Loop Timers. Triggering on External Signals: Polling • Hardware Interrupts • Multiple Interrupt Sources • Port Variations
Modes for Data Transfer: The IEEE 1284 Standard: Definitions • Communication modes. Detecting Port Types: Using the New Modes • Port Detecting in Software • Disabling the Advanced Modes. Negotiating a Mode: Protocol. Controller Chips: Host Chips • Peripheral Chips • Peripheral Daisy Chains. Programming Options
Compatibility and Nibble Modes: Compatibility Mode: Handshaking • Variations. Nibble Mode: Handshaking • Making a Byte from Two Nibbles. A Compatibility & Nibble-mode Application: About the 82C55 PPI • Compatibility and Nibble-mode Interface
Byte Mode: Handshaking: Applications: Compatibility & Byte Mode • Compatibility, Nibble & Byte Mode with Negotiating
Enhanced Parallel Port: EPP: Inside the EPP: Two Strobes • The Registers. Handshaking: Four Types of Transfers • Switching Directions • Timing Considerations. EPP Variations: Use of nWait • Clearing Timeouts • Direction Control. An EPP Application: The Circuit • Programming
Extended Capabilities Port: ECP: ECP Basics: The FIFO, Registers • Extended Control Register (ECR) • Internal Modes. ECP Transfers: Forward transfers • Reverse Transfers • Timing Considerations • Interrupt Use • Using the FIFO. Other ECP Modes: Fast Centronics • Test Mode • Configuration Mode. An ECP Application
PC-to-PC Communications: A PC-to-PC Cable. Dos and Windows Tools: MS-DOS's Interlink • Direct Cable Connection. A PC-to-PC Application
Appendices: Resources. Microcontroller Circuit. Number Systems
Who should read this book?
The book is designed to serve readers with a variety of backgrounds and interests:
Programmers will find code examples that show how to use the port in all of its modes. If you program in Visual Basic, you can use the routines directly in your programs.
For hardware designers, there are details about the port circuits and how to interface them to the world outside the PC. I cover the port’s original design and the many variations and improvements that have evolved. Examples show how to design circuits for reliable data transfers.
System troubleshooters can use the programming techniques and examples for finding and testing ports on a system.
Experimenters will find dozens of circuit and code examples, along with explanations and tips for modifying the examples for a particular application.
Teachers and students have found the parallel port to be a handy tool for experiments with electronics and computer control. Many of the examples in this book are suitable as school projects.
And last but not least, users, or anyone who uses a computer with printers or other devices that connect to the parallel port, will find useful information, including advice on configuring ports, how to add a port, and information on cables, port extenders, and switch boxes.
The definitive handbook on unconventional uses of parallel ports. - Q & A, Electronics Now. If you need to do any development of parallel port devices or want to get a bit-level understanding of the port's inner workings, I strongly recommend Parallel Port Complete. - Bill Machrone, PC Week.
I've said it before and I'll say it again: I love it when an author picks a reasonably narrow topic and then covers that topic thoroughly...There's lots of good VB source code that could be ported to the language and operating system of your choice. I've never written a line of VB code and I had no problem following the examples...The book is written in a very readable style and starts off with the basics; you don't have to be a hardware guru to read it....if you think you might ever need to access a parallel port (under any operating system), this book is for you. In fact, I'm trying really hard to think of a reason why I need to make that digital thermometer described in Chapter 9.- Paula Tomlinson, Windows Developer's Journal.
Finding out how the parallel port works and how to control it can prove difficult, even though parallel ports conform to the IEEE-1284 standard. Now, though, you can get just about everything you need to know in one highly useful book that covers the hardware and software considerations of using the parallel port...By the second chapter, the author is already discussing the ways you can access a port and control it...I like a quick start that gets me thinking about my own possible applications...Given the author's clear diagrams and explanations, it shouldn't take you long to wire and test a simple circuit that you can control through the parallel port with VB software...Even if you can't think of a parallel-port application right now, buy the book anyway. You may find that it inspired an idea to take advantage of a port that already exists on your PC. After all, the author has done most of the hardware and software work for you. - Jon Titus, Test & Measurement World. If you want to learn about PC-based parallel ports, then you need a copy of Jan Axelson's Parallel Port Complete. Good stuff. -Jeff Holtzman, Electronics Now.
An excellent resource for Visual Basic programmers looking to interface hardware through standard ports. Anyone designing hardware to work with a parallel port is well advised to add this book to their library. - Paul G. Schreier, Personal Engineering. It's been a while since I've seen a book so practical as this one. Parallel Port Complete is a real keeper! - Joseph Carr, Nuts & Volts.