Newsgroups: comp.robotics
Path: brunix!sgiblab!spool.mu.edu!torn!nott!cunews!superior!mgetz
From: mgetz@superior.carleton.ca (Mike Getz)
Subject: Re: C and the printer port?
Message-ID: <CtAt06.HMp@cunews.carleton.ca>
Sender: news@cunews.carleton.ca (News Administrator)
Organization: Carleton University
X-Newsreader: TIN [version 1.2 PL0]
References: <1994Jul17.153810.18312@news.vanderbilt.edu>
Date: Thu, 21 Jul 1994 16:12:06 GMT
Lines: 54

HEAGYWS@ctrvax.Vanderbilt.Edu wrote:
: I am currently using QuickBasic and the OUT 888,xx command to control
: the parallel printer port of a PC.  The port is connected to a 
: stepper motor controller.  The whole setup is pretty simple...all I need
: to do is pulse one or two lines high and low to control the direction
: and stepping of the motor.  It works fairly well using QB, but I am sure
: the stepping speed is being limited by the language I am using.  I'm
: currently running the software on a 386sx, so I'm sure a faster machine
: would also improve the situation...the problem is that after the software
: is finished, it will most likely be run on 286 type machines.

: I was considering porting the software to C or assembly and was wondering
: if anyone is aware of the commands used to access the printer port (I
: am particularly interested in the C commands) for this type of work?
: Also, if you have any other ideas how I could increase the stepping speed,
: I would be glad to hear them.

There is a speed difference between QB and C. I did a quick test once by
writing a couple of loops that just toggle one of the bits on the lpt.
There was a 5x difference in max speed. Max speed is also a function of how
much code you execute between steps.

Here are some simple c commands:

#define LPTPORT1 0x3bc
#define LPTPORT2 0x378
#define LPTPORT3 0x278

#define PORT LPTPORT1

#define DATA    PORT
#define STATUS  PORT+1 
#define CONTROL PORT+2

/* to ouput to port */
outportb(DATA, 0x??);
or
outportb(CONTROL, 0x??);

depending which pins you are connected to.

To read the port

PortData =  inportb(STATUS);

etc.

Mike.

|Mike Getz
|mgetz@ccs.carleton.ca
|Nepean, Canada
|Naaahhh, i don't gots no tag line 

