ReviewEssays.com - Term Papers, Book Reports, Research Papers and College Essays
Search

Pc Parallel Port

Essay by   •  March 6, 2011  •  Research Paper  •  3,273 Words (14 Pages)  •  1,206 Views

Essay Preview: Pc Parallel Port

Report this essay
Page 1 of 14

1. Introduction

This is the first in a series of articles on using Forth to interact with the real world. We will explore how to control motors of various types (such as servomotors and stepper motors), switch power to devices, and sense the environment. Each article will present a project that can be used to demonstrate the ideas we are going to discuss.

In this first article, I want to lay the foundation for the future columns and discuss the use of the PC parallel port to control stepper motors. We will adopt the fantasy that we are working on some microprocessor-based control application and will be using the PC parallel port as a proxy for the digital I/O channels on our controller. To the extent possible, the code will be written in high level (so that we can illustrate the principles clearly), and will be in ANS Forth.

2. The PC Parallel Port

First, if you haven't already, go to your back issues of Forth Dimensions and find Ken Merk's article "Forth in Control," (FD XVII/2). In that article, Ken talks about using the PC parallel port for eight digital outputs. We will be expanding on that and use some of those other pins to get input as well as to provide output.

A parallel port on the PC is really three address locations which, for conventional use, could be called #Data, #Command, and #Status. The port #Data is at the base address of the parallel port, #Status is at the base address plus one, and #Command is at base plus two.

The base address depends upon which parallel port we are using and the hardware installed in your computer; usually, this address is one of the hex addresses 03BC, 0378, or 0278. The BIOS determines the address and maps it to the parallel ports at boot time. This allows an application to find out where the port is by simply reading the table in memory that starts at 0040:0008. Ken shows in his article how to get this value and set a constant containing the base address for the first port; we will do the same here.

Table One. The PC parallel port

DB-25 Pin Signal Direction Port Bit

1 Strobe* out #Command 0

2 Data0 out #Data 0

3 Data1 out #Data 1

4 Data2 out #Data 2

5 Data3 out #Data 3

6 Data4 out #Data 4

7 Data5 out #Data 5

8 Data6 out #Data 6

9 Data7 out #Data 7

10 Ack* in #Status 6

11 Busy in #Status 7

12 Paper out in #Status 5

13 Select out in #Status 4

14 Auto_Feed* out #Command 1

15 Error* in #Status 3

16 Init* out #Command 2

17 Select in* out #Command 3

18 to 25 Ground NA NA NA

Table One shows what all the pins on the connector are for. You will notice that #Status port bits zero, one, and two and #Command bits five, six, and seven are not used. The #Command port is used as an output port when the port is being used for a printer, but it is actually an open-collector I/O port and can be used for input. The #Data port latches whatever was written to it, so a read from that port returns the same value that was last written to it. A single PC parallel port then gives us 12 output bits and four input bits, under normal circumstances. (Many PCs use general-purpose parallel I/O chips to implement the parallel port and can actually be programmed to be bi-directional on the pins. Unfortunately, this form of the port is not universal.) For this project we will only need the first four data lines and ground (DB-25 pins two through five and pin 25).

3. Stepper Motors

As our first application, let us consider the control of stepper motors. Stepper motors provide open-loop, relative motion control. Open loop means that, when you command the motor to take 42 steps, it provides no direct means of determining that it actually did so. The control is relative, meaning that there is no way to determine the shaft position directly. You can only command the motor to rotate a certain amount clockwise or counter-clockwise from its current position. These "commands" consist of energizing the various motor coils in a particular sequence of patterns. Each pattern causes the motor to move one step. Smooth motion results from presenting the patterns in the proper order.

Features that stepper motors provide include:

* Excellent rotational accuracy

* Large torque

* Small size

* Work well over a range of speeds

* Can be used for motion or position control

There are two types of stepper motors:

* Bipolar motors, with two coils. These have four wires on them (see Figure One-a). They are tricky to control because they require changing the direction of the current flow through the coils in the proper sequence. We will discuss these motors further when we get to the topic of DC motor control.

* Unipolar motors, with two center-tapped coils which can be treated as four coils (see Figure One-b). These have six or eight (or sometimes five) wires, and can be controlled from a microprocessor with little more than four transistors (see Figure Two).

Figure One. (a) The internal arrangement of the coils for a bipolar stepper motor. (b) The internal arrangement of the coils for a unipolar stepper motor. Wires a through

...

...

Download as:   txt (14.8 Kb)   pdf (174 Kb)   docx (15.9 Kb)  
Continue for 13 more pages »
Only available on ReviewEssays.com