The developer's resource for computer interfacing, especially USB, serial (COM) ports, mass storage, and embedded networking. (Formerly Lvr.com)

Home > Parallel Port Complete > From the Introduction

Parallel Port CompleteParallel Port Complete

Jan Axelson

From the Introduction

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.

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.

What’s Inside

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.

Visual Basic Tools

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.

Applications

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 a synchronous serial interface. A chapter on real-time control shows how to write programs that trigger on external events, such as a signal transition at the parallel port or time or calendar information. There’s a discussion and examples of using the parallel port as the power source for low-power external circuits.

Cables and Interfacing

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.

PC-to-PC Communications

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.

About the Program Code

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.