EssaysForStudent.com - Free Essays, Term Papers & Book Notes
Search

Pc Parallel Port to Control Stepper Motors

By:   •  Research Paper  •  3,273 Words  •  April 25, 2010  •  1,078 Views

Page 1 of 14

Pc Parallel Port to Control Stepper Motors

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,

Download as (for upgraded members)  txt (14.8 Kb)   pdf (202.8 Kb)   docx (17.1 Kb)  
Continue for 13 more pages »